[英]TypeScript errors in react-redux typings file
TypeScript編譯器報告react-redux typings文件中的錯誤,即使我已在tsconfig中排除了typings目錄。
TypeScript版本:1.8.10
這是我得到的錯誤
/home/me/dev/proj/typings/main/ambient/react-redux/index.d.ts(64,16)中的錯誤:錯誤TS2314:通用類型'Dispatch'需要1個類型的參數。
/home/me/dev/proj/typings/main/ambient/react-redux/index.d.ts(68,21)中的錯誤:錯誤TS2314:通用類型'ActionCreator'需要1個類型的參數。
/home/me/dev/proj/typings/main/ambient/react-redux/index.d.ts(95,13)中的錯誤:錯誤TS2314:通用類型“存儲”需要1個類型的參數。
typings.json:
{
"ambientDependencies": {
"es6-shim": "registry:dt/es6-shim#0.31.2+20160602141504",
"material-ui": "registry:dt/material-ui#0.15.0+20160602140214",
"query-string": "registry:dt/query-string#3.0.0+20160331065456",
"react": "github:DefinitelyTyped/DefinitelyTyped/react/react.d.ts#f407264835650f5f38d4bb2c515a79e7a835916b",
"react-addons-css-transition-group": "registry:dt/react-addons-css-transition-group#0.14.0+20160316155526",
"react-addons-transition-group": "registry:dt/react-addons-transition-group#0.14.0+20160417134118",
"react-dom": "github:DefinitelyTyped/DefinitelyTyped/react/react-dom.d.ts#ca5bfe76d2d9bf6852cbc712d9f3e0047c93486e",
"react-redux": "registry:dt/react-redux#4.4.0+20160501125835",
"react-tap-event-plugin": "registry:dt/react-tap-event-plugin#0.0.0+20160226083632",
"require": "registry:dt/require#2.1.20+20160316155526",
"socket.io-client": "registry:dt/socket.io-client#1.4.4+20160317120654"
},
"dependencies": {
"es6-promise": "registry:npm/es6-promise#3.0.0+20160211003958",
"radium": "registry:npm/radium#0.16.6+20160310030142",
"redux-thunk": "registry:npm/redux-thunk#2.0.0+20160525185520",
"webpack": "registry:npm/webpack#1.12.9+20160418172948"
}
}
tsconfig.json:
{
"version": "1.8.10",
"compileOnSave": false,
"compilerOptions": {
"module": "commonjs",
"target": "es5",
"jsx": "react",
"sourceMap": true,
"emitDecoratorMetadata": true,
"experimentalDecorators": true
},
"exclude": [
"node_modules",
"typings"
]
}
為什么報告排除目錄中的錯誤? 如何消除這些錯誤?
更新:
正如Mike在他的回答中所建議的那樣,問題在於react-redux定義是使用redux的dt定義,而不是redux附帶的定義。 為redux安裝dt defintions確實消除了這些錯誤,但這不是我的選擇,因為我自己的代碼使用redux附帶的定義文件中定義的泛型類型。
所以我真正的問題是:如何阻止TypeScript報告來自typings目錄的文件中的錯誤? 我認為將'typings'設置為排除目錄之一會阻止這種情況,但事實並非如此。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.