Sitelet https://github.com/angular/angular/issues/39064
Skip to content

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

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

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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