Skip to content

union types narrowed incorrectly by assertion functions and type predicate functions #43825

@DetachHead

Description

@DetachHead

Bug Report

🔎 Search Terms

union types narrowed incorrectly

🕗 Version & Regression Information

v4.3.0-dev.20210426

⏯ Playground Link

Playground link with relevant code

💻 Code

declare function assert<T>(value: any): asserts value is T

declare const foo: number | string | boolean

assert<1 | string>(foo)

const bar = foo //string

🙁 Actual behavior

foo is narrowed to string

🙂 Expected behavior

foo should be narrowed to 1 | string

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions