我正在使用NPM软件包react-hyperscript-helpers。当我导入它时,它会读取index.js并从index.d.ts获取类型。然而,这些类型似乎已经过时了,因为我遇到了很多这样的错误:
node_modules/react-hyperscript-helpers/lib/index.d.ts(546,53): error TS2314: Generic type 'HTMLAttributes<T>' requires 1 type argument(s).
我知道如何修复类型错误,但我当然不能在node_modules下编辑文件,因为它将在下一个npm install中被覆盖。
如何忽略包含的.d.ts 文件并使用文件?
我试图忽略tsconfig.json中的所有tsconfig.json,并设置typings选项,但没有成功。这是那个文件,如果有什么用的话:
{
"compilerOptions": {
"outDir": "./dist/",
"sourceMap": true,
"noImplicitAny": true,
"module": "commonjs",
"target": "es5",
"jsx": "react",
"typeRoots" : ["./typings"]
},
"include": [
"typescript/**/*"
],
"exclude": [
"node_modules/**/*",
"node_modules/react-hyperscript-helpers/lib/*.ts"
]
}发布于 2016-10-21 17:24:02
第一种选择:
不要使用@types模块,并将所有声明手工放在d.ts文件中,这些文件都包含在tsconfig.json中。您必须用declare module "mymod" {...}包装所有pkgs的定义。
除了这样做,请确保在配置"moduleResolution": "classic"中添加此"moduleResolution": "classic"
第二种选择:
供应商--您想要更正声明的整个npm。您一直使用@type pkgs,但是修复了一个npm不适合您的问题。
第三:
向pkg创建者发送一个PR。
这实际上是在IRC freenode中的##typescript中的帮助的结果。只是在这里贴给有问题的人。
https://stackoverflow.com/questions/40181022
复制相似问题