question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Type checking included turf library in typescript fails for nearest-point-to-line and point-to-line-distance

See original GitHub issue

When 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:closed
  • Created 5 years ago
  • Reactions:20
  • Comments:8

github_iconTop GitHub Comments

9reactions
jfavrodcommented, Oct 24, 2019

Installing the referenced packages resolved the issues for me:

npm i @turf/nearest-point-to-line
npm i @turf/point-to-line-distance

This will install the latest version of these packages (currently 6.0.0)

8reactions
Naitik333commented, Nov 21, 2019

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.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found