@madeja-studio/telar
Version:
UI component library by Madeja Studio
23 lines • 977 B
TypeScript
import type { Primitive } from 'type-fest';
/**
* Recursively traverses the provided type and turns all its function types
* into their return value.
*
* This is useful to turn an undefined Theme type (with all its colors and dimensions)
* and turn them all into specific values that have been resolved.
*/
export type ToResolved<T> = {
[K in keyof T]: T[K] extends (...props: any[]) => infer R ? R : ToResolved<T[K]>;
};
/**
* Recursively traverses the provided type and turns all its primitive
* values into either the value or a function that given a value of type TProps
* return a value of the same type.
*
* This is useful to turn a defined Theme type (with all its colors and dimensions)
* and turn them all into deferred values that will resolve in a later take.
*/
export type ToUnresolved<T, TProps> = {
[K in keyof T]: T[K] extends Primitive ? ((props: TProps) => T[K]) | T[K] : ToUnresolved<T[K], TProps>;
};
//# sourceMappingURL=types.d.ts.map