Closed as not planned
Description
Hello,
I have the following piece of code that allows me to produce an invalid partial object:
type A = { a: number; b: string };
const buildPartial = (key: keyof A, val: A[keyof A]): Partial<A> => ({ [key]: val });
const test = buildPartial('a', 'hello'); // allows me to build an invalid object without compile error
Shouldn't I have a compile error? { [key]: val }
seems to of type { a: number | string } | { b: number | string }
which is not compatible with Partial
Thanks
ps: I understand I should have written const buildPartial = <K extends keyof A>(key: K, val: A[K]) => ...
My question is not on this, it is on why this was not caught by the compiler