Comments (8)
Thank you very much!
from terraformer-wkt-parser.
I had to add import GeoJson from 'geojson';
Another option would be to declare the external dependency the way we do here. Either way, a PR with an improvement would be welcome.
/// <reference types="geojson" />
also had to do npm i @types/geojson
Not sure what else we can do to help with that. @types/geojson
is already listed as a dependency of this lib.
terraformer-wkt-parser/package.json
Line 14 in dd2885d
from terraformer-wkt-parser.
Yeah, I actually went a little farther with changing some other files to get exactly what I needed. I am not 100% with everything I did to get things to work. I need to undo things but the app is currently running for the next few hours. I will make a proper report in the morning (BST) with everything I did.
from terraformer-wkt-parser.
So, is there some progress? I really need this fix.
from terraformer-wkt-parser.
#40 seems to have broken use cases where an external dependency exists for @types/geojson on a version other than 1.x. For example, cases like:
sample package.json
"dependencies": {
...,
"terraformer-wkt-parser": "1.2.1",
...
},
"devDependencies": {
...,
"@types/geojson": "7946.0.7",
...
}
sample TypeScript source code
import terraWkt from 'terraformer-wkt-parser';
import * as GeoJSON from 'geojson';
const sampleWkt = '...';
const parsedWkt: GeoJSON.GeometryObject = terraWkt.parse(sampleWkt);
^^^^^^^^^
Type 'GeometryObject' is not assignable to type 'Geometry'.
Type 'DirectGeometryObject' is not assignable to type 'Geometry'.
Type 'DirectGeometryObject' is not assignable to type 'MultiPolygon'.
Types of property 'type' are incompatible.
Type 'string' is not assignable to type '"MultiPolygon"'.ts(2322)
The same sample block above works with [email protected]
.
from terraformer-wkt-parser.
Thanks for the report. I'm no typescript expert, but it looks like you can fix the problem and regain control over the version of the typings you're importing in your own application by making sure to import them before you import the terraformer parser.
import * as GeoJSON from 'geojson'
import terraWkt from 'terraformer-wkt-parser';
const parsedWkt: GeoJSON.GeometryObject = terraWkt.parse(sampleWkt);
from terraformer-wkt-parser.
@jgravois I wasn't expecting this to work at first, but it strangely does seem to work, thanks.
I'm guessing moving the import up somehow "shadows" over the GeoJSON
that the types for terraformer-wkt-parser try to reference, since GeoJSON itself is exported as a global namespace?
In other words, the import order is actually influencing the type definitions that terraformer-wkt-parser is trying to use internally?
Specifically this part: https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/geojson/index.d.ts#L14
from terraformer-wkt-parser.
the import order is actually influencing the type definitions that terraformer-wkt-parser is trying to use internally?
tbh, I'm not sure.
your import might be overriding the definitions our parser declares as a dependency internally or maybe it's just a lucky coincidence that they are compatible.
from terraformer-wkt-parser.
Related Issues (19)
- setup Travis
- BROKEN v1.1.0 !!! HOT 2
- Counter clockwise polygons HOT 8
- support for converting FeatureCollection to WKT HOT 2
- Cannot parse GEOMETRYCOLLECTION HOT 2
- automate release process
- Error: Cannot find module with sequelize in 1.1.1 HOT 8
- get tests passing in node v7 HOT 1
- Geometry Collection support not released HOT 3
- TerraFormer.io HOT 1
- Support for parsing WKT GeometryCollections HOT 1
- Update npm package HOT 1
- Conflicting @types/geojson dependency with terraformer HOT 3
- The documentation portal is down ? HOT 1
- Wrong npm package mentioned in docs HOT 1
- unable to parse scientific notation numbers (i.e 1.234E-4) HOT 4
- Update to latest terraformer HOT 2
- Informative parse errors HOT 8
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from terraformer-wkt-parser.