Skip to content

Type MatChipGrid is not assignable to type MatChipGrid & MatLegacyChipList #28268

@seyfer

Description

@seyfer

Is this a regression?

  • Yes, this behavior used to work in the previous version

The previous version in which this bug was not present was

No response

Description

Just by following the example of Chips with Input from official documentation for v16 Material

https://v16.material.angular.io/components/chips/overview#chips-connected-to-an-input-field

I have the following error with this code

<mat-form-field class="example-chip-list">
  <mat-label>Favorite Fruits</mat-label>
  <mat-chip-grid #chipGrid aria-label="Enter fruits">
    <mat-chip-row *ngFor="let fruit of fruits"
                  (removed)="remove(fruit)"
                  [editable]="true"
                  (edited)="edit(fruit, $event)"
                  [aria-description]="'press enter to edit ' + fruit.name">
      {{fruit.name}}
      <button matChipRemove [attr.aria-label]="'remove ' + fruit.name">
        <mat-icon>cancel</mat-icon>
      </button>
    </mat-chip-row>
    <input placeholder="New fruit..."
           [matChipInputFor]="chipGrid"
           [matChipInputSeparatorKeyCodes]="separatorKeysCodes"
           [matChipInputAddOnBlur]="addOnBlur"
           (matChipInputTokenEnd)="add($event)"/>
  </mat-chip-grid>
</mat-form-field>

specifically, at [matChipInputFor]="chipGrid"

the error is:

Type MatChipGrid is not assignable to type MatChipGrid & MatLegacyChipList   
Type MatChipGrid is not assignable to type MatLegacyChipList

There is SO question with the same issue, without an answer.
https://stackoverflow.com/questions/76497544/mat-chip-grid-is-not-assignable-to-mat-chip-grid-and-mat-legacy-chip-list

Reproduction

Steps to reproduce:

  1. just follow https://v16.material.angular.io/components/chips/overview#chips-connected-to-an-input-field

Expected Behavior

No TS error when assigning chip grid template to matChipInputFor
[matChipInputFor]='chipGrid'

Actual Behavior

TS error at [matChipInputFor]='chipGrid', see in the description.

Environment

  • Angular: v16 latest
  • CDK/Material: v16 latest
  • Browser(s): any
  • Operating System (e.g. Windows, macOS, Ubuntu): Linux, any

Metadata

Metadata

Assignees

No one assigned

    Labels

    needs triageThis issue needs to be triaged by the team

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions