TypeScript Version: 4.0.0-beta
Search Terms: index signature spread undefined computed
Code
declare const m: { [k: string]: string };
const x: { [k: string]: string } = { ...m, ["a" + "b"]: "" };
Expected behavior: No error (3.9.3)
Actual behavior: Error
a.ts:2:7 - error TS2322: Type '{ [x: string]: string | undefined; }' is not assignable to type '{ [k: string]: string; }'.
Index signatures are incompatible.
Type 'string | undefined' is not assignable to type 'string'.
Type 'undefined' is not assignable to type 'string'.
2 const x: { [k: string]: string } = { ...m, ["a" + "b"]: "" };
~
Playground Link: linky
Related Issues: no
Caught this in our CI earlier, was just about to enter an Issue, thanks!
Links to 3.9.2 and 4.0.0-beta.
Most helpful comment
Caught this in our CI earlier, was just about to enter an Issue, thanks!
Links to 3.9.2 and 4.0.0-beta.