How can I rewrite this so that I don't have the const?
const theme: ITheme = { color: 'blue' };
export default theme;
The following will disable type checks which is not what I want.
export default {color: Blue} as ITheme
May be related
For TypeScript 4.9+ you can use the satisfies keyword to ensure the type is statically checked:
export default { color: 'blue' } satisfies ITheme;
This will guarantee the type is valid, but may set a more specific type ({ color: 'blue' } instead of ITheme). If you need the more generic type, use satisfies and as:
export default { color: 'blue' } satisfies ITheme as ITheme;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With