Angular от 8 до 9 предупреждений об обновлении при сборке - PullRequest
2 голосов
/ 26 февраля 2020

У меня есть проект angular, в котором есть несколько приложений (app, dev, et c.), И я недавно обновил его с Angular v8.2.3 до 9, и теперь начал получать многие из следующие предупреждения (о различных компонентах, это только один пример)

WARNING in {PATH_TO_PROJECT}\src\modules\dev\create-member\create-member.component.ts is part of the TypeScript compilation but it's unused.
Add only entry points to the 'files' or 'include' properties in your tsconfig.

root ts config:

{
    "compileOnSave": false,
    "compilerOptions": {
        "allowJs": true,
        "outDir": "./dist/out-tsc",
        "sourceMap": true,
        "declaration": false,
        "moduleResolution": "node",
        "emitDecoratorMetadata": true,
        "experimentalDecorators": true,
        // tslint bug isn't checking for no unused imports, their solution is to add this
        // https://github.com/Microsoft/vscode-tslint/issues/70#issuecomment-241041929
        "noUnusedLocals": true,
        "noUnusedParameters": true,
        "target": "es2015",
        "typeRoots": [
            "node_modules/@types"
        ],
        "lib": [
            "es2018",
            "dom"
        ],
        "plugins": [
            {"name": "@angular/language-service"}
        ]
    }
}

/ sr c tsconfig:

{
    "extends": "../tsconfig.json",
    "compilerOptions": {
      "outDir": "../out-tsc/app",
      "baseUrl": "./",
      "module": "es2015",
      "types": []
    }
}

Мне удалось заставить все работать без этих предупреждений, добавив отдельный tsconfig для каждого приложения со следующим содержимым:

{
    "extends": "../../tsconfig.json",
    "files": [
        "./{APP_NAME}.main.ts",
        "../../polyfills.ts"
    ]
}

Казалось, что все работает просто отлично с приложением ng build --project но когда я добавляю флаг --prod, я получаю кучу шаблонных ошибок о том, что компоненты не распознаются. Например,

ERROR in src/modules/app/organizations/organization-data-budget-change/organization-data-budget-change.component.html:4:7 - error NG8002: Can't bind to 'formGroup' since it isn't a known property of 'form'.
[1]
[1] 4 <form [formGroup]="DataBudgetChangeForm" class="card-body" novalidate>
[1]         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
[1]
[1]   src/modules/app/organizations/organization-data-budget-change/organization-data-budget-change.component.ts:11:15
[1]     11  templateUrl: 'organization-data-budget-change.component.html'
[1]                      ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
[1]     Error occurs in the template of component OrganizationDataBudgetChangeComponent.

По сути, я просто пытаюсь избавиться от упомянутых выше предупреждений, и я ' я не уверен, что это проблема angular или моя конфигурация неверна

ОБНОВЛЕНИЕ: кажется, что с упомянутыми выше добавлениями tsconfig установка aot в false в моем файле angular. json вызывает все для как обычно (не совсем исправление, так как я все еще хочу использовать в дальнейшем). То же самое для отключения плюща

1 Ответ

0 голосов
/ 26 февраля 2020

У меня было несколько ошибок после следования инструкциям на странице обновления. Поэтому я удалил node_modules, очистил кэш npm и снова установил.

Эти команды предполагают, что вы используете npm.

rd /q /s node_modules (or equivalent command on your platform)
npm cache clean --force
npm install -g @angular/cli (optional if it already latest)
del package-lock.json (or equivalent command 
on your platform)
npm install
ng add @angular/localize (in case it was not already added)
npm install --save-dev @angular/cli
...