2017-03-08 25 views
2

私はクライアント/サーバーJSアプリケーションを構築しており、約束を使用して大きな問題があります。それらは未定義または複製されており、@typesパッケージに依存しているようです。私はそのパッケージを削除した場合Typescriptの入力 - 重複した名前約束/名前が見つかりません約束

cd ../server 
➜ server git:(master) ✗ tsc 
../node_modules/@types/es6-promise/index.d.ts(11,15): error TS2300: Duplicate identifier 'Promise'. 
../node_modules/@types/es6-promise/index.d.ts(42,19): error TS2300: Duplicate identifier 'Promise' 
.../../../../../../../usr/local/lib/node_modules/typescript/lib/lib.es6.d.ts(4936,11): error TS2300: Duplicate identifier 'Promise'. 
../../../../../../../usr/local/lib/node_modules/typescript/lib/lib.es6.d.ts(5261,11): error TS2300: Duplicate identifier 'Promise'. 
../../../../../../../usr/local/lib/node_modules/typescript/lib/lib.es6.d.ts(5511,13): error TS2300: Duplicate identifier 'Promise'. 
../../../../../../../usr/local/lib/node_modules/typescript/lib/lib.es6.d.ts(5737,11): error TS2300: Duplicate identifier 'Promise'. 
➜ server git:(master) ✗ 

、その後、私が取得クライアントエラー:

tsc 
src/components/GeneralChatAdminInputArea.tsx(100,14): error TS2304: Cannot find name 'Promise'. 
src/components/GeneralChatAdminInputArea.tsx(103,16): error TS2304: Cannot find name 'Promise'. 
src/routes/users/index.ts(11,21): error TS2304: Cannot find name 'Promise'. 
src/routes/users/index.ts(12,21): error TS2304: Cannot find name 'Promise'. 
src/routes/users/index.ts(13,3): error TS2304: Cannot find name 'Promise'. 

これから抜け出す方法を教えて

npm install --save @types/es6-promise` 

これは、このようなサーバーのエラーを与えるのだろうか?

マイtsconfig.jsonは次のようになります。

クライアントは

➜ author git:(402-compile-errors) ✗ cd client 
➜ client git:(402-compile-errors) ✗ tsc 
➜ client git:(402-compile-errors) ✗ cd ../server 

罰金コンパイルするが、サーバーは

➜ server git:(402-compile-errors) ✗ tsc 
../node_modules/@types/es6-promise/index.d.ts(11,15): error TS2300: Duplicate identifier 'Promise'. 
../node_modules/@types/es6-promise/index.d.ts(42,19): error TS2300: Duplicate identifier 'Promise'. 
../../../../../../../usr/local/lib/node_modules/typescript/lib/lib.es6.d.ts(4936,11): error TS2300: Duplicate identifier 'Promise'. 
../../../../../../../usr/local/lib/node_modules/typescript/lib/lib.es6.d.ts(5261,11): error TS2300: Duplicate identifier 'Promise'. 
../../../../../../../usr/local/lib/node_modules/typescript/lib/lib.es6.d.ts(5511,13): error TS2300: Duplicate identifier 'Promise'. 
../../../../../../../usr/local/lib/node_modules/typescript/lib/lib.es6.d.ts(5737,11): error TS2300: Duplicate identifier 'Promise'. 
を失敗し、ここで

{ 
    "compilerOptions": { 
     "sourceMap": true, 
     "noImplicitAny": false, 
     "target": "es6", 
     "jsx": "react", 
     "module": "commonjs", 
     "moduleResolution": "node", 
     "isolatedModules": false, 
     "experimentalDecorators": true, 
     "emitDecoratorMetadata": true, 
     "declaration": false, 
     "removeComments": true, 
     "noLib": false, 
     "preserveConstEnums": true, 
     "suppressImplicitAnyIndexErrors": true, 
     "noUnusedLocals": true 
    }, 
    "filesGlob": [ 
     "**/*.ts", 
     "**/*.tsx", 
     "**/*.tsd" 
    ], 
    "compileOnSave": true, 
    "buildOnSave": false, 
    "atom": { 
     "rewriteTsconfig": false 
    } 
} 

問題を示す別のバージョンが行ったり来たりです

ライブラリを削除し、現在サーバが

➜ server git:(402-compile-errors) ✗ rm -rf ../node_modules/@types/es6-promise 
➜ server git:(402-compile-errors) ✗ tsc          
➜ server git:(402-compile-errors) ✗ cd ../client 

をコンパイルしますが、今、クライアントは

➜ client git:(402-compile-errors) ✗ tsc 
src/components/GeneralChatAdminInputArea.tsx(100,14): error TS2304: Cannot find name 'Promise'. 
src/components/GeneralChatAdminInputArea.tsx(103,16): error TS2304: Cannot find name 'Promise'. 
src/routes/users/index.ts(11,21): error TS2304: Cannot find name 'Promise'. 
src/routes/users/index.ts(12,21): error TS2304: Cannot find name 'Promise'. 
src/routes/users/index.ts(13,3): error TS2304: Cannot find name 'Promise'. 
➜ client git:(402-compile-errors) ✗ 

だから、それはあなたのtsconfig.jsonlibがありませんcatch22

+0

はなかったunionalさん答えはあなたの仕事ですか?そのlibオプションをどこに追加しなければならなかったのですか? –

答えて

1

のように思える失敗:

// tsconfig.json 
{ 
    "compilerOptions": { 
    "lib": [ 
     "es2015" 
    ] 
    } 
} 
+0

私はes6をターゲットにしていますか?地球上ではどこから来たのですか? – dcsan

+1

私はクライアントとサーバーのための別個のtsconfigを持っています。 – dcsan

+0

私はこれを試して、 'エラーTS5023:不明なコンパイラオプション 'lib'を取得しました。これは' tsc 1.5.3'とあります。 – dcsan

関連する問題