Skip to content

Commit

Permalink
fix: Ensure attributes w/ never roles can be constructed
Browse files Browse the repository at this point in the history
  • Loading branch information
rschristian committed Dec 16, 2024
1 parent 6a6f672 commit 29a30e0
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 20 deletions.
40 changes: 20 additions & 20 deletions src/jsx.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1609,7 +1609,7 @@ export namespace JSXInternal {
interface BaseHTMLAttributes<T extends EventTarget = HTMLBaseElement>
extends HTMLAttributes<T> {
href?: Signalish<string | undefined>;
role: never;
role?: never;
target?: Signalish<string | undefined>;
}

Expand Down Expand Up @@ -1682,14 +1682,14 @@ export namespace JSXInternal {

interface ColHTMLAttributes<T extends EventTarget = HTMLTableColElement>
extends HTMLAttributes<T> {
role: never;
role?: never;
span?: Signalish<number | undefined>;
width?: Signalish<number | string | undefined>;
}

interface ColgroupHTMLAttributes<T extends EventTarget = HTMLTableColElement>
extends HTMLAttributes<T> {
role: never;
role?: never;
span?: Signalish<number | undefined>;
}

Expand All @@ -1705,7 +1705,7 @@ export namespace JSXInternal {

interface DdHTMLAttributes<T extends EventTarget = HTMLElement>
extends HTMLAttributes<T> {
role: never;
role?: never;
}

interface DelHTMLAttributes<T extends EventTarget = HTMLModElement>
Expand Down Expand Up @@ -1806,7 +1806,7 @@ export namespace JSXInternal {

interface HeadHTMLAttributes<T extends EventTarget = HTMLHeadElement>
extends HTMLAttributes<T> {
role: never;
role?: never;
}

interface HeaderHTMLAttributes<T extends EventTarget = HTMLElement>
Expand Down Expand Up @@ -1984,12 +1984,12 @@ export namespace JSXInternal {
for?: Signalish<string | undefined>;
form?: Signalish<string | undefined>;
htmlFor?: Signalish<string | undefined>;
role: never;
role?: never;
}

interface LegendHTMLAttributes<T extends EventTarget = HTMLLegendElement>
extends HTMLAttributes<T> {
role: never;
role?: never;
}

interface LiHTMLAttributes<T extends EventTarget = HTMLLIElement>
Expand All @@ -2012,7 +2012,7 @@ export namespace JSXInternal {
referrerpolicy?: Signalish<HTMLAttributeReferrerPolicy | undefined>;
referrerPolicy?: HTMLAttributeReferrerPolicy | undefined;
rel?: Signalish<string | undefined>;
role: never;
role?: never;
sizes?: Signalish<string | undefined>;
type?: Signalish<string | undefined>;
charset?: Signalish<string | undefined>;
Expand All @@ -2027,7 +2027,7 @@ export namespace JSXInternal {
interface MapHTMLAttributes<T extends EventTarget = HTMLMapElement>
extends HTMLAttributes<T> {
name?: Signalish<string | undefined>;
role: never;
role?: never;
}

interface MarqueeHTMLAttributes<T extends EventTarget = HTMLMarqueeElement>
Expand Down Expand Up @@ -2089,7 +2089,7 @@ export namespace JSXInternal {
httpEquiv?: Signalish<string | undefined>;
name?: Signalish<string | undefined>;
media?: Signalish<string | undefined>;
role: never;
role?: never;
}

interface MeterHTMLAttributes<T extends EventTarget = HTMLMeterElement>
Expand Down Expand Up @@ -2119,7 +2119,7 @@ export namespace JSXInternal {

interface NoScriptHTMLAttributes<T extends EventTarget = HTMLElement>
extends HTMLAttributes<T> {
role: never;
role?: never;
}

interface ObjectHTMLAttributes<T extends EventTarget = HTMLObjectElement>
Expand Down Expand Up @@ -2185,13 +2185,13 @@ export namespace JSXInternal {
interface ParamHTMLAttributes<T extends EventTarget = HTMLParamElement>
extends HTMLAttributes<T> {
name?: Signalish<string | undefined>;
role: never;
role?: never;
value?: Signalish<string | number | undefined>;
}

interface PictureHTMLAttributes<T extends EventTarget = HTMLPictureElement>
extends HTMLAttributes<T> {
role: never;
role?: never;
}

interface ProgressHTMLAttributes<T extends EventTarget = HTMLProgressElement>
Expand Down Expand Up @@ -2221,7 +2221,7 @@ export namespace JSXInternal {
noModule?: Signalish<boolean | undefined>;
referrerpolicy?: Signalish<HTMLAttributeReferrerPolicy | undefined>;
referrerPolicy?: HTMLAttributeReferrerPolicy | undefined;
role: never;
role?: never;
src?: Signalish<string | undefined>;
type?: Signalish<string | undefined>;
}
Expand Down Expand Up @@ -2257,14 +2257,14 @@ export namespace JSXInternal {
interface SlotHTMLAttributes<T extends EventTarget = HTMLSlotElement>
extends HTMLAttributes<T> {
name?: Signalish<string | undefined>;
role: never;
role?: never;
}

interface SourceHTMLAttributes<T extends EventTarget = HTMLSourceElement>
extends HTMLAttributes<T> {
height?: Signalish<number | string | undefined>;
media?: Signalish<string | undefined>;
role: never;
role?: never;
sizes?: Signalish<string | undefined>;
src?: Signalish<string | undefined>;
srcset?: Signalish<string | undefined>;
Expand All @@ -2276,7 +2276,7 @@ export namespace JSXInternal {
interface StyleHTMLAttributes<T extends EventTarget = HTMLStyleElement>
extends HTMLAttributes<T> {
media?: Signalish<string | undefined>;
role: never;
role?: never;
scoped?: Signalish<boolean | undefined>;
type?: Signalish<string | undefined>;
}
Expand Down Expand Up @@ -2308,7 +2308,7 @@ export namespace JSXInternal {

interface TemplateHTMLAttributes<T extends EventTarget = HTMLTemplateElement>
extends HTMLAttributes<T> {
role: never;
role?: never;
}

interface TextareaHTMLAttributes<T extends EventTarget = HTMLTextAreaElement>
Expand Down Expand Up @@ -2357,15 +2357,15 @@ export namespace JSXInternal {

interface TitleHTMLAttributes<T extends EventTarget = HTMLTitleElement>
extends HTMLAttributes<T> {
role: never;
role?: never;
}

interface TrackHTMLAttributes<T extends EventTarget = HTMLTrackElement>
extends MediaHTMLAttributes<T> {
default?: Signalish<boolean | undefined>;
kind?: Signalish<string | undefined>;
label?: Signalish<string | undefined>;
role: never;
role?: never;
srclang?: Signalish<string | undefined>;
srcLang?: Signalish<string | undefined>;
}
Expand Down
5 changes: 5 additions & 0 deletions test/ts/dom-attributes-test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,11 @@ const signalInvalidAriaRole = (
// @ts-expect-error A map should never have any role set
<button role={createSignal('presentation' as const)} />
)
const validMissingAriaRole = <base href=""></base>
const signalValidMissingAriaRole = (
// @ts-expect-error A map should never have any role set
<button role={createSignal('presentation' as const)} />
)

// @ts-expect-error We should correctly type aria attributes like autocomplete
const badAriaValues = <div aria-autocomplete="bad-value" />;
Expand Down

0 comments on commit 29a30e0

Please sign in to comment.