You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
If strictNullChecks is off, {} is implicitly {} | null | undefined, which encompasses the same set of values as unknown. I'm not totally clear on why that should change.
If strictNullChecks is off, {} is implicitly {} | null | undefined, which encompasses the same set of values as unknown. I'm not totally clear on why that should change.
Does it ?
3.0 change-log specifically state :
// unknown assignable only to itself and any
let v6: {} = x; // Error
let v7: {} | null | undefined = x; // Error
There is nothing specifying that it's only true with strictNullChecks (and no other change-log between 3.0 and 3.7 defines this change in expected behavior)
@RyanCavanaugh It is not working as intended. There has been an undocumented change in behaviour between 3.3 and 3.4. Even if it was intended (or a desirable accident) and it doesn't need fixing, it need to be documented.
The 3.0 changlog clearly state that this assignation should not be permitted and I can't find any indication that it should have changed.
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
Expected behavior:
Actual behavior:
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
The text was updated successfully, but these errors were encountered: