angular: ERROR in Illegal state: symbol without members expected when using AOT in 4.3.0
I’m submitting a…
[x] Regression
[ ] Bug report
[ ] Feature request
[ ] Documentation issue or request
[ ] Support request
Current behavior
Getting error when building for production (AOT enabled) with a certain pattern of imports/exports (see below). The error reported is:
ERROR in Illegal state: symbol without members expected, but got {"filePath":"snip/test/ng/aottest/src/app/shared/role-co
nstants.ts","name":"RoleConstants","members":["USER"]}.
ERROR in ./src/main.ts
Module not found: Error: Can't resolve './$$_gendir/app/app.module.ngfactory' in 'snip\test\ng\aottest\src'
@ ./src/main.ts 4:0-74
@ multi ./src/main.ts
Worked ok in 4.2.6, does not work in 4.3.0.
Expected behavior
ng build --prod should build correctly without rising the error.
Minimal reproduction of the problem with instructions
download symbol-without-members-error-test-a.zip npm install ng build --prod
The project contain a newly generated project (with ng new) with a number of files added to reproduce the error: shared/const.ts - exports a constant field shared/index.ts - exports consts above intermediate.ts - imports consts exports aggregated data index.ts - exports intermediate above module.ts - is calling RouterModule.forRoot([…intermediate] with intermediate imported from above.
If import { Consts } from './shared';
is changed to import { Consts } from './shared/consts';
in intermediate.ts the problem does not manifest anymore.
What is the motivation / use case for changing the behavior?
n/a
Environment
Angular version: 4.3.0
(worked ok in 4.2.6.)
For Tooling issues:
- Node version: v7.10.0
- Platform: Windows
About this issue
- Original URL
- State: closed
- Created 7 years ago
- Reactions: 26
- Comments: 57 (16 by maintainers)
Commits related to this issue
- Rolled back ng version because of https://github.com/angular/angular/issues/18170 — committed to OysteinAmundsen/gymsystems by OysteinAmundsen 7 years ago
- Upgraded angular https://github.com/angular/angular/issues/18170 seems to be resolved in this build — committed to OysteinAmundsen/gymsystems by OysteinAmundsen 7 years ago
- fix(compiler): do not consider a reference with members as a reference Fixes: #18170 — committed to chuckjaz/angular by chuckjaz 7 years ago
- fix(compiler): do not consider a reference with members as a reference Fixes: #18170 — committed to chuckjaz/angular by chuckjaz 7 years ago
- fix(compiler): do not consider a reference with members as a reference Fixes: #18170 — committed to chuckjaz/angular by chuckjaz 7 years ago
- fix(compiler): do not consider a reference with members as a reference (#19454) Fixes: #18170 — committed to angular/angular by chuckjaz 7 years ago
- fix(compiler): do not consider a reference with members as a reference (#19454) Fixes: #18170 — committed to chuckjaz/angular by chuckjaz 7 years ago
- fix(compiler): do not consider a reference with members as a reference (#19466) fixes: #18170 ref: #19454 — committed to angular/angular by chuckjaz 7 years ago
- fix(compiler): disallow references for select and index evaluation Also fixes an issue where enum values of 0 or statics of `null`, `undefined` or '``' where not treated correctly. Fixes: #18170 — committed to chuckjaz/angular by chuckjaz 7 years ago
- fix(compiler): disallow references for select and index evaluation Also fixes an issue where enum values of 0 or statics of `null`, `undefined` or '``' where not treated correctly. Fixes: #18170 — committed to chuckjaz/angular by chuckjaz 7 years ago
- fix(compiler): disallow references for select and index evaluation Also fixes an issue where enum values of 0 or '``' where not treated correctly. Fixes: #18170 — committed to chuckjaz/angular by chuckjaz 7 years ago
- fix(compiler): disallow references for select and index evaluation Also fixes an issue where enum values of 0 or '``' where not treated correctly. Fixes: #18170 — committed to chuckjaz/angular by chuckjaz 7 years ago
- fix(compiler): disallow references for select and index evaluation Also fixes an issue where enum values of 0 or '``' where not treated correctly. Fixes: #18170 — committed to angular/angular by chuckjaz 7 years ago
- fix(compiler): support enum in namespaces An overly agressive assert in the compiler prevent using enums in namespaces. Fixes #18170 — committed to chuckjaz/angular by chuckjaz 7 years ago
- fix(compiler): support referencing enums in namespaces Due to an overly agressive assert the compiler would generate an internal error when referencing an enum declared in namspace. Fixes #18170 — committed to chuckjaz/angular by chuckjaz 7 years ago
- fix(compiler): support referencing enums in namespaces Due to an overly agressive assert the compiler would generate an internal error when referencing an enum declared in namspace. Fixes #18170 — committed to chuckjaz/angular by chuckjaz 7 years ago
- fix(compiler): support referencing enums in namespaces (#20947) Due to an overly agressive assert the compiler would generate an internal error when referencing an enum declared in namspace. Fixes #... — committed to angular/angular by chuckjaz 7 years ago
The error rises because of the commit https://github.com/angular/angular/commit/ddb766e456f4d629ffe344d1178476c8c8657375 from @chuckjaz
Concretely because of the new condition
references > 0
in this if:Almost a month with this very important bug without any author reaction 😦
I’m also getting this on an enum export when using Angular 4.3.0 on CLI 1.2.1:
Downgrade to 4.2.6 fixes it
I’m facing the same problem having an enum like this:
Environment:
Reverting the Angular version to 4.2.6 isn’t an option, because I’m already using the new HttpClient API (which one was added in 4.3.0).
@alxhub @chuckjaz can you check this please? IMHO, it’s a real bug and should have higher priority.
@DincaRoberto In my case the following kind of change helped (thanks @chuckjaz):
Same error as this, I just new a project and exec ‘ng build --prod’, and then the error comes 😃. By the way, I install npm package by cnpm
Sorry I’m still getting the issue with latest versions. It’s some enum generated by swagger.
Angular CLI: 1.5.5 Node: 6.10.3 OS: win32 x64 Angular: 4.4.6
@ ./src/main.ts 3:0-74 @ multi ./src/main.ts ERROR in Error: Illegal state: symbol without members expected, but got {“filePath”:“C:/Users/xxx/Documents/workspaceWORK/xxx/src/app/shared/backend-api/emart/model/GetUserPermissionsResponseResult.ts”,“name”:“GetUserPermissionsResponseResult”,“members”:[“PermissionsEnum”,“CREATEUPDATEROLE”]}.
Just updated to release 4.4.4, which according to the changelog included the fix for this, and the issue is still present when using an
enum
on a route.hello, same error with 4.3.0, but it works with 4.2.3
@angular/cli: 1.1.2
@aleris I can’t reproduce this issue. See screenshot below. What version of the CLI are you using? Can you update the CLI to 1.3.0-beta.1 and test against it plz?
@NateWarner It turns out my fix was incomplete. I fixed some, but not all, of the cases.
If you replace line ~25021 in compiler.umd.js that looks like:
with:
It should fix the case you are running into.
Hi,
I’m vaguely aware that Angular 4 is going to get LTS maintenance. However, the answer for this issue seems to be “wait for v5”.
Are there plans to fix this issue for v4, because if not, many people using standard typescript language features seem like they’ll be unable to access the LTS patches past 4.2.6.
Apologies if I’ve completely misunderstood the advice and workarounds.
Thanks in advance!
@trotyl Yes. In 5 the compiler will “lower” these expressions into exported variables automatically avoiding this issue entirely.
@piernik What exactly did you try?
@chuckjaz michal-filip’s solution didn’t work for me.
Running without the --prod flag at the moment, but could you please fix this until I go into production? :3
@chuckjaz I can confirm that making this change does fix
enums
on routes. Thanks for the quick response.4.4.4 Works on my environment (windows and ubuntu in docker), enums and all!
Me === Happy!
In my case this error happens on a plain enum. Not sure if the workaround explained above is applicable, or even how I would go about implementing this workaround in my particular case…
Compiled using
--prod
flag in angular-cli:ERROR in Error: Illegal state: symbol without members expected, but got {"filePath":"./client/app/model/IUser.ts","name":"Role","members":["Organizer"]}.
With a dependency to:
This compiles fine. > 4.2.6, not so much.
@Mindsers sorry, I meant, “I can build by disabling just AOT, and not all prod flag”
I do need AOT, too.
@aldo-roman
--aot
functionality is precisely what we need here…4.3.4 AOT build yields:
I’ve found that I can actually use every part of 4.3.4 except @angular/compiler. That still needs to be 4.2.6 in order to workaround this issue.
+1 @rafaelss95
We have the same problem and reverting is not an option: we can’t modify the application’s code base.
I have the same problem with 4.3.3. When it will be fixed?
I tried Angular 4.3.2 and this bug it’s still been reproduced.
Building with Angular 4.3.2 AoT:
Building with Angular 4.3.2 without AoT:
After downgrading to Angular 4.2.6 with or without AoT:
I don’t understand why the angular team doesn’t care about this, because it’s impossible to use the latest AoT Angular version in any CI environment.
+1 this error with enums like:
After:
npm install @angular/cli@1.3.0-beta.1
Same with 1.2.1 (@latest)