Skip to content

custom Popover types are breaking with TypeScript 6.x #264

@thescientist13

Description

@thescientist13

What happened?

Tried upgrading a few WCC based projects to TypeScript 6.x and now getting errors on <button> tags

popovertarget

thescientist13/greenwood-counter-jsx#7

➜  greenwood-counter-jsx git:(signals) ✗ npm run check                                                               

> greenwood-counter-jsx@1.0.0 check
> tsc

src/components/counter/counter.tsx:50:10 - error TS2322: Type '{ onclick: () => void; }' is not assignable to type '{ command?: string | undefined; commandForElement?: Element | null | undefined; disabled?: boolean | undefined; readonly form?: HTMLFormElement | null | undefined; ... 342 more ...; popoverTargetElement?: Element | ... 1 more ... | undefined; } & { ...; } & PopoverTargetAttributes'.
  Type '{ onclick: () => void; }' is missing the following properties from type 'PopoverTargetAttributes': popoverTargetAction, popoverTargetElement

50         <button onclick={this.increment}>Increment (+)</button>
            ~~~~~~

src/components/counter/counter.tsx:51:10 - error TS2322: Type '{ onclick: () => void; }' is not assignable to type '{ command?: string | undefined; commandForElement?: Element | null | undefined; disabled?: boolean | undefined; readonly form?: HTMLFormElement | null | undefined; ... 342 more ...; popoverTargetElement?: Element | ... 1 more ... | undefined; } & { ...; } & PopoverTargetAttributes'.
  Type '{ onclick: () => void; }' is missing the following properties from type 'PopoverTargetAttributes': popoverTargetAction, popoverTargetElement

51         <button onclick={this.decrement}>Decrement (-)</button>
            ~~~~~~

src/components/counter/counter.tsx:52:10 - error TS2322: Type '{ onclick: () => void; }' is not assignable to type '{ command?: string | undefined; commandForElement?: Element | null | undefined; disabled?: boolean | undefined; readonly form?: HTMLFormElement | null | undefined; ... 342 more ...; popoverTargetElement?: Element | ... 1 more ... | undefined; } & { ...; } & PopoverTargetAttributes'.
  Type '{ onclick: () => void; }' is missing the following properties from type 'PopoverTargetAttributes': popoverTargetAction, popoverTargetElement

52         <button onclick={this.double}>Double (++)</button>
            ~~~~~~


Found 3 errors in the same file, starting at: src/components/counter/counter.tsx:50

mise WARN  missing: node@22.18.0  

onclick

ProjectEvergreen/playground.wcc.dev#18

➜  playground.wcc.dev git:(feat/issue-9-initial-editor-experience) ✗ npm run check

> playground.wcc.dev@1.0.0 check
> tsgo

src/components/header/header.tsx:93:11 - error TS2322: Type '{ class: string; popovertarget: string; "aria-label": string; }' is not assignable to type '{ ariaActiveDescendantElement?: Element | null | undefined; ariaAtomic?: string | null | undefined; ariaAutoComplete?: string | null | undefined; ariaBrailleLabel?: string | null | undefined; ... 340 more ...; readonly assignedSlot?: HTMLSlotElement | ... 1 more ... | undefined; } & { ...; } & PopoverTargetAttributes'.
  Property 'popovertarget' does not exist on type '{ ariaActiveDescendantElement?: Element | null | undefined; ariaAtomic?: string | null | undefined; ariaAutoComplete?: string | null | undefined; ariaBrailleLabel?: string | null | undefined; ... 340 more ...; readonly assignedSlot?: HTMLSlotElement | ... 1 more ... | undefined; } & { ...; } & PopoverTargetAttributes'.

93           popovertarget="mobile-menu"
             ~~~~~~~~~~~~~

src/components/header/header.tsx:103:15 - error TS2322: Type '{ class: string; popovertarget: string; popovertargetaction: string; "aria-label": string; }' is not assignable to type '{ ariaActiveDescendantElement?: Element | null | undefined; ariaAtomic?: string | null | undefined; ariaAutoComplete?: string | null | undefined; ariaBrailleLabel?: string | null | undefined; ... 340 more ...; readonly assignedSlot?: HTMLSlotElement | ... 1 more ... | undefined; } & { ...; } & PopoverTargetAttributes'.
  Property 'popovertarget' does not exist on type '{ ariaActiveDescendantElement?: Element | null | undefined; ariaAtomic?: string | null | undefined; ariaAutoComplete?: string | null | undefined; ariaBrailleLabel?: string | null | undefined; ... 340 more ...; readonly assignedSlot?: HTMLSlotElement | ... 1 more ... | undefined; } & { ...; } & PopoverTargetAttributes'.

103               popovertarget="mobile-menu"
                  ~~~~~~~~~~~~~


Found 2 errors in the same file, starting at: src/components/header/header.tsx:93

Steps to reproduce

  1. Be using TypeScript >= 6.x
  2. Have a <button> tags with a popover or onclick attribute

Environment

  • WCC 0.21.1
  • TypeScript >= 6.x

Additional Context

Do we need to document / assert TypeScript compat? Might need to document / clarify minimum TS version support

Metadata

Metadata

Labels

JSXdocumentationImprovements or additions to the website and / or documentationenhancementImprovement to existing functionalitytypes

Type

Projects

Status

👀 In review

Relationships

None yet

Development

No branches or pull requests

Issue actions