Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions table/src/-private/-type-tests/public-option-types.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import { expectTypeOf } from 'expect-type';

import type { CellContext, CellOptions, CellOptionsOf } from '../../index.ts';

interface Person {
name: string;
}

// An app writing an `options` callback names what it must return.
const options = (_context: CellContext<Person>): CellOptions => ({
defaultValue: '--',
unit: 'years',
});

expectTypeOf(options).returns.toEqualTypeOf<CellOptions>();

// And code that takes what `getOptionsForRow` gives a Cell names that.
interface UnitCellArgs {
options: { unit: string };
}

expectTypeOf<CellOptionsOf<UnitCellArgs>>().toEqualTypeOf<{ unit: string }>();
2 changes: 2 additions & 0 deletions table/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,10 @@ export { deserializeSorts, serializeSorts } from './utils.ts';
* Public Types
*******************************/
export type { Column } from './-private/column.ts';
export type { CellOptionsOf } from './-private/meta.ts';
export type {
CellContext,
CellOptions,
ColumnConfig,
ColumnKey,
HeadlessTableConfig,
Expand Down