From 53ae2b81707d202c00d784f3cc793707510492de Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20Crozatier?= <48696601+fcrozatier@users.noreply.github.com> Date: Wed, 16 Oct 2024 15:04:18 +0200 Subject: [PATCH] breaking: stronger enumerated types (#13624) * dir * as * http-equiv * kind * preload * shape * scope * method * enctype * template * writingsuggestions * autocapitalize * autocapitalize is standard * autocorrect * changeset --- .changeset/poor-shrimps-explain.md | 5 ++ packages/svelte/elements.d.ts | 93 ++++++++++++++++++++++++------ 2 files changed, 79 insertions(+), 19 deletions(-) create mode 100644 .changeset/poor-shrimps-explain.md diff --git a/.changeset/poor-shrimps-explain.md b/.changeset/poor-shrimps-explain.md new file mode 100644 index 0000000000..5a2cc1c229 --- /dev/null +++ b/.changeset/poor-shrimps-explain.md @@ -0,0 +1,5 @@ +--- +'svelte': patch +--- + +breaking: stronger enumerated types diff --git a/packages/svelte/elements.d.ts b/packages/svelte/elements.d.ts index 05954efdad..d44a7c3981 100644 --- a/packages/svelte/elements.d.ts +++ b/packages/svelte/elements.d.ts @@ -721,11 +721,12 @@ export type AriaRole = export interface HTMLAttributes extends AriaAttributes, DOMAttributes { // Standard HTML Attributes accesskey?: string | undefined | null; + autocapitalize?: 'characters' | 'off' | 'on' | 'none' | 'sentences' | 'words' | undefined | null; autofocus?: boolean | undefined | null; class?: string | undefined | null; contenteditable?: Booleanish | 'inherit' | 'plaintext-only' | undefined | null; contextmenu?: string | undefined | null; - dir?: string | undefined | null; + dir?: 'ltr' | 'rtl' | 'auto' | undefined | null; draggable?: Booleanish | undefined | null; elementtiming?: string | undefined | null; enterkeyhint?: @@ -751,6 +752,7 @@ export interface HTMLAttributes extends AriaAttributes, D translate?: 'yes' | 'no' | '' | undefined | null; inert?: boolean | undefined | null; popover?: 'auto' | 'manual' | '' | undefined | null; + writingsuggestions?: Booleanish | undefined | null; // Unknown radiogroup?: string | undefined | null; // , @@ -769,8 +771,6 @@ export interface HTMLAttributes extends AriaAttributes, D vocab?: string | undefined | null; // Non-standard Attributes - autocapitalize?: string | undefined | null; - autocorrect?: string | undefined | null; autosave?: string | undefined | null; color?: string | undefined | null; itemprop?: string | undefined | null; @@ -868,7 +868,7 @@ export interface HTMLAreaAttributes extends HTMLAttributes { media?: string | undefined | null; referrerpolicy?: ReferrerPolicy | undefined | null; rel?: string | undefined | null; - shape?: string | undefined | null; + shape?: 'circle' | 'default' | 'poly' | 'rect' | undefined | null; target?: string | undefined | null; ping?: string | undefined | null; } @@ -886,8 +886,13 @@ export interface HTMLButtonAttributes extends HTMLAttributes disabled?: boolean | undefined | null; form?: string | undefined | null; formaction?: string | undefined | null; - formenctype?: string | undefined | null; - formmethod?: string | undefined | null; + formenctype?: + | 'application/x-www-form-urlencoded' + | 'multipart/form-data' + | 'text/plain' + | undefined + | null; + formmethod?: 'dialog' | 'get' | 'post' | undefined | null; formnovalidate?: boolean | undefined | null; formtarget?: string | undefined | null; name?: string | undefined | null; @@ -952,8 +957,13 @@ export interface HTMLFormAttributes extends HTMLAttributes { acceptcharset?: string | undefined | null; action?: string | undefined | null; autocomplete?: AutoFillBase | undefined | null; - enctype?: string | undefined | null; - method?: string | undefined | null; + enctype?: + | 'application/x-www-form-urlencoded' + | 'multipart/form-data' + | 'text/plain' + | undefined + | null; + method?: 'dialog' | 'get' | 'post' | undefined | null; name?: string | undefined | null; novalidate?: boolean | undefined | null; target?: string | undefined | null; @@ -1040,14 +1050,21 @@ export interface HTMLInputAttributes extends HTMLAttributes { accept?: string | undefined | null; alt?: string | undefined | null; autocomplete?: FullAutoFill | undefined | null; + // Safari only https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input#autocorrect + autocorrect?: 'on' | 'off' | '' | undefined | null; capture?: boolean | 'user' | 'environment' | undefined | null; // https://www.w3.org/TR/html-media-capture/#the-capture-attribute checked?: boolean | undefined | null; dirname?: string | undefined | null; disabled?: boolean | undefined | null; form?: string | undefined | null; formaction?: string | undefined | null; - formenctype?: string | undefined | null; - formmethod?: string | undefined | null; + formenctype?: + | 'application/x-www-form-urlencoded' + | 'multipart/form-data' + | 'text/plain' + | undefined + | null; + formmethod?: 'dialog' | 'get' | 'post' | undefined | null; formnovalidate?: boolean | undefined | null; formtarget?: string | undefined | null; height?: number | string | undefined | null; @@ -1100,7 +1117,33 @@ export interface HTMLLiAttributes extends HTMLAttributes { } export interface HTMLLinkAttributes extends HTMLAttributes { - as?: string | undefined | null; + as?: + | 'fetch' + | 'audio' + | 'audioworklet' + | 'document' + | 'embed' + | 'font' + | 'frame' + | 'iframe' + | 'image' + | 'json' + | 'manifest' + | 'object' + | 'paintworklet' + | 'report' + | 'script' + | 'serviceworker' + | 'sharedworker' + | 'style' + | 'track' + | 'video' + | 'webidentity' + | 'worker' + | 'xslt' + | '' + | undefined + | null; crossorigin?: 'anonymous' | 'use-credentials' | '' | undefined | null; href?: string | undefined | null; hreflang?: string | undefined | null; @@ -1143,7 +1186,7 @@ export interface HTMLMediaAttributes extends HTMLAtt mediagroup?: string | undefined | null; muted?: boolean | undefined | null; playsinline?: boolean | undefined | null; - preload?: string | undefined | null; + preload?: 'auto' | 'none' | 'metadata' | '' | undefined | null; src?: string | undefined | null; /** * a value between 0 and 1 @@ -1173,7 +1216,14 @@ export interface HTMLMediaAttributes extends HTMLAtt export interface HTMLMetaAttributes extends HTMLAttributes { charset?: string | undefined | null; content?: string | undefined | null; - 'http-equiv'?: string | undefined | null; + 'http-equiv'?: + | 'content-security-policy' + | 'content-type' + | 'default-style' + | 'refresh' + | 'x-ua-compatible' + | undefined + | null; name?: string | undefined | null; media?: string | undefined | null; } @@ -1329,7 +1379,7 @@ export interface HTMLTdAttributes extends HTMLAttributes { colspan?: number | undefined | null; headers?: string | undefined | null; rowspan?: number | undefined | null; - scope?: string | undefined | null; + scope?: 'col' | 'colgroup' | 'row' | 'rowgroup' | undefined | null; abbr?: string | undefined | null; height?: number | string | undefined | null; width?: number | string | undefined | null; @@ -1341,7 +1391,7 @@ export interface HTMLThAttributes extends HTMLAttributes { colspan?: number | undefined | null; headers?: string | undefined | null; rowspan?: number | undefined | null; - scope?: string | undefined | null; + scope?: 'col' | 'colgroup' | 'row' | 'rowgroup' | undefined | null; abbr?: string | undefined | null; } @@ -1351,7 +1401,7 @@ export interface HTMLTimeAttributes extends HTMLAttributes { export interface HTMLTrackAttributes extends HTMLAttributes { default?: boolean | undefined | null; - kind?: string | undefined | null; + kind?: 'captions' | 'chapters' | 'descriptions' | 'metadata' | 'subtitles' | undefined | null; label?: string | undefined | null; src?: string | undefined | null; srclang?: string | undefined | null; @@ -1453,7 +1503,8 @@ export interface SVGAttributes extends AriaAttributes, DO lang?: string | undefined | null; max?: number | string | undefined | null; media?: string | undefined | null; - method?: string | undefined | null; + // On the `textPath` element + method?: 'align' | 'stretch' | undefined | null; min?: number | string | undefined | null; name?: string | undefined | null; style?: string | undefined | null; @@ -1737,6 +1788,10 @@ export interface SVGAttributes extends AriaAttributes, DO [key: `data-${string}`]: any; } +export interface HTMLTemplateAttributes extends HTMLAttributes { + shadowrootmode?: 'open' | 'closed' | undefined | null; +} + export interface HTMLWebViewAttributes extends HTMLAttributes { allowfullscreen?: boolean | undefined | null; allowpopups?: boolean | undefined | null; @@ -1750,7 +1805,7 @@ export interface HTMLWebViewAttributes extends HTMLAttributes { nodeintegration?: boolean | undefined | null; partition?: string | undefined | null; plugins?: boolean | undefined | null; - preload?: string | undefined | null; + preload?: 'auto' | 'none' | 'metadata' | '' | undefined | null; src?: string | undefined | null; useragent?: string | undefined | null; webpreferences?: string | undefined | null; @@ -1861,7 +1916,7 @@ export interface SvelteHTMLElements { summary: HTMLAttributes; sup: HTMLAttributes; table: HTMLTableAttributes; - template: HTMLAttributes; + template: HTMLTemplateAttributes; tbody: HTMLAttributes; td: HTMLTdAttributes; textarea: HTMLTextareaAttributes;