Skip to content

ERROR in Illegal state: symbol without members expected when using AOT in 4.3.0 #18170

Closed

Description

@aleris

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

Activity

  1. manekinekko commented on Jul 17, 2017

    @manekinekko
    Contributor

    @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

  2. deepu105 commented on Jul 17, 2017

    @deepu105

    We were using 1.2.1 in JHipster

  3. deepu105 commented on Jul 17, 2017

    @deepu105

    I made few tests with this sample
    With Global CLI 1.2.1 and local 1.0.0
    image
    With global and local CLI 1.2.1
    image
    With local CLI 1.3.0-beta.1
    image
    With global and local CLI 1.3.0-beta.1
    image

    Could it be possible that you have a different angular version linked or something?

  4. aleris commented on Jul 17, 2017

    @aleris
    Author
    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)

  5. cjamaldine commented on Jul 17, 2017

    @cjamaldine

    hello,
    same error with 4.3.0, but it works with 4.2.3

    @angular/cli: 1.1.2

  6. tmakin commented on Jul 18, 2017

    @tmakin

    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

  7. janousek commented on Jul 20, 2017

    @janousek

    The error rises because of the commit ddb766e 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;
                    }
    
  8. rimlin commented on Jul 21, 2017

    @rimlin

    +1 this error with enums like:

    export enum MyEnum {
      val1 = <any>"val1",
      val2 = <any>"val2"
    }
    
  9. cdllqos commented on Jul 24, 2017

    @cdllqos

    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

  10. montella1507 commented on Jul 27, 2017

    @montella1507

    @chuckjaz can you give us some advice, please?

  11. florinr1 commented on Jul 28, 2017

    @florinr1

    I have the same error after upgrading angular from 4.1.3 to 4.3.1 and CLI from 1.1.0 to 1.2.3.
    export enum ModDeschidere { CREATE = 0, VIEW = 1, EDIT = 2 }

    ERROR in Illegal state: symbol without members expected, but got {"filePath":"src/app/core/modDeschidere.ts","name":"ModDeschidere","members":["CREATE"]}.

    I don't know what to do / test.

  12. janousek commented on Jul 28, 2017

    @janousek

    For everyone who needs temporary fix for this error. Just manually modify this file:

    node_modules@angular\compiler\bundles\compiler.umd.js

    Find this part of code:

                    // 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;
                    }
    

    And modify it to look like this:

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

    Everything will work.

  13. montella1507 commented on Jul 28, 2017

    @montella1507

    @janousek unfortunately it is not possible (it is dangerous) in CI environment when you want to build "clean build". So i would rather suggest temporary downgrade to older angular as temporary solution.

  14. 58 remaining items

  15. sunb0002 commented on Dec 2, 2017

    @sunb0002

    @chuckjaz Thank you for the prompt response.
    I've created it here: https://github.com/sunb0002/angularissue
    'ng build' is ok, while 'ng build --aot' gets errors.

    Also noticed that if I aot compile the same code with Angular 5.0.0, I won't get the error.
    But anyway we are not rushing on this issue as it's an internal application.
    We can persuade client to go without aot.

  16. chuckjaz commented on Dec 11, 2017

    @chuckjaz
    Contributor

    @sunb0002 A work around for your case is to introduce a intermediate exported symbol:

    export const HomePermissions = [PermissionsEnum.CREATEVENDORUSER];
    
    const routes: Routes = [
      {
        path: '**', redirectTo: 'dashboard',
        data: { title: 'Home', accessPermissions: HomePermissions }
      }
    ];

    This type of rewriting is performed automatically in 5.0 and is transformed into something like,

    export const ɵ1 = { title: 'Home', accessPermissions: [PermissionsEnum.CREATEVENDORUSER] };
    
    const routes: Routes = [
      {
        path: '**', redirectTo: 'dashboard',
        data: ɵ1
      }
    ];
    
    @NgModule({
      imports: [RouterModule.forRoot(routes, { useHash: true })],
      exports: [RouterModule]
    })
    export class RoutesRoutingModule { }

    I will rework the assert into a better error message for 4.x.x. We will not support indexing into members of an namespace but, at least, we should give a reasonable error message instead of an internal assert violation.

  17. sunb0002 commented on Dec 12, 2017

    @sunb0002

    @chuckjaz Thanks a lot for the help. It's working now.

  18. added a commit that references this issue on Dec 12, 2017
    a90a343
  19. added a commit that references this issue on Dec 13, 2017
    d6da798
  20. angular-automatic-lock-bot commented on Sep 13, 2019

    @angular-automatic-lock-bot

    This issue has been automatically locked due to inactivity.
    Please file a new issue if you are encountering a similar or related problem.

    Read more about our automatic conversation locking policy.

    This action has been performed automatically by a bot.

  21. locked and limited conversation to collaborators on Sep 13, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

area: coreIssues related to the framework runtimefreq2: mediumregressionIndicates than the issue relates to something that worked in a previous versiontype: bug/fix

Type

No type

Projects

No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions