npm 将angular,angular mat升级到版本13后,mat-contentedable停止工作

oo7oh9g9  于 2022-11-14  发布在  Angular
关注(0)|答案(2)|浏览(190)

将anguarl版本从12升级到13后,mat-contentetable导致错误

Error: /node_modules/mat-contenteditable/lib/mat-ckeditor.directive.d.ts:9:22 - error TS2420: Class 'MatCkeditorDirective' incorrectly implements interface 'CanUpdateErrorState'.
  Property 'updateErrorState' is missing in type 'MatCkeditorDirective' but required in type 'CanUpdateErrorState'.

9 export declare class MatCkeditorDirective extends _MatInputMixinBase implements MatFormFieldControl<string>, DoCheck, CanUpdateErrorState, OnInit {
                       ~~~~~~~~~~~~~~~~~~~~

  /node_modules/@angular/material/core/common-behaviors/error-state.d.ts:17:5
    17     updateErrorState(): void;
           ~~~~~~~~~~~~~~~~~~~~~~~~~
    'updateErrorState' is declared here.

Error: /node_modules/mat-contenteditable/lib/mat-contenteditable.directive.d.ts:4:29 - error TS2305: Module '"@angular/material/core"' has no exported member 'CanUpdateErrorStateCtor'.

4 import { ErrorStateMatcher, CanUpdateErrorStateCtor, CanUpdateErrorState } from '@angular/material/core';
                              ~~~~~~~~~~~~~~~~~~~~~~~

Error:/node_modules/mat-contenteditable/lib/mat-contenteditable.directive.d.ts:19:22 - error TS2420: Class 'MatContenteditableDirective' incorrectly implements interface 'CanUpdateErrorState'.
  Property 'updateErrorState' is missing in type 'MatContenteditableDirective' but required in type 'CanUpdateErrorState'.

19 export declare class MatContenteditableDirective extends _MatInputMixinBase implements ControlValueAccessor, MatFormFieldControl<string>, DoCheck, CanUpdateErrorState {
                        ~~~~~~~~~~~~~~~~~~~~~~~~~~~

  /node_modules/@angular/material/core/common-behaviors/error-state.d.ts:17:5
    17     updateErrorState(): void;
           ~~~~~~~~~~~~~~~~~~~~~~~~~
    'updateErrorState' is declared here.



× Failed to compile.

package.json:
“@Angular /材料”:“^13.3.2”,“@检查编辑器/检查编辑器5-Angular ”:“^2.0.2”,“@检查编辑器/检查编辑器5-构建-分离-文档”:“^31.1.0”,“可包含蒙版”:“^9.1.0”,

qf9go6mv

qf9go6mv1#

不知道这是否是解决问题的好方法,我不喜欢接触我不拥有的代码......,但我设法再次构建做这两个更新:
在文件***node_modules\mat-contenteditable\mat-contenteditable.指令.d.ts***中:

- remove --> import { CanUpdateErrorStateCtor } from '@angular/material/core';
+ add --> import { _Constructor, _AbstractConstructor } from '@angular/material/core';
+ add (just after the imports) --> declare type CanUpdateErrorStateCtor = _Constructor<CanUpdateErrorState> & _AbstractConstructor<CanUpdateErrorState>;
+ add (in the directive) --> updateErrorState(): void;

在文件***节点模块\mat-contenteditable\mat-ckeditor.指令.d.ts***中:

+ add (in the directive) --> updateErrorState(): void;
m2xkgtsf

m2xkgtsf2#

更改/node_modules中的文件并不是最好的方法。
该类CanUpdateErrorStateCtorhas been removed in Material for Angular 13,因此唯一的“安全”选项是处理它并更新导致该错误的依赖项。
我在同一个类上遇到了一个问题,但由另一个库(@angular-material-components/file-input)引起:

Error: node_modules/@angular-material-components/file-input/lib/file-input.component.d.ts:4:64 - error TS2305: Module '"@angular/material/core"' has no exported member 'CanUpdateErrorStateCtor'.

4 import { CanUpdateErrorState, ErrorStateMatcher, ThemePalette, CanUpdateErrorStateCtor } from '@angular/material/core';
                                                                 ~~~~~~~~~~~~~~~~~~~~~~~

Error: node_modules/@angular-material-components/file-input/lib/file-input.component.d.ts:24:22 - error TS2420: Class 'NgxMatFileInputComponent' incorrectly implements interface 'CanUpdateErrorState'.
Property 'updateErrorState' is missing in type 'NgxMatFileInputComponent' but required in type 'CanUpdateErrorState'.

24 export declare class NgxMatFileInputComponent extends _NgxMatInputMixinBase implements MatFormFieldControl<FileOrArrayFile>, OnDestroy, DoCheck, CanUpdateErrorState, ControlValueAccessor {
                        ~~~~~~~~~~~~~~~~~~~~~~~~

node_modules/@angular/material/core/common-behaviors/error-state.d.ts:17:5
17     updateErrorState(): void;
       ~~~~~~~~~~~~~~~~~~~~~~~~~
'updateErrorState' is declared here.

这是在版本6.0.0,相反,它需要至少版本7.0.0。更新该版本解决了问题。

相关问题