Can you create a mapped type based on the property type? For example, if I want to map all properties with type String
to Foo
and all other types to Bar
. Can this be done like this:
type MappedType<T> = {
[P in keyof T]: T[P] === String ? Foo : Bar
}
Is there a syntax to achieve this?