There was an error while loading. Please reload this page.
unknown
TypeScript Version: 3.5.0-dev.20190410, (v3.4.3 doesn't have this bug)
3.5.0-dev.20190410
v3.4.3
Search Terms: enum, class, assignable, index signature
Code
enum Enum { A } const e0: { [key: string]: any } = Enum; // ok const e1: { [key: string]: unknown } = Enum; // produces an unexpected error report // const obj = { A: 0 }; const o0: { [key: string]: any } = obj; // ok const o1: { [key: string]: unknown } = obj; // ok // class Class {} export const cl0: { [key: string]: any } = new Class; // ok export const cl1: { [key: string]: unknown } = new Class; // produces an unexpected error report
Expected behavior: This code should compile with no errors.
Actual behavior: Error near the definition of e1 and cl1:
e1
cl1
Type 'typeof Enum/Class' is not assignable to type '{ [key: string]: unknown; }'. Index signature is missing in type 'typeof Enum/Class'.
Playground Link: This works well in the playground as it uses the stable version of tsc, but this bug appears in dev build. Klick me.
tsc
Related Issues: None.