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

151
Vistas
Can .d.ts declarations add `as const` assertions to exports?

In TS, I can write a constant with a const assertion as long as it's done immediately after a literal.

export const stuff = {
  a: {
    b: "xyz"
  }
} as const

This makes typeof stuff very strict, allowing TS to leverage the values of the type. It knows that stuff.a.b is and will always be "xyz", which can be useful in performing conditional typing, lookups, etc.

If I have the same structure in a .js file, it obviously can't have the as const assertion:

export const stuff = {
  a: {
    b: "xyz"
  }
}

Is there any way I can add the as const assertion to the export in the declaration file?

about 4 years ago · Juan Pablo Isaza
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