Skip to content

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

Open
damyanpetev wants to merge 2 commits intomasterfrom
dpetev/grid-lite-column-noinfer
Open

fix(grid-lite): column field NoInfer to avoid fallback type compat issue#17249
damyanpetev wants to merge 2 commits intomasterfrom
dpetev/grid-lite-column-noinfer

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 a Grid Lite template type-checking inference issue where binding column.field could cause TypeScript to infer an incorrect fallback model type, leading to symbol incompatibility errors.

Changes:

  • Updated IgxGridLiteColumnComponent.field input type to use NoInfer<Keys<T>> to prevent reverse-inference of T from the field binding.
  • Updated the Grid Lite sample to demonstrate both untyped and typed IgxGridLiteColumnConfiguration usage with dynamic column rendering via @for.
  • Typed the sample data as User[] to align with the sample data service model.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.

File Description
src/app/grid-lite/grid-lite.sample.ts Updates the sample to use IgxGridLiteColumnConfiguration arrays (typed and untyped) and types the data as User[].
src/app/grid-lite/grid-lite.sample.html Replaces the hard-coded age column with @for-rendered columns from the sample configuration arrays.
projects/igniteui-angular/grids/lite/src/grid-lite-column.component.ts Prevents generic type inference from the field input by wrapping Keys<T> in NoInfer.

Comment thread src/app/grid-lite/grid-lite.sample.ts Outdated
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.

[Grid Lite] IgxGridLiteColumnConfiguration requires explicit generic type and cannot be inferred

2 participants