Skip to content

[TypeScript] Can't infer type from switch and conditions #62042

Open
@CrazyboyQCD

Description

@CrazyboyQCD

Consider code like this, lsp can't infer that a and b are any[] while the if can:

function equal(a: object, b: object) {
    switch ([true, true]) {
        case [Array.isArray(a), Array.isArray(b)]: {
            if (a.length !== b.length) {
                return false;
            }
            // ...
            return true;
        }
        // ...
        default: return false;
    }
}

Metadata

Metadata

Assignees

Labels

DeclinedThe issue was declined as something which matches the TypeScript visionSuggestionAn idea for TypeScript

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions