Can someone please explain why this works in typescript while exporting an object:
export const config={
port:4000
};
This also works:
const config = { port:4000 };
export { config };
But this gives an error
const config={
port:4000
};
export config;
Error : declaration or statement expected.
export
expects a type object or curly braces. The second version is a syntax error.
If you want to export just a config objects then do
export const config = { port:4000 };
From the docs:
This can also be written as export {config}
;
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