Microsoft/TypeScript

`autocapitalize` type is incorrect according to MDN

Open

#54,372 创建于 2023年5月24日

在 GitHub 查看
 (9 评论) (0 反应) (0 负责人)TypeScript (6,726 fork)batch import
BugDomain: lib.d.tsHelp Wanted

仓库指标

Star
 (48,455 star)
PR 合并指标
 (平均合并 6天 17小时) (30 天内合并 9 个 PR)

描述

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

贡献者指南