Skip to content

fix(grid-lite): column field NoInfer to avoid fallback type compat issue#17250

Open
damyanpetev wants to merge 2 commits into21.2.xfrom
dpetev/grid-lite-column-noinfer-21.2
Open

fix(grid-lite): column field NoInfer to avoid fallback type compat issue#17250
damyanpetev wants to merge 2 commits into21.2.xfrom
dpetev/grid-lite-column-noinfer-21.2

Conversation

@damyanpetev
Copy link
Copy Markdown
Member

Closes #16962

Description

When assigning Grid Lite column field template type checker infers the column component's T from the binding, uses TypeScript's type inference to solve for T from Keys<T>. Since Keys is a complex conditional/mapped type (and kinda inferred itself), TypeScript can't reverse-infer it cleanly and lands on { [x: string]: {} }, where Keys<{ [x: string]: {} }> = string | number (no symbol). Meanwhile column.field is Keys<any> = keyof any = string | number | symbol. The symbol can't be assigned — hence the error.

The cleanest solution without narrowing the defaults is to turn off the infer on field; feels a bit odd to have the key produce the type back anyway.

Type of Change (check all that apply):

  • Bug fix
  • New functionality
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Refactoring (no functional changes)
  • Documentation
  • Demos
  • CI/CD
  • Tests
  • Changelog
  • Skills/Agents

How Has This Been Tested?

  • Unit tests Can't repro type error in current test setup, demo build should keep the error in check
  • Manual testing
  • Automated e2e tests

Checklist:

  • All relevant tags have been applied to this PR
  • This PR includes unit tests covering all the new code (test guidelines)
  • This PR includes API docs for newly added methods/properties (api docs guidelines)
  • This PR includes feature/README.MD updates for the feature docs
  • This PR includes general feature table updates in the root README.MD
  • This PR includes CHANGELOG.MD updates for newly added functionality
  • This PR contains breaking changes
  • This PR includes ng update migrations for the breaking changes (migrations guidelines)
  • This PR includes behavioral changes and the feature specification has been updated with them
  • Accessibility (ARIA, keyboard navigation, focus management) has been verified

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR addresses an Angular template type-checking issue in Grid Lite where binding a column configuration’s field could incorrectly back-infer the column component generic T, leading to a symbol incompatibility error (as reported in #16962).

Changes:

  • Prevent TypeScript from inferring IgxGridLiteColumnComponent<T>’s T from the field input by wrapping it in NoInfer.
  • Update the Grid Lite demo sample to include both untyped and typed column configuration arrays and bind them via @for loops to validate the fix in a real template scenario.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.

File Description
projects/igniteui-angular/grids/lite/src/grid-lite-column.component.ts Applies NoInfer<Keys<T>> to the field input type to stop problematic reverse inference.
src/app/grid-lite/grid-lite.sample.ts Adds IgxGridLiteColumnConfiguration examples (untyped + User-typed) and types demo data as User[].
src/app/grid-lite/grid-lite.sample.html Switches the “age” column to be generated from configuration via @for and adds a second typed columns loop.

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

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants