Skip to content

How to create an object describing all the paths in an object #221

Answered by millsp
regevbr asked this question in Q&A
Discussion options

You must be logged in to vote
declare const d: unique symbol
interface Context {
    str: string;
    num: number;
    nested: {
        value: number;
        nested2: {
            value2: string;
        };
    };
}

type Keys<A> = S.Join<L.Required<O.Paths<A>>, '.'>

type Regev<A> = {
    [K in Keys<A>]: {
        propertyPath: K
        type: O.Path<A, S.Split<K, '.'>>
    }
}

type t = Regev<Context>

Replies: 1 comment 3 replies

Comment options

You must be logged in to vote
3 replies
@millsp
Comment options

@millsp
Comment options

@regevbr
Comment options

Answer selected by millsp
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants