Skip to content

Commit 53ae2b8

Browse files
authored
breaking: stronger enumerated types (#13624)
* dir * as * http-equiv * kind * preload * shape * scope * method * enctype * template * writingsuggestions * autocapitalize * autocapitalize is standard * autocorrect * changeset
1 parent 2070c8a commit 53ae2b8

File tree

2 files changed

+79
-19
lines changed

2 files changed

+79
-19
lines changed

.changeset/poor-shrimps-explain.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'svelte': patch
3+
---
4+
5+
breaking: stronger enumerated types

packages/svelte/elements.d.ts

Lines changed: 74 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -721,11 +721,12 @@ export type AriaRole =
721721
export interface HTMLAttributes<T extends EventTarget> extends AriaAttributes, DOMAttributes<T> {
722722
// Standard HTML Attributes
723723
accesskey?: string | undefined | null;
724+
autocapitalize?: 'characters' | 'off' | 'on' | 'none' | 'sentences' | 'words' | undefined | null;
724725
autofocus?: boolean | undefined | null;
725726
class?: string | undefined | null;
726727
contenteditable?: Booleanish | 'inherit' | 'plaintext-only' | undefined | null;
727728
contextmenu?: string | undefined | null;
728-
dir?: string | undefined | null;
729+
dir?: 'ltr' | 'rtl' | 'auto' | undefined | null;
729730
draggable?: Booleanish | undefined | null;
730731
elementtiming?: string | undefined | null;
731732
enterkeyhint?:
@@ -751,6 +752,7 @@ export interface HTMLAttributes<T extends EventTarget> extends AriaAttributes, D
751752
translate?: 'yes' | 'no' | '' | undefined | null;
752753
inert?: boolean | undefined | null;
753754
popover?: 'auto' | 'manual' | '' | undefined | null;
755+
writingsuggestions?: Booleanish | undefined | null;
754756

755757
// Unknown
756758
radiogroup?: string | undefined | null; // <command>, <menuitem>
@@ -769,8 +771,6 @@ export interface HTMLAttributes<T extends EventTarget> extends AriaAttributes, D
769771
vocab?: string | undefined | null;
770772

771773
// Non-standard Attributes
772-
autocapitalize?: string | undefined | null;
773-
autocorrect?: string | undefined | null;
774774
autosave?: string | undefined | null;
775775
color?: string | undefined | null;
776776
itemprop?: string | undefined | null;
@@ -868,7 +868,7 @@ export interface HTMLAreaAttributes extends HTMLAttributes<HTMLAreaElement> {
868868
media?: string | undefined | null;
869869
referrerpolicy?: ReferrerPolicy | undefined | null;
870870
rel?: string | undefined | null;
871-
shape?: string | undefined | null;
871+
shape?: 'circle' | 'default' | 'poly' | 'rect' | undefined | null;
872872
target?: string | undefined | null;
873873
ping?: string | undefined | null;
874874
}
@@ -886,8 +886,13 @@ export interface HTMLButtonAttributes extends HTMLAttributes<HTMLButtonElement>
886886
disabled?: boolean | undefined | null;
887887
form?: string | undefined | null;
888888
formaction?: string | undefined | null;
889-
formenctype?: string | undefined | null;
890-
formmethod?: string | undefined | null;
889+
formenctype?:
890+
| 'application/x-www-form-urlencoded'
891+
| 'multipart/form-data'
892+
| 'text/plain'
893+
| undefined
894+
| null;
895+
formmethod?: 'dialog' | 'get' | 'post' | undefined | null;
891896
formnovalidate?: boolean | undefined | null;
892897
formtarget?: string | undefined | null;
893898
name?: string | undefined | null;
@@ -952,8 +957,13 @@ export interface HTMLFormAttributes extends HTMLAttributes<HTMLFormElement> {
952957
acceptcharset?: string | undefined | null;
953958
action?: string | undefined | null;
954959
autocomplete?: AutoFillBase | undefined | null;
955-
enctype?: string | undefined | null;
956-
method?: string | undefined | null;
960+
enctype?:
961+
| 'application/x-www-form-urlencoded'
962+
| 'multipart/form-data'
963+
| 'text/plain'
964+
| undefined
965+
| null;
966+
method?: 'dialog' | 'get' | 'post' | undefined | null;
957967
name?: string | undefined | null;
958968
novalidate?: boolean | undefined | null;
959969
target?: string | undefined | null;
@@ -1040,14 +1050,21 @@ export interface HTMLInputAttributes extends HTMLAttributes<HTMLInputElement> {
10401050
accept?: string | undefined | null;
10411051
alt?: string | undefined | null;
10421052
autocomplete?: FullAutoFill | undefined | null;
1053+
// Safari only https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input#autocorrect
1054+
autocorrect?: 'on' | 'off' | '' | undefined | null;
10431055
capture?: boolean | 'user' | 'environment' | undefined | null; // https://www.w3.org/TR/html-media-capture/#the-capture-attribute
10441056
checked?: boolean | undefined | null;
10451057
dirname?: string | undefined | null;
10461058
disabled?: boolean | undefined | null;
10471059
form?: string | undefined | null;
10481060
formaction?: string | undefined | null;
1049-
formenctype?: string | undefined | null;
1050-
formmethod?: string | undefined | null;
1061+
formenctype?:
1062+
| 'application/x-www-form-urlencoded'
1063+
| 'multipart/form-data'
1064+
| 'text/plain'
1065+
| undefined
1066+
| null;
1067+
formmethod?: 'dialog' | 'get' | 'post' | undefined | null;
10511068
formnovalidate?: boolean | undefined | null;
10521069
formtarget?: string | undefined | null;
10531070
height?: number | string | undefined | null;
@@ -1100,7 +1117,33 @@ export interface HTMLLiAttributes extends HTMLAttributes<HTMLLIElement> {
11001117
}
11011118

11021119
export interface HTMLLinkAttributes extends HTMLAttributes<HTMLLinkElement> {
1103-
as?: string | undefined | null;
1120+
as?:
1121+
| 'fetch'
1122+
| 'audio'
1123+
| 'audioworklet'
1124+
| 'document'
1125+
| 'embed'
1126+
| 'font'
1127+
| 'frame'
1128+
| 'iframe'
1129+
| 'image'
1130+
| 'json'
1131+
| 'manifest'
1132+
| 'object'
1133+
| 'paintworklet'
1134+
| 'report'
1135+
| 'script'
1136+
| 'serviceworker'
1137+
| 'sharedworker'
1138+
| 'style'
1139+
| 'track'
1140+
| 'video'
1141+
| 'webidentity'
1142+
| 'worker'
1143+
| 'xslt'
1144+
| ''
1145+
| undefined
1146+
| null;
11041147
crossorigin?: 'anonymous' | 'use-credentials' | '' | undefined | null;
11051148
href?: string | undefined | null;
11061149
hreflang?: string | undefined | null;
@@ -1143,7 +1186,7 @@ export interface HTMLMediaAttributes<T extends HTMLMediaElement> extends HTMLAtt
11431186
mediagroup?: string | undefined | null;
11441187
muted?: boolean | undefined | null;
11451188
playsinline?: boolean | undefined | null;
1146-
preload?: string | undefined | null;
1189+
preload?: 'auto' | 'none' | 'metadata' | '' | undefined | null;
11471190
src?: string | undefined | null;
11481191
/**
11491192
* a value between 0 and 1
@@ -1173,7 +1216,14 @@ export interface HTMLMediaAttributes<T extends HTMLMediaElement> extends HTMLAtt
11731216
export interface HTMLMetaAttributes extends HTMLAttributes<HTMLMetaElement> {
11741217
charset?: string | undefined | null;
11751218
content?: string | undefined | null;
1176-
'http-equiv'?: string | undefined | null;
1219+
'http-equiv'?:
1220+
| 'content-security-policy'
1221+
| 'content-type'
1222+
| 'default-style'
1223+
| 'refresh'
1224+
| 'x-ua-compatible'
1225+
| undefined
1226+
| null;
11771227
name?: string | undefined | null;
11781228
media?: string | undefined | null;
11791229
}
@@ -1329,7 +1379,7 @@ export interface HTMLTdAttributes extends HTMLAttributes<HTMLTableCellElement> {
13291379
colspan?: number | undefined | null;
13301380
headers?: string | undefined | null;
13311381
rowspan?: number | undefined | null;
1332-
scope?: string | undefined | null;
1382+
scope?: 'col' | 'colgroup' | 'row' | 'rowgroup' | undefined | null;
13331383
abbr?: string | undefined | null;
13341384
height?: number | string | undefined | null;
13351385
width?: number | string | undefined | null;
@@ -1341,7 +1391,7 @@ export interface HTMLThAttributes extends HTMLAttributes<HTMLTableCellElement> {
13411391
colspan?: number | undefined | null;
13421392
headers?: string | undefined | null;
13431393
rowspan?: number | undefined | null;
1344-
scope?: string | undefined | null;
1394+
scope?: 'col' | 'colgroup' | 'row' | 'rowgroup' | undefined | null;
13451395
abbr?: string | undefined | null;
13461396
}
13471397

@@ -1351,7 +1401,7 @@ export interface HTMLTimeAttributes extends HTMLAttributes<HTMLTimeElement> {
13511401

13521402
export interface HTMLTrackAttributes extends HTMLAttributes<HTMLTrackElement> {
13531403
default?: boolean | undefined | null;
1354-
kind?: string | undefined | null;
1404+
kind?: 'captions' | 'chapters' | 'descriptions' | 'metadata' | 'subtitles' | undefined | null;
13551405
label?: string | undefined | null;
13561406
src?: string | undefined | null;
13571407
srclang?: string | undefined | null;
@@ -1453,7 +1503,8 @@ export interface SVGAttributes<T extends EventTarget> extends AriaAttributes, DO
14531503
lang?: string | undefined | null;
14541504
max?: number | string | undefined | null;
14551505
media?: string | undefined | null;
1456-
method?: string | undefined | null;
1506+
// On the `textPath` element
1507+
method?: 'align' | 'stretch' | undefined | null;
14571508
min?: number | string | undefined | null;
14581509
name?: string | undefined | null;
14591510
style?: string | undefined | null;
@@ -1737,6 +1788,10 @@ export interface SVGAttributes<T extends EventTarget> extends AriaAttributes, DO
17371788
[key: `data-${string}`]: any;
17381789
}
17391790

1791+
export interface HTMLTemplateAttributes extends HTMLAttributes<HTMLElement> {
1792+
shadowrootmode?: 'open' | 'closed' | undefined | null;
1793+
}
1794+
17401795
export interface HTMLWebViewAttributes extends HTMLAttributes<HTMLElement> {
17411796
allowfullscreen?: boolean | undefined | null;
17421797
allowpopups?: boolean | undefined | null;
@@ -1750,7 +1805,7 @@ export interface HTMLWebViewAttributes extends HTMLAttributes<HTMLElement> {
17501805
nodeintegration?: boolean | undefined | null;
17511806
partition?: string | undefined | null;
17521807
plugins?: boolean | undefined | null;
1753-
preload?: string | undefined | null;
1808+
preload?: 'auto' | 'none' | 'metadata' | '' | undefined | null;
17541809
src?: string | undefined | null;
17551810
useragent?: string | undefined | null;
17561811
webpreferences?: string | undefined | null;
@@ -1861,7 +1916,7 @@ export interface SvelteHTMLElements {
18611916
summary: HTMLAttributes<HTMLElement>;
18621917
sup: HTMLAttributes<HTMLElement>;
18631918
table: HTMLTableAttributes;
1864-
template: HTMLAttributes<HTMLTemplateElement>;
1919+
template: HTMLTemplateAttributes;
18651920
tbody: HTMLAttributes<HTMLTableSectionElement>;
18661921
td: HTMLTdAttributes;
18671922
textarea: HTMLTextareaAttributes;

0 commit comments

Comments
 (0)