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
- Fix embedded ToC:
Previously, the element was added too late and was never instantiated.
- Improve ToC update timing:
Previously, the ToC was updated after the entering animation was over, which
resulted in the ToC being outdated for the duration of the animation.
- Improve destroying components timing:
Previously, the old embedded components were destroyed as soon as a
new document was requested. Even if the transition ended up never
happening (e.g. due to error while preparing the new document), the
embedded components would have been destroyed and the displayed
document would not work as expected.
Now the old embedded components are destroyed only after the new
document has been fully prepared.
- Improve scroll-to-top timing:
Previously, the page was scrolled to top after the entering animation was
over, which resulted in "jumpi-ness". Now the scrolling happens after the
leaving document has been removed and before the entering document has been
inserted.
PR Close#18428
Previously, the document was shown as soon as the HTML was received, but before
the embedded components were ready (e.g. downloaded and instantiated). This
caused FOUC (Flash Of Uninstantiated Components).
This commit fixes it by preparing the new document in an off-DOM node and
swapping the nodes when the embedded components are ready.
PR Close#18428
Fixes app build error in testing guide which has testing folder at multiple levels,
with files in them referring to files in the root `testing` folder.
Also removed the exclusion of files with `.1` in the name because
all app `.ts` files must be buildable per aio policy.
must build
PR Close#20779
For some reason, prior to this fix, the boolean set matching
code (within `animation_transition_expr.ts`) failed to remain
the same when compiled with closure. This refactor makes sure
that the code stays in tact.
Reproduction Details:
Passes without `ng build --prod`: https://burger.stackblitz.io/
Fails with `ng build --prod`: http://burger.fxck.cz/Closes#20374
PR Close#20725
Closure Compiler by default will report diagnostics from type checks in
any JavaScript code, including code emitted by the Angular compiler.
Disabling `checkTypes` substantially reduces warning spam for users, and
allows them to run with stricter compiler flags (e.g. treating actual
diagnostics from user code as errors).
Closure Compiler will still type check the code and use types (where
found and correct) for optimizations.
PR Close#20828
Add enough BUILD files to make it possible to
`bazel build packages/core/test`
Also re-format BUILD.bazel files with Buildifier.
Add a CI lint check that they stay formatted.
PR Close#20768
The package.json esm2015 points to the wrong path.
"esm15" should be "esm2015"
Service Worker can't be compiled with use of Closure Compiler
PR Close#20800
The scripts were accidentally broken in #20524. More specifically, when a limit
was exceeded the script would break while trying to log an error message due to
a missing `commit` variable.
This commit fixes it and also does some minor clean-up (improve docs, use more
descriptive variable names, remove dead code, etc).
PR Close#20683