私は、モジュールフォルダ内の古い定義を持つサードパーティ製モジュール( "handsontable" node_modules/handsontable/handsontable.d.ts ")、/ node_modules/@ typesフォルダーに適切な" index.d.ts "があります。 ので、構造は以下の通りです:"module/index.d.ts"と "@ types/module/index.d.ts"のtypescriptの競合
/node_modules
/@types
/handsontable
/index.d.ts (LATEST)
/handsontable
/handsontable.d.ts (OUTDATED)
/src/app.ts
私はES6モジュールを使用していますが、私はグローバルにhandsontable公開したくないので、私はapp.tsに書くとき:
import ht from 'handsontable'
let options: ht.Options
それは示していht.Options
が/node_modules/handsontable/handsontable.d.ts
に存在しないので、それが唯一の/node_modules/@types/handsontable/index.d.ts
に存在している間、私は中に/node_modules/@type/module
から型情報をロードするためにtypescriptですを強制的にとにかくあり、エラー3210?
{
"exclude": [
"node_modules","build","dist", "typings","types"
],
"include": [
"./src/**/*.ts"
],
"typeAcquisition": {
"enable": true
// "exclude": [ //tried that too
// "handsontable"
// ]
},
"compileOnSave": true,
"compilerOptions": {
"baseUrl": "node_modules",
"paths": {
"src/*":["../src/*"],
"app/*":["../src/*"],
"*":["../src/*", "./node_modules"]
},
"target": "es2016",
//"module": "es6", //es6 is not compatible with webpack.config.ts
"moduleResolution": "node",
"allowSyntheticDefaultImports": true,
"sourceMap": true,
"allowJs": true,
"outDir": "./build",
"experimentalDecorators": true,
"lib": [
"dom",
"es6"
]
}
}
活字版:ここ
は私tsconfig.jsonあるコメント"node_modules/{module}/{module}.d.ts"
で述べたように2.4.2
のですか? – Nayish
は、質問を情報 –
で更新しました。まず、除外されたファイルから型を削除する必要があります。次に、手持ち型の型を追加する必要があります。最後に、あなたは型宣言型を除外する必要があります。 – Nayish