fix(grid-lite): column field NoInfer to avoid fallback type compat issue#17249
Open
damyanpetev wants to merge 2 commits intomasterfrom
Open
fix(grid-lite): column field NoInfer to avoid fallback type compat issue#17249damyanpetev wants to merge 2 commits intomasterfrom
damyanpetev wants to merge 2 commits intomasterfrom
Conversation
Contributor
There was a problem hiding this comment.
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.fieldinput type to useNoInfer<Keys<T>>to prevent reverse-inference ofTfrom thefieldbinding. - Updated the Grid Lite sample to demonstrate both untyped and typed
IgxGridLiteColumnConfigurationusage 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. |
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)