Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

219
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda