从版本 9 更新到 10 后的 Angular 警告堆栈。ngtypecheck.ts 和 Add only entry points ... in tsconfig

Posted

技术标签:

【中文标题】从版本 9 更新到 10 后的 Angular 警告堆栈。ngtypecheck.ts 和 Add only entry points ... in tsconfig【英文标题】:Angular warning stack after the update from version 9 to 10. ngtypecheck.ts and Add only entry points ... in tsconfig 【发布时间】:2020-12-14 22:49:03 【问题描述】:

我刚刚将我的 Angular 版本从 9 更新到 10。

我按照以下步骤进行操作。根据 Angular 更新指南

第 1 步:

ng 更新 @angular/core @angular/cli

第 2 步:因为我使用的是棱角材料。我也更新了角度材质。

ng 更新@angular/material

第 3 步:最后一步。

更新

我的 package.json 文件


  "name": "my-app-name",
  "version": "0.0.0",
  "scripts": 
    "ng": "ng",
    "start": "ng serve",
    "build": "ng build",
    "test": "ng test",
    "lint": "ng lint",
    "e2e": "ng e2e"
  ,
  "private": true,
  "dependencies": 
    "@angular/animations": "~10.0.12",
    "@angular/cdk": "^10.1.3",
    "@angular/common": "~10.0.12",
    "@angular/compiler": "~10.0.12",
    "@angular/core": "~10.0.12",
    "@angular/flex-layout": "^10.0.0-beta.32",
    "@angular/forms": "~10.0.12",
    "@angular/material": "^10.1.3",
    "@angular/platform-browser": "~10.0.12",
    "@angular/platform-browser-dynamic": "~10.0.12",
    "@angular/router": "~10.0.12",
    "rxjs": "~6.5.4",
    "tslib": "^1.10.0",
    "zone.js": "~0.10.2"
  ,
  "devDependencies": 
    "@angular-devkit/build-angular": "^0.900.7",
    "@angular/cli": "^10.0.7",
    "@angular/compiler-cli": "~10.0.12",
    "@angular/language-service": "~10.0.12",
    "@types/jasmine": "~3.5.0",
    "@types/jasminewd2": "~2.0.3",
    "@types/node": "^12.11.1",
    "codelyzer": "^5.1.2",
    "jasmine-core": "~3.5.0",
    "jasmine-spec-reporter": "~4.2.1",
    "karma": "~4.3.0",
    "karma-chrome-launcher": "~3.1.0",
    "karma-coverage-istanbul-reporter": "~2.1.0",
    "karma-jasmine": "~2.0.1",
    "karma-jasmine-html-reporter": "^1.4.2",
    "protractor": "~5.4.3",
    "ts-node": "~8.3.0",
    "tslint": "~5.18.0",
    "typescript": "~3.9.7"
  

我的 Angular 版本

Angular CLI: 10.0.7
Node: 12.18.3
OS: win32 x64

Angular: 10.0.12
... animations, common, compiler, compiler-cli, core, forms
... language-service, platform-browser, platform-browser-dynamic
... router
Ivy Workspace: <error>

Package                           Version
-----------------------------------------------------------
@angular-devkit/architect         0.900.7
@angular-devkit/build-angular     0.900.7
@angular-devkit/build-optimizer   0.900.7
@angular-devkit/build-webpack     0.900.7
@angular-devkit/core              9.0.7
@angular-devkit/schematics        10.0.7
@angular/cdk                      10.1.3
@angular/cli                      10.0.7
@angular/flex-layout              10.0.0-beta.32
@angular/material                 10.1.3
@ngtools/webpack                  9.0.7
@schematics/angular               10.0.7
@schematics/update                0.1000.7
rxjs                              6.5.5
typescript                        3.9.7
webpack                           4.41.2

我收到了太多如下所述的警告。

__local_path__file_name..ngtypecheck.ts 中的警告是 TypeScript 编译的一部分,但未使用。 仅将入口点添加到 tsconfig 中的“文件”或“包含”属性。

还有,下面提到的 tsconfig.app.json 文件

  
          "extends": "./tsconfig.json",
          "compilerOptions": 
            "outDir": "./out-tsc/app",
            "types": []
          ,
          "files": ["src/main.ts", "src/polyfills.ts"],
          "include": ["src/**/*.d.ts"]
    

我尝试了几种解决方案。但没有什么对我有用。

提前致谢。

【问题讨论】:

【参考方案1】:

您能否尝试更新 tsconfig.app.json

    
  "extends": "../tsconfig.json",
  "compilerOptions": 
    "outDir": "../out-tsc/app",
    "module": "es2015",
    "types": []
  ,
  "include": [
    "src/test.ts",
    "src/**/*.prod.ts"
  ],
  "exclude": [
    "**/*.spec.ts"
  ]

参考: https://github.com/angular/angular-cli/issues/17066

【讨论】:

以上是关于从版本 9 更新到 10 后的 Angular 警告堆栈。ngtypecheck.ts 和 Add only entry points ... in tsconfig的主要内容,如果未能解决你的问题,请参考以下文章

将 ASP.Net Core Angular 模板从版本 8 更新到 9

从 Angular 9 升级到 Angular 10 时遇到问题

Angular 10 PWA 中 Chrome 更新后的新警告“无法安装站点:页面无法脱机工作。从 Chrome 93 开始...”

角度更新后的引导 SCSS 错误

升级到 9.0 和 angular 7 后修复 angular-redux/store

角度更新 10.2 到 11