Skip to content

Commit

Permalink
fix(typing): improve ColumnInformation renderer property typing (#7554)
Browse files Browse the repository at this point in the history
* fix: typecheck

Signed-off-by: axel7083 <42176370+axel7083@users.noreply.github.com>

* revert: unwanted modification

Signed-off-by: axel7083 <42176370+axel7083@users.noreply.github.com>

---------

Signed-off-by: axel7083 <42176370+axel7083@users.noreply.github.com>
  • Loading branch information
axel7083 committed Jun 12, 2024
1 parent 13491a1 commit fc042fe
Show file tree
Hide file tree
Showing 8 changed files with 12 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ let ageColumn = new TableColumn<DeploymentUI, Date | undefined>('Age', {
comparator: (a, b) => moment(b.created).diff(moment(a.created)),
});
const columns: TableColumn<DeploymentUI, DeploymentUI | string | Date | undefined>[] = [
const columns = [
statusColumn,
nameColumn,
namespaceColumn,
Expand Down
2 changes: 1 addition & 1 deletion packages/renderer/src/lib/image/ImagesList.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -280,7 +280,7 @@ let sizeColumn = new TableColumn<ImageInfoUI, string>('Size', {
comparator: (a, b) => b.size - a.size,
});
const columns: TableColumn<ImageInfoUI, ImageInfoUI | string>[] = [
const columns = [
statusColumn,
nameColumn,
envColumn,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ let namespaceColumn = new TableColumn<IngressUI | RouteUI, string>('Namespace',
comparator: (a, b) => a.namespace.localeCompare(b.namespace),
});
let pathColumn = new TableColumn<IngressUI | RouteUI, string>('Host/Path', {
let pathColumn = new TableColumn<IngressUI | RouteUI>('Host/Path', {
width: '1.5fr',
renderer: IngressRouteColumnHostPath,
comparator: (a, b) => compareHostPath(a, b),
Expand All @@ -137,7 +137,7 @@ function compareHostPath(object1: IngressUI | RouteUI, object2: IngressUI | Rout
return hostPathObject1.label.localeCompare(hostPathObject2.label);
}
let backendColumn = new TableColumn<IngressUI | RouteUI, string>('Backend', {
let backendColumn = new TableColumn<IngressUI | RouteUI>('Backend', {
width: '1.5fr',
renderer: IngressRouteColumnBackend,
comparator: (a, b) => compareBackend(a, b),
Expand All @@ -149,7 +149,7 @@ function compareBackend(object1: IngressUI | RouteUI, object2: IngressUI | Route
return backendObject1.localeCompare(backendObject2);
}
const columns: TableColumn<IngressUI | RouteUI, IngressUI | RouteUI | string | Date | undefined>[] = [
const columns = [
statusColumn,
nameColumn,
namespaceColumn,
Expand Down
10 changes: 1 addition & 9 deletions packages/renderer/src/lib/node/NodesList.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -81,15 +81,7 @@ let kernelVersionColumn = new TableColumn<NodeUI, string>('Kernel', {
comparator: (a, b) => a.kernelVersion.localeCompare(b.kernelVersion),
});
const columns: TableColumn<NodeUI, NodeUI | string | Date | undefined>[] = [
statusColumn,
nameColumn,
rolesColumn,
versionColumn,
osImageColumn,
kernelVersionColumn,
ageColumn,
];
const columns = [statusColumn, nameColumn, rolesColumn, versionColumn, osImageColumn, kernelVersionColumn, ageColumn];
const row = new TableRow<NodeUI>({});
</script>
Expand Down
2 changes: 1 addition & 1 deletion packages/renderer/src/lib/pod/PodsList.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ let ageColumn = new TableColumn<PodInfoUI>('Age', {
comparator: (a, b) => moment().diff(a.created) - moment().diff(b.created),
});
const columns: TableColumn<PodInfoUI>[] = [
const columns = [
statusColumn,
nameColumn,
envColumn,
Expand Down
2 changes: 1 addition & 1 deletion packages/renderer/src/lib/service/ServicesList.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ let ageColumn = new TableColumn<ServiceUI, Date | undefined>('Age', {
comparator: (a, b) => moment(b.created).diff(moment(a.created)),
});
const columns: TableColumn<ServiceUI, ServiceUI | string | Date | undefined>[] = [
const columns = [
statusColumn,
nameColumn,
namespaceColumn,
Expand Down
2 changes: 1 addition & 1 deletion packages/renderer/src/lib/volume/VolumesList.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ let sizeColumn = new TableColumn<VolumeInfoUI, string>('Size', {
initialOrder: 'descending',
});
const columns: TableColumn<VolumeInfoUI, VolumeInfoUI | string>[] = [
const columns = [
statusColumn,
nameColumn,
envColumn,
Expand Down
5 changes: 3 additions & 2 deletions packages/ui/src/lib/table/table.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@
* SPDX-License-Identifier: Apache-2.0
***********************************************************************/

import type { ComponentType, SvelteComponent } from 'svelte';

/**
* Options to be used when creating a Column.
*/
Expand Down Expand Up @@ -47,8 +49,7 @@ export interface ColumnInformation<Type, RenderType = Type> {
* The component must have a property 'object' that has the
* same type as the Column.
*/
// eslint-disable-next-line @typescript-eslint/no-explicit-any
readonly renderer?: any;
readonly renderer?: ComponentType<SvelteComponent<{ object: RenderType }>>;

/**
* Set a comparator used to sort the data by the values in this column.
Expand Down

0 comments on commit fc042fe

Please sign in to comment.