Recently, I encountered an issue with my React / Mobex application written in TypeScript and built by Webpack 1. Upon updating the TypeScript version from 2.3.4 to 2.4.2, an error started occurring. The error message reads:
ERROR in C:\myproject\tsconfig.json
error TS2688: Cannot find type definition file for 'reflect-metadata'.
Even after trying Typescript 2.7.2 and explicitly providing the path to typings in "paths"
, as well as installing the latest version of 'reflect-metadata'
globally, the error persists.
tsconfig.json
{
"compilerOptions": {
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"jsx": "react",
"lib": ["dom", "es2015.promise", "es6"],
"module": "commonjs",
"moduleResolution": "node",
"noImplicitAny": true,
//"noUnusedLocals": true,
"noUnusedParameters": true,
"outDir": "./dist/",
"sourceMap": true,
"suppressImplicitAnyIndexErrors": true,
"target": "es5",
"types": ["reflect-metadata"],
"baseUrl": ".",
"paths": {
"react-split-pane": ["./type_fixes/react-split-pane/index.d.ts"],
"react-dropzone": ["./type_fixes/react-dropzone/index.d.ts"],
"react-bootstrap-toggle": ["./type_fixes/react-bootstrap-toggle/index.d.ts"]
}
},
"include": [
"./src/**/*",
"./index.tsx",
"./declarations.d.ts"
],
"exclude": [
"node_modules"
]
}
package.json
"dependencies": {
//...
"reflect-metadata": "0.1.10",
//...
},
"devDependencies": {
//...
"typescript": "2.4.2",
//...
},