element-internals-polyfill icon indicating copy to clipboard operation
element-internals-polyfill copied to clipboard

Missing aria properties

Open rcbyron opened this issue 1 year ago • 2 comments

Receiving the following typescript error in my Angular app:

Error: node_modules/.pnpm/[email protected]/node_modules/element-internals-polyfill/dist/element-internals.d.ts:4:22 - error TS2420: Class 'ElementInternals' incorrectly implements interface 'IElementInternals'.
  Type 'ElementInternals' is missing the following properties from type 'IElementInternals': ariaBrailleLabel, ariaBrailleRoleDescription

4 export declare class ElementInternals implements IElementInternals {
                       ~~~~~~~~~~~~~~~~

rcbyron avatar Jul 26 '24 21:07 rcbyron

Downgrading Typescript from 5.5.4 to 5.4.5 fixed the issue for now

rcbyron avatar Jul 26 '24 22:07 rcbyron

I have a version of this in progress on the fix-ts branch if you want to look at it to see if it fixes your issues. I'm working through how best to test this right now.

calebdwilliams avatar Sep 27 '24 01:09 calebdwilliams

Same issue here. In the meantime, there are two open PRs #134 and #135. Any chance this issue can be resolved?

abeggchr avatar Dec 09 '24 07:12 abeggchr

Those PRs don’t actually fix the issue. If I could get feedback on the branch from the previous post I’ll merge and release that bi just don’t want to break anything else.

calebdwilliams avatar Dec 11 '24 19:12 calebdwilliams

Any update on this? I'm using a dependency that requires TypeScript 5.5 or higher, so downgrading to a lower version to work around this issue is not an option. If I understand correctly, a branch with a fix exists, but it still needs an approved PR in order to be merged and released? Would be nice to have this soon.

Senne avatar Jan 06 '25 09:01 Senne

I've published a prerelease of 2.x at version 2.0.0-next.1. LMK if that fixes your issue.

calebdwilliams avatar Jan 25 '25 15:01 calebdwilliams

The error Type 'ElementInternals' is missing the following properties… isn't thrown anymore, but with typescript set to ^5.5.4 in package.json of my project I now get this error:

✘ [ERROR] TS2717: Subsequent property declarations must have the same type.  Property 'form' must be of type 'HTMLFormElement | null', but here has type 'HTMLFormElement'. [plugin angular-compiler]

    node_modules/element-internals-polyfill/dist/types.d.ts:18:17:
      18 │         readonly form: HTMLFormElement;
         ╵                  ~~~~

  'form' was also declared here.

    node_modules/typescript/lib/lib.dom.d.ts:8002:13:
      8002 │     readonly form: HTMLFormElement | null;
           ╵              ~~~~

Seems that the types are not aligned, yours is missing | null. When I add that manually to element-internals-polyfill/dist/types.d.ts in the node_modules folder, the error is fixed and the build goes fine.

Senne avatar Jan 28 '25 11:01 Senne

@Senne OK, I updated the next build to version 2.0.0-next.2 which has that fix in there as well. Thanks for finding that.

calebdwilliams avatar Jan 28 '25 15:01 calebdwilliams

Thanks for publishing that newer version, Caleb. I now get these errors with TypeScript 5.5.4 however:

✘ [ERROR] TS2717: Subsequent property declarations must have the same type.  Property 'ariaColIndexText' must be of type 'string | null', but here has type 'string'. [plugin angular-compiler]

    node_modules/element-internals-polyfill/dist/types.d.ts:10:8:
      10 │         ariaColIndexText: string;
         ╵         ~~~~~~~~~~~~~~~~

  'ariaColIndexText' was also declared here.

    node_modules/typescript/lib/lib.dom.d.ts:2421:4:
      2421 │     ariaColIndexText: string | null;
           ╵     ~~~~~~~~~~~~~~~~

✘ [ERROR] TS2717: Subsequent property declarations must have the same type.  Property 'ariaRowIndexText' must be of type 'string | null', but here has type 'string'. [plugin angular-compiler]

    node_modules/element-internals-polyfill/dist/types.d.ts:14:8:
      14 │         ariaRowIndexText: string;
         ╵         ~~~~~~~~~~~~~~~~

  'ariaRowIndexText' was also declared here.

    node_modules/typescript/lib/lib.dom.d.ts:2470:4:
      2470 │     ariaRowIndexText: string | null;
           ╵     ~~~~~~~~~~~~~~~~

Senne avatar Jan 29 '25 09:01 Senne

@Senne Oof, that's not throwing for me locally, but I've updated the implementation at 2.0.0-next.3

calebdwilliams avatar Jan 29 '25 19:01 calebdwilliams

That indeed fixes the issue. Thank you for the quick responses!

Senne avatar Jan 30 '25 10:01 Senne