typescript - Åtgärdar TS2688: Kan inte hitta typdefinitionsfil i node_modules
När jag kör tsc får jag många TS2688: Kan inte hitta typdefinitionsfil för 'someLibrary'. Dessa bibliotek kom från node_modules. Jag har försökt att exkludera node_modules och skipLibCheck i tsconfig, men ingen av dem fungerar för mig. Någon idé varför detta händer?
Här är min tsconfig.json
{
"ts-node": {
"files": true,
"emit": true,
"compilerHost": true
},
"compilerOptions": {
"experimentalDecorators": true,
"emitDecoratorMetadata": true,
"target": "es2016",
"sourceMap": true,
"typeRoots" : ["./node_modules","./node_modules/@types"],
"jsx": "react",
"allowSyntheticDefaultImports": true,
"skipLibCheck": true,
"esModuleInterop": true,
"strict": true,
"forceConsistentCasingInFileNames": true,
"module": "commonJS",
"moduleResolution": "node",
"resolveJsonModule": true,
"isolatedModules": true,
},
"exclude": [
"node_modules"
]
}
Svar #1
Problemet var fel typeRoots. Bör använda standard ./node_modules/@types
Svar #2
I tsconfig.json har du lagt typeRoots som standard. Så här:
"compilerOptions": {
...
"typeRoots": ["./node_modules/@types"]
}
