You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
interfaceFoo{foo: string;}interfaceBar{bar: string;}interfaceBaz{baz: string;}functionmyFunction(input: Foo|Bar|Baz){constisBaz='baz'ininput;constisBar=//'bar' in input; // This works to narrow `bar` when true and narrow `foo` in the else block!('foo'ininput)&&!isBaz;// This works to narrow `bar` when true but does not narrow `foo` in the else blockletx: string;if(isBaz){x=input.baz;}elseif(isBar){x=input.bar;}else{// In 4.8.4 and earlier, `input` is narrowed to `Foo`// In 4.9.5 and later, `input` is narrowed to `Foo | ((Foo | Bar) & Record<"baz", unknown>)`x=input.foo;}}
π Actual behavior
In 4.9.5 and later, in the else block, input.foo incorrectly narrows and errors
π Expected behavior
In 4.8.4 and earlier, in the else block, input.foo correctly narrows
Additional information about the issue
No response
The text was updated successfully, but these errors were encountered:
π Search Terms
"union type", "narrowing", "inverted", "4.9"
π Version & Regression Information
β― Playground Link
Playground link
π» Code
π Actual behavior
In 4.9.5 and later, in the else block,
input.foo
incorrectly narrows and errorsπ Expected behavior
In 4.8.4 and earlier, in the else block,
input.foo
correctly narrowsAdditional information about the issue
No response
The text was updated successfully, but these errors were encountered: