2

I have this type:

interface Intf1
{
    n: number;
    s: string;
    c: { x: number, y: string };
}

And I want to transform (may use generics, mapped types, etc) to one that I my use like this below. Rules is, non-object T changes to MyType and objects T transformed to T-like (with the same MyType rules appying to properties):

interface Intf2
{
    n: MyType<number>;
    s: MyType<string>;
    c: { x: MyType<number>, y: MyType<string> };
}

Is this possible?

  • Even though your question is in regard to an interface `MyType`, it's essentially the same question: how to apply a mapped type recursively. – rossipedia Dec 29 '16 at 06:32

0 Answers0