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

144
Views
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
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!