diff --git a/src/jsx.d.ts b/src/jsx.d.ts index ca6e96a..160e5dc 100644 --- a/src/jsx.d.ts +++ b/src/jsx.d.ts @@ -7,6 +7,21 @@ type ElementAttributes = { [A in keyof E]?: E[A] extends (...args: any) => any ? any : IsCSSStyleDeclaration; } & { class?: string; + children?: any; +}; + +// creates a utility type for SVG attributes, allowing string values for SVG-specific attributes +type SVGElementAttributes = { + [A in keyof E]?: string | undefined; +} & { + class?: string; + fill?: string; + stroke?: string; + d?: string; + viewBox?: string; + xmlns?: string; + preserveAspectRatio?: string; + [key: string]: any; }; type PopoverState = 'auto' | 'manual' | 'hint'; @@ -25,9 +40,15 @@ type PopoverAttributes = { // map each HTML tag to its attributes type IntrinsicElementsFromDom = { [E in keyof HTMLElementTagNameMap]: ElementAttributes & - (E extends 'button' | 'input' ? PopoverAttributes : {}); + (E extends 'button' | 'input' ? PopoverAttributes : {}) & + (E extends 'button' ? { tabindex?: number | string } : {}); +}; + +// map each SVG tag to its attributes +type IntrinsicElementsFromSVG = { + [E in keyof SVGElementTagNameMap]: SVGElementAttributes; }; declare namespace JSX { - interface IntrinsicElements extends IntrinsicElementsFromDom {} + interface IntrinsicElements extends IntrinsicElementsFromDom, IntrinsicElementsFromSVG {} } diff --git a/test/cases/tsx/src/counter.tsx b/test/cases/tsx/src/counter.tsx index 7a32dfc..498afc5 100644 --- a/test/cases/tsx/src/counter.tsx +++ b/test/cases/tsx/src/counter.tsx @@ -55,7 +55,24 @@ export default class Counter extends HTMLElement { {/* @ts-expect-error - onclick should be a function, but we coerce to an assignment */} - + {/* test for https://github.com/ProjectEvergreen/wcc/issues/277 */} + + {/* test for https://github.com/ProjectEvergreen/wcc/issues/277 */} + ); }