const foo : {[key:string]:string} = {'hello': 'world', 'hi': 'there'};
const bar : number = 42
const foobar = {...foo, bar}
console.log(foobar)
// { hello: 'world', hi: 'there', bar: 42 }
The type of foobar resolves to {bar: number}. Why is this? I would expect the type of foobar to be {[key:string]: string|number} or {[key:string]: string} & {bar: number}
EDIT: I'm particularly confused on why in some cases the types are determined correctly:
const foo : {a: number} = {a: 1}
const bar : string = "bar"
const foobar = {...foo, bar}
console.log(foobar)
// foobar is type {bar: string, a: number}
Why does this case work, and the first case doesn't?