TypeScript Types
Our
TypeScript types are published as part of the package, as named exports from the root of the package.The 2 main components that you can need to use and import are:
InfiniteTableDataSource
import { InfiniteTable, DataSource } from '@infinite-table/infinite-vue';The Vue components are not generic: the types of their props are. Bind those types to the type of the data you are rendering, in
<script setup>, where you define the values you pass as props - that is where TypeScript checks them.Throughout the documentation, we will use the
DATA_TYPE placeholder to refer to the type of the data that those types are bound to.You can still use
InfiniteTable in plain JavaScript, but you won't get all the type-checking benefits.Both
InfiniteTable and DataSource components have types provided for most of the props they support. Generally the naming pattern is <COMPONENT_NAME>Prop<PROP_NAME>, so here are a few examples to clarify the rule:DataSource Types
Here are a few examples for types for the
DataSource component:DataSourcePropGroupBy<DATA_TYPE>- the type forDataSource.groupBy
DataSourcePropAggregationReducers<DATA_TYPE>- the type forDataSource.aggregationReducers
Not all the
DataSource props have types exported that follow this convention, so you can always use DataSourceProps<DATA_TYPE> to get the type that define all the props.In this way you can access specific prop types by name
DataSourceProps<DATA_TYPE>['groupBy']- the type forDataSource.groupByDataSourceProps<DATA_TYPE>['data']- the type forDataSource.data- etc
InfiniteTable Types
Below you can find a few examples for types for the
InfiniteTable component:InfiniteTablePropColumns<DATA_TYPE>- the type forInfiniteTable.columns
InfiniteTablePropRowStyle<DATA_TYPE>- the type forInfiniteTable.rowStyle
InfiniteTablePropColumnGroups<DATA_TYPE>- the type forInfiniteTable.columnGroups
Not all the
InfiniteTable props have types exported that follow this convention, so you can always use InfiniteTableProps<DATA_TYPE> to get the type that define all the props the InfiniteTable component supports.In this way you can access specific prop types by name:
InfiniteTableProps<DATA_TYPE>['columns']- the type forInfiniteTable.columnsInfiniteTableProps<DATA_TYPE>['columnSizing']- the type forInfiniteTable.columnSizing- etc
Worth mentioning is the
InfiniteTableColumn<DATA_TYPE> prop, which defines the type for the table columns.