angular: Wrong warning : ng8102

Which @angular/* package(s) are the source of the bug?

compiler

Is this a regression?

Yes

Description

Wrong warning in this case

Exemple : warning NG8102: The left side of this nullish coalescing operation does not include ‘null’ or ‘undefined’ in its type, therefore the ‘??’ operator can be safely removed.

{{element.CurrentLock?.Clinician?.Label ?? '--'}}

In this case CurrentLock and Clinician could be null

Please provide a link to a minimal reproduction of the bug

No response

Please provide the exception or error you saw

No response

Please provide the environment you discovered this bug in (run ng version)

Angular CLI: 13.2.0
Node: 14.18.3
Package Manager: npm 6.14.15
OS: win32 x64

Angular: 13.2.0
... animations, cdk, cli, common, compiler, compiler-cli, core
... forms, localize, material, material-moment-adapter
... platform-browser, platform-browser-dynamic, router

Package                         Version
---------------------------------------------------------
@angular-devkit/architect       0.1302.0
@angular-devkit/build-angular   13.2.0
@angular-devkit/core            13.2.0
@angular-devkit/schematics      13.2.0
@schematics/angular             13.2.0
rxjs                            6.6.7
typescript                      4.5.4

Anything else?

No response

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Reactions: 1
  • Comments: 17 (10 by maintainers)

Most upvoted comments

13.2.1 is out which should have improved things. I’ll keep this open for a while, please report situations where you believe the rule is incorrect below.

I will have a look at this.

There’s also an issue when strictNullChecks and strict are both disabled (or their default values), which is also being fixed in #44862.