Skip to content

Commit

Permalink
fix types
Browse files Browse the repository at this point in the history
  • Loading branch information
riccardoperra committed Nov 24, 2024
1 parent ad4d96f commit 6cebaa7
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 10 deletions.
4 changes: 0 additions & 4 deletions examples/angular/grouping/src/app/app.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,13 +56,9 @@ export class AppComponent {
rowExpandingFeature,
},
_rowModels: {
// @ts-expect-error Fix type
groupedRowModel: createGroupedRowModel(),
// @ts-expect-error Fix type
expandedRowModel: createExpandedRowModel(),
// @ts-expect-error Fix type
paginatedRowModel: createPaginatedRowModel(),
// @ts-expect-error Fix type
filteredRowModel: createFilteredRowModel(),
},
onGroupingChange: (updaterOrValue: Updater<GroupingState>) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,9 +108,7 @@ export class AppComponent {
columnVisibilityFeature,
},
_rowModels: {
// @ts-expect-error Fix type
filteredRowModel: createFilteredRowModel(),
// @ts-expect-error Fix type
paginatedRowModel: createPaginatedRowModel(),
},
columns: this.columns,
Expand Down
10 changes: 8 additions & 2 deletions packages/angular-table/src/createTableHelper.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { constructTableHelper } from './createTableHelperCore'
import { Signal } from '@angular/core'
import { constructTableHelper } from './constructTableHelper'
import { injectTable } from './injectTable'
import type {
RowData,
Expand Down Expand Up @@ -27,7 +28,12 @@ export function createTableHelper<
>(
tableHelperOptions: TableHelperOptions<TFeatures, TData>,
): TableHelper<TFeatures, TData> {
const tableHelper = constructTableHelper(injectTable, tableHelperOptions)
const tableHelper = constructTableHelper(
injectTable as unknown as (
tableOptions: () => TableOptions<TFeatures, TData>,
) => Table<TFeatures, TData> & Signal<Table<TFeatures, TData>>,
tableHelperOptions,
)
return {
...tableHelper,
injectTable: tableHelper.tableCreator,
Expand Down
14 changes: 12 additions & 2 deletions packages/angular-table/src/injectTable.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import { lazyInit } from './lazy-signal-initializer'
import { proxifyTable } from './proxy'
import { reactivityFeature } from './reactivity'
import type {
CreateRowModels_All,
RowData,
Table,
TableFeatures,
Expand All @@ -17,11 +18,20 @@ import type {
} from '@tanstack/table-core'
import type { Signal } from '@angular/core'

export type AngularTableOptions<
TFeatures extends TableFeatures,
TData extends RowData,
> = Omit<TableOptions<TFeatures, TData>, '_rowModels'> & {
_rowModels: CreateRowModels_All<TFeatures, TData>
// TODO: no exported
// _rowModelsFns: RowModelFns<TFeatures, TData>
}

export function injectTable<
TFeatures extends TableFeatures,
TData extends RowData,
>(
options: () => TableOptions<TFeatures, TData>,
options: () => AngularTableOptions<TFeatures, TData>,
): Table<TFeatures, TData> & Signal<Table<TFeatures, TData>> {
return lazyInit(() => {
const features = () => {
Expand All @@ -41,7 +51,7 @@ export function injectTable<
...options(),
_features: features(),
state: { ...state(), ...options().state },
}
} as TableOptions<TFeatures, TData>

const table = constructTable(resolvedOptions)

Expand Down

0 comments on commit 6cebaa7

Please sign in to comment.