From 6dfe82f9ad15497ae740df1d9e6451aec1a9161f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Yann=20Breli=C3=A8re?= Date: Mon, 9 Jan 2023 19:12:15 +0100 Subject: [PATCH] Add more precise typing for autoComplete HTML attribute MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This will allow to autocomplete… the `autoComplete` attribute in vscode for example. blob:vector://vector/f78d41f4-76af-4c04-b3e2-6c594d97f3e2 The list is quite long and it's not easy remembering the spelling of each one of them (first_name or given-name? password or current-password?), and it would improve the UX of sites if they were more appropriately used (for example, some people may think that the input's `type` and/or `name` attributes may be enough for fields like email or password, but knowing to use `autoComplete="new-password"` or `one-time-code` can be really useful). I can also add a description above the `autoComplete` line, something like that: ```ts /** See https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes/autocomplete * and https://html.spec.whatwg.org/multipage/forms.html#autofill * for more information and examples. */ ``` and I can even add [MDN](https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes/autocomplete#values)'s descriptions above each value, as they are really well explained and some of them may not always be intuitive at first glance. I didn't add them for now, as it looks like the list is kept quite compact. Please tell me if I need to make any changes or improvements. --- lib/lib.dom.d.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/lib.dom.d.ts b/lib/lib.dom.d.ts index 753f7673d8924..af112aa8d2ae5 100644 --- a/lib/lib.dom.d.ts +++ b/lib/lib.dom.d.ts @@ -7081,7 +7081,7 @@ interface HTMLInputElement extends HTMLElement { /** Sets or retrieves a text alternative to the graphic. */ alt: string; /** Specifies whether autocomplete is applied to an editable text field. */ - autocomplete: string; + autocomplete: AutoComplete; capture: string; /** Sets or retrieves the state of the check box or radio button. */ checked: boolean; @@ -18359,6 +18359,7 @@ type AudioContextLatencyCategory = "balanced" | "interactive" | "playback"; type AudioContextState = "closed" | "running" | "suspended"; type AuthenticatorAttachment = "cross-platform" | "platform"; type AuthenticatorTransport = "ble" | "hybrid" | "internal" | "nfc" | "usb"; +type AutoComplete = 'off' | 'on' | 'name' | 'honorific-prefix' | 'given-name' | 'family-name' | 'honorific-suffix' | 'nickname' | 'email' | 'username' | 'new-password' | 'current-password' | 'one-time-code' | 'organization-title' | 'organization' | 'street-address' | 'address-line1' | 'address-line2' | 'address-line3' | 'address-level4' | 'address-level3' | 'address-level2' | 'address-level1' | 'country' | 'country-name' | 'postal-code' | 'cc-name' | 'cc-given-name' | 'cc-additional-name' | 'cc-family-name' | 'cc-number' | 'cc-exp' | 'cc-exp-month' | 'cc-exp-year' | 'cc-csc' | 'cc-type' | 'transaction-currency' | 'transaction-amount' | 'language' | 'bday' | 'bday-day' | 'bday-month' | 'bday-year' | 'sex' | 'tel' | 'tel-country-code' | 'tel-national' | 'tel-area-code' | 'tel-local' | 'tel-extension' | 'impp' | 'url' | 'photo' | (string & {}); type AutoKeyword = "auto"; type AutomationRate = "a-rate" | "k-rate"; type BinaryType = "arraybuffer" | "blob";