pet*_*erc 6 typescript ngrx angular
我有一个 Angular 应用程序,它一直在构建和运行得很好,但是当我添加 Angular/material 时,出现了一些奇怪的 npm 依赖问题,所以我删除了这两个应用程序package-lock.json和我的node_modules,npm i现在安装时不会出现错误。
然而,我现在在编译时遇到了一堆 TypeScript 错误,这是我以前没有的。
我的 package.json 具有以下依赖项:
"dependencies": {
"@angular/animations": "^14.1.0",
"@angular/common": "^14.1.0",
"@angular/compiler": "^14.1.0",
"@angular/core": "^14.1.0",
"@angular/forms": "^14.1.0",
"@angular/material": "14.1.0",
"@angular/material-moment-adapter": "14.1.0",
"@angular/platform-browser": "^14.1.0",
"@angular/platform-browser-dynamic": "^14.1.0",
"@angular/router": "^14.1.0",
"@ngrx/component-store": "^14.3.0",
"@ngrx/effects": "^14.2.0",
"@ngrx/entity": "^14.2.0",
"@ngrx/store": "^14.2.0",
"@ngrx/store-devtools": "^14.2.0",
"@ngx-translate/core": "^14.0.0",
"tslib": "^2.3.0",
"uuid": "^8.3.2",
"zone.js": "~0.11.4"
"devDependencies": {
"@angular-devkit/build-angular": "^14.1.0",
"@angular-eslint/builder": "14.0.2",
"@angular-eslint/eslint-plugin": "14.0.2",
"@angular-eslint/eslint-plugin-template": "14.0.2",
"@angular-eslint/schematics": "14.0.2",
"@angular-eslint/template-parser": "14.0.2",
"@angular/cli": "~14.1.0",
"@angular/compiler-cli": "^14.1.0",
"@types/jasmine": "~4.0.0",
"@types/lodash": "^4.14.184",
"@types/uuid": "^8.3.4",
"@typescript-eslint/eslint-plugin": "5.29.0",
"@typescript-eslint/parser": "5.29.0",
"eslint": "^7.32.0",
"jasmine-core": "~4.2.0",
"karma": "~6.4.0",
"karma-chrome-launcher": "~3.1.0",
"karma-coverage": "~2.2.0",
"karma-jasmine": "~5.1.0",
"karma-jasmine-html-reporter": "~2.0.0",
"typescript": "^4.8.2"
Run Code Online (Sandbox Code Playgroud)
我确实有 TypeScript 4.7,但在收到以下错误后尝试升级(没有任何区别)。
我现在得到的错误是
Error: node_modules/@angular/material/datepicker/index.d.ts:602:48 - error TS2344: Type 'MatDatepickerControl<unknown>' does not satisfy the constraint 'MatDatepickerControl<{}>'.
The types returned by 'getStartValue()' are incompatible between these types.
Type 'unknown' is not assignable to type '{} | null'.
602 constructor(_datepicker: MatDatepickerBase<MatDatepickerControl<unknown>, unknown>, _viewContainerRef: ViewContainerRef);
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Error: node_modules/@angular/material/datepicker/index.d.ts:621:48 - error TS2344: Type 'MatDatepickerControl<unknown>' does not satisfy the constraint 'MatDatepickerControl<{}>'.
621 constructor(_datepicker: MatDatepickerBase<MatDatepickerControl<unknown>, unknown>);
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Error: node_modules/@angular/material/datepicker/index.d.ts:777:36 - error TS2344: Type 'MatDatepickerControl<unknown>' does not satisfy the constraint 'MatDatepickerControl<{}>'.
777 _datepicker: MatDatepickerBase<MatDatepickerControl<unknown>, unknown>;
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Error: node_modules/@angular/material/datepicker/index.d.ts:778:48 - error TS2344: Type 'MatDatepickerControl<unknown>' does not satisfy the constraint 'MatDatepickerControl<{}>'.
778 constructor(_datepicker: MatDatepickerBase<MatDatepickerControl<unknown>, unknown>);
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Error: node_modules/@ngrx/effects/src/effect_decorator.d.ts:7:84 - error TS2344: Type 'T' does not satisfy the constraint 'Object'.
7 export declare function getEffectDecoratorMetadata<T>(instance: T): EffectMetadata<T>[];
~
node_modules/@ngrx/effects/src/effect_decorator.d.ts:7:52
7 export declare function getEffectDecoratorMetadata<T>(instance: T): EffectMetadata<T>[];
~
This type parameter might need an `extends Object` constraint.
Error: node_modules/@ngrx/effects/src/effects_metadata.d.ts:3:75 - error TS2344: Type 'T' does not satisfy the constraint 'Object'.
3 export declare function getSourceMetadata<T>(instance: T): EffectMetadata<T>[];
~
node_modules/@ngrx/effects/src/effects_metadata.d.ts:3:43
3 export declare function getSourceMetadata<T>(instance: T): EffectMetadata<T>[];
~
This type parameter might need an `extends Object` constraint.
Error: node_modules/@ngrx/effects/src/models.d.ts:25:31 - error TS2344: Type 'T' does not satisfy the constraint 'Object'.
25 [key in EffectPropertyKey<T>]?: EffectConfig;
~
node_modules/@ngrx/effects/src/models.d.ts:24:37
24 export declare type EffectsMetadata<T> = {
~
This type parameter might need an `extends Object` constraint.
Run Code Online (Sandbox Code Playgroud)
所以全部来自图书馆。我刚刚添加了材料,所以不确定我之前是否会得到它们,但是,我之前没有从 NgRx 库中得到这些错误
我可以通过添加以下内容来摆脱这些:
"compilerOptions": {
"skipLibCheck": true,
Run Code Online (Sandbox Code Playgroud)
到tsconfig.json,但请注意,隐藏这些错误是最好的主意。
为什么我突然得到这些?
小智 0
我不确定它是否正确,但对于这个问题
Error: node_modules/@angular/material/datepicker/index.d.ts:778:48
- error TS2344: Type 'MatDatepickerControl unknown '
does not satisfy the constraint 'MatDatepickerControl {}
Run Code Online (Sandbox Code Playgroud)
我遇到了同样的问题,我转到node_modules/@angular/material/datepicker/index.d.ts:778:48并更改MatDatepickerControl unknown为MatDatepickerControl any。这对我有用,但我只有一个错误,而不是像你一样的所有列表。
| 归档时间: |
|
| 查看次数: |
6550 次 |
| 最近记录: |