-
Notifications
You must be signed in to change notification settings - Fork 6.8k
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
ivy: Boolean inputs cause compile errors #17495
Comments
As workaround you can use |
Yes. We are working on this. See #17483. |
It looks like in one of the recent angular pre-releases they've disabled (or broke) the strict template checks by default (presumably here: angular/angular#33365), so this issue doesn't seem to manifest for now. |
There is still a problem with async pipe:
|
@manklu Thanks for reporting back. I'm actually trying to think about the Mostly to support both scenarios: <comp disabled></comp>
<comp [disabled]="boolean"></comp> If the input binding is used with the I think there is a flag called |
What is the alternative? One async pipe per data type which does the coercion? Magic from the compiler?
At least most of the inputs already support null. The only problem is that the compiler doesn't know it.
Hiding possible errors, just to be able to use the components with async pipe, can only be an interim solution. And if there is a company policy to enforce strict checks, it's not a solution at all. |
The alternative is to just ensure that the value assigned to the input is always a boolean (if done through binding). i.e. by using
Null makes sense from a convenience standpoint, but technically this is a boolean input expecting two values (i.e. true / false). We mostly support an empty string for the DX with empty attributes. It's not enforced in view engine, because view engine's compiler is not smart enough about these things and doesn't even do proper input type checking. This is a new feature in the Angular Ivy compiler.
It definitely is not a good idea to disable it, but with the current state, Ivy's strict template type checking is already hidden behind a flag called I've brought this up to the team and we are looking into it, but it's good to discuss this. I definitely see your point, but I'm also afraid that we do too much. The coercion is only intended to work for the two cases shown above. If someone assigns |
@devversion Just a side note. The problem with asynchronous pipes doesn't just affect boolean values, it affects any input that does not support a null value. |
Exactly. And that's why I think it's not an issue from the component side, but rather something general we need to think of. Sounds like it will not be a problem for
|
This should be resolved as of a few releases ago |
This issue has been automatically locked due to inactivity. Read more about our automatic conversation locking policy. This action has been performed automatically by a bot. |
Reproduction
(StackBlitz doesn't seem to support ivy)
Steps to reproduce:
npm install -g @angular/cli@next
ng new app
ng add @angular/material
ng update @angular/material --next
Expected Behavior
The build should pass
Actual Behavior
This usage is prevalent in Material and CDK (e.g.
cdkTrapFocus
), so it's causing a lot of errors for consumers experimenting with ivy. Any input that relies oncoerceBooleanProperty()
is subject to this problem.Environment
The text was updated successfully, but these errors were encountered: