@Types/node/index.d.ts TypeScript 错误 TS2309

2024-02-13

我有一个使用 SystemJs 的 .Net Core Angular 2 项目,我最近从 Typings 升级到了 @Types。

截至 2016 年 12 月 21 日,该项目已使用适用于 .Net Core 1.0.1、TypeScript 2.0.10 和 Node.js 7.0.0 的最新 VS 工具完全重建。

在更新到 @Types 之前,项目文件可以正常工作。

我从 @Types/node/index.d.ts 收到以下错误:

TS2309“构建:导出分配不能在具有其他导出元素的模块中使用。” 3626线

@Types/node/index.d.ts 的第 3626 行是“assert”模块声明的导出。

这是我的配置文件

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"
]

包.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": {}
}

GitHub 上 TypeScript 人员的建议已为我们解决。

搜索以下内容 -

declare module "assert" {

它应该只在您的项目中出现一次。我们将它放在两个文件中 - @types/node 包中的 TypeScript 定义文件和 wwwroot 文件夹中的第二个文件,该文件需要删除,并且已被 Gulp 任务错误地复制并被编译器拾取。希望这可以帮助!

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

@Types/node/index.d.ts TypeScript 错误 TS2309 的相关文章

随机推荐