Skip to content

Commit

Permalink
NAS-130854: fixed type check
Browse files Browse the repository at this point in the history
  • Loading branch information
RehanY147 committed Sep 12, 2024
1 parent 8b4c312 commit c50c49a
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 11 deletions.
8 changes: 2 additions & 6 deletions src/app/modules/ix-table/directives/ix-body-cell.directive.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import {
ViewContainerRef,
} from '@angular/core';
import { IxCellTextComponent } from 'app/modules/ix-table/components/ix-table-body/cells/ix-cell-text/ix-cell-text.component';
import { Column, ColumnComponent } from 'app/modules/ix-table/interfaces/column-component.class';
import { Column, ColumnComponent, ColumnKeys } from 'app/modules/ix-table/interfaces/column-component.class';

@Directive({
selector: '[ix-body-cell]',
Expand Down Expand Up @@ -48,11 +48,7 @@ export class IxTableBodyCellDirective<T> implements AfterViewInit, OnChanges {

private setComponentProps(): void {
this.componentRef.instance.setRow(this.row);
Object.keys(this.column).forEach((key: keyof ColumnComponent<T>) => {
if (key === 'value') {
return;
}
// TODO: Replace never.
Object.keys(this.column).forEach((key: ColumnKeys<T>) => {
this.componentRef.instance[key] = this.column[key] as never;
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import {
ViewContainerRef,
} from '@angular/core';
import { IxHeaderCellTextComponent } from 'app/modules/ix-table/components/ix-table-head/head-cells/ix-header-cell-text/ix-header-cell-text.component';
import { Column, ColumnComponent } from 'app/modules/ix-table/interfaces/column-component.class';
import { Column, ColumnComponent, ColumnKeys } from 'app/modules/ix-table/interfaces/column-component.class';
import { DataProvider } from 'app/modules/ix-table/interfaces/data-provider.interface';

@Directive({
Expand All @@ -31,10 +31,7 @@ export class IxTableHeaderCellDirective<T> implements AfterViewInit {
);

componentRef.instance.dataProvider = this.dataProvider;
Object.keys(this.column).forEach((key: keyof ColumnComponent<T>) => {
if (key === 'value') {
return;
}
Object.keys(this.column).forEach((key: ColumnKeys<T>) => {
// TODO: replace never
componentRef.instance[key] = this.column[key] as never;
});
Expand Down
3 changes: 3 additions & 0 deletions src/app/modules/ix-table/interfaces/column-component.class.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { signal, WritableSignal } from '@angular/core';
import { MutableKeys } from 'utility-types';
import { DataProvider } from 'app/modules/ix-table/interfaces/data-provider.interface';

export abstract class ColumnComponent<T> {
Expand Down Expand Up @@ -35,3 +36,5 @@ export type Column<T, C extends ColumnComponent<T>> = {
type?: new () => C;
headerType?: new () => C;
} & Partial<C>;

export type ColumnKeys<T> = MutableKeys<ColumnComponent<T>>;

0 comments on commit c50c49a

Please sign in to comment.