Skip to content

Commit 2f40faa

Browse files
committed
Use precise types allowing completion of several tokens
1 parent 09a6eab commit 2f40faa

File tree

4 files changed

+81
-30
lines changed

4 files changed

+81
-30
lines changed

baselines/dom.generated.d.ts

+13-5
Original file line numberDiff line numberDiff line change
@@ -6676,7 +6676,7 @@ interface HTMLFormElement extends HTMLElement {
66766676
/** Sets or retrieves the URL to which the form content is sent for processing. */
66776677
action: string;
66786678
/** Specifies whether autocomplete is applied to an editable text field. */
6679-
autocomplete: "off" | "on";
6679+
autocomplete: AutoFillBase;
66806680
/** Retrieves a collection, in source order, of all controls in a given form. */
66816681
readonly elements: HTMLFormControlsCollection;
66826682
/** Sets or retrieves the MIME encoding for the form. */
@@ -7105,7 +7105,7 @@ interface HTMLInputElement extends HTMLElement {
71057105
/** Sets or retrieves a text alternative to the graphic. */
71067106
alt: string;
71077107
/** Specifies whether autocomplete is applied to an editable text field. */
7108-
autocomplete: AutoFill | (string & {});
7108+
autocomplete: AutoFill;
71097109
capture: string;
71107110
/** Sets or retrieves the state of the check box or radio button. */
71117111
checked: boolean;
@@ -7948,7 +7948,7 @@ declare var HTMLScriptElement: {
79487948

79497949
/** A <select> HTML Element. These elements also share all of the properties and methods of other HTML elements via the HTMLElement interface. */
79507950
interface HTMLSelectElement extends HTMLElement {
7951-
autocomplete: AutoFill | (string & {});
7951+
autocomplete: AutoFill;
79527952
disabled: boolean;
79537953
/** Retrieves a reference to the form that the object is embedded in. */
79547954
readonly form: HTMLFormElement | null;
@@ -8402,7 +8402,7 @@ declare var HTMLTemplateElement: {
84028402

84038403
/** Provides special properties and methods for manipulating the layout and presentation of <textarea> elements. */
84048404
interface HTMLTextAreaElement extends HTMLElement {
8405-
autocomplete: AutoFill | (string & {});
8405+
autocomplete: AutoFill;
84068406
/** Sets or retrieves the width of the object. */
84078407
cols: number;
84088408
/** Sets or retrieves the initial contents of the object. */
@@ -18482,6 +18482,9 @@ declare function addEventListener(type: string, listener: EventListenerOrEventLi
1848218482
declare function removeEventListener<K extends keyof WindowEventMap>(type: K, listener: (this: Window, ev: WindowEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
1848318483
declare function removeEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | EventListenerOptions): void;
1848418484
type AlgorithmIdentifier = Algorithm | string;
18485+
type AutoFill = AutoFillBase | AutoFillField | `${AutoFillSection} ${AutoFillField}` | `${AutoFillAddressKind} ${AutoFillField}` | `${AutoFillSection} ${AutoFillAddressKind} ${AutoFillField}` | `${AutoFillSection} ${AutoFillAddressKind} ${AutoFillField} ${AutoFillCredentialField}` | `${AutoFillAddressKind} ${AutoFillField} ${AutoFillCredentialField}` | `${AutoFillSection} ${AutoFillField} ${AutoFillCredentialField}` | `${AutoFillField} ${AutoFillCredentialField}`;
18486+
type AutoFillField = AutoFillNormalField | AutoFillContactField | `${AutoFillContactKind} ${AutoFillContactField}`;
18487+
type AutoFillSection = `section-${string}`;
1848518488
type BigInteger = Uint8Array;
1848618489
type BinaryData = ArrayBuffer | ArrayBufferView;
1848718490
type BlobPart = BufferSource | Blob | string;
@@ -18550,7 +18553,12 @@ type AudioContextLatencyCategory = "balanced" | "interactive" | "playback";
1855018553
type AudioContextState = "closed" | "running" | "suspended";
1855118554
type AuthenticatorAttachment = "cross-platform" | "platform";
1855218555
type AuthenticatorTransport = "ble" | "hybrid" | "internal" | "nfc" | "usb";
18553-
type AutoFill = "additional-name" | "address-level1" | "address-level2" | "address-level3" | "address-level4" | "address-line1" | "address-line2" | "address-line3" | "bday" | "bday-day" | "bday-month" | "bday-year" | "cc-additional-name" | "cc-csc" | "cc-exp" | "cc-exp-month" | "cc-exp-year" | "cc-family-name" | "cc-given-name" | "cc-name" | "cc-number" | "cc-type" | "country" | "country-name" | "current-password" | "email" | "family-name" | "given-name" | "honorific-prefix" | "honorific-suffix" | "impp" | "language" | "name" | "new-password" | "nickname" | "off" | "on" | "one-time-code" | "organization" | "organization-title" | "photo" | "postal-code" | "sex" | "street-address" | "tel" | "tel-area-code" | "tel-country-code" | "tel-extension" | "tel-local" | "tel-national" | "transaction-amount" | "transaction-currency" | "url" | "username" | "webauthn";
18556+
type AutoFillAddressKind = "billing" | "shipping";
18557+
type AutoFillBase = "off" | "on";
18558+
type AutoFillContactField = "email" | "impp" | "tel" | "tel-area-code" | "tel-country-code" | "tel-extension" | "tel-local" | "tel-local-prefix" | "tel-local-suffix" | "tel-national";
18559+
type AutoFillContactKind = "fax" | "home" | "mobile" | "pager" | "work";
18560+
type AutoFillCredentialField = "webauthn";
18561+
type AutoFillNormalField = "additional-name" | "address-level1" | "address-level2" | "address-level3" | "address-level4" | "address-line1" | "address-line2" | "address-line3" | "bday" | "bday-day" | "bday-month" | "bday-year" | "cc-additional-name" | "cc-csc" | "cc-exp" | "cc-exp-month" | "cc-exp-year" | "cc-family-name" | "cc-given-name" | "cc-name" | "cc-number" | "cc-type" | "country" | "country-name" | "current-password" | "family-name" | "given-name" | "honorific-prefix" | "honorific-suffix" | "language" | "name" | "new-password" | "nickname" | "one-time-code" | "organization" | "organization-title" | "photo" | "postal-code" | "sex" | "street-address" | "transaction-amount" | "transaction-currency" | "url" | "username";
1855418562
type AutoKeyword = "auto";
1855518563
type AutomationRate = "a-rate" | "k-rate";
1855618564
type BinaryType = "arraybuffer" | "blob";

inputfiles/addedTypes.jsonc

+56-18
Original file line numberDiff line numberDiff line change
@@ -354,33 +354,39 @@
354354
"xr-spatial-tracking"
355355
]
356356
},
357-
"AutoFill": {
358-
"name": "AutoFill",
359-
// See the full list of possible autofill values for the `autocomplete`attribut:
360-
// https://html.spec.whatwg.org/multipage/form-control-infrastructure.html#determine-a-field's-category
361-
// Note that other values are also possible, like section-*, so it should still allow a string.
362-
// Full spec at https://html.spec.whatwg.org/multipage/form-control-infrastructure.html#autofill.
357+
"AutoFillBase": {
358+
"name": "AutoFillBase",
363359
"value": [
364360
// Off
365361
"off",
366362
// Automatic
367-
"on",
368-
369-
// Normal
363+
"on"
364+
]
365+
},
366+
"AutoFillAddressKind": {
367+
"name": "AutoFillAddressKind",
368+
"value": [
369+
"shipping",
370+
"billing"
371+
]
372+
},
373+
"AutoFillNormalField": {
374+
"name": "AutoFillNormalField",
375+
"value": [
370376
"name",
371377
"honorific-prefix",
372378
"given-name",
373379
"additional-name",
374380
"family-name",
375381
"honorific-suffix",
376382
"nickname",
377-
"organization-title",
378383

379384
"username",
380385
"new-password",
381386
"current-password",
382387
"one-time-code",
383388

389+
"organization-title",
384390
"organization",
385391
"street-address",
386392
"address-line1",
@@ -414,20 +420,37 @@
414420
"bday-year",
415421
"sex",
416422
"url",
417-
"photo",
418-
419-
// Contact
423+
"photo"
424+
]
425+
},
426+
"AutoFillContactKind": {
427+
"name": "AutoFillContactKind",
428+
"value": [
429+
"home",
430+
"work",
431+
"mobile",
432+
"fax",
433+
"pager"
434+
]
435+
},
436+
"AutoFillContactField": {
437+
"name": "AutoFillContactField",
438+
"value": [
420439
"tel",
421440
"tel-country-code",
422441
"tel-national",
423442
"tel-area-code",
424443
"tel-local",
444+
"tel-local-prefix",
445+
"tel-local-suffix",
425446
"tel-extension",
426-
427447
"email",
428-
"impp",
429-
430-
// Credential
448+
"impp"
449+
]
450+
},
451+
"AutoFillCredentialField": {
452+
"name": "AutoFillCredentialField",
453+
"value": [
431454
"webauthn"
432455
]
433456
}
@@ -1451,7 +1474,22 @@
14511474
{
14521475
"name": "EventListenerOrEventListenerObject",
14531476
"overrideType": "EventListener | EventListenerObject"
1477+
},
1478+
{
1479+
"name": "AutoFillSection",
1480+
"overrideType": "`section-${string}`"
1481+
},
1482+
{
1483+
"name": "AutoFillField",
1484+
"overrideType": "AutoFillNormalField | AutoFillContactField | `${AutoFillContactKind} ${AutoFillContactField}`"
1485+
},
1486+
{
1487+
// See the full list of possible autofill values for the `autocomplete` attribute:
1488+
// https://html.spec.whatwg.org/multipage/form-control-infrastructure.html#determine-a-field's-category
1489+
// Full spec at https://html.spec.whatwg.org/multipage/form-control-infrastructure.html#autofill.
1490+
"name": "AutoFill",
1491+
"overrideType": "AutoFillBase | AutoFillField | `${AutoFillSection} ${AutoFillField}` | `${AutoFillAddressKind} ${AutoFillField}` | `${AutoFillSection} ${AutoFillAddressKind} ${AutoFillField}` | `${AutoFillSection} ${AutoFillAddressKind} ${AutoFillField} ${AutoFillCredentialField}` | `${AutoFillAddressKind} ${AutoFillField} ${AutoFillCredentialField}` | `${AutoFillSection} ${AutoFillField} ${AutoFillCredentialField}` | `${AutoFillField} ${AutoFillCredentialField}`"
14541492
}
14551493
]
14561494
}
1457-
}
1495+
}

inputfiles/knownTypes.json

+8
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,14 @@
66
"AesGcmParams",
77
"AesKeyAlgorithm",
88
"AesKeyGenParams",
9+
"AutoFillBase",
10+
"AutoFillSection",
11+
"AutoFillAddressKind",
12+
"AutoFillNormalField",
13+
"AutoFillContactKind",
14+
"AutoFillContactField",
15+
"AutoFillField",
16+
"AutoFillCredentialField",
917
"AutoFill",
1018
"BigInteger",
1119
"ClientQueryOptions",

inputfiles/overridingTypes.jsonc

+4-7
Original file line numberDiff line numberDiff line change
@@ -1205,8 +1205,7 @@
12051205
"property": {
12061206
"autocomplete": {
12071207
"name": "autocomplete",
1208-
// allow custom values like section-* without losing type completion
1209-
"overrideType": "AutoFill | (string & {})"
1208+
"overrideType": "AutoFill"
12101209
},
12111210
"selectedOptions": {
12121211
"name": "selectedOptions",
@@ -1613,8 +1612,7 @@
16131612
"property": {
16141613
"autocomplete": {
16151614
"name": "autocomplete",
1616-
// allow custom values like section-* without losing type completion
1617-
"overrideType": "AutoFill | (string & {})"
1615+
"overrideType": "AutoFill"
16181616
},
16191617
"selectionDirection": {
16201618
"name": "selectionDirection",
@@ -1737,8 +1735,7 @@
17371735
"property": {
17381736
"autocomplete": {
17391737
"name": "autocomplete",
1740-
// allow custom values like section-* without losing type completion
1741-
"overrideType": "AutoFill | (string & {})"
1738+
"overrideType": "AutoFill"
17421739
},
17431740
"labels": {
17441741
"name": "labels",
@@ -2374,7 +2371,7 @@
23742371
"property": {
23752372
"autocomplete": {
23762373
"name": "autocomplete",
2377-
"overrideType": "\"off\" | \"on\""
2374+
"overrideType": "AutoFillBase"
23782375
}
23792376
}
23802377
}

0 commit comments

Comments
 (0)