-
Notifications
You must be signed in to change notification settings - Fork 12.9k
Closed
Labels
BugA bug in TypeScriptA bug in TypeScriptFix AvailableA PR has been opened for this issueA PR has been opened for this issueRecent RegressionThis is a new regression just found in the last major/minor version of TypeScript.This is a new regression just found in the last major/minor version of TypeScript.
Milestone
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.
Metadata
Metadata
Assignees
Labels
BugA bug in TypeScriptA bug in TypeScriptFix AvailableA PR has been opened for this issueA PR has been opened for this issueRecent RegressionThis is a new regression just found in the last major/minor version of TypeScript.This is a new regression just found in the last major/minor version of TypeScript.