The Wayback Machine - https://web.archive.org/web/20200628001842/https://github.com/angular/angular/pull/37747
Skip to content
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

fix(compiler-cli): use `null` in type checking of safe navigation operators #37747

Draft
wants to merge 1 commit into
base: master
from

Conversation

@JoostK
Copy link
Member

JoostK commented Jun 25, 2020

Safe navigation operators in Angular templates will evaluate to null if the LHS
operand is null or undefined, however the type checker would use undefined
instead. This results in inaccurate type checking when strictNullChecks is enabled.

BREAKING CHANGE:

Using the safe navigation operator in templates will now infer the type of the
expressions to be a union type including null, instead of undefined as it
previously was. If TypeScript's strictNullChecks is enabled together with Angular's
strictTemplates or strictSafeNavigationTypes you may start to see new type errors.
The previous behavior of including undefined in the type does not correspond with
the behavior at runtime, where the null value is used instead.

Fixes #37622

…rators

Safe navigation operators in Angular templates will evaluate to `null` if the LHS
operand is `null` or `undefined`, however the type checker would use `undefined`
instead. This results in inaccurate type checking when `strictNullChecks` is enabled.

BREAKING CHANGE:

Using the safe navigation operator in templates will now infer the type of the
expressions to be a union type including `null`, instead of `undefined` as it
previously was. If TypeScript's `strictNullChecks` is enabled together with Angular's
`strictTemplates` or `strictSafeNavigationTypes` you may start to see new type errors.
The previous behavior of including `undefined` in the type does not correspond with
the behavior at runtime, where the `null` value is used instead.

Fixes #37622
@alfaproject
Copy link
Contributor

alfaproject commented Jun 26, 2020

Shouldn't TypeScript handle this operator now? As in, shouldn't this have the same semantics as the JS version?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

3 participants
You can’t perform that action at this time.