Tôi đang sử dụng kiểu chữ 1.7.5, kiểu chữ 0.6.9 và góc 2.0.0-beta.0.Lỗi biên dịch TypeScript do các kiểu chữ
Làm thế nào tôi có thể loại bỏ các thông báo lỗi biên dịch dạng số Duplicate identifier
do tệp định nghĩa kiểu đánh máy?
Các lỗi Duplicate identifier
xảy ra trong các tập tin định nghĩa các thư mục sau:
node_modules/angular2/typings/es6-shim/es6-shim.d.ts
node_modules/angular2/typings/jasmine/jasmine.d.ts
node_modules/angular2/typings/zone/zone.d.ts
typings/browser/ambient/es6-promise/es6-promise.d.ts
typings/browser/ambient/es6-shim/es6-shim.d.ts
typings/browser/ambient/jasmine/jasmine.d.ts
typings/browser/ambient/karma/karma.d.ts
typings/browser/ambient/zone.js/zone.js.d.ts
trình biên dịch làm trong node_modules/angular2
thư mục kể từ khi tôi loại trừ nó trong tsconfig.json
là gì?
I also posted this question on GitHub
tsconfig.json
{
"compilerOptions": {
"target": "es5",
"module": "system",
"moduleResolution": "node",
"sourceMap": true,
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"removeComments": false,
"noImplicitAny": false
},
"exclude": [
"node_modules",
"typings/main",
"typings/main.d.ts"
]
}
Họ đã mất hết nếu tôi thay đổi exclude
phần của tsconfig.json
:
"exclude": [
"node_modules",
"typings"
]
Nhưng rồi sau khi thêm sau tôi nhận được một lần nữa cùng Duplicate identifier
lỗi biên dịch:
/// <reference path="../../typings/browser.d.ts" />
typings.json
{
"name": "example-mean-app-client",
"dependencies": {},
"devDependencies": {},
"ambientDependencies": {
"bootstrap": "github:DefinitelyTyped/DefinitelyTyped/bootstrap/bootstrap.d.ts#4de74cb527395c13ba20b438c3a7a419ad931f1c",
"es6-promise": "github:DefinitelyTyped/DefinitelyTyped/es6-promise/es6-promise.d.ts#830e8ebd9ef137d039d5c7ede24a421f08595f83",
"es6-shim": "github:DefinitelyTyped/DefinitelyTyped/es6-shim/es6-shim.d.ts#4de74cb527395c13ba20b438c3a7a419ad931f1c",
"jasmine": "github:DefinitelyTyped/DefinitelyTyped/jasmine/jasmine.d.ts#dd638012d63e069f2c99d06ef4dcc9616a943ee4",
"karma": "github:DefinitelyTyped/DefinitelyTyped/karma/karma.d.ts#02dd2f323e1bcb8a823269f89e0909ec9e5e38b5",
"karma-jasmine": "github:DefinitelyTyped/DefinitelyTyped/karma-jasmine/karma-jasmine.d.ts#661e01689612eeb784e931e4f5274d4ea5d588b7",
"systemjs": "github:DefinitelyTyped/DefinitelyTyped/systemjs/systemjs.d.ts#83af898254689400de8fb6495c34119ae57ec3fe",
"zone.js": "github:DefinitelyTyped/DefinitelyTyped/zone.js/zone.js.d.ts#9027703c0bd831319dcdf7f3169f7a468537f448"
}
}
Thiết lập "moduleResolution": " cổ điển "cho các lỗi khác mặc dù do không tìm thấy các mô-đun bạn muốn nhập. Tôi không biết có các kiểu chữ trùng lặp trong thư mục "node_modules/angular2/typing" và "typings". Xóa các kiểu nhập trùng lặp đã giải quyết được sự cố –
Điều này đã được giải quyết chưa? Tôi đang gặp phải vấn đề tương tự. Tôi đã ở đó trong một tuần và không có giải pháp nào hữu ích. –
Nếu bạn gặp vấn đề tương tự, thì vấn đề là anh ta đã cài đặt một số kiểu đã được đưa vào với Angular 2. Điều này gây ra các bản sao. Độ phân giải là gỡ cài đặt các bản sao. – rgvassar