Type checking included turf library in typescript fails for nearest-point-to-line and point-to-line-distance
See original GitHub issueWhen type checking a project including turf two d.ts
files seem to not get registered properly. This can be trivially fixed by adding local declarations (copied from the relevant ones in the repo), but it’s not obvious and leads to a rougher onboarding experience.
To replicate
Install turf as part of a package and try to check using typescript
tsconfig.json
{
"compilerOptions": {
"esModuleInterop": true,
"isolatedModules": true,
"jsx": "react",
"module": "commonjs",
"noEmit": true,
"noImplicitAny": true,
"noUnusedLocals": true,
"outDir": "./dist/",
"sourceMap": true,
"strict": true,
"target": "es5"
},
"include": ["./src/**/*.ts", "./src/**/*.tsx"],
"exclude": ["./dist/", "./node_modules"]
}
$ tsc
node_modules/@turf/turf/index.d.ts:34:45 - error TS7016: Could not find a declaration file for module '@turf/nearest-point-to-line'. '/Users/jabrahamson/Development/cibo/ursa-web/node_modules/@turf/nearest-point-to-line/index.js' implicitly has an 'any' type.
Try `npm install @types/turf__nearest-point-to-line` if it exists or add a new declaration (.d.ts) file containing `declare module '@turf/nearest-point-to-line';`
34 export {default as nearestPointToLine} from '@turf/nearest-point-to-line';
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
node_modules/@turf/turf/index.d.ts:84:46 - error TS7016: Could not find a declaration file for module '@turf/point-to-line-distance'. '/Users/jabrahamson/Development/cibo/ursa-web/node_modules/@turf/point-to-line-distance/index.js' implicitly has an 'any' type.
Try `npm install @types/turf__point-to-line-distance` if it exists or add a new declaration (.d.ts) file containing `declare module '@turf/point-to-line-distance';`
84 export {default as pointToLineDistance} from '@turf/point-to-line-distance';
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
error Command failed with exit code 1.
Issue Analytics
- State:
- Created 5 years ago
- Reactions:20
- Comments:8
Top Results From Across the Web
@turf/point-to-line-distance - npm
Start using @turf/point-to-line-distance in your project by ... TypeScript icon, indicating that this package has built-in type declarations.
Read more >@turf/nearest-point-to-line | Yarn - Package Manager
Most Turf functions work with GeoJSON features. These are pieces of data that represent a collection of properties (ie: population, elevation, zipcode, etc.) ......
Read more >Advanced geospatial analysis - Turf.js
Takes a Point and calculates the location of a destination point given a distance in degrees, radians, miles, or kilometers; and bearing in...
Read more >proximiio-js-library - npm Package Health Analysis - Snyk
At last, you have to connect poi to polygon via adding its id to poi metadata like polygon_id property. Polygon Feature Example: {...
Read more >Turfjs - Bountysource
function for checking if a given geojson object is valid. ... import turfLength from "@turf/length"; const lineString = { type: "Feature", geometry: {...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Installing the referenced packages resolved the issues for me:
This will install the latest version of these packages (currently
6.0.0
)Can some admin please release 6.0.0 version of @turf/turf module, so that this issue gets fixed and also we get the latest version of all the modules.