This file contains 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
type Primitive = string | number | boolean | bigint | symbol | undefined | null; | |
type PathImpl<T, K extends keyof T> = K extends string | |
? // eslint-disable-next-line @typescript-eslint/ban-types | |
T[K] extends Function // Check if it's a function | |
? never // Exclude functions | |
: T[K] extends Primitive // Check if it's a primitive value | |
? K // Include primitives directly | |
: T[K] extends Record<string, any> // Check if it's an object to traverse | |
? T[K] extends ArrayLike<any> |
This file contains 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
// Type definitions | |
type Split<S extends string, D extends string> = string extends S | |
? string[] | |
: S extends '' | |
? [] | |
: S extends `${infer T}${D}${infer U}` | |
? [T, ...Split<U, D>] | |
: [S]; |