Skip to content

Commit 6295245

Browse files
committed
fix: loosen label plugin type
Components being passed as label arguments should not rely on plugin state. Setting the plugins to `AnyPlugins` prevents type narrowing from causing type errors
1 parent 84e2235 commit 6295245

File tree

4 files changed

+6
-6
lines changed

4 files changed

+6
-6
lines changed

src/lib/bodyCells.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ export class DataBodyCell<
101101
if (this.state === undefined) {
102102
throw new Error('Missing `state` reference');
103103
}
104-
return this.label(this, this.state);
104+
return this.label(this as DataBodyCell<Item, AnyPlugins, Value>, this.state);
105105
}
106106

107107
clone(): DataBodyCell<Item, Plugins> {

src/lib/columns.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ export class DataColumn<
152152
}
153153

154154
export type DisplayColumnDataGetter<Item, Plugins extends AnyPlugins = AnyPlugins> = (
155-
cell: DisplayBodyCell<Item, Plugins>,
155+
cell: DisplayBodyCell<Item>,
156156
state?: TableState<Item, Plugins>
157157
) => unknown;
158158

src/lib/headerCells.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ export abstract class HeaderCell<
3838
throw new Error('Missing `state` reference');
3939
}
4040
// eslint-disable-next-line @typescript-eslint/no-explicit-any
41-
return this.label(this, this.state as any);
41+
return this.label(this as HeaderCell<Item, AnyPlugins>, this.state as any);
4242
}
4343
return this.label;
4444
}

src/lib/types/Label.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,17 +6,17 @@ import type { AnyPlugins } from './TablePlugin';
66

77
// eslint-disable-next-line @typescript-eslint/no-explicit-any
88
export type DataLabel<Item, Plugins extends AnyPlugins = AnyPlugins, Value = any> = (
9-
cell: DataBodyCell<Item, Plugins, Value>,
9+
cell: DataBodyCell<Item, AnyPlugins, Value>,
1010
state: TableState<Item, Plugins>
1111
) => RenderConfig;
1212

1313
export type DisplayLabel<Item, Plugins extends AnyPlugins = AnyPlugins> = (
14-
cell: DisplayBodyCell<Item, Plugins>,
14+
cell: DisplayBodyCell<Item>,
1515
state: TableState<Item, Plugins>
1616
) => RenderConfig;
1717

1818
// If the function type is removed from the union, generics will not be
1919
// inferred for subtypes.
2020
export type HeaderLabel<Item, Plugins extends AnyPlugins = AnyPlugins> =
2121
| RenderConfig
22-
| ((cell: HeaderCell<Item, Plugins>, state: TableState<Item, Plugins>) => RenderConfig);
22+
| ((cell: HeaderCell<Item>, state: TableState<Item, Plugins>) => RenderConfig);

0 commit comments

Comments
 (0)