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

NGC compilation error with 2.3.0 #1307

Closed
sluglit opened this issue Dec 9, 2016 · 17 comments
Closed

NGC compilation error with 2.3.0 #1307

sluglit opened this issue Dec 9, 2016 · 17 comments
Assignees

Comments

@sluglit
Copy link

sluglit commented Dec 9, 2016

When compiling with @angular/[email protected]
I get the following error:

Error: Error encountered resolving symbol values statically. Only initialized variables and constants can be referenced because the value of this variable is needed by the template compiler (position 7:12 in the original .ts file), resolving symbol Ng2BootstrapConfig in c:/project/node_modules/ng2-bootstrap/components/ng2-bootstrap-config.d.ts, resolving symbol TypeaheadContainerComponent in c:/project/node_modules/ng2-bootstrap/components/typeahead/typeahead-container.component.d.ts, resolving symbol TypeaheadContainerComponent in c:/project/node_modules/ng2-bootstrap/components/typeahead/typeahead-container.component.d.ts
at positionalError (c:\project\node_modules@angular\compiler\bundles\compiler.umd.js:25370:37)
at simplifyInContext (c:\project\node_modules@angular\compiler\bundles\compiler.umd.js:25177:29)
at StaticReflector.simplify (c:\project\node_modules@angular\compiler\bundles\compiler.umd.js:25191:15)
at StaticReflector.annotations (c:\project\node_modules@angular\compiler\bundles\compiler.umd.js:24533:62)
at NgModuleResolver.resolve (c:\project\node_modules@angular\compiler\bundles\compiler.umd.js:17207:84)
at CompileMetadataResolver.getNgModuleMetadata (c:\project\node_modules@angular\compiler\bundles\compiler.umd.js:17681:62)
at addNgModule (c:\project\node_modules@angular\compiler\bundles\compiler.umd.js:24285:60)
at c:\project\node_modules@angular\compiler\bundles\compiler.umd.js:24296:16
at Array.forEach (native)
at _createNgModules (c:\project\node_modules@angular\compiler\bundles\compiler.umd.js:24295:28)
Compilation failed

This is caused by the ng2-bootstrap-config.ts code static variable and that aren't initialized.
https://github.com/valor-software/ng2-bootstrap/blob/development/src/utils/ng2-bootstrap-config.ts

@sluglit sluglit changed the title NGC compilation error with NGC compilation error with 2.3.0 Dec 9, 2016
@corner22
Copy link

corner22 commented Dec 12, 2016

I also get this problem. Angular 2.3.0. Typescript 2.0.10. My workaround was to revert to Angular 2.2.0.

@valorkin
Copy link
Member

this is awesome, so you just need to set default value
@sluglit this is a perfect chance for small PR ;)

@sluglit
Copy link
Author

sluglit commented Dec 14, 2016

@valorkin It isn't that simple.
I tried to fix the code on my cloned repo, and it seems to be an issue with the way angular-cli pre-compiles static methods and variables.

To resolve this we will have to get rid of the static declarations and make this class instance based (instead of calling the methods statically)

Then to make the class behave the same, we will have to inject the instance into the NgModule in provided.

I will play with that approach and if it work's; I'll raise a PR.

@valorkin
Copy link
Member

omfg ... this sounds as a bad news
but you can try simply export function
it will static for module (file module level)

@linusbrolin
Copy link
Contributor

@sluglit @valorkin any progress on this?
This bug is currently preventing me from compiling my project at work, and I cannot revert Angular back to 2.2.0 either because that gives me other errors, so I'm kinda stuck.

@tsoposki
Copy link

@linusbrolin Try revert Angular back to "2.2.4". I am using that version and I don't have any issue.

@linusbrolin
Copy link
Contributor

@tsoposki Thanks! That specific version seemed to not produce error messages.
Now I can continue my work. phew ;)

@valorkin
Copy link
Member

There are v1.1.16-4, who can try it with ng v2.3
I would really appreciate it

@tsoposki
Copy link

@valorkin I tried with ng2 "2.3.0" and "2.3.1" with the latest ng2-bootstrap "1.1.16-4" and I am still getting the same issue.

@valorkin valorkin self-assigned this Dec 16, 2016
@valorkin
Copy link
Member

please try v1.1.16-5

@valorkin valorkin reopened this Dec 16, 2016
@valorkin
Copy link
Member

I will reopen issue, until fix confirmed
DM me here if anything https://ngx-slack.herokuapp.com/

@valorkin valorkin reopened this Dec 17, 2016
@valorkin
Copy link
Member

Please confirm that issue is fixed in v1.1.16-6

@sluglit
Copy link
Author

sluglit commented Dec 17, 2016

Hi Valorkin
With 1.1.16-6 I get the following error.

Error at D:/project/node_modules/ng2-bootstrap/typeahead/typeahead-c
ontainer.component.ngfactory.ts:167:44: Property 'isBs4' does not exist on type 'TypeaheadContainerComponent'.

FYI: I am working on a PR but it's taking a while...

@valorkin
Copy link
Member

ok, check v1.1.16-7
I don't know WHY, in prev build it is just skipped variable

@sluglit
Copy link
Author

sluglit commented Dec 17, 2016

Thanks for the work you put in, version 1.1.16-7 works with angular 2.3.1.
(Probably for 2.3.0 too)

@sluglit sluglit closed this as completed Dec 17, 2016
@valorkin
Copy link
Member

valorkin commented Dec 17, 2016

awesome, back to docs ;)
BTW I am planing to add spec to each demo sample,
would it make sense?

@sluglit
Copy link
Author

sluglit commented Dec 17, 2016

I believe that it would help, it would effectively be your e2e tests.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants