Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Instanceof in type guards should not narrow any #1426

Copy link
Copy link
@JsonFreeman

Description

@JsonFreeman
Issue body actions

Usually narrowing a type causes us to have access to more properties. Not so if the original type was any. In this case, narrowing actually causes us to lose properties. So we should not get an error in the following case:

var x: any = { p: 0 };
if (x instanceof Object) {
    x.p; // Error that p does not exist on Object
}
Reactions are currently unavailable

Metadata

Metadata

Assignees

Labels

Breaking ChangeWould introduce errors in existing codeWould introduce errors in existing codeBugA bug in TypeScriptA bug in TypeScriptFixedA PR has been merged for this issueA PR has been merged for this issueSpecIssues related to the TypeScript language specificationIssues related to the TypeScript language specification

Type

No type
No fields configured for issues without a type.

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions

    Morty Proxy This is a proxified and sanitized view of the page, visit original site.