Skip to content

Comma Operator breaks Assertion FunctionsΒ #44487

Closed
@pushkine

Description

@pushkine

Bug Report

πŸ•— Version & Regression Information

ts stable & nightly

⏯ Playground Link

Playground Link

πŸ’» Code

function Narrow<T>(value: any): asserts value is T {}

function test(foo: any, bar: any) {
    Narrow<number>(foo), Narrow<string>(bar);
    foo; // foo: number;
    bar; // bar: any;
}

πŸ™ Actual behavior

foo is asserted as number, bar is asserted as string.
The type of foo becomes number, but the type of bar is still any.

πŸ™‚ Expected behavior

Type of bar to be narrowed to string.

Metadata

Metadata

Assignees

Labels

BugA bug in TypeScriptFix AvailableA PR has been opened for this issueHelp WantedYou can do this

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions