Closed
Description
π Search Terms
- asserts
- assertion function
- type guard
- record
π Version & Regression Information
Worked on 4.9, broken since 5.0
Probably introduced by #52984
β― Playground Link
Playground link with relevant code
π» Code
declare function isObject(o: unknown): o is Record<string, any>
declare function assertObject(o: unknown): asserts o is Record<string, any>
let value: {} = null!;
if(isObject(value)) {
value.anything // error since 5.0.2
}
assertObject(value)
value.anything // error since 5.0.2
π Actual behavior
Property 'anything' does not exist on type '{}'.(2339)
π Expected behavior
No error, narrowing / assertion should work fine.