diff --git a/internal/checker/checker.go b/internal/checker/checker.go index a6b3a684c5..54d6c19590 100644 --- a/internal/checker/checker.go +++ b/internal/checker/checker.go @@ -19746,7 +19746,7 @@ func (c *Checker) checkIfExpressionRefinesParameter(fn *ast.Node, expr *ast.Node // "x is T" means that x is T if and only if it returns true. If it returns false then x is not T. // This means that if the function is called with an argument of type trueType, there can't be anything left in the `else` branch. It must reduce to `never`. falseCondition := &ast.FlowNode{Flags: ast.FlowFlagsFalseCondition, Node: expr, Antecedent: antecedent} - falseSubtype := c.getFlowTypeOfReferenceEx(param.Name(), initType, trueType, fn, falseCondition) + falseSubtype := c.getReducedType(c.getFlowTypeOfReferenceEx(param.Name(), initType, trueType, fn, falseCondition)) if falseSubtype.flags&TypeFlagsNever != 0 { return trueType } diff --git a/testdata/baselines/reference/submodule/compiler/inferTypePredicates.js b/testdata/baselines/reference/submodule/compiler/inferTypePredicates.js index 36a1e674b9..b2935a4b55 100644 --- a/testdata/baselines/reference/submodule/compiler/inferTypePredicates.js +++ b/testdata/baselines/reference/submodule/compiler/inferTypePredicates.js @@ -648,4 +648,4 @@ type Rock = { type Something = Animal | Rock; declare function isAnimal(something: Something): something is Animal; declare function positive(t: Something): t is Animal; -declare function negative(t: Something): boolean; +declare function negative(t: Something): t is Rock; diff --git a/testdata/baselines/reference/submodule/compiler/inferTypePredicates.js.diff b/testdata/baselines/reference/submodule/compiler/inferTypePredicates.js.diff index dab9bddb64..e93a7ca535 100644 --- a/testdata/baselines/reference/submodule/compiler/inferTypePredicates.js.diff +++ b/testdata/baselines/reference/submodule/compiler/inferTypePredicates.js.diff @@ -58,10 +58,4 @@ +}) => fb is { type: "foo"; foo: number; - }; -@@= skipped -15, +21 lines =@@ - type Something = Animal | Rock; - declare function isAnimal(something: Something): something is Animal; - declare function positive(t: Something): t is Animal; --declare function negative(t: Something): t is Rock; -+declare function negative(t: Something): boolean; \ No newline at end of file + }; \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/inferTypePredicates.types b/testdata/baselines/reference/submodule/compiler/inferTypePredicates.types index f97f331b7e..f047f50381 100644 --- a/testdata/baselines/reference/submodule/compiler/inferTypePredicates.types +++ b/testdata/baselines/reference/submodule/compiler/inferTypePredicates.types @@ -1092,7 +1092,7 @@ function positive(t: Something) { } function negative(t: Something) { ->negative : (t: Something) => boolean +>negative : (t: Something) => t is Rock >t : Something return !isAnimal(t) diff --git a/testdata/baselines/reference/submodule/compiler/inferTypePredicates.types.diff b/testdata/baselines/reference/submodule/compiler/inferTypePredicates.types.diff index 2462f501fd..27e41e4855 100644 --- a/testdata/baselines/reference/submodule/compiler/inferTypePredicates.types.diff +++ b/testdata/baselines/reference/submodule/compiler/inferTypePredicates.types.diff @@ -141,13 +141,4 @@ +>foobarPred : (fb: { type: "foo"; foo: number; } | { type: "bar"; bar: string; }) => fb is { type: "foo"; foo: number; } >foobar : { type: "foo"; foo: number; } | { type: "bar"; bar: string; } - foobar.foo; -@@= skipped -88, +88 lines =@@ - } - - function negative(t: Something) { -->negative : (t: Something) => t is Rock -+>negative : (t: Something) => boolean - >t : Something - - return !isAnimal(t) \ No newline at end of file + foobar.foo; \ No newline at end of file