Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Angular 4 export enum type from library/dependency

I want to make a library to use in my Angular 4 applications, and for some business I will do on it I have an enum that the applications will need to use later. Problem is, I declare the enum like this in my-enum.ts:

export enum MyEnum {
    value1 = 1,
    value2 = 2,
    value3 = 3
}

But then, I can't seem to import it from my app when I do the following:

import { MyEnum } from 'my-library';

How should I proceed to have this correctly?

like image 877
CesarD Avatar asked Oct 14 '25 18:10

CesarD


1 Answers

If you are writing Angular libraries, you have to export enums with the keyword const

export const enum <ENUM_NAME>
like image 199
Amine Safi Avatar answered Oct 17 '25 09:10

Amine Safi



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!