mirror of
https://github.com/carbon-design-system/carbon-components-svelte.git
synced 2025-09-15 02:11:05 +00:00
feat(data-table): support generics (#1954)
Co-authored-by: K.Kiyokawa <koichi20110068@gmail.com> Co-authored-by: brunnerh <brunnerh@users.noreply.github.com>
This commit is contained in:
parent
752c46b94c
commit
dd43224119
13 changed files with 278 additions and 132 deletions
18
types/DataTable/DataTableTypes.d.ts
vendored
Normal file
18
types/DataTable/DataTableTypes.d.ts
vendored
Normal file
|
@ -0,0 +1,18 @@
|
|||
type PathDepth = [never, 0, 1, 2, ...0[]];
|
||||
|
||||
type Join<K, P> = K extends string | number
|
||||
? P extends string | number
|
||||
? `${K}${"" extends P ? "" : "."}${P}`
|
||||
: never
|
||||
: never;
|
||||
|
||||
// For performance, the maximum traversal depth is 10.
|
||||
export type PropertyPath<T, D extends number = 10> = [D] extends [never]
|
||||
? never
|
||||
: T extends object
|
||||
? {
|
||||
[K in keyof T]-?: K extends string | number
|
||||
? `${K}` | Join<K, PropertyPath<T[K], PathDepth[D]>>
|
||||
: never;
|
||||
}[keyof T]
|
||||
: "";
|
Loading…
Add table
Add a link
Reference in a new issue