From 3f5874f5d1c4e6148b821ffa63c8c571a7f45e65 Mon Sep 17 00:00:00 2001 From: damyanpetev Date: Thu, 29 Jan 2026 18:22:37 +0200 Subject: [PATCH] refactor(types): add defaults for generic type params on main types --- src/components/column.ts | 6 +++--- src/components/grid.ts | 14 +++++++------- src/internal/types.ts | 11 ++++++----- src/operations/filter/types.ts | 2 +- src/operations/sort/types.ts | 2 +- 5 files changed, 18 insertions(+), 17 deletions(-) diff --git a/src/components/column.ts b/src/components/column.ts index 89e3e8d..8ac68c8 100644 --- a/src/components/column.ts +++ b/src/components/column.ts @@ -15,7 +15,7 @@ import type { /** * @element igc-grid-lite-column */ -export class IgcGridLiteColumn +export class IgcGridLiteColumn extends LitElement implements BaseColumnConfiguration { @@ -88,7 +88,7 @@ export class IgcGridLiteColumn /** Custom cell template for the column. */ @property({ attribute: false }) - public cellTemplate?: (params: IgcCellContext) => unknown; + public cellTemplate?: (params: IgcCellContext) => unknown; protected override update(props: PropertyValues): void { if (this.hasUpdated && props.size > 0) { @@ -105,6 +105,6 @@ export class IgcGridLiteColumn declare global { interface HTMLElementTagNameMap { - [IgcGridLiteColumn.tagName]: IgcGridLiteColumn; + [IgcGridLiteColumn.tagName]: IgcGridLiteColumn; } } diff --git a/src/components/grid.ts b/src/components/grid.ts index 9df7e4e..0ad16c6 100644 --- a/src/components/grid.ts +++ b/src/components/grid.ts @@ -51,7 +51,7 @@ function columnReducer(acc: T[], el: T): T[] { /** * Event object for the filtering event of the grid. */ -export interface IgcFilteringEvent { +export interface IgcFilteringEvent { /** * The target column for the filter operation. */ @@ -77,7 +77,7 @@ export interface IgcFilteringEvent { /** * Event object for the filtered event of the grid. */ -export interface IgcFilteredEvent { +export interface IgcFilteredEvent { /** * The target column for the filter operation. */ @@ -92,7 +92,7 @@ export interface IgcFilteredEvent { /** * Events for the igc-grid-lite. */ -export interface IgcGridLiteEventMap { +export interface IgcGridLiteEventMap { /** * Emitted when sorting is initiated through the UI. * Returns the sort expression which will be used for the operation. @@ -103,14 +103,14 @@ export interface IgcGridLiteEventMap { * * @event */ - sorting: CustomEvent>; + sorting: CustomEvent>; /** * Emitted when a sort operation initiated through the UI has completed. * Returns the sort expression used for the operation. * * @event */ - sorted: CustomEvent>; + sorted: CustomEvent>; /** * Emitted when filtering is initiated through the UI. * @@ -144,7 +144,7 @@ export interface IgcGridLiteEventMap { * @fires filtered - Emitted when a filter operation initiated through the UI has completed. * */ -export class IgcGridLite extends EventEmitterBase> { +export class IgcGridLite extends EventEmitterBase> { public static get tagName() { return GRID_TAG; } @@ -504,6 +504,6 @@ export class IgcGridLite extends EventEmitterBase; + [IgcGridLite.tagName]: IgcGridLite; } } diff --git a/src/internal/types.ts b/src/internal/types.ts index 8f3cd75..bcc8b6d 100644 --- a/src/internal/types.ts +++ b/src/internal/types.ts @@ -170,9 +170,10 @@ export interface BaseColumnConfiguration = K /** * See {@link BaseColumnConfiguration} for the full documentation. */ -export type ColumnConfiguration = Keys> = K extends Keys - ? BaseColumnConfiguration - : never; +export type ColumnConfiguration< + T extends object = any, + K extends Keys = Keys, +> = K extends Keys ? BaseColumnConfiguration : never; export interface ActiveNode { column: Keys; @@ -182,7 +183,7 @@ export interface ActiveNode { /** * Context object for the column header template callback. */ -export interface IgcHeaderContext { +export interface IgcHeaderContext { /** * The header element parent of the template. */ @@ -218,7 +219,7 @@ export interface BaseIgcCellContext = Keys = Keys> = K extends Keys +export type IgcCellContext = Keys> = K extends Keys ? BaseIgcCellContext : never; diff --git a/src/operations/filter/types.ts b/src/operations/filter/types.ts index e8d918b..37b607b 100644 --- a/src/operations/filter/types.ts +++ b/src/operations/filter/types.ts @@ -64,7 +64,7 @@ export interface BaseFilterExpression = Keys> { /** * See {@link BaseFilterExpression} for the full documentation. */ -export type FilterExpression = Keys> = K extends Keys +export type FilterExpression = Keys> = K extends Keys ? BaseFilterExpression : never; diff --git a/src/operations/sort/types.ts b/src/operations/sort/types.ts index d7cfb15..7037d78 100644 --- a/src/operations/sort/types.ts +++ b/src/operations/sort/types.ts @@ -54,7 +54,7 @@ export interface BaseSortingExpression = Keys> { /** * See {@link BaseSortingExpression} for the full documentation. */ -export type SortingExpression = Keys> = K extends Keys +export type SortingExpression = Keys> = K extends Keys ? BaseSortingExpression : never;