TypeScriptバージョン: 2.0.3
コード
完全なプロジェクトはこちら。
tsconfig.json :
{
"compilerOptions": {
"target": "es6",
"module": "system",
"moduleResolution": "node",
"sourceMap": true,
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"removeComments": false,
"noImplicitAny": false
},
"exclude": [
"../node_modules"
]
}
予想される行動:
プロジェクトをコンパイルする場合、およびtsconfigで指定されているように、 node_modules
ディレクトリは無視されるため、そのディレクトリからのエラーは発生しません。
実際の動作:
node_modules/@types
ディレクトリからの多くのエラー。例:
[0] node_modules / @ types / core-js / index.d.ts(21,14):エラーTS2300:識別子 'PropertyKey'が重複しています。
[0] node_modules / @ types / core-js / index.d.ts(85,5):エラーTS2687:「name」のすべての宣言には同一の修飾子が必要です。
[0] node_modules / @ types / core-js / index.d.ts(145,5):エラーTS2403:後続の変数宣言は同じ型である必要があります。 変数 '[Symbol.unscopables]'はタイプ '{copyWithin:boolean;である必要があります。 エントリ:ブール値; 塗りつぶし:ブール値; 検索:ブール値; findIndex:ブール値; キー:... 'ですが、ここではタイプ' any 'があります。
[0] node_modules / @ types / core-js / index.d.ts(262,5):エラーTS2687:「フラグ」のすべての宣言には同一の修飾子が必要です。
[0] node_modules / @ types / core-js / index.d.ts(276,5):エラーTS2687:「EPSILON」のすべての宣言には同一の修飾子が必要です。
[0] node_modules / @ types / core-js / index.d.ts(311,5):エラーTS2687:「MAX_SAFE_INTEGER」のすべての宣言には同一の修飾子が必要です。
@typesは自動的にコンパイルに含まれます。 それらを除外するには、tsconfig.jsonに"types": []
を追加します
@mhegazyこれを私のtsconfigとしても:
{
"compilerOptions": {
"target": "es6",
"module": "commonjs",
"moduleResolution": "node",
"sourceMap": true,
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"removeComments": false,
"noImplicitAny": false
},
"types": [],
"exclude": [
"../node_modules"
]
}
それでもエラーが発生します。
[1] node_modules / @ types / core-js / index.d.ts(21,14):エラーTS2300:識別子 'PropertyKey'が重複しています。
[1] node_modules / @ types / core-js / index.d.ts(85,5):エラーTS2687:「name」のすべての宣言には同一の修飾子が必要です。
[1] node_modules / @ types / core-js / index.d.ts(145,5):エラーTS2403:後続の変数宣言は同じ型である必要があります。 変数 '[Symbol.unscopables]'はタイプ '{copyWithin:boolean;である必要があります。 エントリ:ブール値; 塗りつぶし:ブール値; 検索:ブール値; findIndex:ブール値; キー:... 'ですが、ここではタイプ' any 'があります。[1] node_modules / @ types / core-js / index.d.ts(262,5):エラーTS2687:「フラグ」のすべての宣言には同一の修飾子が必要です。
{
"compilerOptions": {
"target": "es6",
"module": "commonjs",
"moduleResolution": "node",
"sourceMap": true,
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"removeComments": false,
"noImplicitAny": false,
"types": []
},
"exclude": [
"../node_modules"
]
}
タイプはcompilerOptions
中にあるべきだと思います
最も参考になるコメント
タイプは
compilerOptions
中にあるべきだと思います