I have the following typescript code:
const a = [{ foo: 1 }, { bar: '2' }]
I wish to use a to create an object of the form:
const b = {
foo: 1,
bar: '2'
}
and the typing of b should be equivalent to the type:
type EquivalentType = {
foo: number
bar: string
}
Is this possible without casting? How can this be done?