angular/packages/compiler-cli/src
JoostK 5de5b52beb fix(ivy): repeat template guards to narrow types in event handlers (#35193)
In Ivy's template type checker, event bindings are checked in a closure
to allow for accurate type inference of the `$event` parameter. Because
of the closure, any narrowing effects of template guards will no longer
be in effect when checking the event binding, as TypeScript assumes that
the guard outside of the closure may no longer be true once the closure
is invoked. For more information on TypeScript's Control Flow Analysis,
please refer to https://github.com/microsoft/TypeScript/issues/9998.

In Angular templates, it is known that an event binding can only be
executed when the view it occurs in is currently rendered, hence the
corresponding template guard is known to hold during the invocation of
an event handler closure. As such, it is desirable that any narrowing
effects from template guards are still in effect within the event
handler closure.

This commit tweaks the generated Type-Check Block (TCB) to repeat all
template guards within an event handler closure. This achieves the
narrowing effect of the guards even within the closure.

Fixes #35073

PR Close #35193
2020-02-07 13:06:00 -08:00
..
diagnostics refactor(compiler-cli): Move diagnostics files to language service (#33809) 2019-11-14 09:29:07 -08:00
metadata fix(compiler-cli): allow declaration-only template type check members (#34296) 2019-12-10 16:31:23 -08:00
ngtsc fix(ivy): repeat template guards to narrow types in event handlers (#35193) 2020-02-07 13:06:00 -08:00
transformers fix(compiler-cli): add sass as a valid css preprocessor extension (#35052) 2020-01-31 13:28:39 -08:00
extract_i18n.ts refactor(ivy): implement a virtual file-system layer in ngtsc + ngcc (#30921) 2019-06-25 16:25:24 -07:00
language_services.ts refactor(compiler-cli): Move diagnostics files to language service (#33809) 2019-11-14 09:29:07 -08:00
main.ts fix(compiler): switch to modern diagnostic formatting (#34234) 2019-12-09 11:37:49 -08:00
perform_compile.ts fix(compiler): switch to modern diagnostic formatting (#34234) 2019-12-09 11:37:49 -08:00
perform_watch.ts fix(ivy): recompile on template change in ngc watch mode on Windows (#34015) 2020-02-04 10:40:22 -08:00
tooling.ts fix(ivy): retain JIT metadata unless JIT mode is explicitly disabled (#33671) 2019-11-20 12:55:43 -08:00
typescript_support.ts build: typescript 3.7 support (#33717) 2020-01-14 16:42:21 -08:00
version.ts style: remove empty comments (#23404) 2018-05-10 15:48:13 -07:00