angular - 接口(interface) 'HTMLIonIconElement' 不能同时扩展类型 'IonIc on' 和 'HTMLStencilElement'

标签 angular typescript ionic-framework angular13

我刚刚通过运行 ng update 将我的 angular ionic 应用程序升级为使用 angular 12 的 angular v13。更新成功但现在我无法运行应用程序并出现以下错误

[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 目录中。我该如何解决这个问题?

最佳答案

好像是ng update更新了typescript版本到4.4,但是ionic ion-icon好像和这个版本的typescript不兼容。

我使用的当前修复是恢复到 typescript 版本 4.3.5

如何执行此降级:

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

然后运行 -> npm install

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

关于angular - 接口(interface) 'HTMLIonIconElement' 不能同时扩展类型 'IonIc on' 和 'HTMLStencilElement',我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/69928845/

相关文章:

javascript - 我想使用 rxjs subject 来检测多个组件中的值变化。但它只显示改变它的组件的变化

angular - createSelector函数最多可以得到9个参数

angular - 选择后清除 Angular Material 自动完成

ionic-framework - ionic 5 强制浏览器应用程序的灯光主题

asp.net-mvc - 使用 .net mvc 在 IIS angular 2 应用程序上发布

javascript - ng2-split-pane 在初始渲染后调整垂直 Pane 的高度

angular - Ionic Framework 3 缺少 main.css

angular - Angular Testing 中 tick() 和 flush() 有什么区别?

typescript - 用于删除未定义项的过滤器未被 TypeScript 选取

AngularFire2 在 Typescript 中获取经过身份验证的用户 ID