2

我刚刚升级了我的 angular ionic 应用程序,通过运行ng update. 更新成功,但现在我无法运行应用程序并出现以下错误

[ng] Error: node_modules/ionicons/dist/types/components.d.ts:66:15 - error TS2320: Interface 'HTMLIonIconElement' cannot simultaneously extend types 'IonIc
on' and 'HTMLStencilElement'.
[ng]   Named property 'ariaHidden' of types 'IonIcon' and 'HTMLStencilElement' are not identical.
[ng]
[ng] 66     interface HTMLIonIconElement extends Components.IonIcon, HTMLStencilElement {
[ng]                  ~~~~~~~~~~~~~~~~~~
[ng]
[ng]
[ng] Error: node_modules/ionicons/dist/types/components.d.ts:66:15 - error TS2320: Interface 'HTMLIonIconElement' cannot simultaneously extend types 'IonIc
on' and 'HTMLStencilElement'.
[ng]   Named property 'ariaLabel' of types 'IonIcon' and 'HTMLStencilElement' are not identical.
[ng]
[ng] 66     interface HTMLIonIconElement extends Components.IonIcon, HTMLStencilElement {
[ng]                  ~~~~~~~~~~~~~~~~~~
[ng]
[ng]
[ng] Error: node_modules/typescript/lib/lib.dom.d.ts:4632:101 - error TS2344: Type 'HTMLElementTagNameMap[K]' does not satisfy the constraint 'Element'.
[ng]   Type 'HTMLElement | HTMLMetaElement | HTMLAnchorElement | HTMLAreaElement | HTMLAudioElement | ... 151 more ... | HTMLMarqueeElement' is not assigna
ble to type 'Element'.
[ng]     Type 'HTMLIonIconElement' is not assignable to type 'Element'.
[ng]       Property 'ariaHidden' is optional in type 'HTMLIonIconElement' but required in type 'Element'.
[ng]
[ng] 4632     getElementsByTagName<K extends keyof HTMLElementTagNameMap>(qualifiedName: K): HTMLCollectionOf<HTMLElementTagNameMap[K]>;
[ng]                                                                                                          ~~~~~~~~~~~~~~~~~~~~~~~~
[ng]
[ng]
[ng] Error: node_modules/typescript/lib/lib.dom.d.ts:4953:101 - error TS2344: Type 'HTMLElementTagNameMap[K]' does not satisfy the constraint 'Element'.
[ng]   Type 'HTMLElement | HTMLMetaElement | HTMLAnchorElement | HTMLAreaElement | HTMLAudioElement | ... 151 more ... | HTMLMarqueeElement' is not assigna
ble to type 'Element'.
[ng]
[ng] 4953     getElementsByTagName<K extends keyof HTMLElementTagNameMap>(qualifiedName: K): HTMLCollectionOf<HTMLElementTagNameMap[K]>;
[ng]        

问题是所有被投诉的文件都在 node_modules 目录中。我该如何解决这个问题?

4

3 回答 3

2

似乎ng update将 typescript 版本更新为 4.4,但 ionic ion-icon 似乎与此版本的 typescript 不兼容。

我使用的当前修复是恢复到打字稿版本 4.3.5

如何执行此降级:

更新你的 package.json -> 替换:"typescript": "~4.4.4""typescript": "~4.3.5"

然后运行->npm install

如果有人有更多关于这种不兼容的根本原因和解决这个问题的其他方法的信息,我非常感兴趣,因为我非常想升级到 typescript 4.4。

于 2021-11-12T17:05:43.127 回答
1

对我来说,我刚刚"skipLibCheck": true,在 tsconfig.json 中添加,请参见下面的代码:

在此处输入图像描述

于 2021-12-13T08:10:40.997 回答
0

好吧,替换版本的技巧奏效了!对我来说,当我想构建应用程序时触发了这个问题,然后出现了从 angular 12 升级到 13 的消息。之后出现了一些关于没有识别 angular 模块的错误。

现在我启动测试没有错误,但是当应用程序尝试访问服务时出现错误“已被 CORS 策略阻止”。

任何进一步的反馈将不胜感激。

于 2021-11-22T02:51:35.800 回答