fix(grid-lite): column field NoInfer to avoid fallback type compat issue#17250
Open
damyanpetev wants to merge 2 commits into21.2.xfrom
Open
fix(grid-lite): column field NoInfer to avoid fallback type compat issue#17250damyanpetev wants to merge 2 commits into21.2.xfrom
damyanpetev wants to merge 2 commits into21.2.xfrom
Conversation
Contributor
There was a problem hiding this comment.
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>’sTfrom thefieldinput by wrapping it inNoInfer. - Update the Grid Lite demo sample to include both untyped and typed column configuration arrays and bind them via
@forloops 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. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #16962
Description
When assigning Grid Lite column
fieldtemplate type checker infers the column component'sTfrom the binding, uses TypeScript's type inference to solve forTfromKeys<T>. SinceKeysis a complex conditional/mapped type (and kinda inferred itself), TypeScript can't reverse-infer it cleanly and lands on{ [x: string]: {} }, whereKeys<{ [x: string]: {} }>=string | number(nosymbol). Meanwhilecolumn.fieldisKeys<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):
How Has This Been Tested?
Unit testsCan't repro type error in current test setup, demo build should keep the error in checkChecklist:
feature/README.MDupdates for the feature docsREADME.MDCHANGELOG.MDupdates for newly added functionalityng updatemigrations for the breaking changes (migrations guidelines)