Skip to content
Closed
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
14 changes: 2 additions & 12 deletions tsc/internal/checker/checker.go
Original file line number Diff line number Diff line change
Expand Up @@ -7605,21 +7605,15 @@ func (c *Checker) checkExpressionCached(node *ast.Node) *Type {
}

func (c *Checker) checkExpressionCachedEx(node *ast.Node, checkMode CheckMode) *Type {
if checkMode != CheckModeNormal {
if checkMode != CheckModeNormal || len(c.flowLoopStack) != 0 {
return c.checkExpressionEx(node, checkMode)
}
links := c.typeNodeLinks.Get(node)
if links.resolvedType == nil {
// When computing a type that we're going to cache, we need to ignore any ongoing control flow
// analysis because variables may have transient types in indeterminable states. Moving flowLoopStart
// to the top of the stack ensures all transient types are computed from a known point.
saveFlowLoopStack := c.flowLoopStack
saveFlowTypeCache := c.flowTypeCache
c.flowLoopStack = nil
c.flowTypeCache = nil
links.resolvedType = c.checkExpressionEx(node, checkMode)
c.flowTypeCache = saveFlowTypeCache
c.flowLoopStack = saveFlowLoopStack
}
return links.resolvedType
}
Expand Down Expand Up @@ -30224,11 +30218,7 @@ func (c *Checker) getEffectiveCallArguments(node *ast.Node) []*ast.Node {
var spreadType *Type
// We can call checkExpressionCached because spread expressions never have a contextual type.
if ast.IsSpreadElement(arg) {
if len(c.flowLoopStack) != 0 {
spreadType = c.checkExpression(arg.Expression())
} else {
spreadType = c.checkExpressionCached(arg.Expression())
}
spreadType = c.checkExpressionCached(arg.Expression())
}
if spreadType != nil && isTupleType(spreadType) {
for i, t := range c.getElementTypes(spreadType) {
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -26,24 +26,24 @@ function IterateNodes(data: { node: Node }) {
>node : Node | undefined

const { children, index = -1 } = node;
>children : any
>index : any
>children : readonly Node[] | undefined
>index : number
>-1 : -1
>1 : 1
>node : Node

const activeNode: Node | undefined = index != -1 && children ? children[index] : undefined;
>activeNode : Node | undefined
>index != -1 && children ? children[index] : undefined : any
>index != -1 && children : any
>index != -1 && children ? children[index] : undefined : Node | undefined
>index != -1 && children : false | readonly Node[] | undefined
>index != -1 : boolean
>index : any
>index : number
>-1 : -1
>1 : 1
>children : any
>children[index] : any
>children : any
>index : any
>children : readonly Node[] | undefined
>children[index] : Node
>children : readonly Node[]
>index : number
>undefined : undefined

node = activeNode;
Expand Down Expand Up @@ -71,20 +71,20 @@ function f(init: MyNode) {
>init : MyNode

while (node) {
>node : MyNode | undefined
>node : MyNode

const { children, index = 0 } = node;
>children : any
>index : any
>children : MyNode[]
>index : number
>0 : 0
>node : MyNode

node = children[index];
>node = children[index] : any
>node = children[index] : MyNode
>node : MyNode | undefined
>children[index] : any
>children : any
>index : any
>children[index] : MyNode
>children : MyNode[]
>index : number
}
}