Jindrich Vavruska
Jindrich Vavruska

Reputation: 830

In typescript, how to export enum type defined in a module?

I have an enum type with many items and therefore I want to put the definition in an individual file. The type is defined as

const enum Band {
  B2190m = '2190m',
  B631m  = '631m',
   // ... etc. many more
};

However, trying to export this by export or export default fails with "Expression expected" TS1109. What is the correct way to do this?

Thank you.

Upvotes: 1

Views: 3752

Answers (1)

user14915326
user14915326

Reputation: 111

const enum is inlined while transpilation to js, so can't be exported. You should emit "const" and use just enum:

export enum Band {
...

Upvotes: 1

Related Questions