Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

213
Views
How to use stage 3 features in TypeScript?

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?

P.S. typescript version is v4.3.5.

about 4 years ago · Juan Pablo Isaza
2 answers
Answer question

0

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.

about 4 years ago · Juan Pablo Isaza Report

0

It is not possible to use Stage 3 features in Typescript. Not all. It generally depends on the feature. Something such as Optional Chaining required a syntax update of Typescript.

About Array.prototype.at, the lib.d.ts file for ESNext is probably not updated for such function.

Because of this, you should create a new .d.ts file in your project, and use module augmentation to extend the Array declaration and add correct interfaces for Array.prototype.at. You can look here to see several examples of how lib.es<year>.d.ts are implemented.

e.g. https://github.com/microsoft/TypeScript/blob/main/lib/lib.es2019.array.d.ts#L58

Of course, creating a new .d.ts feature will not polyfill your code to add Array.prototype.at if not available in your environment. You will still need a polyfill system, such as Babel with core-js.

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!