2016-09-28 15 views
0

後、私は(これに類似し、他の多くの)次のエラーを取得する私が構築しようとすると:重複識別子のエラーがtypescriptですし、ノード更新

タイピング/セレンwebdriverを/セレンwebdriver.d.tsを(12、 11):エラーTS2300:重複した識別子 'Driver'。

このエラーは、typescript v2に更新した後に表示され始めました。 私はindex.tsのtds.d.tsを参照しています

このエラーを解決する方法はありますか?

答えて

0

おそらく、selenium-webdriver * .tsファイルが複数回含まれている可能性があります。すべての可視「@types」のパッケージはあなたの コンパイルに含まれている

https://www.typescriptlang.org/docs/handbook/tsconfig-json.html#types-typeroots-and-types

@types、typeRootsと種類デフォルトで

:このリンク(以下のドキュメントスニペット)をチェックしてください。 node_modules/@囲みフォルダ内のパッケージ は可視と見なされます。具体的には、 ./node_modules/@types/、../node_modules/@types/、 ../../node_modules/@types/などのパッケージを意味します。あなたのコンソール出力で

あなたはスクロールダウンして、「重複識別子 『ドライバ』」のエラーメッセージ内の任意の繰り返しを探している場合、あなたはおそらく何かのように表示されます/タイプ@

node_modules/selenium-webdriver/index.d.ts(12,11):エラー TS2300:Duplicate identifier 'Driver'。

tsconfig.jsonファイルでは、「typeRoots」という設定で再生できます。これは、コンパイル時に考慮する明示的な「タイプ」ルートディレクトリ/ロケーションの配列です。また、他のいくつかのtsconfig.json属性があります

{ 
    "compilerOptions": { 
    "target": "es5", 
    "module": "commonjs", 
    "moduleResolution": "node", 
    "sourceMap": true, 
    "emitDecoratorMetadata": true, 
    "experimentalDecorators": true, 
    "lib": [ "es2015", "dom" ], 
    "noImplicitAny": true, 
    "suppressImplicitAnyIndexErrors": true, 
    "typeRoots": ["./typings"] 
    }, 
    "exclude": [ 
    "node_modules", 
    "**/*-aot.ts" 
    ] 
} 

または

{ 
    "compilerOptions": { 
    "target": "es5", 
    "module": "commonjs", 
    "moduleResolution": "node", 
    "sourceMap": true, 
    "emitDecoratorMetadata": true, 
    "experimentalDecorators": true, 
    "lib": [ "es2015", "dom" ], 
    "noImplicitAny": true, 
    "suppressImplicitAnyIndexErrors": true, 
    "typeRoots": ["./node_modules/@types"] 
    }, 
    "exclude": [ 
    "node_modules", 
    "**/*-aot.ts" 
    ] 
} 

:私の推測では、あなたはあなたが複数の同様の「typeRoots」の自動ロードを防ぐために、次のいずれかのように見えるしたいです"ファイル"、 "除外"、 "インクルード"、 "タイプ"など、あなたの興味を引くかもしれません。

関連する問題