Microsoft/TypeScript

`autocapitalize` type is incorrect according to MDN

Open

#54.372 aperta il 24 mag 2023

Vedi su GitHub
 (9 commenti) (0 reazioni) (0 assegnatari)TypeScript (6726 fork)batch import
BugDomain: lib.d.tsHelp Wanted

Metriche repository

Star
 (48.455 star)
Metriche merge PR
 (Merge medio 6g 17h) (9 PR mergiate in 30 g)

Descrizione

lib Update Request

In lib/dom.d.ts

https://github.com/microsoft/TypeScript/blob/main/src/lib/dom.generated.d.ts#L9992

the type for HTMLElement.autocapitalize is incorrectly typed as string. According to the MDN article, the autocapitalize attribute/property can only be set to certain keywords.

Therefore, the internal lib dom type should be:

autocapitalize: 'off' | 'none' | 'on' | 'sentences' | 'words' | 'characters';

Sample Code

This issue affects proper typing in web components that extend HTMLElement that attempt to correctly type autocapitalize. TS errors because string and a union type are not compatible. Every reference to a web component class extending HTMLElement with a proper type for autocapitalize errors incorrectly.

Documentation Link

MDN article on autocapitalize

Guida contributor