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?