New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

After build, enum is not being imported #13379

Open
fernandoiwamoto opened this Issue Jan 7, 2019 · 1 comment

Comments

Projects
None yet
3 participants
@fernandoiwamoto
Copy link

fernandoiwamoto commented Jan 7, 2019

Bug Report or Feature Request (mark with an x)

- [x] bug report -> please search issues before submitting
- [ ] feature request

Command (mark with an x)

- [ ] new
- [x] build
- [ ] serve
- [ ] test
- [ ] e2e
- [ ] generate
- [ ] add
- [ ] update
- [ ] lint
- [ ] xi18n
- [ ] run
- [ ] config
- [ ] help
- [ ] version
- [ ] doc

Versions

npm 6.4.1
Angular CLI: 7.1.4
Node: 8.12.0
OS: win32 x64
Angular: 7.1.4

Repro steps

Create projectA(ng new projectA)
Generate as libraryA(ng generate library libraryA)
Create file enum inside of projects/libraryA(export enum SomeEnum)

export enum SomeEnum { SOMEVALUE = 'Some value', OTHERVALUE = 'Other Value' }

Create projectB(ng new projectB)
Generate as library B(ng generate library libraryB)
Use the libraryA inside of projectB
Inside of projects/libraryB.component.ts, declare variable.
readonly enum = SomeEnum.SOMEVALUE ;

Then build as library (ng build libraryB)

When you check the compiled libraryB, libraryB.component.ts doesn't have import of SomeEnum.

Another examples to investigate:

enum2 = SomeEnum.SomeValue; // does import but doesn't set attribute to value readonly enum3: SomeEnum = SomeEnum.SomeValue; // does import but doesn't set attribute to value enum4: SomeEnum = SomeEnum.SomeValue; // does import but doesn't set attribute to value

The log given by the failure

error TS1254: A 'const' initializer in an ambient context must be a string or numeric literal or literal enum reference.

Desired functionality

After compiling, the enum should be imported.

@fernandoiwamoto fernandoiwamoto changed the title After build, enum is not begin imported After build, enum is not being imported Jan 7, 2019

@mgechev

This comment has been minimized.

Copy link
Member

mgechev commented Jan 8, 2019

Do you need projectA or you can use only libraryA? @fernandoiwamoto would you share a demo on GitHub?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment