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
// custom type names | |
type CustomType = "type1" | "type2"; | |
// mapping from custom type names to TypeScript types | |
type TypeOf<T extends CustomType> = | |
T extends "type1" ? string | |
: T extends "type2" ? number | |
: never; | |
// generic Options type parametrized by custom types |
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
/** | |
* Generický typ pro cestu v objektu | |
*/ | |
type PathOf<Object extends object, Value> = { | |
[Property in keyof Object & string]: | |
Object[Property] extends Value | |
? `${Property}` | |
: Object[Property] extends object | |
? `${Property}.${PathOf<Object[Property], Value>}` | |
: never |