2017-08-16 6 views
0

私は、モジュールフォルダ内の古い定義を持つサードパーティ製モジュール( "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

+0

のですか? – Nayish

+0

は、質問を情報 –

+0

で更新しました。まず、除外されたファイルから型を削除する必要があります。次に、手持ち型の型を追加する必要があります。最後に、あなたは型宣言型を除外する必要があります。 – Nayish

答えて

0

常に最善ので

"node_modules/@types/{module}/index.d.ts"よりも優先されます回避策は、これまでのところ、tsconfig.json/compilationOptions/pathsをマップすることです。 :それを見つけるために私を助けた何

{ 
    compilationOptions:{ 
     baseUrl:"node_modules", 
     paths:{ 
     "handsontable":["@types/handsontable"] 
     } 
    }  
} 

は、フラグTSCの--traceResolutionsあなたは `tsconfig`ファイルに何を持っているん