我收到以下错误
error TS7016: Could not find a declaration file for module 'react-native-camera'. '/Users/ilja/Documents/Repositories/blok/node_modules/react-native-camera/index.js' implicitly has an 'any' type.
Try `npm install @types/react-native-camera` if it exists or add a new declaration (.d.ts) file containing `declare module 'react-native-camera';`
作为快速修复,我在typings/index.d.ts
项目的根目录创建了(没有 @types/react-native-camera)文件并填充它
declare module 'react-native-camera';
然后,在我的 tsconfig 文件中,我将它添加到我的类型根目录中
"typeRoots": ["node_modules/@types", "./typings"],
但是我在构建时仍然遇到同样的错误,导致我认为我的实现不正确,我错过了什么?
编辑,我完整的 tsconfig 看起来像这样
{
"compilerOptions": {
"target": "ES6",
"module": "commonjs",
"lib": ["es7"],
"allowJs": true,
"checkJs": true,
"jsx": "react-native",
"removeComments": true,
"outDir": "./dist",
"typeRoots": ["node_modules/@types", "./typings"],
"experimentalDecorators": true,
"noFallthroughCasesInSwitch": true,
"noImplicitReturns": true,
"noUnusedLocals": true,
"noUnusedParameters": true,
"allowSyntheticDefaultImports": true,
"strict": true
},
"exclude": ["./node_modules", "./android", "./ios", "./assets", "./__tests__", "./dist"],
"include": ["./src"]
}