mirror of
https://github.com/angular/angular
synced 2026-05-24 09:28:37 +00:00
Deliver web apps with confidence 🚀
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: #19756?
PR Close #20702
|
||
|---|---|---|
| .circleci | ||
| .github | ||
| aio | ||
| docs | ||
| integration | ||
| modules | ||
| packages | ||
| scripts | ||
| tools | ||
| .bowerrc | ||
| .clang-format | ||
| .editorconfig | ||
| .gitattributes | ||
| .gitignore | ||
| .mailmap | ||
| .nvmrc | ||
| .pullapprove.yml | ||
| .travis.yml | ||
| bower.json | ||
| browser-providers.conf.js | ||
| BUILD.bazel | ||
| build.sh | ||
| CHANGELOG.md | ||
| CONTRIBUTING.md | ||
| gulpfile.js | ||
| karma-js.conf.js | ||
| LICENSE | ||
| package.json | ||
| protractor-e2e.conf.js | ||
| protractor-examples-e2e.conf.js | ||
| protractor-perf.conf.js | ||
| README.md | ||
| shims_for_IE.js | ||
| test-events.js | ||
| test-main.js | ||
| test.sh | ||
| tslint.json | ||
| WORKSPACE | ||
| yarn.lock | ||
| yarn.lock.readme.md | ||
Safari (7+), iOS (7+) and IE mobile (11) are tested on BrowserStack.
Angular
Angular is a development platform for building mobile and desktop web applications using Typescript/JavaScript and other languages.
Quickstart
Want to help?
Want to file a bug, contribute some code, or improve documentation? Excellent! Read up on our guidelines for contributing and then check out one of our issues in the hotlist: community-help.