angular - @Types/node/index.d.ts Lỗi TypeScript TS2309
Tôi có một dự án .Net Core Angular 2 sử dụng SystemJs mà gần đây tôi đã nâng cấp từ Typings lên @Types.
Dự án đã được xây dựng lại hoàn toàn với các công cụ VS mới nhất cho .Net Core 1.0.1 và TypeScript 2.0.10 và Node.js 7.0.0 tính đến ngày 21/12/2016.
Các tệp dự án đã hoạt động bình thường trước khi cập nhật lên @Types.
Tôi đang nhận được Lỗi sau từ @Types/node/index.d.ts:
TS2309 "Xây dựng: Một phép gán xuất khẩu không thể được sử dụng trong một module có các phần tử xuất khẩu khác." Dòng 3626
Dòng 3626 của @Types/node/index.d.ts là xuất khẩu cho khai báo mô-đun "assert".
Đây là các tệp cấu hình của tôi
tsconfig.json
"compilerOptions": {
"target": "es5",
"module": "commonjs",
"moduleResolution": "node",
"sourceMap": true,
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"removeComments": false,
"noImplicitAny": false,
"skipLibCheck": true
},
"compileOnSave": true,
"exclude": [
"node_modules",
"wwwroot/shared/lib"
]
Gói.json
"name": "angular-quickstart",
"version": "1.0.0",
"description": "QuickStart package.json from the documentation, supplemented with testing support",
"scripts": {
"start": "tsc && concurrently \"tsc -w\" \"lite-server\" ",
"lite": "lite-server",
"tsc": "tsc",
"tsc:w": "tsc -w"
},
"keywords": [],
"author": "",
"license": "ISC",
"dependencies": {
"@angular/common": "~2.2.0",
"@angular/compiler": "~2.2.0",
"@angular/core": "~2.2.0",
"@angular/forms": "~2.2.0",
"@angular/http": "~2.2.0",
"@angular/platform-browser": "~2.2.0",
"@angular/platform-browser-dynamic": "~2.2.0",
"@angular/router": "~3.2.0",
"@angular/upgrade": "~2.2.0",
"angular-in-memory-web-api": "~0.1.15",
"core-js": "^2.4.1",
"reflect-metadata": "^0.1.8",
"rxjs": "5.0.0-beta.12",
"systemjs": "0.19.41",
"zone.js": "^0.6.26",
"@progress/kendo-angular-grid": "^0.6.1",
"@progress/kendo-angular-charts": "^0.9.0",
"@progress/kendo-angular-dropdowns": "^0.16.10",
"@progress/kendo-angular-inputs": "^0.13.1",
"@progress/kendo-angular-layout": "^0.15.0",
"@progress/kendo-angular-dialog": "^0.12.2",
"@progress/kendo-angular-upload": "^0.10.4",
"@progress/kendo-angular-buttons": "^0.13.3",
"@progress/kendo-angular-popup": "^0.13.2",
"@progress/kendo-angular-scrollview": "^0.5.1",
"@progress/kendo-angular-sortable": "^0.5.1",
"@progress/kendo-data-query": "^0.1.6",
"@telerik/kendo-theme-default": "^1.28.1",
"jquery": "2.1.1",
"jquery-validation": "1.15.1",
"jquery-validation-unobtrusive": "3.2.6",
"office-ui-fabric-core": "5.0.1",
"bootstrap": "3.3.7"
},
"devDependencies": {
"@types/core-js": "^0.9.34",
"@types/node": "^6.0.49",
"@types/jasmine": "2.5.38",
"concurrently": "^3.0.0",
"lite-server": "^2.2.2",
"typescript": "^2.0.10",
"gulp": "3.9.1",
"gulp-cssmin": "0.1.7",
"gulp-concat": "2.6.0",
"gulp-uglify": "2.0.0",
"gulp-clean": "0.3.2",
"gulp-typescript": "2.14.1"
},
"repository": {}
}
Câu trả lời #1
Gợi ý từ các anh em TypeScript trên GitHub đã được sửa cho chúng tôi.
Tìm kiếm những điều sau -
declare module "assert" {
Nó chỉ nên xuất hiện một lần trong dự án của bạn. Chúng tôi đã có nó trong hai tệp - tệp định nghĩa TypeScript trong gói @types/node và tệp thứ hai trong thư mục wwwroot của chúng tôi cần xóa và đã bị sao chép nhầm bởi một tác vụ Gulp và đang được trình biên dịch phát hiện. Hy vọng điều này hữu ích!
