Open
Description
TypeScript Version: 3.8.2
Search Terms:
- strictNullChecks
- object spread
- computed key
Code
const b = { a: 'hello' };
const key: string = 'hello';
const a: Record<string, string> = { ...b, [key]: undefined };
Expected behavior:
Type check fails
Actual behavior:
No Typecheck error.
It is interesting that if we remove explicit string
type for key
the code is not compilable as expected.