Closed
Description
Typescript no longer preventing assignation of unknown to {} without strictNullChecks
TypeScript Version: from 3.5.3 to 3.7.5
Work as expect from 3.0.3 to 3.4.5
Search Terms: unknown assignable {} empty type
Code
let a: unknown;
const b: {} = a;
const c: object = a;
Expected behavior:
let a: unknown;
const b: {} = a;// Type 'unknown' is not assignable to type '{}'.
const c: object = a;// Type 'unknown' is not assignable to type 'object'
Actual behavior:
let a: unknown;
const b: {} = a;// No error for this line
const c: object = a;// Type 'unknown' is not assignable to type 'object'
Playground Link:
3.3.3 strictNullChecks=true Error as expected
3.3.3 strictNullChecks=false Error as expected
3.7.5 strictNullChecks=true Error as expected
3.7.5 strictNullChecks=false Missing error
Related Issues:
#26796