Intl.supportedValuesOf 类型“typeof Intl”上不存在属性“supportedValuesOf”

Ar2*_*r26 2 typescript

我使用 dayJS 作为我的日期时间库,并希望呈现所有时区的列表。
我尝试使用 Intl 对象:
Intl.supportedValuesOf("timeZone")
但出现打字稿错误:
TS2339: Property 'supportedValuesOf' does not exist on type 'typeof Intl'.
我可以获取值,但我想避免使用 @ts-ignore 表示法

如何为 Intl 对象添加更新的类型?

小智 5

请参阅https://github.com/microsoft/TypeScript/issues/49231

“更改直到 Typescript 5.1 才会发布”

  • 要添加此内容,请参阅[建议的临时解决方案](https://github.com/microsoft/TypeScript/issues/49231#issuecomment-1137251612)。 (2认同)