Created
November 7, 2020 06:00
-
-
Save voratham/03e1019a7aa29463e0e6f4a3ada5d993 to your computer and use it in GitHub Desktop.
typescript-generic-exmaple.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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