مستودع نسخ بسيط: https://github.com/plantain-00/test ، بعد npm i && npm run build
، الخطأ هو:
node_modules/@types/core-js/index.d.ts(21,14): error TS2300: Duplicate identifier 'PropertyKey'.
node_modules/typescript/lib/lib.es6.d.ts(4133,14): error TS2300: Duplicate identifier 'PropertyKey'.
المتوقع: لا يوجد خطأ ، لأن app.ts
فارغ. يتم استخدام @types/core-js
في static/app.ts
.
"devDependencies": {
"@types/core-js": "^0.9.34",
"core-js": "^2.4.1",
"typescript": "^2.0.3"
}
ما هو الجزء المطلوب من core-js والذي لم يتم تضمينه في lib.es6؟ ألا يمكنك ببساطة عدم تثبيت @types/core-js
؟
يتم استخدامaciccarello core-js و @ types / core-js بواسطة الواجهة الأمامية في static/app.ts
، هذا الجزء يعمل بشكل جيد
هناك 2 tsconfig.json
، واحد للواجهة الخلفية (es6 ، حدث خطأ هنا) ، والآخر للواجهة الأمامية (es5 ، لا يوجد خطأ ، يعمل بشكل جيد) ،
@ plantain-00 هل عرفت ذلك؟
أواجه مشكلة مماثلة ، حيث أريد استخدام بعض الميزات غير القياسية لـ core-js (القواميس) ، لكن الأنواع تتعارض مع مكتبة النصوص المطبوعة.
jefbarn بالنسبة إلى الميزات غير القياسية ، ليس لدي حل.
بالنسبة إلى الميزات القياسية ، قمت بإلغاء تثبيت @types/core-js
، وإزالة import "core-js";
، لأن core-js عبارة عن polyfills لـ ES2015 + ، لذا يمكنني استخدام typescript/lib/lib.es6.d.ts
بدلاً من ذلك ، tsconfig.json
يشبه:
{
"compilerOptions": {
"module": "commonjs",
"target": "es5",
"lib": [
"es2015",
"es5",
"dom",
"scripthost"
]
}
}
يبدو أن هذه المشكلة لا تزال مطلوبة ، سأعيد فتح هذا.
أواجه هذه المشكلة باستخدام @types\core-js
واستهداف ES6
anorborg لقد
"compilerOptions": {
"module": "commonjs",
"target": "es6",
"moduleResolution": "node",
"lib": ["es5", "dom"],
...
}
jefbarn التي لم تنجح. بشكل أساسي ، يتعارض core-js
و typecript 2.x es6.d.ts
libs وهذا يخبر الكتابة المطبوعة بعدم استخدام es6.d.ts
. أعتقد أن الحل الأكثر _pure_ هو إنشاء بعض تعريفات نوع الوحدة النمطية لـ core-js
(على سبيل المثال core-js-es6-object
) بدلاً من تضمين تعريف core-js
بالكامل. حاولت بدء هذا محليًا ، لكن لم أتمكن من تشغيل الأنواع المخصصة المحلية. إذا كان لدي الوقت ، فسأحاول اكتشاف ذلك وإنشاء علاقات عامة لجميع الوحدات.
اهتزت للانتباه.
لقد أنشأت للتو مشروعًا جديدًا باستخدام tsc
2.2.0
باستخدام تهيئة ts التالية:
{
"compilerOptions": {
"outDir": "./build/",
"rootDir": "./src/",
"baseUrl": ".",
"sourceMap": true,
"noImplicitAny": false,
"module": "commonjs",
"target": "es6"
},
"include": [
"./src/**/*.ts"
],
"compileOnSave": false
}
مما ينتج عنه هذه الأخطاء:
node_modules/@types/core-js/index.d.ts(21,14): error TS2300: Duplicate identifier 'PropertyKey'.
node_modules/@types/core-js/index.d.ts(85,5): error TS2687: All declarations of 'name' must have identical modifiers.
node_modules/@types/core-js/index.d.ts(145,5): error TS2403: Subsequent variable declarations must have the same type. Variable '[Symbol.unscopables]' must be of type '{ copyWithin: boolean; entries: boolean; fill: boolean; find: boolean; findIndex: boolean; keys: ...', but here has type 'any'.
node_modules/@types/core-js/index.d.ts(262,5): error TS2687: All declarations of 'flags' must have identical modifiers.
node_modules/@types/core-js/index.d.ts(276,5): error TS2687: All declarations of 'EPSILON' must have identical modifiers.
node_modules/@types/core-js/index.d.ts(311,5): error TS2687: All declarations of 'MAX_SAFE_INTEGER' must have identical modifiers.
node_modules/@types/core-js/index.d.ts(318,5): error TS2687: All declarations of 'MIN_SAFE_INTEGER' must have identical modifiers.
node_modules/@types/core-js/index.d.ts(457,5): error TS2403: Subsequent variable declarations must have the same type. Variable '[Symbol.toStringTag]' must be of type '"Symbol"', but here has type 'string'.
node_modules/@types/core-js/index.d.ts(457,5): error TS2687: All declarations of '[Symbol.toStringTag]' must have identical modifiers.
node_modules/@types/core-js/index.d.ts(464,5): error TS2687: All declarations of 'prototype' must have identical modifiers.
node_modules/@types/core-js/index.d.ts(492,5): error TS2687: All declarations of 'hasInstance' must have identical modifiers.
node_modules/@types/core-js/index.d.ts(498,5): error TS2687: All declarations of 'isConcatSpreadable' must have identical modifiers.
node_modules/@types/core-js/index.d.ts(504,5): error TS2687: All declarations of 'iterator' must have identical modifiers.
node_modules/@types/core-js/index.d.ts(510,5): error TS2687: All declarations of 'match' must have identical modifiers.
node_modules/@types/core-js/index.d.ts(516,5): error TS2687: All declarations of 'replace' must have identical modifiers.
node_modules/@types/core-js/index.d.ts(522,5): error TS2687: All declarations of 'search' must have identical modifiers.
node_modules/@types/core-js/index.d.ts(528,5): error TS2687: All declarations of 'species' must have identical modifiers.
node_modules/@types/core-js/index.d.ts(534,5): error TS2687: All declarations of 'split' must have identical modifiers.
node_modules/@types/core-js/index.d.ts(540,5): error TS2687: All declarations of 'toPrimitive' must have identical modifiers.
node_modules/@types/core-js/index.d.ts(546,5): error TS2687: All declarations of 'toStringTag' must have identical modifiers.
node_modules/@types/core-js/index.d.ts(552,5): error TS2687: All declarations of 'unscopables' must have identical modifiers.
node_modules/@types/core-js/index.d.ts(609,5): error TS2403: Subsequent variable declarations must have the same type. Variable '[Symbol.toStringTag]' must be of type '"Math"', but here has type 'string'.
node_modules/@types/core-js/index.d.ts(609,5): error TS2687: All declarations of '[Symbol.toStringTag]' must have identical modifiers.
node_modules/@types/core-js/index.d.ts(613,5): error TS2403: Subsequent variable declarations must have the same type. Variable '[Symbol.toStringTag]' must be of type '"JSON"', but here has type 'string'.
node_modules/@types/core-js/index.d.ts(613,5): error TS2687: All declarations of '[Symbol.toStringTag]' must have identical modifiers.
node_modules/@types/core-js/index.d.ts(628,5): error TS2687: All declarations of 'size' must have identical modifiers.
node_modules/@types/core-js/index.d.ts(634,5): error TS2687: All declarations of 'prototype' must have identical modifiers.
node_modules/@types/core-js/index.d.ts(645,5): error TS2687: All declarations of 'size' must have identical modifiers.
node_modules/@types/core-js/index.d.ts(651,5): error TS2687: All declarations of 'prototype' must have identical modifiers.
node_modules/@types/core-js/index.d.ts(656,11): error TS2428: All declarations of 'WeakMap' must have identical type parameters.
node_modules/@types/core-js/index.d.ts(664,27): error TS2344: Type 'K' does not satisfy the constraint 'object'.
node_modules/@types/core-js/index.d.ts(665,53): error TS2344: Type 'K' does not satisfy the constraint 'object'.
node_modules/@types/core-js/index.d.ts(666,5): error TS2687: All declarations of 'prototype' must have identical modifiers.
node_modules/@types/core-js/index.d.ts(680,5): error TS2687: All declarations of 'prototype' must have identical modifiers.
node_modules/@types/core-js/index.d.ts(692,5): error TS2687: All declarations of 'value' must have identical modifiers.
node_modules/@types/core-js/index.d.ts(804,5): error TS2687: All declarations of 'prototype' must have identical modifiers.
node_modules/typescript/lib/lib.es6.d.ts(4199,14): error TS2300: Duplicate identifier 'PropertyKey'.
يؤدي تغيير الهدف إلى es5
إلى إنشاء بنية نظيفة.
لست متأكدًا من كيفية حصول هذه المشكلة على القليل من الاهتمام ؛ بالتأكيد يحاول العديد من الأشخاص استهداف ES6 باستخدام TS وهل سيواجهون هذا أيضًا؟
يعرّف كلا من
أنا أيضًا أحصل على نوع مماثل من الصراع.
1> c: \ Program Files (x86) \ Microsoft SDKs \ TypeScript \ 2.6 \ lib.es2015.iterable.d.ts (203،11): الخطأ TS2300: الإنشاء: المعرف المكرر "الوعد".1> c: \ Program Files (x86) \ Microsoft SDKs \ TypeScript \ 2.6 \ lib.es2015.promise.d.ts (223،13): خطأ TS2300: الإنشاء: المعرف المكرر "وعد".1> c: \ Program Files (x86) \ Microsoft SDKs \ TypeScript \ 2.6 \ lib.es2015.symbol.wellknown.d.ts (168،11): خطأ TS2300: الإنشاء: المعرف المكرر "وعد".1> c: \ Program Files (x86) \ Microsoft SDKs \ TypeScript \ 2.6 \ lib.es5.d.ts (1292،11): الخطأ TS2300: الإنشاء: المعرف المكرر "الوعد".1> c: \ users \ username \ node_modules \types \ es6-response \ index.d.ts (11،15): الخطأ TS2300: الإنشاء: المعرف المكرر "الوعد".1> c: \ users \ username \ node_modules \types \ es6-response \ index.d.ts (42،19): الخطأ TS2300: البناء: المعرف
tsconfig: -
{
"compilerOptions": {
"الهدف": "es5"،
"الوحدة النمطية": "commonjs" ،
"moduleResolution": "عقدة"،
"sourceMap": صحيح ،
"emitDecoratorMetadata": صحيح ،
"ديكورات تجريبية": صحيح ،
"lib": ["es2015"، "dom"]،
"noImplicitAny": صحيح ،
"suppressImplicitAnyIndexErrors": صحيح ،
"noStrictGenericChecks": صحيح
}
}
الحزمة. json:
{
"name": "angular-quickstart",
"version": "1.0.0",
"description": "QuickStart package.json from the documentation, supplemented with testing support",
"scripts": {
"build": "tsc -p src/",
"build:watch": "tsc -p src/ -w",
"build:e2e": "tsc -p e2e/",
"serve": "lite-server -c=bs-config.json",
"serve:e2e": "lite-server -c=bs-config.e2e.json",
"prestart": "npm run build",
"start": "concurrently \"npm run build:watch\" \"npm run serve\"",
"pree2e": "npm run build:e2e",
"e2e": "concurrently \"npm run serve:e2e\" \"npm run protractor\" --kill-others --success first",
"preprotractor": "webdriver-manager update",
"protractor": "protractor protractor.config.js",
"pretest": "npm run build",
"test": "concurrently \"npm run build:watch\" \"karma start karma.conf.js\"",
"pretest:once": "npm run build",
"test:once": "karma start karma.conf.js --single-run",
"lint": "tslint ./src/**/*.ts -t verbose"
},
"keywords": [],
"author": "",
"license": "MIT",
"dependencies": {
"@angular/common": "~4.3.4",
"@angular/compiler": "~4.3.4",
"@angular/core": "~4.3.4",
"@angular/forms": "~4.3.4",
"@angular/http": "~4.3.4",
"@angular/platform-browser": "~4.3.4",
"@angular/platform-browser-dynamic": "~4.3.4",
"@angular/router": "~4.3.4",
"angular-in-memory-web-api": "~0.3.0",
"systemjs": "0.19.40",
"core-js": "^2.4.1",
"rxjs": "5.0.1",
"zone.js": "^0.8.4"
},
"devDependencies": {
"concurrently": "^3.2.0",
"lite-server": "^2.2.2",
"typescript": "2.6.0",
"canonical-path": "0.0.2",
"tslint": "^3.15.1",
"lodash": "^4.16.4",
"jasmine-core": "~2.4.1",
"karma": "^1.3.0",
"karma-chrome-launcher": "^2.0.0",
"karma-cli": "^1.0.1",
"karma-jasmine": "^1.0.2",
"karma-jasmine-html-reporter": "^0.2.2",
"protractor": "~4.0.14",
"rimraf": "^2.5.4",
"@types/node": "^6.0.46",
"@types/jasmine": "2.5.36"
},
"repository": {}
}
npm 5.5.1
العقدة 8.9.1
أي حل؟
كان لديه مشكلة مماثلة. تمت إضافة "skipLibCheck": true
إلى compilerOptions
في tsconfig.json
وساعدت أكثر
أهلا
./node_modules/@types/core-js/index.d.ts:1461:36 - الخطأ TS2339: الخاصية 'لـ' غير موجودة في النوع 'SymbolConstructor'.
1461 const _ for: typeof core.Symbol.for ؛
~~~
../node_modules/@types/core-js/index.d.ts:1465:43 - الخطأ TS2339: الخاصية "hasInstance" غير موجودة في النوع "SymbolConstructor".
1465 كونست لهالمثال: نوع النواة.الرمز.
~ ~ ~
../node_modules/@types/core-js/index.d.ts:1469:50 - الخطأ TS2339: الخاصية "isConcatSpreadable" غير موجودة في النوع "SymbolConstructor".
1469 const isConcatSpreadable: typeof core.Symbol.isConcatSpreadable ؛
~ ~ ~ ~~~
../node_modules/@types/core-js/index.d.ts:1477:38 - الخطأ TS2339: الخاصية 'keyFor' غير موجودة في النوع 'SymbolConstructor'.
مفتاح ثابت 1477 لـ: typeof core.Symbol.keyFor ؛
~ ~
../node_modules/@types/core-js/index.d.ts:1481:37 - الخطأ TS2339: الخاصية "match" غير موجودة في النوع "SymbolConstructor".
تطابق ثابت 1481: typeof core.Symbol.match ؛
~
../node_modules/@types/core-js/index.d.ts:1485:39 - الخطأ TS2339: الخاصية "استبدال" غير موجودة في النوع "SymbolConstructor".
1485 const استبدال: typeof core.Symbol.replace ؛
~ ~~
../node_modules/@types/core-js/index.d.ts:1489:38 - الخطأ TS2339: خاصية "البحث" غير موجودة في النوع "SymbolConstructor".
1489 بحث const: typeof core.Symbol.search؛
~ ~
../node_modules/@types/core-js/index.d.ts:1493:39 - الخطأ TS2339: الخاصية "الأنواع" غير موجودة في النوع "SymbolConstructor".
1493 نوعًا من الأنواع الثابتة: typeof core.Symbol.species؛
~ ~~
../node_modules/@types/core-js/index.d.ts:1497:37 - الخطأ TS2339: الخاصية "split" غير موجودة في النوع "SymbolConstructor".
1497 انقسام كونست: typeof core.Symbol.split ؛
~
../node_modules/@types/core-js/index.d.ts:1501:43 - الخطأ TS2339: الخاصية "toPrimitive" غير موجودة في النوع "SymbolConstructor".
1501 const toPrimitive: typeof core.Symbol.toPrimitive ؛
~ ~ ~
../node_modules/@types/core-js/index.d.ts:1505:43 - الخطأ TS2339: الخاصية "toStringTag" غير موجودة في النوع "SymbolConstructor".
1505 const toStringTag: typeof core.Symbol.toStringTag ؛
~ ~ ~
../node_modules/@types/core-js/index.d.ts:1509:43 - الخطأ TS2339: الخاصية "unscopables" غير موجودة في النوع "SymbolConstructor".
1509 const unscopables: typeof core.Symbol.unscopables ؛
~ ~ ~
../node_modules/@types/core-js/index.d.ts:2272:36 - الخطأ TS2339: الخاصية 'لـ' غير موجودة في النوع 'SymbolConstructor'.
2272 const _ for: typeof core.Symbol.for ؛
~~~
../node_modules/@types/core-js/index.d.ts:2276:43 - الخطأ TS2339: الخاصية "hasInstance" غير موجودة في النوع "SymbolConstructor".
2276 الثابت لهالمثال: typeof core.Symbol.hasInstance؛
~ ~ ~
../node_modules/@types/core-js/index.d.ts:2280:50 - الخطأ TS2339: الخاصية "isConcatSpreadable" غير موجودة في النوع "SymbolConstructor".
2280 const isConcatSpreadable: typeof core.Symbol.isConcatSpreadable ؛
~ ~ ~ ~~~
../node_modules/@types/core-js/index.d.ts:2288:38 - الخطأ TS2339: الخاصية "keyFor" غير موجودة في النوع "SymbolConstructor".
2288 مفتاح ثابت لـ: typeof core.Symbol.keyFor ؛
~ ~
../node_modules/@types/core-js/index.d.ts:2292:37 - الخطأ TS2339: الخاصية "match" غير موجودة في النوع "SymbolConstructor".
2292 تطابق ثابت: typeof core.Symbol.match ؛
~
../node_modules/@types/core-js/index.d.ts:2296:39 - الخطأ TS2339: الخاصية "استبدال" غير موجودة في النوع "SymbolConstructor".
2296 const استبدال: typeof core.Symbol.replace ؛
~ ~~
../node_modules/@types/core-js/index.d.ts:2300:38 - الخطأ TS2339: خاصية "البحث" غير موجودة في النوع "SymbolConstructor".
2300 بحث const: typeof core.Symbol.search ؛
~ ~
../node_modules/@types/core-js/index.d.ts:2304:39 - الخطأ TS2339: خاصية "الأنواع" غير موجودة في النوع "SymbolConstructor".
2304 نوعًا من الأنواع الثابتة: typeof core.Symbol.species ؛
~ ~~
../node_modules/@types/core-js/index.d.ts:2308:37 - الخطأ TS2339: الخاصية "split" غير موجودة في النوع "SymbolConstructor".
2308 انقسام كونست: typeof core.Symbol.split ؛
~
../node_modules/@types/core-js/index.d.ts:2312:43 - الخطأ TS2339: الخاصية "toPrimitive" غير موجودة في النوع "SymbolConstructor".
2312 const toPrimitive: typeof core.Symbol.toPrimitive ؛
~ ~ ~
../node_modules/@types/core-js/index.d.ts:2316:43 - الخطأ TS2339: الخاصية "toStringTag" غير موجودة في النوع "SymbolConstructor".
2316 const toStringTag: typeof core.Symbol.toStringTag ؛
~ ~ ~
../node_modules/@types/core-js/index.d.ts:2320:43 - الخطأ TS2339: الخاصية "unscopables" غير موجودة في النوع "SymbolConstructor".
2320 const unscopables: typeof core.Symbol.unscopables ؛
~ ~ ~
هذا هو الخطأ الذي أواجهه
tsconfig الخاص بي
{
"compileOnSave": خطأ ،
"compilerOptions": {
"baseUrl": ""،
"outDir": "./dist/out-tsc"،
"sourceMap": صحيح ،
"إعلان": خطأ ،
"downlevelIteration": صحيح ،
"ديكورات تجريبية": صحيح ،
"الوحدة النمطية": "es6"،
"moduleResolution": "عقدة"،
"importHelpers": صحيح ،
"الهدف": "es5"،
"typeRoots": [
"node_modules / @ أنواع"
] ،
"ليب": [
"es5"،
"es2015"،
"es2017"،
"دوم" ،
"مضيف البرنامج النصي"
] ،
} ،
"angularCompilerOptions": {
"fullTemplateTypeCheck": صحيح ،
"rictInjectionParameters ": صحيح
}
}
ساعدني في حل المشكلة
التعليق الأكثر فائدة
كان لديه مشكلة مماثلة. تمت إضافة
"skipLibCheck": true
إلىcompilerOptions
فيtsconfig.json
وساعدت أكثر