In a Vite TypeScript project (for the browser - not Node) I have installed both jsts
and @types/jsts
:
$ npm ls --depth=0 | grep jsts
├── @types/[email protected]
├── [email protected]
In my code I try to import the types as follows:
import Centroid from 'jsts/org/locationtech/jts/algorithm/Centroid';
import * as jsts from 'jsts/org/locationtech/jts';
The above generates the following errors:
ERROR(TypeScript) Could not find a declaration file for module 'jsts/org/locationtech/jts/algorithm/Centroid'.
'/home/[ommited...]/node_modules/jsts/org/locationtech/jts/algorithm/Centroid.js' implicitly has an 'any' type.
Try `npm i --save-dev @types/jsts` if it exists or add a new declaration (.d.ts) file containing `declare module 'jsts/org/locationtech/jts/algorithm/Centroid';`
ERROR(TypeScript) Could not find a declaration file for module 'jsts/org/locationtech/jts'.
'/home/[ommited...]/node_modules/jsts/org/locationtech/jts/index.js' implicitly has an 'any' type.
Try `npm i --save-dev @types/jsts` if it exists or add a new declaration (.d.ts) file containing `declare module 'jsts/org/locationtech/jts';
My tsconfig.json
file is:
{
"compilerOptions": {
"target": "ES2020",
"useDefineForClassFields": true,
"lib": ["ES2020", "DOM", "DOM.Iterable"],
"module": "ESNext",
/* Bundler mode */
"moduleResolution": "bundler",
"allowImportingTsExtensions": true,
"resolveJsonModule": true,
"isolatedModules": true,
"noEmit": true,
"jsx": "react-jsx",
/* Linting */
"strict": true,
"strictNullChecks": true,
"noUnusedLocals": true,
"noUnusedParameters": true,
"noFallthroughCasesInSwitch": true,
"paths": {
"react": [ "./node_modules/@types/react" ]
}
},
"include": ["src"],
"references": [{ "path": "./tsconfig.node.json" }]
}