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

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions