Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ionicons errors on typescript >= 4.4.x #1011

Closed
4 of 6 tasks
godenji opened this issue Oct 7, 2021 · 13 comments
Closed
4 of 6 tasks

ionicons errors on typescript >= 4.4.x #1011

godenji opened this issue Oct 7, 2021 · 13 comments

Comments

@godenji
Copy link

godenji commented Oct 7, 2021

Prerequisites

Ionic Framework Version

  • v4.x
  • v5.x
  • v6.x

Current Behavior

Attempting to use Ionic 6 RC.0 with Angular 13 beta fails due to the latter requiring TypeScript >= 4.4.3.

Looking at the Ionic/Angular 6 package.json, some of the dependencies are quite out of date. It was my impression that moving forward Ionic was only going to support the last 2 major versions of Angular, which would mean the oldest supported version would be Angular 11, not Angular 8 as things currently stand.

Expected Behavior

That Ionic 6 supports TypeScript >= 4.4.3

Steps to Reproduce

Install Ionic 6 RC + Angular Beta

Code Reproduction URL

No response

Ionic Info

No response

Additional Information

No response

@liamdebeasi
Copy link
Contributor

Thanks for the issue. Could you please reproduce this issue in an Ionic app and provide a link to the repo?

@godenji
Copy link
Author

godenji commented Oct 19, 2021

Repro repo

ionic serve stacktrace:

Build at: 2021-10-19T21:52:16.687Z - Hash: 4a7b8cfe14a274c8 - Time: 420ms
[ng]
[ng] Error: node_modules/ionicons/dist/types/components.d.ts:66:15 - error TS2320: Interface 'HTMLIonIconElement' cannot simultaneously extend types 'IonIcon' 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 'IonIcon' 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 | HTMLAnchorElement | HTMLAreaElement | HTMLAudioElement | HTMLBaseElement | ... 157 more ... | HTMLMarqueeElement' is not assignable 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(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 | HTMLAnchorElement | HTMLAreaElement | HTMLAudioElement | HTMLBaseElement | ... 157 more ... | HTMLMarqueeElement' is not assignable to type 'Element'.
[ng]
[ng] 4953 getElementsByTagName(qualifiedName: K): HTMLCollectionOf<HTMLElementTagNameMap[K]>;

@liamdebeasi
Copy link
Contributor

Thanks! The issue here seems to be related to something in Ionicons, so I am going to move the issue to that repo.

@liamdebeasi
Copy link
Contributor

liamdebeasi commented Oct 27, 2021

Took a closer look and there are a few things at play here:

  1. TypeScript changed the ARIA mixins to be of type string in TypeScript 4.4: Migrate latest dom types into libdom.d.ts  microsoft/TypeScript#44684. Previously properties like ariaHidden could be undefined. This change is what is causing the error noted in this thread.
  2. There is confusion over whether or not these properties should accept null or undefined. According to the ARIA spec, using undefined or null is incorrect usage: ARIAMixin properties should be nullable? microsoft/TypeScript-DOM-lib-generator#1119 (comment). But there is a proposal to make these properties nullable again: Update IDL and enumerated attribute section w3c/aria#1611.
  3. There is a mismatch between what the ARIA spec says and what browsers actually do. According to the spec, passing Element.ariaHidden = undefined should yield "undefined" (note this is a string not the actual undefined value): https://www.w3.org/TR/wai-aria-1.2/#example-16. However, browsers such as Chrome and Safari do not convert it to "undefined" currently.

Changing the ariaHidden and ariaLabel properties in the Ionicon component yields its own issue. Changing the prop from:

@Prop() ariaHidden?: string;

to:

@Prop() ariaHidden: string;

Will result in TypeScript errors in most applications as it now expects developers to explicitly set aria-hidden on each instance of <ion-icon>. This is not ideal as it is a big departure from what was previously expected of developers. Additionally, this usage does not align with working with HTML elements (I.e. you can omit aria-hidden).


To get developers unblocked, we plan to remove the ariaHidden and ariaLabel properties from the Ionicon component. This is a breaking change, so we will be releasing this update as ionicons@6.0.0.

While this is a breaking change, developer usage will not change there will be no change for most developers (see below). This is because these properties collide with properties of the same name on Element. In other words, developers will be able to continue to omit aria-hidden and aria-label from their <ion-icon> components.

That being said, ariaHidden was added as a result of #710, so we will need to find another solution to that issue before this update is shipped.


To summarize:

  1. This issue is caused by things beyond the scope of Ionicons.
  2. We will be shipping a fix in ionicons@6.0.0.
  3. Despite this being a major release, there will be no change minimal changes (see below) to how developers use aria-hidden and aria-label on their <ion-icon> components.

Let me know if there are any questions. Thanks!

edit: We identified two use cases where there will be breaking changes:

  1. Adding ARIA via JavaScript:
// Before
iconEl.ariaHidden = "true";

// After
iconEl.setAttribute('aria-hidden', 'true');
  1. Using JSX in React:
{/* Before */}
<IonIcon ariaHidden="true" />

{/* After */}
<IonIcon aria-hidden="true" />

This change is more aligned with what React expects: https://reactjs.org/docs/accessibility.html#wai-aria

@olaisen81
Copy link

Hi @liamdebeasi, how to resolve this before the fix is released?

@liamdebeasi
Copy link
Contributor

liamdebeasi commented Nov 5, 2021

Add "skipLibCheck": true to your tsconfig.json file to resolve the error for now.

@olaisen81
Copy link

Great Liam, it works like a charm! Thanks.

@danielehrhardt
Copy link

Blocks Angular 13 upgrade

@hussainarthuna
Copy link

Add "skipLibCheck": true to your tsconfig.json file to resolve the error for now.

Thank you, that's great

@eduboxgithub
Copy link

eduboxgithub commented Nov 8, 2021

I'm facing the same issue...

I'm trying to upgrade an ionic app (5.x.x) to Angular 13... but when building there's the following errors:

[ng] Build at: 2021-11-08T09:30:56.660Z - Hash: dadcf150b0122158 - Time: 1620ms
[ng]
[ng] Error: node_modules/ionicons/dist/types/components.d.ts:66:15 - error TS2320: Interface 'HTMLIonIconElement' cannot simultaneously extend types 'IonIcon' 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 'IonIcon' 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 | HTMLAnchorElement | HTMLAreaElement | HTMLAudioElement | HTMLBaseElement | ... 151 more ... | HTMLMarqueeElement' is not assignable 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 | HTMLAnchorElement | HTMLAreaElement | HTMLAudioElement | HTMLBaseElement | ... 151 more ... | HTMLMarqueeElement' is not assignable to type 'Element'.
[ng]
[ng] 4953     getElementsByTagName<K extends keyof HTMLElementTagNameMap>(qualifiedName: K): HTMLCollectionOf<HTMLElementTagNameMap[K]>;

I will try the "skipLibCheck": true for now and see if it overrides this build errors.

@liamdebeasi
Copy link
Contributor

Hi everyone,

Going to lock this thread for now. We have a fix in place and will be shipping the update soon.

Please see #1011 (comment) for a workaround. I will update this thread when I have more to share. Thanks!

@ionic-team ionic-team locked and limited conversation to collaborators Nov 8, 2021
@liamdebeasi
Copy link
Contributor

Resolved via #1014. I will post here when Ionicons 6.0 has shipped.

@liamdebeasi
Copy link
Contributor

Ionicons 6.0.0 has been released! Please be sure to review the breaking changes when updating: https://github.com/ionic-team/ionicons/releases/tag/v6.0.0

The next Ionic 6 RC will have Ionicons 6.0 installed.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants