Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Could not find a declaration file for module '@turf..." #2553

Closed
2 tasks done
wjlee2020 opened this issue Dec 10, 2023 · 5 comments · Fixed by #2555
Closed
2 tasks done

Could not find a declaration file for module '@turf..." #2553

wjlee2020 opened this issue Dec 10, 2023 · 5 comments · Fixed by #2555
Assignees
Labels
bundling Anything related to issues with bundling
Milestone

Comments

@wjlee2020
Copy link

wjlee2020 commented Dec 10, 2023

Please provide the following when reporting an issue:

  • The version of Turf you are using, and any other relevant versions.
    "@turf/helpers": "^6.5.0",
    "@turf/simplify": "^6.5.0"

  • Snippet of source code or for complex examples use jsfiddle.

import simplify from "@turf/simplify";
const turf = require("@turf/helpers");

when using an import statement, i get Could not find a declaration file for module '@turf/simplify'. ts error.
It's the same with all other modules even @turf/turf.

Any ideas/tips?

@smallsaucepan smallsaucepan added the bundling Anything related to issues with bundling label Dec 11, 2023
@smallsaucepan
Copy link
Member

Thanks for raising the issue @wjlee2020 . I'm working on a PR at the moment that should improve the declarations that are shipped. Would you be happy to give that a try once the next v7.0.0-alpha is released?

The only shorter term option I can think of would be to edit or patch the files already installed in your node_modules/ folder - not ideal.

@smallsaucepan smallsaucepan added this to the v7 milestone Dec 11, 2023
@smallsaucepan
Copy link
Member

@wjlee2020 can you please provide some more info about your environment? Vanilla node app, NextJS, Vite? Does the error appear in VSCode, or does it only show up when you're building? Any other details would be a help to reproduce the problem and also make sure the PR fixes it. Thanks!

@wjlee2020
Copy link
Author

@smallsaucepan I apologize for the lack of details

Environment - NextJS ("13.5.6")
Error appears in VSCode - Yes
Build fails due to typescript error (error: Could not find a declaration file for module '@turf/turf')

Currently, I have made a turf.d.ts file with:

declare module "@turf/turf" {
  export function point(coordinates: number[]): any;
  export function polygon(coordinates: [number, number][][][]): any;
  export function booleanPointInPolygon(point: any, polygon: any): boolean;
}

to help me remove the typescript errors for the turf modules I am using.

import { booleanPointInPolygon, point, polygon } from "@turf/turf";

Please let me know if you would like more information 🙇🏻‍♂️

@sutanmufti
Copy link

I am having this problem too with svelte kit 2.0.0 and svelte 4.2.7, turf 6.5 and typescript 5.. Resolving this by editing the tsconfig.json by adding the "moduleResolution" : "node" and the turf loads.

@ben-xD
Copy link

ben-xD commented Mar 28, 2024

I faced this issue today trying to use turf in a vite/react project. Following #2521 (comment) resolves my issue. I'm using the latest alpha turf, 7.0.0-alpha.114

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bundling Anything related to issues with bundling
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants