Union type as key in interface?

You can use an object type instead of an interface, which are mostly interchangeable:

type IMargin = {
    [key in 'foo' | 'bar']: boolean;
}

Leave a Comment