Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

154
Visualizações
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 à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda