![](/img/trans.png)
[英]Component fails to auto import types from index.d.ts file in React Native
[英]External typing file fails to resolve relative path to its own index.d.ts
当构建我的项目时,依赖于react-color时,tsc无法导入该依赖项,并显示以下错误:
node_modules/@types/react-color/lib/components/sketch/Sketch.d.ts(2,41): error TS2307: Cannot find module '../../..'.
如果我编辑Sketch.d.ts以引用“ ../../../index.d.ts”,问题就消失了,因此隐式标识index.d.ts文件似乎有些问题。
在原本为空的ts + react中进行最小程度的复制不会出现类似的问题,因此我认为我的项目的配置存在问题。
{
"compilerOptions": {
"outDir": "./dist/",
"sourceMap": true,
//"noImplicitAny": true,
"module": "es6",
"target": "es5",
"jsx": "react",
"allowJs": true
}
}
如果从我的tsc -p client/
克隆此分支并运行tsc -p client/
,则会看到错误。
发生这种情况是因为我没有正确配置我的editorOptions.module字段。 将其更改为commonjs
可以达到commonjs
。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.