Skip to content

Extraneous control flow error #37480

Description

From vscode: src/vs/workbench/contrib/search/common/searchModel.ts

Code

interface F {
    d(): void
}
export function doRemove(dds: F | F[]) {
    if (!Array.isArray(dds)) {
        dds = [dds]
    }
    for (let n of dds) {
        n.d()
    }
    return dds
}

Expected behavior:

No error, and n: F at all locations, and dds: F[] at all locations.

Actual behavior:

Types are correct; bogus error: 'F | F[]' must have a 'Symbol.iterator' method that returns an iterator.

Looks like narrowing works as expected, except for errors.

Activity

  1. sandersn commented on Mar 19, 2020

    @sandersn
    MemberAuthor

    For future bisecting: Doesn't repro on a commit from March 2: dd6811f

  2. locked as resolved and limited conversation to collaborators on Oct 21, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

BugA bug in TypeScriptFix AvailableA PR has been opened for this issue

Type

No type

Projects

No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions