Repository navigation
Conversation
|
Likely will close #19756? |
|
You can preview 4d39227 at https://pr20702-4d39227.ngbuilds.io/. |
4d39227 to
b4bdf80
Compare
|
You can preview b4bdf80 at https://pr20702-b4bdf80.ngbuilds.io/. |
There was a problem hiding this comment.
Consider adding this to the @Input() instead of doing name matching ?
There was a problem hiding this comment.
I discussed this with Misko and, though this is technically right, it give an esoteric feature way to much visibility and using naming convention is much better for such a corner case.
There was a problem hiding this comment.
q to discuss reduce vs foreach
There was a problem hiding this comment.
let does not default to undefined but, rather, raises an error if it is accessed before initialization.
|
Comments:
|
|
You can preview 2360d6e at https://pr20702-2360d6e.ngbuilds.io/. |
|
You can preview f7ef4a3 at https://pr20702-f7ef4a3.ngbuilds.io/. |
|
You can preview 4bc39c0 at https://pr20702-4bc39c0.ngbuilds.io/. |
|
You can preview 080e072 at https://pr20702-080e072.ngbuilds.io/. |
|
You can preview d9a3fa0 at https://pr20702-d9a3fa0.ngbuilds.io/. |
|
You can preview ce114a3 at https://pr20702-ce114a3.ngbuilds.io/. |
As discussed off-line, this would raise the visibility of a very infrequently used feature.
Fixed.
Will do in a follow-on PR. Done;
Missed this one. Will add a test.
I prefer to keep them together as they need to be taken together for the feature to work. For example, we would never revert one of the commits without reverting them all as the NgIf change makes no sense without the rest and vis versa. |
Structural directives can now specify a type guard that describes
what types can be inferred for an input expression inside the
directive's template.
NgIf was modified to declare an input guard on ngIf.
After this change, `fullTemplateTypeCheck` will infer that
usage of `ngIf` expression inside it's template is truthy.
For example, if a component has a property `person?: Person`
and a template of `<div *ngIf="person"> {{person.name}} </div>`
the compiler will no longer report that `person` might be null or
undefined.
The template compiler will generate code similar to,
```
if (NgIf.ngIfTypeGuard(instance.person)) {
instance.person.name
}
```
to validate the template's use of the interpolation expression.
Calling the type guard in this fashion allows TypeScript to infer
that `person` is non-null.
Fixes: angular#19756?
Done. |
|
You can preview 4c47bc4 at https://pr20702-4c47bc4.ngbuilds.io/. |
|
@chuckjaz Can't get this to work. Angular 5.2.1, TS 2.5.3, |
|
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. |
Structural directives can now specify a type guard that describes
what types can be inferred for an input expression inside the
directive's template.
NgIf was modified to declare an input guard on ngIf.
After this change,
fullTemplateTypeCheckwill infer thatusage of
ngIfexpression inside it's template is truthy.For example, if a component has a property
person?: Personand a template of
<div *ngIf="person"> {{person.name}} </div>the compiler will no longer report that person might be null or
undefined.
The template compiler will generate code similar to,
to validate the template's use of the interpolation expression.
Calling the type guard in this fashion allows TypeScript to infer
that
personis non-null.PR Type
What kind of change does this PR introduce?
What is the current behavior?
Given a component like:
The compiler would produce an error stating that
personmight be undefined.What is the new behavior?
The compiler infers that
personisPersoninside the*ngIfbut is stillPerson | undefinedoutside the*ngIf.Does this PR introduce a breaking change?
Other information