-
Notifications
You must be signed in to change notification settings - Fork 13k
Closed
Labels
BugA bug in TypeScriptA bug in TypeScriptFix AvailableA PR has been opened for this issueA PR has been opened for this issueHelp WantedYou can do thisYou can do this
Milestone
Description
Bug Report
π Version & Regression Information
ts stable & nightly
β― 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 TypeScriptA bug in TypeScriptFix AvailableA PR has been opened for this issueA PR has been opened for this issueHelp WantedYou can do thisYou can do this