Skip to content
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

Exported variable 'X' has or is using name errors with AOT off #3470

Closed
the-destro opened this issue Dec 8, 2016 · 6 comments
Closed

Exported variable 'X' has or is using name errors with AOT off #3470

the-destro opened this issue Dec 8, 2016 · 6 comments

Comments

@the-destro
Copy link
Contributor

OS?

Sierra

Versions.

imac:js fridder$ ng version
angular-cli: local (v1.0.0-beta.22-1, branch: tsconfig_issue)
node: 7.2.0
os: darwin x64

(exists in non local version as well)

Repro steps.

It seems to be when I import * from a submodule that does not export all of its members.
I ran a build with ng build --aot=false and ng build and that produced an error. ng build --aot no error.

The log given by the failure.

imac:angular_qq fridder$ ng build --aot=false
Hash: d69badf52a00bd8b9ea5
Time: 11255ms
chunk    {0} main.bundle.js, main.bundle.map (main) 63.4 kB {2} [initial] [rendered]
chunk    {1} styles.bundle.js, styles.bundle.map (styles) 144 kB {3} [initial] [rendered]
chunk    {2} vendor.bundle.js, vendor.bundle.map (vendor) 3.56 MB [initial] [rendered]
chunk    {3} inline.bundle.js, inline.bundle.map (inline) 0 bytes [entry] [rendered]

ERROR in ./src/app/reducers/index.ts
Module build failed: Error: /Users/fridder/code/angular_qq/src/app/reducers/index.ts (12,14): Exported variable 'reducers' has or is using name 'Action' from external module "/Users/fridder/code/angular_qq/node_modules/@ngrx/store/src/dispatcher" but cannot be named.)
/Users/fridder/code/angular_qq/src/app/reducers/index.ts (12,14): Exported variable 'reducers' has or is using name 'InitilizeCarAction' from external module "/Users/fridder/code/angular_qq/src/app/actions/car" but cannot be named.)
/Users/fridder/code/angular_qq/src/app/reducers/index.ts (12,14): Exported variable 'reducers' has or is using name 'SelectMakeAction' from external module "/Users/fridder/code/angular_qq/src/app/actions/car" but cannot be named.)
/Users/fridder/code/angular_qq/src/app/reducers/index.ts (12,14): Exported variable 'reducers' has or is using name 'SelectModelAction' from external module "/Users/fridder/code/angular_qq/src/app/actions/car" but cannot be named.)
/Users/fridder/code/angular_qq/src/app/reducers/index.ts (12,14): Exported variable 'reducers' has or is using name 'SelectStyleAction' from external module "/Users/fridder/code/angular_qq/src/app/actions/car" but cannot be named.)
/Users/fridder/code/angular_qq/src/app/reducers/index.ts (12,14): Exported variable 'reducers' has or is using name 'SelectValuesFromFormAction' from external module "/Users/fridder/code/angular_qq/src/app/actions/car" but cannot be named.)
/Users/fridder/code/angular_qq/src/app/reducers/index.ts (12,14): Exported variable 'reducers' has or is using name 'SelectYearAction' from external module "/Users/fridder/code/angular_qq/src/app/actions/car" but cannot be named.)
/Users/fridder/code/angular_qq/src/app/reducers/index.ts (12,14): Exported variable 'reducers' has or is using name 'SetUserDataAction' from external module "/Users/fridder/code/angular_qq/src/app/actions/user" but cannot be named.)
    at _checkDiagnostics (/Users/fridder/code/angular-cli/packages/@ngtools/webpack/src/loader.ts:115:15)
    at /Users/fridder/code/angular-cli/packages/@ngtools/webpack/src/loader.ts:140:17
 @ ./src/app/app.module.ts 18:0-38
 @ ./src/app/index.ts
 @ ./src/main.ts
 @ multi main

Mention any other details that might be useful.

googling the error message suggested that it is related to declaration: true being in the tsconfig or somehow set during compilation. I have it set to false in my code base and verified that it is looking at the correct tsconfig all the way down to the config models and in the build task.

@mattdistefano
Copy link

I had this issue as well and IIRC the problem was that I had properties/methods with an implicit return type that I wasn't actually importing. So for example even just a return this.$http.get() would cause a problem if I didn't also import Observable in the same file.

@the-destro
Copy link
Contributor Author

What is annoying though is the different behavior on the different aot flags and also how this changed from one beta to this one. I suspect, though can not verify, that it is related to the skipCodeGeneration bit.

@hansl
Copy link
Contributor

hansl commented Dec 8, 2016

Before we were using Awesome-TypeScript-Loader, now we use the AoTPlugin for both AoT and non-AoT mode. It's actually faster than A-T-L, we just do the same thing but skip AoT code generation. That's the context for skipCodeGeneration.

To go back to your error, this is actually a TypeScript error and your code is missing something: microsoft/TypeScript#5711

@hansl hansl closed this as completed Dec 8, 2016
@the-destro
Copy link
Contributor Author

I get that @hansl however why does this only occur during skipCodeGeneration: true? Especially if I don't have declaration set as is mentioned in that bug?

@veliancreate-zz
Copy link

Considering angular-cli sets "declaration": false, in tsconfig, I would expect these types of Typescript errors to go away?

@angular-automatic-lock-bot
Copy link

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.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators Sep 6, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants