As I'm reading here, ES2015 allows you to export var
, const
, let
, function
, class
and default
.
export var myVar1 = ...;
export let myVar2 = ...;
export const MY_CONST = ...;
export function myFunc() {
...
}
export function* myGeneratorFunc() {
...
}
export class MyClass {
...
}
But I don't understand why. In my layman opinion, there should be named exports
and default exports
.
The type of what you are exporting doesn't seem to matter. I mean, when you export default
, do you specify the type? No you don't, and it works. Additionally, what difference can it make to export var
or let
? What difference can it make to export const
? When you import a module it's immutable anyway (AFAIK).
So, why do you have to specify the type of the export?