Reputation: 1147
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.
Upvotes: 4
Views: 5578
Reputation: 9931
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}
;
Upvotes: 2