Skip to content

template type-checking in Ivy throws error for slice pipe #30086

Closed

Description

@cexbrayat

🐞 bug report

Affected Package

The issue is caused by package @angular/compiler-cli

Is this a regression?

it appeared with ng 8.0.0-beta.14

Description

A component with an ngFor and a slice like:

<div *ngFor="let user of users | slice:0:1">{{ user.name }}</div>

with users declared as

interface UserModel { 
  name: string; 
};
//...
users: Array<UserModel> = [{ name: 'jane' }];

throws an error in Ivy when compiling with template type-check.

🔬 Minimal Reproduction

ng new ivy-slice --defaults --enable-ivy

Edit tsconfig.app.json to add:

"angularCompilerOptions": {
  "enableIvy": true,
  "fullTemplateTypeCheck": true
}

Update app.component.html and app.component.ts as above, and run ng build --aot

🔥 Exception or Error


ERROR in __ng_typecheck__.ts(14,13): error TS2339: Property 'name' does not exist on type '{}'.

🌍 Your Environment

Angular Version:


Angular CLI: 8.0.0-beta.18
Node: 11.11.0
OS: darwin x64
Angular: 8.0.0-beta.14
... animations, common, compiler, compiler-cli, core, forms
... language-service, platform-browser, platform-browser-dynamic
... router

Package                           Version
-----------------------------------------------------------
@angular-devkit/architect         0.800.0-beta.18
@angular-devkit/build-angular     0.800.0-beta.18
@angular-devkit/build-optimizer   0.800.0-beta.18
@angular-devkit/build-webpack     0.800.0-beta.18
@angular-devkit/core              8.0.0-beta.18
@angular-devkit/schematics        8.0.0-beta.18
@angular/cli                      8.0.0-beta.18
@ngtools/webpack                  8.0.0-beta.18
@schematics/angular               8.0.0-beta.18
@schematics/update                0.800.0-beta.18
rxjs                              6.4.0
typescript                        3.4.5
webpack                           4.30.0

Activity

  1. added this to the needsTriage milestone on Apr 25, 2019
  2. cexbrayat commented on Apr 25, 2019

    @cexbrayat
    MemberAuthor

    Should be fixed by 79141f4 which will be available in 8.0.0-rc.0. I'll reopen if that's not the case.

  3. chacabuk commented on Jun 3, 2019

    @chacabuk

    Angular CLI: 8.0.1 Still broken.
    Property 'name' does not exist on type "<T>".

    slice_pipe.ts line 65:
    transform<T>(value: ReadonlyArray<T>, start: number, end?: number): Array<T>;

  4. cexbrayat commented on Jun 4, 2019

    @cexbrayat
    MemberAuthor

    @chacabuk SlicePipe is now more strictly typed and can catch errors with Ivy and fullTemplateTypeCheck that it couldn't previously. If you think this is a bug in Angular, and not an real error in your template, please open an issue with a reproduction, and we'll take a look.

  5. daileytj commented on Jul 19, 2019

    @daileytj

    I'm having this same issue. Has anyone been able to find a workaround and/or is this issue being addressed by the Angular team?

  6. cexbrayat commented on Jul 20, 2019

    @cexbrayat
    MemberAuthor

    @daileytj The issue should be fixed in Angular 8.0.0, so if you still encounter it in recent versions, please open an issue with a minimal reproduction and ping me, and I or someone on the team will take a look.

  7. angular-automatic-lock-bot commented on Sep 15, 2019

    @angular-automatic-lock-bot

    This issue has been automatically locked due to inactivity.
    Please file a new issue if you are encountering a similar or related problem.

    Read more about our automatic conversation locking policy.

    This action has been performed automatically by a bot.

  8. locked and limited conversation to collaborators on Sep 15, 2019
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

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions