> by explicitly annotating `promisedString` you are widening the type from the inferred `number` to `any`
That's something I don't understand. Isn't that incorrect behaviour? Shouldn't TS try unify RHS and LHS?
That's something I don't understand. Isn't that incorrect behaviour? Shouldn't TS try unify RHS and LHS?
In this case in Typescript it is generally more strict to add a type annotation to the generic than the LHS:
let promise = new Promise<string>((resolve) => resolve(42)) // This won't work
This is as much because the inference here that matters isn't between LHS and RHS but between generic arguments and function return inference.