angular - 如何摆脱警告 .ts 文件是 TypeScript 编译的一部分,但未使用

标签 angular typescript angular-cli

我刚刚将 angular 更新为最新 9.0.0-next.4 .我没有使用路由,但在更新后突然我一直看到这个警告。如何删除此警告

WARNING in src/war/angular/src/app/app-routing.module.ts is part of the TypeScript compilation but it's unused. Add only entry points to the 'files' or 'include' properties in your tsconfig.



package.json
  "dependencies": {
"@angular/animations": "^9.0.0-next.4",
"@angular/cdk": "^8.1.4",
"@angular/common": "^9.0.0-next.4",
"@angular/compiler": "^9.0.0-next.4",
"@angular/core": "^9.0.0-next.4",
"@angular/forms": "^9.0.0-next.4",
"@angular/material": "^8.1.4",
"@angular/platform-browser": "^9.0.0-next.4",
"@angular/platform-browser-dynamic": "^9.0.0-next.4",
"@angular/router": "^9.0.0-next.4",
"@ng-bootstrap/ng-bootstrap": "^5.1.0",
"bootstrap": "^4.3.1",
"hammerjs": "^2.0.8",
"moment": "^2.24.0",
"ng-image-slider": "^2.0.1",
"panzoom": "^8.1.2",
"rxjs": "~6.5.2",
"tslib": "^1.9.0",
"zone.js": "^0.10.2"
  },
  "devDependencies": {
    "@angular-devkit/build-angular": "^0.803.2",
    "@angular/cli": "^8.3.2",
    "@angular/compiler-cli": "^9.0.0-next.4",
    "@angular/language-service": "^9.0.0-next.4",
    "@types/jasmine": "~3.3.8",
    "@types/jasminewd2": "~2.0.3",
    "@types/node": "~8.9.4",
    "codelyzer": "^5.0.0",
    "jasmine-core": "~3.4.0",
    "jasmine-spec-reporter": "~4.2.1",
    "karma": "~4.1.0",
    "karma-chrome-launcher": "~2.2.0",
    "karma-coverage-istanbul-reporter": "~2.0.1",
    "karma-jasmine": "~2.0.1",
    "karma-jasmine-html-reporter": "^1.4.0",
    "protractor": "~5.4.0",
    "ts-node": "~7.0.0",
    "tslint": "^5.15.0",
    "typescript": "^3.5.3"
  }

tsconfig.json
    {
  "compileOnSave": false,
  "compilerOptions": {
    "baseUrl": "./",
    "outDir": "./dist/out-tsc",
    "sourceMap": true,
    "declaration": false,
    "module": "esnext",
    "moduleResolution": "node",
    "emitDecoratorMetadata": true,
    "experimentalDecorators": true,
    "importHelpers": true,
    "target": "es2015",
    "typeRoots": [
      "node_modules/@types"
    ],
    "lib": [
      "es2018",
      "dom"
    ]
  }
}

最佳答案

原来你需要从“include”中删除这一行"src/**/*.ts"来自 tsconfig.app.json并且只在文件中保留入口点(main.ts 和 polyfills.ts)

关于angular - 如何摆脱警告 .ts 文件是 TypeScript 编译的一部分,但未使用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57729518/

相关文章:

javascript - Angular 组件中的@Input() 属性返回空数组

angular - 使用angular4下载pdf格式的网页

asp.net - Angular2 路由不适用于生产 IIS

angular - 按 bool 值排序

angular - Ng-serve 在终端中显示一个空白屏幕

angular - 递归 Angular 2 HTML 绑定(bind)

typescript - TypeScript 中 lambda 返回类型的签名

javascript - 比较数组并将数据推送到索引位置

Angular CLI 删除带前缀的 CSS

Angular - 类型 'string' 不可分配给类型 'boolean'