Skip to content

Code used inside ICU expressions is not fully type safe/checked. #39064

@LastDragon-ru

Description

@LastDragon-ru

🐞 bug report

Is this a regression?

Not sure.

Description

Component:

@Component({
  selector: 'my-app',
  templateUrl: './app.component.html',
  styleUrls: [ './app.component.css' ]
})
export class AppComponent  {
  value: {a?: {v: number}, b?: {v: number}} = {b: {v: 123}};
}

Code

<!-- This will fail: Object is possibly 'undefined'-->
<p *ngIf="value.b">{{value.a.v}}</p>

<!-- But this will not :( -->
<p *ngIf="value.b">
  {value.a.v, plural, other {...}}.
</p>

Expected behavior:

Both examples must fail with the message "Object is possibly 'undefined'".

Actual behavior:

No errors for {value.a.v, plural, other {...}}.

🔬 Minimal Reproduction

https://stackblitz.com/edit/angular-ivy-kinrts?file=src%2Fapp%2Fapp.component.html

🌍 Your Environment

Angular CLI: 10.1.3
Node: 13.14.0
OS: linux x64

Angular: 10.1.3
... animations, cli, common, compiler, compiler-cli, core, forms
... localize, platform-browser, platform-browser-dynamic, router
Ivy Workspace: Yes

Package                            Version
------------------------------------------------------------
@angular-devkit/architect          0.1001.3
@angular-devkit/build-angular      0.1001.3
@angular-devkit/build-ng-packagr   0.1001.3
@angular-devkit/core               10.1.3
@angular-devkit/schematics         10.1.3
@schematics/angular                10.1.3
@schematics/update                 0.1001.3
ng-packagr                         10.1.2
rxjs                               6.6.3
typescript                         4.0.3

Metadata

Metadata

Assignees

No one assigned

    Labels

    P4A relatively minor issue that is not relevant to core functionsarea: compilerIssues related to `ngc`, Angular's template compilerarea: i18nIssues related to localization and internationalizationfreq1: lowstate: confirmedstate: has PRtype: bug/fix

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions