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

Most upvoted comments

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:

                // Stop simplification at builtin symbols or if we are in a reference context
                if (expression === self.injectionToken || expression === self.opaqueToken ||
                    self.conversionMap.has(expression) || references > 0) {
                    return expression;
                }

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:

ERROR in Illegal state: symbol without members expected, but got {"filePath":"snip/src/app/core/models/index.ts","name":"Role","members":["Advisor"]}.

Downgrade to 4.2.6 fixes it

I’m facing the same problem having an enum like this:

export enum Role {
  User = 'user',
  Admin = 'admin'
}

ERROR in Illegal state: symbol without members expected, but got {“filePath”:“/filePath/enums/role.enum.ts”,“name”:“Role”,“members”:[“User”]}.

Environment:

@angular/cli: 1.2.7
node: 8.1.1
os: linux x64
@angular/animations: 4.3.3
@angular/cdk: 2.0.0-beta.8
@angular/common: 4.3.3
@angular/compiler: 4.3.3
@angular/core: 4.3.3
@angular/forms: 4.3.3
@angular/http: 4.3.3
@angular/material: 2.0.0-beta.8
@angular/platform-browser: 4.3.3
@angular/platform-browser-dynamic: 4.3.3
@angular/platform-server: 4.3.3
@angular/router: 4.3.3
@angular/cli: 1.2.7
@angular/compiler-cli: 4.3.3
@angular/language-service: 4.3.3
typescript: 2.4.2

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):

+ export const UiFlag_CONTROL_BOARD_VISIBLE = UiFlag.CONTROL_BOARD_VISIBLE;
const routes: Routes = [
    // ...
   {
         path: 'control-board',
         canActivate: [AuthGuard, FlagGuard],
         data: {
-            flag: UiFlag.CONTROL_BOARD_VISIBLE
+            flag: UiFlag_CONTROL_BOARD_VISIBLE
         }
         // ...
     }
];

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 image

image

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?

image

@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:

var /** @type {?} */ selectTarget = simplify(expression['expression']);

with:

var /** @type {?} */ selectTarget = simplifyInContext(context, expression['expression'], depth, 0);

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…

export enum Role {
  Admin = 99, Organizer = 90, Secretariat = 80, Club = 50, User = 10
}

export interface IUser  {
  id: number;
  name: string;
  email: string;
  password: string;
  role?: Role;
}

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:

@angular/compiler”: “4.2.6”,

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:

ERROR in Illegal state: symbol without members expected, but got {"filePath":"D:/dev/gymsystems/client/app/services/model/IUser.ts","name":"Role","members":["Club"]}.
ERROR in ./client/main.ts
Module not found: Error: Can't resolve './$$_gendir/app/app.module.ngfactory' in 'D:\dev\gymsystems\client'
resolve './$$_gendir/app/app.module.ngfactory' in 'D:\dev\gymsystems\client'
  using description file: D:\dev\gymsystems\package.json (relative path: ./client)
    Field 'browser' doesn't contain a valid alias configuration
  after using description file: D:\dev\gymsystems\package.json (relative path: ./client)
    using description file: D:\dev\gymsystems\package.json (relative path: ./client/$$_gendir/app/app.module.ngfactory)
      no extension
        Field 'browser' doesn't contain a valid alias configuration
        D:\dev\gymsystems\client\$$_gendir\app\app.module.ngfactory doesn't exist
      .ts
        Field 'browser' doesn't contain a valid alias configuration
        D:\dev\gymsystems\client\$$_gendir\app\app.module.ngfactory.ts doesn't exist
      .js
        Field 'browser' doesn't contain a valid alias configuration
        D:\dev\gymsystems\client\$$_gendir\app\app.module.ngfactory.js doesn't exist
      as directory
        D:\dev\gymsystems\client\$$_gendir\app\app.module.ngfactory doesn't exist
[D:\dev\gymsystems\client\$$_gendir\app\app.module.ngfactory]
[D:\dev\gymsystems\client\$$_gendir\app\app.module.ngfactory.ts]
[D:\dev\gymsystems\client\$$_gendir\app\app.module.ngfactory.js]
[D:\dev\gymsystems\client\$$_gendir\app\app.module.ngfactory]
 @ ./client/main.ts 3:0-74
 @ multi ./client/main.ts
error Command failed with exit code 1.

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:

Error: Illegal state: symbol without members expected, but got {“filePath”:“/my-model.model.ts”,“name”:“ModelCode”,“members”:[“ModelData”]}.

Building with Angular 4.3.2 without AoT:

[at-loader] Ok, 6.462 sec.

After downgrading to Angular 4.2.6 with or without AoT:

[at-loader] Ok, 10.517 sec.

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:

export enum MyEnum {
  val1 = <any>"val1",
  val2 = <any>"val2"
}
ng -v
@angular/cli: 1.0.0
node: 7.10.0
os: win32 x64
@angular/common: 4.3.0
@angular/compiler: 4.3.0
@angular/core: 4.3.0
@angular/forms: 4.3.0
@angular/http: 4.3.0
@angular/platform-browser: 4.3.0
@angular/platform-browser-dynamic: 4.3.0
@angular/router: 4.3.0
@angular/cli: 1.0.0
@angular/compiler-cli: 4.3.0

After: npm install @angular/cli@1.3.0-beta.1

a

Same with 1.2.1 (@latest)