Issue
Array.prototype.at()
is currently a stage 3 proposal. I've tried setting "lib": ["ESNext"]
in my tsconfig.json
, but I still got:
Property 'at' does not exist on type 'number[]'.
So how to use Array.prototype.at()
in TypeScript?
And to generalize, how to use stage 3 features in TypeScript?
TypeScript version is 4.3.5.
Solution
Currently, Array.prototype.at()
support hasn't landed in TypeScript. To use it now, we need to install @types/proposal-relative-indexing-method
and include the corresponding polyfill.
The same steps apply to the other stage 3 features if they're not already supported in TypeScript.
Answered By - Wenfang Du
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.