Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion internal/checker/checker.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Original file line number Diff line number Diff line change
Expand Up @@ -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;
};
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
foobar.foo;