Skip to content

Instantly share code, notes, and snippets.

@voratham
Created November 7, 2020 06:00
Show Gist options
  • Select an option

  • Save voratham/03e1019a7aa29463e0e6f4a3ada5d993 to your computer and use it in GitHub Desktop.

Select an option

Save voratham/03e1019a7aa29463e0e6f4a3ada5d993 to your computer and use it in GitHub Desktop.
typescript-generic-exmaple.ts
interface UseTableRowProps<D extends object> {
cells: Array<Cell<D>>
}
interface ColumnInstance<D extends object = {}> {
width: string,
height: string
}
interface Row<D extends object = {}> extends UseTableRowProps<D> { }
export interface UseTableCellProps<D extends object, V = any> {
column: ColumnInstance<D>;
row: Row<D>;
}
export interface Cell<D extends object = {}, V = any> extends UseTableCellProps<D, V> { }
const a: Cell<{ width: string, height: string }> = {
column: {
width: "1",
height: "1"
},
row: {
cells: [
{
column: {
width: "1",
height: "1"
},
row: {
cells: [
]
}
}
]
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment