type Test = { a: string; b: boolean; c: number }
type Key = keyof Test;
function foo(x: Key): Partial<Test> {
return {[x]: null};
}
For the above code, foo
returns a Partial
of Test
, and the key of the return object is bound to Key
, 'a' | 'b' | 'c'
. However, even though the argument is the key of the Test
, the null
value is assignable for the Partial<Test>
.
Is it intended behaviour for TypeScript?