I have an enum object which I want to make the export default at the top level like that :
export default enum Hashes{
FOO = 'foo',
BAR = 'bar',
}
I got this error :
Module parse failed: Unexpected token (1:15) File was processed with these loaders: [02:54] MABROUK, Sahnoun (external - Project)
- ./node_modules/@angular-devkit/build-angular/src/babel/webpack-loader.js
- ./node_modules/@ngtools/webpack/src/ivy/index.js
I tried this way :
export enum Hashes{
FOO = 'foo',
BAR = 'bar',
}
and it seems work only if I import Hashes as alias in all my components like that :
import {Hashes} from ... which is a huge change in my project !
any solution ?
This is how ES6 works.
enum Hashes {
FOO = 'foo',
BAR = 'bar',
}
export default Hashes;
Exporting it as const? Concerning the default export, there is only a single default export per module. A default export can be a function, a class, an object or anything else. This value is to be considered as the "main" exported value since it will be the simplest to import.
export const enum Hashes {
FOO = 'foo',
BAR = 'bar',
}
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