admin管理员组文章数量:1333389
I am using nodeJS v12.10.0
This supports Intl.ListFormat
Using Typescript v3.6.3
However, when piling with typescript, I get Property 'ListFormat' does not exist on type 'typeof Intl' (ts2339) error.
I've tried googling and found this and other advice, but nothing has worked.
A consensus of what I've found seems to be to use a name.d.ts
file and to somehow extend the Intl
object there, but I haven't been able to.
I am still learning typescript, but am familiar with javascript.
I am using nodeJS v12.10.0
This supports Intl.ListFormat
Using Typescript v3.6.3
However, when piling with typescript, I get Property 'ListFormat' does not exist on type 'typeof Intl' (ts2339) error.
I've tried googling and found this and other advice, but nothing has worked.
A consensus of what I've found seems to be to use a name.d.ts
file and to somehow extend the Intl
object there, but I haven't been able to.
I am still learning typescript, but am familiar with javascript.
Share Improve this question edited Sep 17, 2019 at 22:08 James Wilson asked Sep 16, 2019 at 21:21 James WilsonJames Wilson 94213 silver badges31 bronze badges2 Answers
Reset to default 5I found that the accepted answer didn't work for me. I used the following:
declare namespace Intl {
class ListFormat {
constructor(locales?: string | string[], options?: Intl.ListFormatOptions);
public format: (items: string[]) => string;
}
}
Adding the following in a something.d.ts
file seems to work.
declare namespace Intl {
class ListFormat {
public format: (items: [string?]) => string;
}
}
I got the idea from my original googling, but then reading this helped me work it out.
Posting this in case it helps others.
本文标签: javascriptHow can I add types to use IntlListFormat in node v12Stack Overflow
版权声明:本文标题:javascript - How can I add types to use Intl.ListFormat in node v12 - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1742334287a2455313.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论