Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Extraneous control flow error #37480

Closed
sandersn opened this issue Mar 19, 2020 · 1 comment · Fixed by #37965
Closed

Extraneous control flow error #37480

sandersn opened this issue Mar 19, 2020 · 1 comment · Fixed by #37965
Assignees
Labels
Bug A bug in TypeScript Fix Available A PR has been opened for this issue

Comments

@sandersn
Copy link
Member

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.

@sandersn sandersn added the Bug A bug in TypeScript label Mar 19, 2020
@sandersn sandersn added this to the TypeScript 3.9.0 milestone Mar 19, 2020
@sandersn
Copy link
Member Author

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug A bug in TypeScript Fix Available A PR has been opened for this issue
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants