Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

317
Vistas
Does TypeScript support export default Enum?

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 ?

about 4 years ago · Juan Pablo Isaza
2 Respuestas
Responde la pregunta

0

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',
}
about 4 years ago · Juan Pablo Isaza Denunciar

0

export default expects an expression/function/class after it, you can read here more Export MDN

This is not due to TS, this is due to error in your statement. You can simply defined you enum first and then export it default.

enum Hashes {
 FOO = 'foo',
 BAR = 'bar',
}

export default Hashes
about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda