2

I am looking for a type def that can flatten a type like this:

interface Model {
    name: string;
    address: {
        zipcode: string;
        street: string;
    };
    foo: {
        boo: {
            bar: number;
        }
    }
}

type FlatModel = Flatten<Model>
// ideally FlatModel should now look like this to the compiler
// {
//     name: string;
//     "address.zipcode": string;
//     "address.street": string;
//     "foo.boo.bar": number;
// }

Basically converting a nested type/interface into a single layer/level type.

0 Answers0