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
{{ message }}
Repository navigation
Assertion function & Type guards for Record types broken on 5.0 Β #53379
BugA bug in TypeScriptFix AvailableA PR has been opened for this issueRecent RegressionThis is a new regression just found in the last major/minor version of TypeScript.
declarefunctionisObject(o: unknown): o is Record<string,any>declarefunctionassertObject(o: unknown): asserts o is Record<string,any>letvalue: {}=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)
Hmm, looks like the strict subtype relation considers {} and Record<string, any> to be mutual subtypes. That's an oversight and apparently we don't have test coverage for that combination. It should be the case that {} is a strict supertype of Record<string, any>, similar to {} being a strict supertype of Record<string, unknown> (for which we do have test coverage).
BugA bug in TypeScriptFix AvailableA PR has been opened for this issueRecent RegressionThis is a new regression just found in the last major/minor version of TypeScript.
Activity
ahejlsberg commentedon Mar 20, 2023
Hmm, looks like the strict subtype relation considers
{}andRecord<string, any>to be mutual subtypes. That's an oversight and apparently we don't have test coverage for that combination. It should be the case that{}is a strict supertype ofRecord<string, any>, similar to{}being a strict supertype ofRecord<string, unknown>(for which we do have test coverage).