Solvedangular 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
32 Answers

✔️Accepted Answer

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

Other Answers:

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

Almost a month with this very important bug without any author reaction :-(

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.

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

@angular/cli: 1.1.2

More Issues: