angular: Internal compiler error on style interpolation `style="{{exp}}"` with Ivy
🐞 bug report
Affected Package
Is this a regression?
Yes, works without ivy
Description
Interpolating the style of a component with
style = {{style}}
Throws error in ivy
🔬 Minimal Reproduction
https://github.com/EmaGht/angularStyleInterpolation
instructions in README
🌍 Your Environment
Angular Version: 9.0.0-rc0
Anything else relevant? Could you also, please, give a couple informations more when something like this happens?
When ivy crashes during template compilation it doesn’t give any pointer to which file is actually affected by the error. It took me 5 hours of commenting out components to find this bug.
Next time this happens, my sanity is on your conscience! 😭
About this issue
- Original URL
- State: closed
- Created 5 years ago
- Reactions: 8
- Comments: 19 (7 by maintainers)
Commits related to this issue
- fix(ivy): Add `style="{{exp}}"` based interpolation Fixes #33575 Add support for interpolation in styles as shown: ``` <div style="color: {{exp1}}; width: {{exp2}};"> ``` — committed to mhevery/angular by mhevery 5 years ago
- fix(ivy): Add `style="{{exp}}"` based interpolation Fixes #33575 Add support for interpolation in styles as shown: ``` <div style="color: {{exp1}}; width: {{exp2}};"> ``` — committed to mhevery/angular by mhevery 5 years ago
- fix(ivy): Add `style="{{exp}}"` based interpolation (#34202) Fixes #33575 Add support for interpolation in styles as shown: ``` <div style="color: {{exp1}}; width: {{exp2}};"> ``` PR Close #34202 — committed to angular/angular by mhevery 5 years ago
Just as an aside a big problem with this particular bug is that it isn’t reporting the source. Fixing the
style
issue is great, but the underlying problem of some sort of compilation error in a template not pointing back to the template is really the bigger problem here I think.Is there a particular reason this has been pushed away from blockers? 😟
This broken “common use-case” is gonna cause me major problems on updating my company’s applications and i was eager to try the new version of Angular when it came out 😭😭
WIP: https://github.com/angular/angular/pull/34202
The culprit in question: https://github.com/EmaGht/angularStyleInterpolation/blob/master/src/app/test-comp/test-comp.component.html
The compiler should definitely give you info about the file location of the error. I’m sorry that you wasted so much time on this. We’ll need to investigate.
I’m still getting the same error with Angular 9.0.4 😦
I’m blocked for that too 😦 when you have 100k line of code, you can’t try to find where is the problem without more information 😦
This is an Ivy-specific error tho. If you disable it, compilation will work.
For other kind of errors your suggestion may work
I have the same error, at least the compiler should point to the files that contain errors.
Version:
Currently this is not supported because
<div style="{{exp1}}" [style.width]="exp1">
requires that we parse theexp1
to see if it haswidth
so thatexp2
can overwrite it.Turns out that @matsko had to add parser for other reasons so now we should be able to support it.