Skip to content

Type guard variables do not get narrowed within class bodies #5619

Description

For example:

let x: string | number;

if (typeof x === "string") {

    let n = class {
        constructor() {
            x; // Should be "string" but is "string | number".
        }
    }
}

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugA bug in TypeScriptFixedA PR has been merged for this issue

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions