From 9ca86e39dbe7f369a36fc70e8e58c9eed9723b17 Mon Sep 17 00:00:00 2001 From: Wesley Wigham Date: Thu, 10 Jul 2025 14:13:06 -0700 Subject: [PATCH] Port optional chain emit --- internal/ast/ast.go | 65 ++ internal/printer/factory.go | 8 + internal/printer/printer.go | 4 +- .../estransforms/optionalchain.go | 217 +++++- ...sertionFunctionsCanNarrowByDiscriminant.js | 2 +- ...onFunctionsCanNarrowByDiscriminant.js.diff | 6 +- .../invalidOptionalChainFromNewExpression.js | 5 +- ...alidOptionalChainFromNewExpression.js.diff | 14 - .../mappedTypeGenericIndexedAccess.js | 8 +- .../mappedTypeGenericIndexedAccess.js.diff | 18 +- .../compiler/narrowingTypeofDiscriminant.js | 8 +- .../narrowingTypeofDiscriminant.js.diff | 34 +- .../compiler/narrowingUnionWithBang.js | 3 +- .../compiler/narrowingUnionWithBang.js.diff | 19 - .../narrowingWithNonNullExpression.js | 2 +- .../narrowingWithNonNullExpression.js.diff | 2 +- .../compiler/nonNullableReduction.js | 4 +- .../compiler/nonNullableReduction.js.diff | 9 +- .../compiler/nonNullableReductionNonStrict.js | 4 +- .../nonNullableReductionNonStrict.js.diff | 9 +- .../submodule/compiler/nonNullableTypes1.js | 8 +- .../compiler/nonNullableTypes1.js.diff | 26 +- ...InstantiationExpression1(target=es2019).js | 4 +- ...ntiationExpression1(target=es2019).js.diff | 10 - ...InstantiationExpression2(target=es2019).js | 5 +- ...ntiationExpression2(target=es2019).js.diff | 11 +- .../propertyAccessExpressionInnerComments.js | 22 +- ...pertyAccessExpressionInnerComments.js.diff | 22 +- .../compiler/trackedSymbolsNoCrash.js | 2 +- .../compiler/trackedSymbolsNoCrash.js.diff | 11 +- .../submodule/compiler/typeParameterLeak.js | 3 +- .../compiler/typeParameterLeak.js.diff | 9 +- .../typePredicatesOptionalChaining1.js | 3 +- .../typePredicatesOptionalChaining1.js.diff | 11 +- .../typePredicatesOptionalChaining2.js | 4 +- .../typePredicatesOptionalChaining2.js.diff | 10 +- .../typePredicatesOptionalChaining3.js | 6 +- .../typePredicatesOptionalChaining3.js.diff | 18 +- .../compiler/unionOfArraysFilterCall.js | 2 +- .../compiler/unionOfArraysFilterCall.js.diff | 8 - .../compiler/useUnknownInCatchVariables01.js | 3 +- .../useUnknownInCatchVariables01.js.diff | 19 - .../submodule/conformance/callChain.2.js | 7 +- .../submodule/conformance/callChain.2.js.diff | 13 - .../submodule/conformance/callChain.3.js | 11 +- .../submodule/conformance/callChain.3.js.diff | 16 +- .../submodule/conformance/callChain.js | 57 +- .../submodule/conformance/callChain.js.diff | 61 +- .../conformance/callChainInference.js | 4 +- .../conformance/callChainInference.js.diff | 7 +- .../callChainWithSuper(target=es2016).js | 4 +- .../callChainWithSuper(target=es2016).js.diff | 9 +- .../callChainWithSuper(target=es2017).js | 4 +- .../callChainWithSuper(target=es2017).js.diff | 9 +- .../callChainWithSuper(target=es2018).js | 4 +- .../callChainWithSuper(target=es2018).js.diff | 9 +- .../callChainWithSuper(target=es2019).js | 4 +- .../callChainWithSuper(target=es2019).js.diff | 9 +- .../callChainWithSuper(target=es5).js | 4 +- .../callChainWithSuper(target=es5).js.diff | 9 +- .../callChainWithSuper(target=es6).js | 4 +- .../callChainWithSuper(target=es6).js.diff | 9 +- .../classExtendingOptionalChain.js | 2 +- .../classExtendingOptionalChain.js.diff | 11 - .../conformance/controlFlowOptionalChain.js | 233 +++--- .../controlFlowOptionalChain.js.diff | 679 +----------------- .../conformance/controlFlowOptionalChain2.js | 24 +- .../controlFlowOptionalChain2.js.diff | 94 --- .../submodule/conformance/deleteChain.js | 27 +- .../submodule/conformance/deleteChain.js.diff | 30 +- .../conformance/elementAccessChain.2.js | 11 +- .../conformance/elementAccessChain.2.js.diff | 17 - .../conformance/elementAccessChain.3.js | 44 +- .../conformance/elementAccessChain.3.js.diff | 68 +- .../conformance/elementAccessChain.js | 33 +- .../conformance/elementAccessChain.js.diff | 37 +- .../exhaustiveSwitchStatements1.js | 2 +- .../exhaustiveSwitchStatements1.js.diff | 11 +- .../instantiationExpressionErrors.js | 13 +- .../instantiationExpressionErrors.js.diff | 17 +- .../logicalAssignment8(target=es2015).js | 6 +- .../logicalAssignment8(target=es2015).js.diff | 14 +- .../noPropertyAccessFromIndexSignature1.js | 8 +- ...oPropertyAccessFromIndexSignature1.js.diff | 15 - .../nullishCoalescingOperator12.js | 2 +- .../nullishCoalescingOperator12.js.diff | 3 +- .../conformance/optionalChainingInArrow.js | 2 +- .../optionalChainingInArrow.js.diff | 8 - .../conformance/optionalChainingInLoop.js | 3 +- .../optionalChainingInLoop.js.diff | 16 - ...nParameterBindingPattern(target=es2015).js | 2 +- ...meterBindingPattern(target=es2015).js.diff | 8 - ...ngInParameterBindingPattern(target=es5).js | 2 +- ...arameterBindingPattern(target=es5).js.diff | 2 +- ...ngInParameterInitializer(target=es2015).js | 2 +- ...arameterInitializer(target=es2015).js.diff | 8 - ...iningInParameterInitializer(target=es5).js | 2 +- ...InParameterInitializer(target=es5).js.diff | 2 +- ...ChainingInTypeAssertions(target=es2015).js | 17 +- ...ingInTypeAssertions(target=es2015).js.diff | 27 +- .../conformance/optionalChainingInference.js | 16 +- .../optionalChainingInference.js.diff | 30 - .../submodule/conformance/parentheses.js | 7 +- .../submodule/conformance/parentheses.js.diff | 14 - .../privateNameFieldCallExpression.js | 3 +- .../privateNameFieldCallExpression.js.diff | 4 +- .../privateNameStaticFieldCallExpression.js | 3 +- ...ivateNameStaticFieldCallExpression.js.diff | 3 +- .../conformance/propertyAccessChain.2.js | 7 +- .../conformance/propertyAccessChain.2.js.diff | 13 - .../conformance/propertyAccessChain.3.js | 44 +- .../conformance/propertyAccessChain.3.js.diff | 68 +- .../conformance/propertyAccessChain.js | 19 +- .../conformance/propertyAccessChain.js.diff | 24 +- .../submodule/conformance/superMethodCall.js | 6 +- .../conformance/superMethodCall.js.diff | 11 +- ...AndSuperInStaticMembers1(target=es2015).js | 4 +- ...perInStaticMembers1(target=es2015).js.diff | 4 +- ...AndSuperInStaticMembers2(target=es2015).js | 4 +- ...perInStaticMembers2(target=es2015).js.diff | 4 +- .../thisAndSuperInStaticMembers3.js | 4 +- .../thisAndSuperInStaticMembers3.js.diff | 4 +- .../thisAndSuperInStaticMembers4.js | 4 +- .../thisAndSuperInStaticMembers4.js.diff | 4 +- .../submodule/conformance/thisMethodCall.js | 3 +- .../conformance/thisMethodCall.js.diff | 7 +- .../conformance/thisTypeOptionalCall.js | 2 +- .../conformance/thisTypeOptionalCall.js.diff | 9 - ...nstanceMemberNarrowedWithLoopAntecedent.js | 3 +- ...ceMemberNarrowedWithLoopAntecedent.js.diff | 12 +- 130 files changed, 841 insertions(+), 1913 deletions(-) delete mode 100644 testdata/baselines/reference/submodule/compiler/invalidOptionalChainFromNewExpression.js.diff delete mode 100644 testdata/baselines/reference/submodule/compiler/narrowingUnionWithBang.js.diff delete mode 100644 testdata/baselines/reference/submodule/compiler/optionalChainWithInstantiationExpression1(target=es2019).js.diff delete mode 100644 testdata/baselines/reference/submodule/compiler/unionOfArraysFilterCall.js.diff delete mode 100644 testdata/baselines/reference/submodule/compiler/useUnknownInCatchVariables01.js.diff delete mode 100644 testdata/baselines/reference/submodule/conformance/callChain.2.js.diff delete mode 100644 testdata/baselines/reference/submodule/conformance/classExtendingOptionalChain.js.diff delete mode 100644 testdata/baselines/reference/submodule/conformance/controlFlowOptionalChain2.js.diff delete mode 100644 testdata/baselines/reference/submodule/conformance/elementAccessChain.2.js.diff delete mode 100644 testdata/baselines/reference/submodule/conformance/noPropertyAccessFromIndexSignature1.js.diff delete mode 100644 testdata/baselines/reference/submodule/conformance/optionalChainingInArrow.js.diff delete mode 100644 testdata/baselines/reference/submodule/conformance/optionalChainingInLoop.js.diff delete mode 100644 testdata/baselines/reference/submodule/conformance/optionalChainingInParameterBindingPattern(target=es2015).js.diff delete mode 100644 testdata/baselines/reference/submodule/conformance/optionalChainingInParameterInitializer(target=es2015).js.diff delete mode 100644 testdata/baselines/reference/submodule/conformance/optionalChainingInference.js.diff delete mode 100644 testdata/baselines/reference/submodule/conformance/parentheses.js.diff delete mode 100644 testdata/baselines/reference/submodule/conformance/propertyAccessChain.2.js.diff delete mode 100644 testdata/baselines/reference/submodule/conformance/thisTypeOptionalCall.js.diff diff --git a/internal/ast/ast.go b/internal/ast/ast.go index 726796500a..0b4138b658 100644 --- a/internal/ast/ast.go +++ b/internal/ast/ast.go @@ -878,6 +878,20 @@ func (n *Node) Elements() []*Node { return nil } +func (n *Node) QuestionDotToken() *Node { + switch n.Kind { + case KindElementAccessExpression: + return n.AsElementAccessExpression().QuestionDotToken + case KindPropertyAccessExpression: + return n.AsPropertyAccessExpression().QuestionDotToken + case KindCallExpression: + return n.AsCallExpression().QuestionDotToken + case KindTaggedTemplateExpression: + return n.AsTaggedTemplateExpression().QuestionDotToken + } + panic("Unhandled case in Node.QuestionDotToken: " + n.Kind.String()) +} + // Determines if `n` contains `descendant` by walking up the `Parent` pointers from `descendant`. This method panics if // `descendant` or one of its ancestors is not parented except when that node is a `SourceFile`. func (n *Node) Contains(descendant *Node) bool { @@ -1672,6 +1686,10 @@ func (n *Node) AsSyntaxList() *SyntaxList { return n.data.(*SyntaxList) } +func (n *Node) AsSyntheticReferenceExpression() *SyntheticReferenceExpression { + return n.data.(*SyntheticReferenceExpression) +} + // NodeData type nodeData interface { @@ -4126,6 +4144,53 @@ func IsNotEmittedTypeElement(node *Node) bool { return node.Kind == KindNotEmittedTypeElement } +// SyntheticReferenceExpression +// Used by optional chaining transform to shuffle a `this` arg expression between steps of a chain. +// While this does implement the full expected interface of a node, and is used in place of a node in transforms, +// it generally shouldn't be treated or visited like a normal node. + +type SyntheticReferenceExpression struct { + ExpressionBase + Expression *Expression + ThisArg *Expression +} + +func (f *NodeFactory) NewSyntheticReferenceExpression(expr *Expression, thisArg *Expression) *Node { + data := &SyntheticReferenceExpression{Expression: expr, ThisArg: thisArg} + return newNode(KindSyntheticReferenceExpression, data, f.hooks) +} + +func (f *NodeFactory) UpdateSyntheticReferenceExpression(node *SyntheticReferenceExpression, expr *Expression, thisArg *Expression) *Node { + if expr != node.Expression || thisArg != node.ThisArg { + return updateNode(f.NewSyntheticReferenceExpression(expr, thisArg), node.AsNode(), f.hooks) + } + return node.AsNode() +} + +func (node *SyntheticReferenceExpression) ForEachChild(v Visitor) bool { + return visit(v, node.Expression) +} + +func (node *SyntheticReferenceExpression) VisitEachChild(v *NodeVisitor) *Node { + return v.Factory.UpdateSyntheticReferenceExpression(node, v.visitNode(node.Expression), node.ThisArg) +} + +func (node *SyntheticReferenceExpression) Clone(f NodeFactoryCoercible) *Node { + return cloneNode(f.AsNodeFactory().NewSyntheticReferenceExpression(node.Expression, node.ThisArg), node.AsNode(), f.AsNodeFactory().hooks) +} + +func (node *SyntheticReferenceExpression) computeSubtreeFacts() SubtreeFacts { + return propagateSubtreeFacts(node.Expression) +} + +func (node *SyntheticReferenceExpression) propagateSubtreeFacts() SubtreeFacts { + return node.SubtreeFacts() +} + +func IsSyntheticReferenceExpression(node *Node) bool { + return node.Kind == KindSyntheticReferenceExpression +} + // ImportEqualsDeclaration type ImportEqualsDeclaration struct { diff --git a/internal/printer/factory.go b/internal/printer/factory.go index 71472f4ab4..f4928c6174 100644 --- a/internal/printer/factory.go +++ b/internal/printer/factory.go @@ -308,6 +308,14 @@ func (f *NodeFactory) NewGlobalMethodCall(globalObjectName string, methodName st return f.NewMethodCall(f.NewIdentifier(globalObjectName), f.NewIdentifier(methodName), argumentsList) } +func (f *NodeFactory) NewFunctionCallCall(target *ast.Expression, thisArg *ast.Expression, argumentsList []*ast.Node) *ast.Node { + if thisArg == nil { + panic("Attempted to construct function call call without this argument expression") + } + args := append([]*ast.Expression{thisArg}, argumentsList...) + return f.NewMethodCall(target, f.NewIdentifier("call"), args) +} + // Determines whether a node is a parenthesized expression that can be ignored when recreating outer expressions. // // A parenthesized expression can be ignored when all of the following are true: diff --git a/internal/printer/printer.go b/internal/printer/printer.go index 9f078e44e8..0a3a3e6ef4 100644 --- a/internal/printer/printer.go +++ b/internal/printer/printer.go @@ -3093,12 +3093,12 @@ func (p *Printer) emitExpression(node *ast.Expression, precedence ast.OperatorPr return case ast.KindPartiallyEmittedExpression: p.emitPartiallyEmittedExpression(node.AsPartiallyEmittedExpression(), precedence) + case ast.KindSyntheticReferenceExpression: + panic("SyntheticReferenceExpression should not be printed") // !!! ////case ast.KindCommaListExpression: //// p.emitCommaList(node.AsCommaListExpression()) - ////case ast.KindSyntheticReferenceExpression: - //// return Debug.fail("SyntheticReferenceExpression should not be printed") default: panic(fmt.Sprintf("unexpected Expression: %v", node.Kind)) diff --git a/internal/transformers/estransforms/optionalchain.go b/internal/transformers/estransforms/optionalchain.go index 634ae61d2f..46cf10145f 100644 --- a/internal/transformers/estransforms/optionalchain.go +++ b/internal/transformers/estransforms/optionalchain.go @@ -11,7 +11,222 @@ type optionalChainTransformer struct { } func (ch *optionalChainTransformer) visit(node *ast.Node) *ast.Node { - return node // !!! + if node.SubtreeFacts()&ast.SubtreeContainsOptionalChaining == 0 { + return node + } + switch node.Kind { + case ast.KindCallExpression: + return ch.visitCallExpression(node.AsCallExpression(), false) + case ast.KindPropertyAccessExpression, + ast.KindElementAccessExpression: + if node.Flags&ast.NodeFlagsOptionalChain != 0 { + return ch.visitOptionalExpression(node, false, false) + } + return ch.Visitor().VisitEachChild(node) + case ast.KindDeleteExpression: + return ch.visitDeleteExpression(node.AsDeleteExpression()) + default: + return ch.Visitor().VisitEachChild(node) + } +} + +func (ch *optionalChainTransformer) visitCallExpression(node *ast.CallExpression, captureThisArg bool) *ast.Node { + if node.Flags&ast.NodeFlagsOptionalChain != 0 { + // If `node` is an optional chain, then it is the outermost chain of an optional expression. + return ch.visitOptionalExpression(node.AsNode(), captureThisArg, false) + } + if ast.IsParenthesizedExpression(node.Expression) { + unwrapped := ast.SkipParentheses(node.Expression) + if unwrapped.Flags&ast.NodeFlagsOptionalChain != 0 { + // capture thisArg for calls of parenthesized optional chains like `(foo?.bar)()` + expression := ch.visitParenthesizedExpression(node.Expression.AsParenthesizedExpression(), true, false) + args := ch.Visitor().VisitNodes(node.Arguments) + if ast.IsSyntheticReferenceExpression(expression) { + res := ch.Factory().NewFunctionCallCall(expression.AsSyntheticReferenceExpression().Expression, expression.AsSyntheticReferenceExpression().ThisArg, args.Nodes) + res.Loc = node.Loc + ch.EmitContext().SetOriginal(res, node.AsNode()) + return res + } + return ch.Factory().UpdateCallExpression(node, expression, nil, nil, args) + } + } + return ch.Visitor().VisitEachChild(node.AsNode()) +} + +func (ch *optionalChainTransformer) visitParenthesizedExpression(node *ast.ParenthesizedExpression, captureThisArg bool, isDelete bool) *ast.Node { + expr := ch.visitNonOptionalExpression(node.Expression, captureThisArg, isDelete) + if ast.IsSyntheticReferenceExpression(expr) { + // `(a.b)` -> { expression `((_a = a).b)`, thisArg: `_a` } + // `(a[b])` -> { expression `((_a = a)[b])`, thisArg: `_a` } + synth := expr.AsSyntheticReferenceExpression() + res := ch.Factory().NewSyntheticReferenceExpression(ch.Factory().UpdateParenthesizedExpression(node, synth.Expression), synth.ThisArg) + ch.EmitContext().SetOriginal(res, node.AsNode()) + return res + } + return ch.Factory().UpdateParenthesizedExpression(node, expr) +} + +func (ch *optionalChainTransformer) visitPropertyOrElementAccessExpression(node *ast.Expression, captureThisArg bool, isDelete bool) *ast.Expression { + if node.Flags&ast.NodeFlagsOptionalChain != 0 { + // If `node` is an optional chain, then it is the outermost chain of an optional expression. + return ch.visitOptionalExpression(node.AsNode(), captureThisArg, isDelete) + } + expression := ch.Visitor().VisitNode(node.Expression()) + // Debug.assertNotNode(expression, isSyntheticReference); // !!! + + var thisArg *ast.Expression + if captureThisArg { + if !transformers.IsSimpleCopiableExpression(expression) { + thisArg = ch.Factory().NewTempVariable() + ch.EmitContext().AddVariableDeclaration(thisArg) + expression = ch.Factory().NewAssignmentExpression(thisArg, expression) + } else { + thisArg = expression + } + } + + if node.Kind == ast.KindPropertyAccessExpression { + p := node.AsPropertyAccessExpression() + expression = ch.Factory().UpdatePropertyAccessExpression(p, expression, nil, ch.Visitor().VisitNode(p.Name())) + } else { + p := node.AsElementAccessExpression() + expression = ch.Factory().UpdateElementAccessExpression(p, expression, nil, ch.Visitor().VisitNode(p.AsElementAccessExpression().ArgumentExpression)) + } + + if thisArg != nil { + res := ch.Factory().NewSyntheticReferenceExpression(expression, thisArg) + ch.EmitContext().SetOriginal(res, node.AsNode()) + return res + } + return expression +} + +func (ch *optionalChainTransformer) visitDeleteExpression(node *ast.DeleteExpression) *ast.Node { + unwrapped := ast.SkipParentheses(node.Expression) + if unwrapped.Flags&ast.NodeFlagsOptionalChain != 0 { + return ch.visitNonOptionalExpression(node.Expression, false, true) + } + return ch.Visitor().VisitEachChild(node.AsNode()) +} + +func (ch *optionalChainTransformer) visitNonOptionalExpression(node *ast.Expression, captureThisArg bool, isDelete bool) *ast.Expression { + switch node.Kind { + case ast.KindParenthesizedExpression: + return ch.visitParenthesizedExpression(node.AsParenthesizedExpression(), captureThisArg, isDelete) + case ast.KindElementAccessExpression, ast.KindPropertyAccessExpression: + return ch.visitPropertyOrElementAccessExpression(node, captureThisArg, isDelete) + case ast.KindCallExpression: + return ch.visitCallExpression(node.AsCallExpression(), captureThisArg) + default: + return ch.Visitor().VisitNode(node.AsNode()) + } +} + +type flattenResult struct { + expression *ast.Expression + chain []*ast.Node +} + +func flattenChain(chain *ast.Node) flattenResult { + // Debug.assertNotNode(chain, isNonNullChain); // !!! + links := []*ast.Node{chain} + for !ast.IsTaggedTemplateExpression(chain) && chain.QuestionDotToken() == nil { + chain = ast.SkipPartiallyEmittedExpressions(chain.Expression()) + // Debug.assertNotNode(chain, isNonNullChain); // !!! + links = append([]*ast.Node{chain}, links...) + } + return flattenResult{chain.Expression(), links} +} + +func isCallChain(node *ast.Node) bool { + return ast.IsCallExpression(node) && node.Flags&ast.NodeFlagsOptionalChain != 0 +} + +func (ch *optionalChainTransformer) visitOptionalExpression(node *ast.Node, captureThisArg bool, isDelete bool) *ast.Node { + r := flattenChain(node) + expression := r.expression + chain := r.chain + left := ch.visitNonOptionalExpression(ast.SkipPartiallyEmittedExpressions(expression), isCallChain(chain[0]), false) + var leftThisArg *ast.Expression + capturedLeft := left + if ast.IsSyntheticReferenceExpression(left) { + leftThisArg = left.AsSyntheticReferenceExpression().ThisArg + capturedLeft = left.AsSyntheticReferenceExpression().Expression + } + leftExpression := ch.Factory().RestoreOuterExpressions(expression, capturedLeft, ast.OEKPartiallyEmittedExpressions) + if !transformers.IsSimpleCopiableExpression(capturedLeft) { + capturedLeft = ch.Factory().NewTempVariable() + ch.EmitContext().AddVariableDeclaration(capturedLeft) + leftExpression = ch.Factory().NewAssignmentExpression(capturedLeft, leftExpression) + } + rightExpression := capturedLeft + var thisArg *ast.Expression + + for i, segment := range chain { + switch segment.Kind { + case ast.KindElementAccessExpression, ast.KindPropertyAccessExpression: + if i == len(chain)-1 && captureThisArg { + if !transformers.IsSimpleCopiableExpression(rightExpression) { + thisArg = ch.Factory().NewTempVariable() + ch.EmitContext().AddVariableDeclaration(thisArg) + rightExpression = ch.Factory().NewAssignmentExpression(thisArg, rightExpression) + } else { + thisArg = rightExpression + } + } + if segment.Kind == ast.KindElementAccessExpression { + rightExpression = ch.Factory().NewElementAccessExpression(rightExpression, nil, ch.Visitor().VisitNode(segment.AsElementAccessExpression().ArgumentExpression), ast.NodeFlagsNone) + } else { + rightExpression = ch.Factory().NewPropertyAccessExpression(rightExpression, nil, ch.Visitor().VisitNode(segment.AsPropertyAccessExpression().Name()), ast.NodeFlagsNone) + } + case ast.KindCallExpression: + if i == 0 && leftThisArg != nil { + if !ch.EmitContext().HasAutoGenerateInfo(leftThisArg) { + leftThisArg = leftThisArg.Clone(ch.Factory()) + ch.EmitContext().AddEmitFlags(leftThisArg, printer.EFNoComments) + } + callThisArg := leftThisArg + if leftThisArg.Kind == ast.KindSuperKeyword { + callThisArg = ch.Factory().NewThisExpression() + } + rightExpression = ch.Factory().NewFunctionCallCall(rightExpression, callThisArg, ch.Visitor().VisitNodes(segment.ArgumentList()).Nodes) + } else { + rightExpression = ch.Factory().NewCallExpression( + rightExpression, + nil, + nil, + ch.Visitor().VisitNodes(segment.ArgumentList()), + ast.NodeFlagsNone, + ) + } + } + ch.EmitContext().SetOriginal(rightExpression, segment) + } + + var target *ast.Node + if isDelete { + target = ch.Factory().NewConditionalExpression( + createNotNullCondition(ch.EmitContext(), leftExpression, capturedLeft, true), + ch.Factory().NewToken(ast.KindQuestionToken), + ch.Factory().NewTrueExpression(), + ch.Factory().NewToken(ast.KindColonToken), + ch.Factory().NewDeleteExpression(rightExpression), + ) + } else { + target = ch.Factory().NewConditionalExpression( + createNotNullCondition(ch.EmitContext(), leftExpression, capturedLeft, true), + ch.Factory().NewToken(ast.KindQuestionToken), + ch.Factory().NewVoidZeroExpression(), + ch.Factory().NewToken(ast.KindColonToken), + rightExpression, + ) + } + target.Loc = node.Loc + if thisArg != nil { + target = ch.Factory().NewSyntheticReferenceExpression(target, thisArg) + } + ch.EmitContext().SetOriginal(target, node.AsNode()) + return target } func newOptionalChainTransformer(emitContext *printer.EmitContext) *transformers.Transformer { diff --git a/testdata/baselines/reference/submodule/compiler/assertionFunctionsCanNarrowByDiscriminant.js b/testdata/baselines/reference/submodule/compiler/assertionFunctionsCanNarrowByDiscriminant.js index c42d6a6e6b..2812044f16 100644 --- a/testdata/baselines/reference/submodule/compiler/assertionFunctionsCanNarrowByDiscriminant.js +++ b/testdata/baselines/reference/submodule/compiler/assertionFunctionsCanNarrowByDiscriminant.js @@ -31,5 +31,5 @@ const animal = { type: 'cat', canMeow: true }; assertEqual(animal.type, 'cat'); animal.canMeow; // since is cat, should not be an error const animalOrUndef = { type: 'cat', canMeow: true }; -assertEqual(animalOrUndef?.type, 'cat'); +assertEqual(animalOrUndef === null || animalOrUndef === void 0 ? void 0 : animalOrUndef.type, 'cat'); animalOrUndef.canMeow; // since is cat, should not be an error diff --git a/testdata/baselines/reference/submodule/compiler/assertionFunctionsCanNarrowByDiscriminant.js.diff b/testdata/baselines/reference/submodule/compiler/assertionFunctionsCanNarrowByDiscriminant.js.diff index ec280626a2..bed1d3aed5 100644 --- a/testdata/baselines/reference/submodule/compiler/assertionFunctionsCanNarrowByDiscriminant.js.diff +++ b/testdata/baselines/reference/submodule/compiler/assertionFunctionsCanNarrowByDiscriminant.js.diff @@ -7,8 +7,4 @@ -"use strict"; const animal = { type: 'cat', canMeow: true }; assertEqual(animal.type, 'cat'); - animal.canMeow; // since is cat, should not be an error - const animalOrUndef = { type: 'cat', canMeow: true }; --assertEqual(animalOrUndef === null || animalOrUndef === void 0 ? void 0 : animalOrUndef.type, 'cat'); -+assertEqual(animalOrUndef?.type, 'cat'); - animalOrUndef.canMeow; // since is cat, should not be an error \ No newline at end of file + animal.canMeow; // since is cat, should not be an error \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/invalidOptionalChainFromNewExpression.js b/testdata/baselines/reference/submodule/compiler/invalidOptionalChainFromNewExpression.js index cbfec05da8..9c82584dba 100644 --- a/testdata/baselines/reference/submodule/compiler/invalidOptionalChainFromNewExpression.js +++ b/testdata/baselines/reference/submodule/compiler/invalidOptionalChainFromNewExpression.js @@ -10,8 +10,9 @@ new A()?.b() // ok //// [invalidOptionalChainFromNewExpression.js] +var _a, _b; class A { b() { } } -(new A)?.b(); // error -new A()?.b(); // ok +(_a = new A) === null || _a === void 0 ? void 0 : _a.b(); // error +(_b = new A()) === null || _b === void 0 ? void 0 : _b.b(); // ok diff --git a/testdata/baselines/reference/submodule/compiler/invalidOptionalChainFromNewExpression.js.diff b/testdata/baselines/reference/submodule/compiler/invalidOptionalChainFromNewExpression.js.diff deleted file mode 100644 index c0039414d5..0000000000 --- a/testdata/baselines/reference/submodule/compiler/invalidOptionalChainFromNewExpression.js.diff +++ /dev/null @@ -1,14 +0,0 @@ ---- old.invalidOptionalChainFromNewExpression.js -+++ new.invalidOptionalChainFromNewExpression.js -@@= skipped -9, +9 lines =@@ - - - //// [invalidOptionalChainFromNewExpression.js] --var _a, _b; - class A { - b() { } - } --(_a = new A) === null || _a === void 0 ? void 0 : _a.b(); // error --(_b = new A()) === null || _b === void 0 ? void 0 : _b.b(); // ok -+(new A)?.b(); // error -+new A()?.b(); // ok \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/mappedTypeGenericIndexedAccess.js b/testdata/baselines/reference/submodule/compiler/mappedTypeGenericIndexedAccess.js index 869e99fca1..ff6eacf188 100644 --- a/testdata/baselines/reference/submodule/compiler/mappedTypeGenericIndexedAccess.js +++ b/testdata/baselines/reference/submodule/compiler/mappedTypeGenericIndexedAccess.js @@ -53,17 +53,21 @@ class Test { this.entries = {}; } addEntry(name, entry) { + var _a; if (!this.entries[name]) { this.entries[name] = []; } - this.entries[name]?.push(entry); + (_a = this.entries[name]) === null || _a === void 0 ? void 0 : _a.push(entry); } } const typeHandlers = { [0]: (p) => console.log(p.foo), [1]: (p) => console.log(p.a), }; -const onSomeEvent = (p) => typeHandlers[p.t]?.(p); +const onSomeEvent = (p) => { + var _a; + return (_a = typeHandlers[p.t]) === null || _a === void 0 ? void 0 : _a.call(typeHandlers, p); +}; //// [mappedTypeGenericIndexedAccess.d.ts] diff --git a/testdata/baselines/reference/submodule/compiler/mappedTypeGenericIndexedAccess.js.diff b/testdata/baselines/reference/submodule/compiler/mappedTypeGenericIndexedAccess.js.diff index 340d1ab78b..24c2b5b455 100644 --- a/testdata/baselines/reference/submodule/compiler/mappedTypeGenericIndexedAccess.js.diff +++ b/testdata/baselines/reference/submodule/compiler/mappedTypeGenericIndexedAccess.js.diff @@ -11,21 +11,15 @@ constructor() { this.entries = {}; } - addEntry(name, entry) { -- var _a; - if (!this.entries[name]) { - this.entries[name] = []; - } -- (_a = this.entries[name]) === null || _a === void 0 ? void 0 : _a.push(entry); -+ this.entries[name]?.push(entry); - } - } - const typeHandlers = { +@@= skipped -18, +17 lines =@@ [0]: (p) => console.log(p.foo), [1]: (p) => console.log(p.a), }; -const onSomeEvent = (p) => { var _a; return (_a = typeHandlers[p.t]) === null || _a === void 0 ? void 0 : _a.call(typeHandlers, p); }; -+const onSomeEvent = (p) => typeHandlers[p.t]?.(p); ++const onSomeEvent = (p) => { ++ var _a; ++ return (_a = typeHandlers[p.t]) === null || _a === void 0 ? void 0 : _a.call(typeHandlers, p); ++}; //// [mappedTypeGenericIndexedAccess.d.ts] @@ -33,7 +27,7 @@ type Types = { first: { a1: true; -@@= skipped -40, +39 lines =@@ +@@= skipped -22, +26 lines =@@ constructor(); addEntry(name: T, entry: Types[T]): void; } diff --git a/testdata/baselines/reference/submodule/compiler/narrowingTypeofDiscriminant.js b/testdata/baselines/reference/submodule/compiler/narrowingTypeofDiscriminant.js index 8d2ea9a34c..764c44d01b 100644 --- a/testdata/baselines/reference/submodule/compiler/narrowingTypeofDiscriminant.js +++ b/testdata/baselines/reference/submodule/compiler/narrowingTypeofDiscriminant.js @@ -55,7 +55,7 @@ function f1(obj) { } } function f2(obj) { - if (typeof obj?.kind === "string") { + if (typeof (obj === null || obj === void 0 ? void 0 : obj.kind) === "string") { obj; // { kind: 'a', data: string } } else { @@ -63,19 +63,19 @@ function f2(obj) { } } function numberOk(wrapped) { - if (typeof wrapped?.value !== 'string') { + if (typeof (wrapped === null || wrapped === void 0 ? void 0 : wrapped.value) !== 'string') { return null; } return wrapped.value; } function booleanBad(wrapped) { - if (typeof wrapped?.value !== 'string') { + if (typeof (wrapped === null || wrapped === void 0 ? void 0 : wrapped.value) !== 'string') { return null; } return wrapped.value; } function booleanFixed(wrapped) { - if (typeof (wrapped?.value) !== 'string') { + if (typeof (wrapped === null || wrapped === void 0 ? void 0 : wrapped.value) !== 'string') { return null; } return wrapped.value; diff --git a/testdata/baselines/reference/submodule/compiler/narrowingTypeofDiscriminant.js.diff b/testdata/baselines/reference/submodule/compiler/narrowingTypeofDiscriminant.js.diff index 7d10e09744..14707105d2 100644 --- a/testdata/baselines/reference/submodule/compiler/narrowingTypeofDiscriminant.js.diff +++ b/testdata/baselines/reference/submodule/compiler/narrowingTypeofDiscriminant.js.diff @@ -7,36 +7,4 @@ -"use strict"; function f1(obj) { if (typeof obj.kind === "string") { - obj; // { kind: 'a', data: string } -@@= skipped -10, +9 lines =@@ - } - } - function f2(obj) { -- if (typeof (obj === null || obj === void 0 ? void 0 : obj.kind) === "string") { -+ if (typeof obj?.kind === "string") { - obj; // { kind: 'a', data: string } - } - else { -@@= skipped -8, +8 lines =@@ - } - } - function numberOk(wrapped) { -- if (typeof (wrapped === null || wrapped === void 0 ? void 0 : wrapped.value) !== 'string') { -+ if (typeof wrapped?.value !== 'string') { - return null; - } - return wrapped.value; - } - function booleanBad(wrapped) { -- if (typeof (wrapped === null || wrapped === void 0 ? void 0 : wrapped.value) !== 'string') { -+ if (typeof wrapped?.value !== 'string') { - return null; - } - return wrapped.value; - } - function booleanFixed(wrapped) { -- if (typeof (wrapped === null || wrapped === void 0 ? void 0 : wrapped.value) !== 'string') { -+ if (typeof (wrapped?.value) !== 'string') { - return null; - } - return wrapped.value; \ No newline at end of file + obj; // { kind: 'a', data: string } \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/narrowingUnionWithBang.js b/testdata/baselines/reference/submodule/compiler/narrowingUnionWithBang.js index ed85a3d147..fd73f05c0a 100644 --- a/testdata/baselines/reference/submodule/compiler/narrowingUnionWithBang.js +++ b/testdata/baselines/reference/submodule/compiler/narrowingUnionWithBang.js @@ -62,6 +62,7 @@ if (fixed.thing?.name !== "Correct") { //// [narrowingUnionWithBang.js] "use strict"; +var _a; Object.defineProperty(exports, "__esModule", { value: true }); const working = null; if (working.thing.name !== "Correct") { @@ -78,7 +79,7 @@ else { console.log(borked.thing.id); } const fixed = null; -if (fixed.thing?.name !== "Correct") { +if (((_a = fixed.thing) === null || _a === void 0 ? void 0 : _a.name) !== "Correct") { console.log(fixed.thing.message); } else { diff --git a/testdata/baselines/reference/submodule/compiler/narrowingUnionWithBang.js.diff b/testdata/baselines/reference/submodule/compiler/narrowingUnionWithBang.js.diff deleted file mode 100644 index 06cc1ce7a6..0000000000 --- a/testdata/baselines/reference/submodule/compiler/narrowingUnionWithBang.js.diff +++ /dev/null @@ -1,19 +0,0 @@ ---- old.narrowingUnionWithBang.js -+++ new.narrowingUnionWithBang.js -@@= skipped -61, +61 lines =@@ - - //// [narrowingUnionWithBang.js] - "use strict"; --var _a; - Object.defineProperty(exports, "__esModule", { value: true }); - const working = null; - if (working.thing.name !== "Correct") { -@@= skipped -17, +16 lines =@@ - console.log(borked.thing.id); - } - const fixed = null; --if (((_a = fixed.thing) === null || _a === void 0 ? void 0 : _a.name) !== "Correct") { -+if (fixed.thing?.name !== "Correct") { - console.log(fixed.thing.message); - } - else { \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/narrowingWithNonNullExpression.js b/testdata/baselines/reference/submodule/compiler/narrowingWithNonNullExpression.js index 77cc7fafde..6a5aba6f21 100644 --- a/testdata/baselines/reference/submodule/compiler/narrowingWithNonNullExpression.js +++ b/testdata/baselines/reference/submodule/compiler/narrowingWithNonNullExpression.js @@ -9,4 +9,4 @@ m?.[0]! && m[0]; //// [narrowingWithNonNullExpression.js] const m = ''.match(''); m && m[0]; -m?.[0] && m[0]; +((m === null || m === void 0 ? void 0 : m[0])) && m[0]; diff --git a/testdata/baselines/reference/submodule/compiler/narrowingWithNonNullExpression.js.diff b/testdata/baselines/reference/submodule/compiler/narrowingWithNonNullExpression.js.diff index d26225012f..d174751e11 100644 --- a/testdata/baselines/reference/submodule/compiler/narrowingWithNonNullExpression.js.diff +++ b/testdata/baselines/reference/submodule/compiler/narrowingWithNonNullExpression.js.diff @@ -5,4 +5,4 @@ const m = ''.match(''); m && m[0]; -(m === null || m === void 0 ? void 0 : m[0]) && m[0]; -+m?.[0] && m[0]; \ No newline at end of file ++((m === null || m === void 0 ? void 0 : m[0])) && m[0]; \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/nonNullableReduction.js b/testdata/baselines/reference/submodule/compiler/nonNullableReduction.js index 19f1cbd9f4..7bcb5236cc 100644 --- a/testdata/baselines/reference/submodule/compiler/nonNullableReduction.js +++ b/testdata/baselines/reference/submodule/compiler/nonNullableReduction.js @@ -22,8 +22,8 @@ function f2(x: T | U) { //// [nonNullableReduction.js] function test(f1, f2) { - f1?.("hello"); - f2?.("hello"); + f1 === null || f1 === void 0 ? void 0 : f1("hello"); + f2 === null || f2 === void 0 ? void 0 : f2("hello"); } function f1(x) { let z = x; // NonNullable diff --git a/testdata/baselines/reference/submodule/compiler/nonNullableReduction.js.diff b/testdata/baselines/reference/submodule/compiler/nonNullableReduction.js.diff index e597bf5c0b..764ced1140 100644 --- a/testdata/baselines/reference/submodule/compiler/nonNullableReduction.js.diff +++ b/testdata/baselines/reference/submodule/compiler/nonNullableReduction.js.diff @@ -7,10 +7,5 @@ -"use strict"; -// Repros from #43425 function test(f1, f2) { -- f1 === null || f1 === void 0 ? void 0 : f1("hello"); -- f2 === null || f2 === void 0 ? void 0 : f2("hello"); -+ f1?.("hello"); -+ f2?.("hello"); - } - function f1(x) { - let z = x; // NonNullable \ No newline at end of file + f1 === null || f1 === void 0 ? void 0 : f1("hello"); + f2 === null || f2 === void 0 ? void 0 : f2("hello"); \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/nonNullableReductionNonStrict.js b/testdata/baselines/reference/submodule/compiler/nonNullableReductionNonStrict.js index 54970e10ba..4bec3fee12 100644 --- a/testdata/baselines/reference/submodule/compiler/nonNullableReductionNonStrict.js +++ b/testdata/baselines/reference/submodule/compiler/nonNullableReductionNonStrict.js @@ -22,8 +22,8 @@ function f2(x: T | U) { //// [nonNullableReductionNonStrict.js] function test(f1, f2) { - f1?.("hello"); - f2?.("hello"); + f1 === null || f1 === void 0 ? void 0 : f1("hello"); + f2 === null || f2 === void 0 ? void 0 : f2("hello"); } function f1(x) { let z = x; // NonNullable diff --git a/testdata/baselines/reference/submodule/compiler/nonNullableReductionNonStrict.js.diff b/testdata/baselines/reference/submodule/compiler/nonNullableReductionNonStrict.js.diff index d2137e4a79..4dc8446649 100644 --- a/testdata/baselines/reference/submodule/compiler/nonNullableReductionNonStrict.js.diff +++ b/testdata/baselines/reference/submodule/compiler/nonNullableReductionNonStrict.js.diff @@ -6,10 +6,5 @@ //// [nonNullableReductionNonStrict.js] -// Repros from #43425 function test(f1, f2) { -- f1 === null || f1 === void 0 ? void 0 : f1("hello"); -- f2 === null || f2 === void 0 ? void 0 : f2("hello"); -+ f1?.("hello"); -+ f2?.("hello"); - } - function f1(x) { - let z = x; // NonNullable \ No newline at end of file + f1 === null || f1 === void 0 ? void 0 : f1("hello"); + f2 === null || f2 === void 0 ? void 0 : f2("hello"); \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/nonNullableTypes1.js b/testdata/baselines/reference/submodule/compiler/nonNullableTypes1.js index 363f0c7955..4a03e50c5e 100644 --- a/testdata/baselines/reference/submodule/compiler/nonNullableTypes1.js +++ b/testdata/baselines/reference/submodule/compiler/nonNullableTypes1.js @@ -51,20 +51,20 @@ function f3(x) { let y = x; // {} } function f4(obj) { - if (obj?.x === "hello") { + if ((obj === null || obj === void 0 ? void 0 : obj.x) === "hello") { obj; // NonNullable } - if (obj?.x) { + if (obj === null || obj === void 0 ? void 0 : obj.x) { obj; // NonNullable } - if (typeof obj?.x === "string") { + if (typeof (obj === null || obj === void 0 ? void 0 : obj.x) === "string") { obj; // NonNullable } } class A { x = "hello"; foo() { - let zz = this?.x; // string + let zz = this === null || this === void 0 ? void 0 : this.x; // string } } diff --git a/testdata/baselines/reference/submodule/compiler/nonNullableTypes1.js.diff b/testdata/baselines/reference/submodule/compiler/nonNullableTypes1.js.diff index da78fe8cab..864cf279ed 100644 --- a/testdata/baselines/reference/submodule/compiler/nonNullableTypes1.js.diff +++ b/testdata/baselines/reference/submodule/compiler/nonNullableTypes1.js.diff @@ -8,25 +8,7 @@ function f1(x) { let y = x || "hello"; // NonNullable | string } -@@= skipped -14, +13 lines =@@ - let y = x; // {} - } - function f4(obj) { -- if ((obj === null || obj === void 0 ? void 0 : obj.x) === "hello") { -- obj; // NonNullable -- } -- if (obj === null || obj === void 0 ? void 0 : obj.x) { -- obj; // NonNullable -- } -- if (typeof (obj === null || obj === void 0 ? void 0 : obj.x) === "string") { -+ if (obj?.x === "hello") { -+ obj; // NonNullable -+ } -+ if (obj?.x) { -+ obj; // NonNullable -+ } -+ if (typeof obj?.x === "string") { - obj; // NonNullable +@@= skipped -25, +24 lines =@@ } } class A { @@ -35,7 +17,5 @@ - } + x = "hello"; foo() { -- let zz = this === null || this === void 0 ? void 0 : this.x; // string -+ let zz = this?.x; // string - } - } + let zz = this === null || this === void 0 ? void 0 : this.x; // string + } \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/optionalChainWithInstantiationExpression1(target=es2019).js b/testdata/baselines/reference/submodule/compiler/optionalChainWithInstantiationExpression1(target=es2019).js index cae90bc49e..1a8c60a8aa 100644 --- a/testdata/baselines/reference/submodule/compiler/optionalChainWithInstantiationExpression1(target=es2019).js +++ b/testdata/baselines/reference/submodule/compiler/optionalChainWithInstantiationExpression1(target=es2019).js @@ -18,5 +18,5 @@ a?.b.d //// [optionalChainWithInstantiationExpression1.js] -(a?.b).d; -a?.b.d; +(a === null || a === void 0 ? void 0 : a.b).d; +a === null || a === void 0 ? void 0 : a.b.d; diff --git a/testdata/baselines/reference/submodule/compiler/optionalChainWithInstantiationExpression1(target=es2019).js.diff b/testdata/baselines/reference/submodule/compiler/optionalChainWithInstantiationExpression1(target=es2019).js.diff deleted file mode 100644 index 592501b518..0000000000 --- a/testdata/baselines/reference/submodule/compiler/optionalChainWithInstantiationExpression1(target=es2019).js.diff +++ /dev/null @@ -1,10 +0,0 @@ ---- old.optionalChainWithInstantiationExpression1(target=es2019).js -+++ new.optionalChainWithInstantiationExpression1(target=es2019).js -@@= skipped -17, +17 lines =@@ - - - //// [optionalChainWithInstantiationExpression1.js] --(a === null || a === void 0 ? void 0 : a.b).d; --a === null || a === void 0 ? void 0 : a.b.d; -+(a?.b).d; -+a?.b.d; \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/optionalChainWithInstantiationExpression2(target=es2019).js b/testdata/baselines/reference/submodule/compiler/optionalChainWithInstantiationExpression2(target=es2019).js index bbbac21bd4..85cf1a1c65 100644 --- a/testdata/baselines/reference/submodule/compiler/optionalChainWithInstantiationExpression2(target=es2019).js +++ b/testdata/baselines/reference/submodule/compiler/optionalChainWithInstantiationExpression2(target=es2019).js @@ -16,5 +16,6 @@ a?.(); //// [optionalChainWithInstantiationExpression2.js] -a?.(); -a?.(); +var _a; +a === null || a === void 0 ? void 0 : a(); +(_a = a) === null || _a === void 0 ? void 0 : _a(); diff --git a/testdata/baselines/reference/submodule/compiler/optionalChainWithInstantiationExpression2(target=es2019).js.diff b/testdata/baselines/reference/submodule/compiler/optionalChainWithInstantiationExpression2(target=es2019).js.diff index 24a4a3ffc9..70f2853459 100644 --- a/testdata/baselines/reference/submodule/compiler/optionalChainWithInstantiationExpression2(target=es2019).js.diff +++ b/testdata/baselines/reference/submodule/compiler/optionalChainWithInstantiationExpression2(target=es2019).js.diff @@ -1,11 +1,8 @@ --- old.optionalChainWithInstantiationExpression2(target=es2019).js +++ new.optionalChainWithInstantiationExpression2(target=es2019).js -@@= skipped -15, +15 lines =@@ - - +@@= skipped -17, +17 lines =@@ //// [optionalChainWithInstantiationExpression2.js] --var _a; --a === null || a === void 0 ? void 0 : a(); + var _a; + a === null || a === void 0 ? void 0 : a(); -(_a = (a)) === null || _a === void 0 ? void 0 : _a(); -+a?.(); -+a?.(); \ No newline at end of file ++(_a = a) === null || _a === void 0 ? void 0 : _a(); \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/propertyAccessExpressionInnerComments.js b/testdata/baselines/reference/submodule/compiler/propertyAccessExpressionInnerComments.js index 0338b8acc0..9a1722ba79 100644 --- a/testdata/baselines/reference/submodule/compiler/propertyAccessExpressionInnerComments.js +++ b/testdata/baselines/reference/submodule/compiler/propertyAccessExpressionInnerComments.js @@ -47,14 +47,14 @@ // Single-line comment /*2*/ . /*3*/toString; /*4*/ /* Existing issue: the "2" comments below are duplicated and "3"s are missing */ -/*1*/ Array /*2*/?. /*3*/toString; /*4*/ -/*1*/ Array - /*2*/ ?. /*3*/ - // Single-line comment - toString; /*4*/ -/*1*/ Array /*2*/?. /*3*/ - // Single-line comment - toString; /*4*/ -/*1*/ Array - // Single-line comment - /*2*/ ?. /*3*/toString; /*4*/ +/*1*/ Array /*2*/ === null || Array /*2*/ === void 0 ? void 0 : Array /*2*/. /*3*/toString; /*4*/ +/*1*/ Array === null || Array === void 0 ? void 0 : Array +/*2*/ . /*3*/ +// Single-line comment +toString; /*4*/ +/*1*/ Array /*2*/ === null || Array /*2*/ === void 0 ? void 0 : Array /*2*/. /*3*/ +// Single-line comment +toString; /*4*/ +/*1*/ Array === null || Array === void 0 ? void 0 : Array +// Single-line comment +/*2*/ . /*3*/toString; /*4*/ diff --git a/testdata/baselines/reference/submodule/compiler/propertyAccessExpressionInnerComments.js.diff b/testdata/baselines/reference/submodule/compiler/propertyAccessExpressionInnerComments.js.diff index 58852a3db3..472b8c7415 100644 --- a/testdata/baselines/reference/submodule/compiler/propertyAccessExpressionInnerComments.js.diff +++ b/testdata/baselines/reference/submodule/compiler/propertyAccessExpressionInnerComments.js.diff @@ -15,14 +15,14 @@ -/*1*/ Array === null || Array === void 0 ? void 0 : Array -// Single-line comment -/*2*/ .toString; /*4*/ -+/*1*/ Array /*2*/?. /*3*/toString; /*4*/ -+/*1*/ Array -+ /*2*/ ?. /*3*/ -+ // Single-line comment -+ toString; /*4*/ -+/*1*/ Array /*2*/?. /*3*/ -+ // Single-line comment -+ toString; /*4*/ -+/*1*/ Array -+ // Single-line comment -+ /*2*/ ?. /*3*/toString; /*4*/ \ No newline at end of file ++/*1*/ Array /*2*/ === null || Array /*2*/ === void 0 ? void 0 : Array /*2*/. /*3*/toString; /*4*/ ++/*1*/ Array === null || Array === void 0 ? void 0 : Array ++/*2*/ . /*3*/ ++// Single-line comment ++toString; /*4*/ ++/*1*/ Array /*2*/ === null || Array /*2*/ === void 0 ? void 0 : Array /*2*/. /*3*/ ++// Single-line comment ++toString; /*4*/ ++/*1*/ Array === null || Array === void 0 ? void 0 : Array ++// Single-line comment ++/*2*/ . /*3*/toString; /*4*/ \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/trackedSymbolsNoCrash.js b/testdata/baselines/reference/submodule/compiler/trackedSymbolsNoCrash.js index cda359b1ab..acfb8192a7 100644 --- a/testdata/baselines/reference/submodule/compiler/trackedSymbolsNoCrash.js +++ b/testdata/baselines/reference/submodule/compiler/trackedSymbolsNoCrash.js @@ -229,7 +229,7 @@ var SyntaxKind; "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.isNodeOfType = void 0; -const isNodeOfType = (nodeType) => (node) => node?.kind === nodeType; +const isNodeOfType = (nodeType) => (node) => (node === null || node === void 0 ? void 0 : node.kind) === nodeType; exports.isNodeOfType = isNodeOfType; diff --git a/testdata/baselines/reference/submodule/compiler/trackedSymbolsNoCrash.js.diff b/testdata/baselines/reference/submodule/compiler/trackedSymbolsNoCrash.js.diff index 2aa425060e..0b407896c7 100644 --- a/testdata/baselines/reference/submodule/compiler/trackedSymbolsNoCrash.js.diff +++ b/testdata/baselines/reference/submodule/compiler/trackedSymbolsNoCrash.js.diff @@ -1,15 +1,6 @@ --- old.trackedSymbolsNoCrash.js +++ new.trackedSymbolsNoCrash.js -@@= skipped -228, +228 lines =@@ - "use strict"; - Object.defineProperty(exports, "__esModule", { value: true }); - exports.isNodeOfType = void 0; --const isNodeOfType = (nodeType) => (node) => (node === null || node === void 0 ? void 0 : node.kind) === nodeType; -+const isNodeOfType = (nodeType) => (node) => node?.kind === nodeType; - exports.isNodeOfType = isNodeOfType; - - -@@= skipped -510, +510 lines =@@ +@@= skipped -738, +738 lines =@@ export type Node = Node0 | Node1 | Node2 | Node3 | Node4 | Node5 | Node6 | Node7 | Node8 | Node9 | Node10 | Node11 | Node12 | Node13 | Node14 | Node15 | Node16 | Node17 | Node18 | Node19 | Node20 | Node21 | Node22 | Node23 | Node24 | Node25 | Node26 | Node27 | Node28 | Node29 | Node30 | Node31 | Node32 | Node33 | Node34 | Node35 | Node36 | Node37 | Node38 | Node39 | Node40 | Node41 | Node42 | Node43 | Node44 | Node45 | Node46 | Node47 | Node48 | Node49 | Node50 | Node51 | Node52 | Node53 | Node54 | Node55 | Node56 | Node57 | Node58 | Node59 | Node60 | Node61 | Node62 | Node63 | Node64 | Node65 | Node66 | Node67 | Node68 | Node69 | Node70 | Node71 | Node72 | Node73 | Node74 | Node75 | Node76 | Node77 | Node78 | Node79 | Node80 | Node81 | Node82 | Node83 | Node84 | Node85 | Node86 | Node87 | Node88 | Node89 | Node90 | Node91 | Node92 | Node93 | Node94 | Node95 | Node96 | Node97 | Node98 | Node99; //// [index.d.ts] import * as ast from "./ast"; diff --git a/testdata/baselines/reference/submodule/compiler/typeParameterLeak.js b/testdata/baselines/reference/submodule/compiler/typeParameterLeak.js index ee29f9ebd0..23a0e8b859 100644 --- a/testdata/baselines/reference/submodule/compiler/typeParameterLeak.js +++ b/testdata/baselines/reference/submodule/compiler/typeParameterLeak.js @@ -22,7 +22,8 @@ if (b) { //// [typeParameterLeak.js] -const b = f({ x: "", y: "" })?.getBox(); +var _a; +const b = (_a = f({ x: "", y: "" })) === null || _a === void 0 ? void 0 : _a.getBox(); if (b) { const x = b.data; } diff --git a/testdata/baselines/reference/submodule/compiler/typeParameterLeak.js.diff b/testdata/baselines/reference/submodule/compiler/typeParameterLeak.js.diff index 2c84511acc..8d4bbd55b3 100644 --- a/testdata/baselines/reference/submodule/compiler/typeParameterLeak.js.diff +++ b/testdata/baselines/reference/submodule/compiler/typeParameterLeak.js.diff @@ -6,9 +6,6 @@ //// [typeParameterLeak.js] -"use strict"; -// Repro from #35655 --var _a; --const b = (_a = f({ x: "", y: "" })) === null || _a === void 0 ? void 0 : _a.getBox(); -+const b = f({ x: "", y: "" })?.getBox(); - if (b) { - const x = b.data; - } \ No newline at end of file + var _a; + const b = (_a = f({ x: "", y: "" })) === null || _a === void 0 ? void 0 : _a.getBox(); + if (b) { \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/typePredicatesOptionalChaining1.js b/testdata/baselines/reference/submodule/compiler/typePredicatesOptionalChaining1.js index 4f6979de88..2f113cff0c 100644 --- a/testdata/baselines/reference/submodule/compiler/typePredicatesOptionalChaining1.js +++ b/testdata/baselines/reference/submodule/compiler/typePredicatesOptionalChaining1.js @@ -22,6 +22,7 @@ isNotNull(x?.y?.z) ? title(x.y.z) : null; // should not error //// [typePredicatesOptionalChaining1.js] +var _a; const x = { y: {}, }; @@ -33,4 +34,4 @@ function isNotNull(x) { function title(str) { return str.length > 0 ? "Dear " + str : "Dear nobody"; } -isNotNull(x?.y?.z) ? title(x.y.z) : null; // should not error +isNotNull((_a = x === null || x === void 0 ? void 0 : x.y) === null || _a === void 0 ? void 0 : _a.z) ? title(x.y.z) : null; // should not error diff --git a/testdata/baselines/reference/submodule/compiler/typePredicatesOptionalChaining1.js.diff b/testdata/baselines/reference/submodule/compiler/typePredicatesOptionalChaining1.js.diff index 8fd1a4bef7..b4904b9f68 100644 --- a/testdata/baselines/reference/submodule/compiler/typePredicatesOptionalChaining1.js.diff +++ b/testdata/baselines/reference/submodule/compiler/typePredicatesOptionalChaining1.js.diff @@ -5,13 +5,6 @@ //// [typePredicatesOptionalChaining1.js] -"use strict"; --var _a; + var _a; const x = { - y: {}, - }; -@@= skipped -13, +11 lines =@@ - function title(str) { - return str.length > 0 ? "Dear " + str : "Dear nobody"; - } --isNotNull((_a = x === null || x === void 0 ? void 0 : x.y) === null || _a === void 0 ? void 0 : _a.z) ? title(x.y.z) : null; // should not error -+isNotNull(x?.y?.z) ? title(x.y.z) : null; // should not error \ No newline at end of file + y: {}, \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/typePredicatesOptionalChaining2.js b/testdata/baselines/reference/submodule/compiler/typePredicatesOptionalChaining2.js index 604ee38687..590c7978bf 100644 --- a/testdata/baselines/reference/submodule/compiler/typePredicatesOptionalChaining2.js +++ b/testdata/baselines/reference/submodule/compiler/typePredicatesOptionalChaining2.js @@ -18,11 +18,11 @@ const getName2 = (person?: Person): string => { //// [typePredicatesOptionalChaining2.js] const getName1 = (person) => { - return typeof person?.name === 'string' ? person?.name : ''; + return typeof (person === null || person === void 0 ? void 0 : person.name) === 'string' ? person === null || person === void 0 ? void 0 : person.name : ''; }; const isString = (value) => { return typeof value === 'string'; }; const getName2 = (person) => { - return isString(person?.name) ? person?.name : ''; + return isString(person === null || person === void 0 ? void 0 : person.name) ? person === null || person === void 0 ? void 0 : person.name : ''; }; diff --git a/testdata/baselines/reference/submodule/compiler/typePredicatesOptionalChaining2.js.diff b/testdata/baselines/reference/submodule/compiler/typePredicatesOptionalChaining2.js.diff index a242eabe51..736f53060e 100644 --- a/testdata/baselines/reference/submodule/compiler/typePredicatesOptionalChaining2.js.diff +++ b/testdata/baselines/reference/submodule/compiler/typePredicatesOptionalChaining2.js.diff @@ -6,13 +6,5 @@ //// [typePredicatesOptionalChaining2.js] -"use strict"; const getName1 = (person) => { -- return typeof (person === null || person === void 0 ? void 0 : person.name) === 'string' ? person === null || person === void 0 ? void 0 : person.name : ''; -+ return typeof person?.name === 'string' ? person?.name : ''; - }; - const isString = (value) => { - return typeof value === 'string'; - }; - const getName2 = (person) => { -- return isString(person === null || person === void 0 ? void 0 : person.name) ? person === null || person === void 0 ? void 0 : person.name : ''; -+ return isString(person?.name) ? person?.name : ''; + return typeof (person === null || person === void 0 ? void 0 : person.name) === 'string' ? person === null || person === void 0 ? void 0 : person.name : ''; }; \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/typePredicatesOptionalChaining3.js b/testdata/baselines/reference/submodule/compiler/typePredicatesOptionalChaining3.js index 61cdd22a81..49d1588bb0 100644 --- a/testdata/baselines/reference/submodule/compiler/typePredicatesOptionalChaining3.js +++ b/testdata/baselines/reference/submodule/compiler/typePredicatesOptionalChaining3.js @@ -29,7 +29,8 @@ function getBreedSizeWithFunction(animal: Animal): string | undefined { //// [typePredicatesOptionalChaining3.js] function getBreedSizeWithoutFunction(animal) { - if (animal?.breed?.size != null) { + var _a; + if (((_a = animal === null || animal === void 0 ? void 0 : animal.breed) === null || _a === void 0 ? void 0 : _a.size) != null) { return animal.breed.size; } else { @@ -37,7 +38,8 @@ function getBreedSizeWithoutFunction(animal) { } } function getBreedSizeWithFunction(animal) { - if (!isNil(animal?.breed?.size)) { + var _a; + if (!isNil((_a = animal === null || animal === void 0 ? void 0 : animal.breed) === null || _a === void 0 ? void 0 : _a.size)) { return animal.breed.size; } else { diff --git a/testdata/baselines/reference/submodule/compiler/typePredicatesOptionalChaining3.js.diff b/testdata/baselines/reference/submodule/compiler/typePredicatesOptionalChaining3.js.diff index f8fb26c634..7e123bd9a0 100644 --- a/testdata/baselines/reference/submodule/compiler/typePredicatesOptionalChaining3.js.diff +++ b/testdata/baselines/reference/submodule/compiler/typePredicatesOptionalChaining3.js.diff @@ -6,19 +6,5 @@ //// [typePredicatesOptionalChaining3.js] -"use strict"; function getBreedSizeWithoutFunction(animal) { -- var _a; -- if (((_a = animal === null || animal === void 0 ? void 0 : animal.breed) === null || _a === void 0 ? void 0 : _a.size) != null) { -+ if (animal?.breed?.size != null) { - return animal.breed.size; - } - else { -@@= skipped -11, +9 lines =@@ - } - } - function getBreedSizeWithFunction(animal) { -- var _a; -- if (!isNil((_a = animal === null || animal === void 0 ? void 0 : animal.breed) === null || _a === void 0 ? void 0 : _a.size)) { -+ if (!isNil(animal?.breed?.size)) { - return animal.breed.size; - } - else { \ No newline at end of file + var _a; + if (((_a = animal === null || animal === void 0 ? void 0 : animal.breed) === null || _a === void 0 ? void 0 : _a.size) != null) { \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/unionOfArraysFilterCall.js b/testdata/baselines/reference/submodule/compiler/unionOfArraysFilterCall.js index 88c5e5ad09..7b145ade4e 100644 --- a/testdata/baselines/reference/submodule/compiler/unionOfArraysFilterCall.js +++ b/testdata/baselines/reference/submodule/compiler/unionOfArraysFilterCall.js @@ -35,4 +35,4 @@ declare function isBuzz(x: unknown): x is Buzz; [].find(isBuzz); [].every(item => item.id < 5); [].reduce(item => item); -[].filter(item => item?.id < 5); +[].filter(item => (item === null || item === void 0 ? void 0 : item.id) < 5); diff --git a/testdata/baselines/reference/submodule/compiler/unionOfArraysFilterCall.js.diff b/testdata/baselines/reference/submodule/compiler/unionOfArraysFilterCall.js.diff deleted file mode 100644 index c5b828a941..0000000000 --- a/testdata/baselines/reference/submodule/compiler/unionOfArraysFilterCall.js.diff +++ /dev/null @@ -1,8 +0,0 @@ ---- old.unionOfArraysFilterCall.js -+++ new.unionOfArraysFilterCall.js -@@= skipped -34, +34 lines =@@ - [].find(isBuzz); - [].every(item => item.id < 5); - [].reduce(item => item); --[].filter(item => (item === null || item === void 0 ? void 0 : item.id) < 5); -+[].filter(item => item?.id < 5); \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/useUnknownInCatchVariables01.js b/testdata/baselines/reference/submodule/compiler/useUnknownInCatchVariables01.js index a7f26d0a93..36005f9332 100644 --- a/testdata/baselines/reference/submodule/compiler/useUnknownInCatchVariables01.js +++ b/testdata/baselines/reference/submodule/compiler/useUnknownInCatchVariables01.js @@ -36,6 +36,7 @@ catch (e: any) { } //// [useUnknownInCatchVariables01.js] +var _a; try { // ... } @@ -50,7 +51,7 @@ catch (e) { console.log(e.toUpperCase()); } if (e instanceof Error) { - e.stack?.toUpperCase(); + (_a = e.stack) === null || _a === void 0 ? void 0 : _a.toUpperCase(); } if (typeof e === "number") { e.toExponential(); diff --git a/testdata/baselines/reference/submodule/compiler/useUnknownInCatchVariables01.js.diff b/testdata/baselines/reference/submodule/compiler/useUnknownInCatchVariables01.js.diff deleted file mode 100644 index dee5b3c578..0000000000 --- a/testdata/baselines/reference/submodule/compiler/useUnknownInCatchVariables01.js.diff +++ /dev/null @@ -1,19 +0,0 @@ ---- old.useUnknownInCatchVariables01.js -+++ new.useUnknownInCatchVariables01.js -@@= skipped -35, +35 lines =@@ - } - - //// [useUnknownInCatchVariables01.js] --var _a; - try { - // ... - } -@@= skipped -15, +14 lines =@@ - console.log(e.toUpperCase()); - } - if (e instanceof Error) { -- (_a = e.stack) === null || _a === void 0 ? void 0 : _a.toUpperCase(); -+ e.stack?.toUpperCase(); - } - if (typeof e === "number") { - e.toExponential(); \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/callChain.2.js b/testdata/baselines/reference/submodule/conformance/callChain.2.js index f296c86d13..1e5985f585 100644 --- a/testdata/baselines/reference/submodule/conformance/callChain.2.js +++ b/testdata/baselines/reference/submodule/conformance/callChain.2.js @@ -12,6 +12,7 @@ o3.b?.().c; //// [callChain.2.js] -o1?.(); -o2?.b(); -o3.b?.().c; +var _a; +o1 === null || o1 === void 0 ? void 0 : o1(); +o2 === null || o2 === void 0 ? void 0 : o2.b(); +(_a = o3.b) === null || _a === void 0 ? void 0 : _a.call(o3).c; diff --git a/testdata/baselines/reference/submodule/conformance/callChain.2.js.diff b/testdata/baselines/reference/submodule/conformance/callChain.2.js.diff deleted file mode 100644 index 9f73bd6ea3..0000000000 --- a/testdata/baselines/reference/submodule/conformance/callChain.2.js.diff +++ /dev/null @@ -1,13 +0,0 @@ ---- old.callChain.2.js -+++ new.callChain.2.js -@@= skipped -11, +11 lines =@@ - - - //// [callChain.2.js] --var _a; --o1 === null || o1 === void 0 ? void 0 : o1(); --o2 === null || o2 === void 0 ? void 0 : o2.b(); --(_a = o3.b) === null || _a === void 0 ? void 0 : _a.call(o3).c; -+o1?.(); -+o2?.b(); -+o3.b?.().c; \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/callChain.3.js b/testdata/baselines/reference/submodule/conformance/callChain.3.js index 4e3ef6fc4f..11db94229c 100644 --- a/testdata/baselines/reference/submodule/conformance/callChain.3.js +++ b/testdata/baselines/reference/submodule/conformance/callChain.3.js @@ -13,10 +13,11 @@ let t1 = a?.m?.({x: 12}); t1 = a!.m!({x: 12}); //// [callChain.3.js] -const n1 = a?.m?.({ x: 12 }); // should be an error (`undefined` is not assignable to `number`) -const n2 = a?.m?.({ x: absorb() }); // likewise -const n3 = a?.m?.({ x: 12 }); // should be ok -const n4 = a?.m?.({ x: absorb() }); // likewise +var _a, _b, _c, _d, _e; +const n1 = (_a = a === null || a === void 0 ? void 0 : a.m) === null || _a === void 0 ? void 0 : _a.call(a, { x: 12 }); // should be an error (`undefined` is not assignable to `number`) +const n2 = (_b = a === null || a === void 0 ? void 0 : a.m) === null || _b === void 0 ? void 0 : _b.call(a, { x: absorb() }); // likewise +const n3 = (_c = a === null || a === void 0 ? void 0 : a.m) === null || _c === void 0 ? void 0 : _c.call(a, { x: 12 }); // should be ok +const n4 = (_d = a === null || a === void 0 ? void 0 : a.m) === null || _d === void 0 ? void 0 : _d.call(a, { x: absorb() }); // likewise // Also a test showing `!` vs `?` for good measure -let t1 = a?.m?.({ x: 12 }); +let t1 = (_e = a === null || a === void 0 ? void 0 : a.m) === null || _e === void 0 ? void 0 : _e.call(a, { x: 12 }); t1 = a.m({ x: 12 }); diff --git a/testdata/baselines/reference/submodule/conformance/callChain.3.js.diff b/testdata/baselines/reference/submodule/conformance/callChain.3.js.diff index f4bc9b997e..d520e1b5e1 100644 --- a/testdata/baselines/reference/submodule/conformance/callChain.3.js.diff +++ b/testdata/baselines/reference/submodule/conformance/callChain.3.js.diff @@ -5,16 +5,6 @@ //// [callChain.3.js] -"use strict"; --var _a, _b, _c, _d, _e; --const n1 = (_a = a === null || a === void 0 ? void 0 : a.m) === null || _a === void 0 ? void 0 : _a.call(a, { x: 12 }); // should be an error (`undefined` is not assignable to `number`) --const n2 = (_b = a === null || a === void 0 ? void 0 : a.m) === null || _b === void 0 ? void 0 : _b.call(a, { x: absorb() }); // likewise --const n3 = (_c = a === null || a === void 0 ? void 0 : a.m) === null || _c === void 0 ? void 0 : _c.call(a, { x: 12 }); // should be ok --const n4 = (_d = a === null || a === void 0 ? void 0 : a.m) === null || _d === void 0 ? void 0 : _d.call(a, { x: absorb() }); // likewise -+const n1 = a?.m?.({ x: 12 }); // should be an error (`undefined` is not assignable to `number`) -+const n2 = a?.m?.({ x: absorb() }); // likewise -+const n3 = a?.m?.({ x: 12 }); // should be ok -+const n4 = a?.m?.({ x: absorb() }); // likewise - // Also a test showing `!` vs `?` for good measure --let t1 = (_e = a === null || a === void 0 ? void 0 : a.m) === null || _e === void 0 ? void 0 : _e.call(a, { x: 12 }); -+let t1 = a?.m?.({ x: 12 }); - t1 = a.m({ x: 12 }); \ No newline at end of file + var _a, _b, _c, _d, _e; + const n1 = (_a = a === null || a === void 0 ? void 0 : a.m) === null || _a === void 0 ? void 0 : _a.call(a, { x: 12 }); // should be an error (`undefined` is not assignable to `number`) + const n2 = (_b = a === null || a === void 0 ? void 0 : a.m) === null || _b === void 0 ? void 0 : _b.call(a, { x: absorb() }); // likewise \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/callChain.js b/testdata/baselines/reference/submodule/conformance/callChain.js index 4e2506895c..b5cd01a145 100644 --- a/testdata/baselines/reference/submodule/conformance/callChain.js +++ b/testdata/baselines/reference/submodule/conformance/callChain.js @@ -44,32 +44,33 @@ o2?.b()!.toString; o2?.b()!.toString!; //// [callChain.js] -o1?.(); -o1?.(1); -o1?.(...[1, 2]); -o1?.(1, ...[2, 3], 4); -o2?.b(); -o2?.b(1); -o2?.b(...[1, 2]); -o2?.b(1, ...[2, 3], 4); -o2?.["b"](); -o2?.["b"](1); -o2?.["b"](...[1, 2]); -o2?.["b"](1, ...[2, 3], 4); -o3.b?.().c; -o3.b?.(1).c; -o3.b?.(...[1, 2]).c; -o3.b?.(1, ...[2, 3], 4).c; -o3.b?.()["c"]; -o3.b?.(1)["c"]; -o3.b?.(...[1, 2])["c"]; -o3.b?.(1, ...[2, 3], 4)["c"]; -o3["b"]?.().c; -o3["b"]?.(1).c; -o3["b"]?.(...[1, 2]).c; -o3["b"]?.(1, ...[2, 3], 4).c; -const v = o4?.(incr); -o5()?.(); +var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o; +o1 === null || o1 === void 0 ? void 0 : o1(); +o1 === null || o1 === void 0 ? void 0 : o1(1); +o1 === null || o1 === void 0 ? void 0 : o1(...[1, 2]); +o1 === null || o1 === void 0 ? void 0 : o1(1, ...[2, 3], 4); +o2 === null || o2 === void 0 ? void 0 : o2.b(); +o2 === null || o2 === void 0 ? void 0 : o2.b(1); +o2 === null || o2 === void 0 ? void 0 : o2.b(...[1, 2]); +o2 === null || o2 === void 0 ? void 0 : o2.b(1, ...[2, 3], 4); +o2 === null || o2 === void 0 ? void 0 : o2["b"](); +o2 === null || o2 === void 0 ? void 0 : o2["b"](1); +o2 === null || o2 === void 0 ? void 0 : o2["b"](...[1, 2]); +o2 === null || o2 === void 0 ? void 0 : o2["b"](1, ...[2, 3], 4); +(_a = o3.b) === null || _a === void 0 ? void 0 : _a.call(o3).c; +(_b = o3.b) === null || _b === void 0 ? void 0 : _b.call(o3, 1).c; +(_c = o3.b) === null || _c === void 0 ? void 0 : _c.call(o3, ...[1, 2]).c; +(_d = o3.b) === null || _d === void 0 ? void 0 : _d.call(o3, 1, ...[2, 3], 4).c; +(_e = o3.b) === null || _e === void 0 ? void 0 : _e.call(o3)["c"]; +(_f = o3.b) === null || _f === void 0 ? void 0 : _f.call(o3, 1)["c"]; +(_g = o3.b) === null || _g === void 0 ? void 0 : _g.call(o3, ...[1, 2])["c"]; +(_h = o3.b) === null || _h === void 0 ? void 0 : _h.call(o3, 1, ...[2, 3], 4)["c"]; +(_j = o3["b"]) === null || _j === void 0 ? void 0 : _j.call(o3).c; +(_k = o3["b"]) === null || _k === void 0 ? void 0 : _k.call(o3, 1).c; +(_l = o3["b"]) === null || _l === void 0 ? void 0 : _l.call(o3, ...[1, 2]).c; +(_m = o3["b"]) === null || _m === void 0 ? void 0 : _m.call(o3, 1, ...[2, 3], 4).c; +const v = o4 === null || o4 === void 0 ? void 0 : o4(incr); +(_o = o5()) === null || _o === void 0 ? void 0 : _o(); // GH#36031 -o2?.b().toString; -o2?.b().toString; +o2 === null || o2 === void 0 ? void 0 : o2.b().toString; +o2 === null || o2 === void 0 ? void 0 : o2.b().toString; diff --git a/testdata/baselines/reference/submodule/conformance/callChain.js.diff b/testdata/baselines/reference/submodule/conformance/callChain.js.diff index f26223dfff..1960941793 100644 --- a/testdata/baselines/reference/submodule/conformance/callChain.js.diff +++ b/testdata/baselines/reference/submodule/conformance/callChain.js.diff @@ -5,61 +5,6 @@ //// [callChain.js] -"use strict"; --var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o; --o1 === null || o1 === void 0 ? void 0 : o1(); --o1 === null || o1 === void 0 ? void 0 : o1(1); --o1 === null || o1 === void 0 ? void 0 : o1(...[1, 2]); --o1 === null || o1 === void 0 ? void 0 : o1(1, ...[2, 3], 4); --o2 === null || o2 === void 0 ? void 0 : o2.b(); --o2 === null || o2 === void 0 ? void 0 : o2.b(1); --o2 === null || o2 === void 0 ? void 0 : o2.b(...[1, 2]); --o2 === null || o2 === void 0 ? void 0 : o2.b(1, ...[2, 3], 4); --o2 === null || o2 === void 0 ? void 0 : o2["b"](); --o2 === null || o2 === void 0 ? void 0 : o2["b"](1); --o2 === null || o2 === void 0 ? void 0 : o2["b"](...[1, 2]); --o2 === null || o2 === void 0 ? void 0 : o2["b"](1, ...[2, 3], 4); --(_a = o3.b) === null || _a === void 0 ? void 0 : _a.call(o3).c; --(_b = o3.b) === null || _b === void 0 ? void 0 : _b.call(o3, 1).c; --(_c = o3.b) === null || _c === void 0 ? void 0 : _c.call(o3, ...[1, 2]).c; --(_d = o3.b) === null || _d === void 0 ? void 0 : _d.call(o3, 1, ...[2, 3], 4).c; --(_e = o3.b) === null || _e === void 0 ? void 0 : _e.call(o3)["c"]; --(_f = o3.b) === null || _f === void 0 ? void 0 : _f.call(o3, 1)["c"]; --(_g = o3.b) === null || _g === void 0 ? void 0 : _g.call(o3, ...[1, 2])["c"]; --(_h = o3.b) === null || _h === void 0 ? void 0 : _h.call(o3, 1, ...[2, 3], 4)["c"]; --(_j = o3["b"]) === null || _j === void 0 ? void 0 : _j.call(o3).c; --(_k = o3["b"]) === null || _k === void 0 ? void 0 : _k.call(o3, 1).c; --(_l = o3["b"]) === null || _l === void 0 ? void 0 : _l.call(o3, ...[1, 2]).c; --(_m = o3["b"]) === null || _m === void 0 ? void 0 : _m.call(o3, 1, ...[2, 3], 4).c; --const v = o4 === null || o4 === void 0 ? void 0 : o4(incr); --(_o = o5()) === null || _o === void 0 ? void 0 : _o(); -+o1?.(); -+o1?.(1); -+o1?.(...[1, 2]); -+o1?.(1, ...[2, 3], 4); -+o2?.b(); -+o2?.b(1); -+o2?.b(...[1, 2]); -+o2?.b(1, ...[2, 3], 4); -+o2?.["b"](); -+o2?.["b"](1); -+o2?.["b"](...[1, 2]); -+o2?.["b"](1, ...[2, 3], 4); -+o3.b?.().c; -+o3.b?.(1).c; -+o3.b?.(...[1, 2]).c; -+o3.b?.(1, ...[2, 3], 4).c; -+o3.b?.()["c"]; -+o3.b?.(1)["c"]; -+o3.b?.(...[1, 2])["c"]; -+o3.b?.(1, ...[2, 3], 4)["c"]; -+o3["b"]?.().c; -+o3["b"]?.(1).c; -+o3["b"]?.(...[1, 2]).c; -+o3["b"]?.(1, ...[2, 3], 4).c; -+const v = o4?.(incr); -+o5()?.(); - // GH#36031 --o2 === null || o2 === void 0 ? void 0 : o2.b().toString; --o2 === null || o2 === void 0 ? void 0 : o2.b().toString; -+o2?.b().toString; -+o2?.b().toString; \ No newline at end of file + var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o; + o1 === null || o1 === void 0 ? void 0 : o1(); + o1 === null || o1 === void 0 ? void 0 : o1(1); \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/callChainInference.js b/testdata/baselines/reference/submodule/conformance/callChainInference.js index 7cd577c5af..28f6ee7041 100644 --- a/testdata/baselines/reference/submodule/conformance/callChainInference.js +++ b/testdata/baselines/reference/submodule/conformance/callChainInference.js @@ -20,6 +20,6 @@ value?.foo("a"); //// [callChainInference.js] if (value) { - value?.foo("a"); + value === null || value === void 0 ? void 0 : value.foo("a"); } -value?.foo("a"); +value === null || value === void 0 ? void 0 : value.foo("a"); diff --git a/testdata/baselines/reference/submodule/conformance/callChainInference.js.diff b/testdata/baselines/reference/submodule/conformance/callChainInference.js.diff index ca02e9d5db..3fada13de0 100644 --- a/testdata/baselines/reference/submodule/conformance/callChainInference.js.diff +++ b/testdata/baselines/reference/submodule/conformance/callChainInference.js.diff @@ -7,8 +7,5 @@ -"use strict"; -// Repro from #42404 if (value) { -- value === null || value === void 0 ? void 0 : value.foo("a"); -+ value?.foo("a"); - } --value === null || value === void 0 ? void 0 : value.foo("a"); -+value?.foo("a"); \ No newline at end of file + value === null || value === void 0 ? void 0 : value.foo("a"); + } \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/callChainWithSuper(target=es2016).js b/testdata/baselines/reference/submodule/conformance/callChainWithSuper(target=es2016).js index 425949dba5..82a8454e77 100644 --- a/testdata/baselines/reference/submodule/conformance/callChainWithSuper(target=es2016).js +++ b/testdata/baselines/reference/submodule/conformance/callChainWithSuper(target=es2016).js @@ -14,6 +14,6 @@ class Base { method() { } } class Derived extends Base { - method1() { return super.method?.(); } - method2() { return super["method"]?.(); } + method1() { var _a; return (_a = super.method) === null || _a === void 0 ? void 0 : _a.call(this); } + method2() { var _a; return (_a = super["method"]) === null || _a === void 0 ? void 0 : _a.call(this); } } diff --git a/testdata/baselines/reference/submodule/conformance/callChainWithSuper(target=es2016).js.diff b/testdata/baselines/reference/submodule/conformance/callChainWithSuper(target=es2016).js.diff index d91db1d4ca..d0c5739631 100644 --- a/testdata/baselines/reference/submodule/conformance/callChainWithSuper(target=es2016).js.diff +++ b/testdata/baselines/reference/submodule/conformance/callChainWithSuper(target=es2016).js.diff @@ -7,11 +7,4 @@ -"use strict"; // GH#34952 class Base { - method() { } - } - class Derived extends Base { -- method1() { var _a; return (_a = super.method) === null || _a === void 0 ? void 0 : _a.call(this); } -- method2() { var _a; return (_a = super["method"]) === null || _a === void 0 ? void 0 : _a.call(this); } -+ method1() { return super.method?.(); } -+ method2() { return super["method"]?.(); } - } \ No newline at end of file + method() { } \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/callChainWithSuper(target=es2017).js b/testdata/baselines/reference/submodule/conformance/callChainWithSuper(target=es2017).js index 425949dba5..82a8454e77 100644 --- a/testdata/baselines/reference/submodule/conformance/callChainWithSuper(target=es2017).js +++ b/testdata/baselines/reference/submodule/conformance/callChainWithSuper(target=es2017).js @@ -14,6 +14,6 @@ class Base { method() { } } class Derived extends Base { - method1() { return super.method?.(); } - method2() { return super["method"]?.(); } + method1() { var _a; return (_a = super.method) === null || _a === void 0 ? void 0 : _a.call(this); } + method2() { var _a; return (_a = super["method"]) === null || _a === void 0 ? void 0 : _a.call(this); } } diff --git a/testdata/baselines/reference/submodule/conformance/callChainWithSuper(target=es2017).js.diff b/testdata/baselines/reference/submodule/conformance/callChainWithSuper(target=es2017).js.diff index 0ad867bb10..5be2b1eca8 100644 --- a/testdata/baselines/reference/submodule/conformance/callChainWithSuper(target=es2017).js.diff +++ b/testdata/baselines/reference/submodule/conformance/callChainWithSuper(target=es2017).js.diff @@ -7,11 +7,4 @@ -"use strict"; // GH#34952 class Base { - method() { } - } - class Derived extends Base { -- method1() { var _a; return (_a = super.method) === null || _a === void 0 ? void 0 : _a.call(this); } -- method2() { var _a; return (_a = super["method"]) === null || _a === void 0 ? void 0 : _a.call(this); } -+ method1() { return super.method?.(); } -+ method2() { return super["method"]?.(); } - } \ No newline at end of file + method() { } \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/callChainWithSuper(target=es2018).js b/testdata/baselines/reference/submodule/conformance/callChainWithSuper(target=es2018).js index 425949dba5..82a8454e77 100644 --- a/testdata/baselines/reference/submodule/conformance/callChainWithSuper(target=es2018).js +++ b/testdata/baselines/reference/submodule/conformance/callChainWithSuper(target=es2018).js @@ -14,6 +14,6 @@ class Base { method() { } } class Derived extends Base { - method1() { return super.method?.(); } - method2() { return super["method"]?.(); } + method1() { var _a; return (_a = super.method) === null || _a === void 0 ? void 0 : _a.call(this); } + method2() { var _a; return (_a = super["method"]) === null || _a === void 0 ? void 0 : _a.call(this); } } diff --git a/testdata/baselines/reference/submodule/conformance/callChainWithSuper(target=es2018).js.diff b/testdata/baselines/reference/submodule/conformance/callChainWithSuper(target=es2018).js.diff index 6e6aceb6cf..7aab1f49b8 100644 --- a/testdata/baselines/reference/submodule/conformance/callChainWithSuper(target=es2018).js.diff +++ b/testdata/baselines/reference/submodule/conformance/callChainWithSuper(target=es2018).js.diff @@ -7,11 +7,4 @@ -"use strict"; // GH#34952 class Base { - method() { } - } - class Derived extends Base { -- method1() { var _a; return (_a = super.method) === null || _a === void 0 ? void 0 : _a.call(this); } -- method2() { var _a; return (_a = super["method"]) === null || _a === void 0 ? void 0 : _a.call(this); } -+ method1() { return super.method?.(); } -+ method2() { return super["method"]?.(); } - } \ No newline at end of file + method() { } \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/callChainWithSuper(target=es2019).js b/testdata/baselines/reference/submodule/conformance/callChainWithSuper(target=es2019).js index 425949dba5..82a8454e77 100644 --- a/testdata/baselines/reference/submodule/conformance/callChainWithSuper(target=es2019).js +++ b/testdata/baselines/reference/submodule/conformance/callChainWithSuper(target=es2019).js @@ -14,6 +14,6 @@ class Base { method() { } } class Derived extends Base { - method1() { return super.method?.(); } - method2() { return super["method"]?.(); } + method1() { var _a; return (_a = super.method) === null || _a === void 0 ? void 0 : _a.call(this); } + method2() { var _a; return (_a = super["method"]) === null || _a === void 0 ? void 0 : _a.call(this); } } diff --git a/testdata/baselines/reference/submodule/conformance/callChainWithSuper(target=es2019).js.diff b/testdata/baselines/reference/submodule/conformance/callChainWithSuper(target=es2019).js.diff index 2560d68c78..1c507c6c1c 100644 --- a/testdata/baselines/reference/submodule/conformance/callChainWithSuper(target=es2019).js.diff +++ b/testdata/baselines/reference/submodule/conformance/callChainWithSuper(target=es2019).js.diff @@ -7,11 +7,4 @@ -"use strict"; // GH#34952 class Base { - method() { } - } - class Derived extends Base { -- method1() { var _a; return (_a = super.method) === null || _a === void 0 ? void 0 : _a.call(this); } -- method2() { var _a; return (_a = super["method"]) === null || _a === void 0 ? void 0 : _a.call(this); } -+ method1() { return super.method?.(); } -+ method2() { return super["method"]?.(); } - } \ No newline at end of file + method() { } \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/callChainWithSuper(target=es5).js b/testdata/baselines/reference/submodule/conformance/callChainWithSuper(target=es5).js index 425949dba5..82a8454e77 100644 --- a/testdata/baselines/reference/submodule/conformance/callChainWithSuper(target=es5).js +++ b/testdata/baselines/reference/submodule/conformance/callChainWithSuper(target=es5).js @@ -14,6 +14,6 @@ class Base { method() { } } class Derived extends Base { - method1() { return super.method?.(); } - method2() { return super["method"]?.(); } + method1() { var _a; return (_a = super.method) === null || _a === void 0 ? void 0 : _a.call(this); } + method2() { var _a; return (_a = super["method"]) === null || _a === void 0 ? void 0 : _a.call(this); } } diff --git a/testdata/baselines/reference/submodule/conformance/callChainWithSuper(target=es5).js.diff b/testdata/baselines/reference/submodule/conformance/callChainWithSuper(target=es5).js.diff index dabfdb5b51..07cd4d69f6 100644 --- a/testdata/baselines/reference/submodule/conformance/callChainWithSuper(target=es5).js.diff +++ b/testdata/baselines/reference/submodule/conformance/callChainWithSuper(target=es5).js.diff @@ -7,11 +7,4 @@ -"use strict"; // GH#34952 class Base { - method() { } - } - class Derived extends Base { -- method1() { var _a; return (_a = super.method) === null || _a === void 0 ? void 0 : _a.call(this); } -- method2() { var _a; return (_a = super["method"]) === null || _a === void 0 ? void 0 : _a.call(this); } -+ method1() { return super.method?.(); } -+ method2() { return super["method"]?.(); } - } \ No newline at end of file + method() { } \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/callChainWithSuper(target=es6).js b/testdata/baselines/reference/submodule/conformance/callChainWithSuper(target=es6).js index 425949dba5..82a8454e77 100644 --- a/testdata/baselines/reference/submodule/conformance/callChainWithSuper(target=es6).js +++ b/testdata/baselines/reference/submodule/conformance/callChainWithSuper(target=es6).js @@ -14,6 +14,6 @@ class Base { method() { } } class Derived extends Base { - method1() { return super.method?.(); } - method2() { return super["method"]?.(); } + method1() { var _a; return (_a = super.method) === null || _a === void 0 ? void 0 : _a.call(this); } + method2() { var _a; return (_a = super["method"]) === null || _a === void 0 ? void 0 : _a.call(this); } } diff --git a/testdata/baselines/reference/submodule/conformance/callChainWithSuper(target=es6).js.diff b/testdata/baselines/reference/submodule/conformance/callChainWithSuper(target=es6).js.diff index 03ecdc8d96..222128348a 100644 --- a/testdata/baselines/reference/submodule/conformance/callChainWithSuper(target=es6).js.diff +++ b/testdata/baselines/reference/submodule/conformance/callChainWithSuper(target=es6).js.diff @@ -7,11 +7,4 @@ -"use strict"; // GH#34952 class Base { - method() { } - } - class Derived extends Base { -- method1() { var _a; return (_a = super.method) === null || _a === void 0 ? void 0 : _a.call(this); } -- method2() { var _a; return (_a = super["method"]) === null || _a === void 0 ? void 0 : _a.call(this); } -+ method1() { return super.method?.(); } -+ method2() { return super["method"]?.(); } - } \ No newline at end of file + method() { } \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/classExtendingOptionalChain.js b/testdata/baselines/reference/submodule/conformance/classExtendingOptionalChain.js index 4083ed6850..3746951fea 100644 --- a/testdata/baselines/reference/submodule/conformance/classExtendingOptionalChain.js +++ b/testdata/baselines/reference/submodule/conformance/classExtendingOptionalChain.js @@ -20,7 +20,7 @@ var A; A.B = B; })(A || (A = {})); // ok -class C1 extends (A?.B) { +class C1 extends (A === null || A === void 0 ? void 0 : A.B) { } // error class C2 { diff --git a/testdata/baselines/reference/submodule/conformance/classExtendingOptionalChain.js.diff b/testdata/baselines/reference/submodule/conformance/classExtendingOptionalChain.js.diff deleted file mode 100644 index 2ea36bf474..0000000000 --- a/testdata/baselines/reference/submodule/conformance/classExtendingOptionalChain.js.diff +++ /dev/null @@ -1,11 +0,0 @@ ---- old.classExtendingOptionalChain.js -+++ new.classExtendingOptionalChain.js -@@= skipped -19, +19 lines =@@ - A.B = B; - })(A || (A = {})); - // ok --class C1 extends (A === null || A === void 0 ? void 0 : A.B) { -+class C1 extends (A?.B) { - } - // error - class C2 { \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/controlFlowOptionalChain.js b/testdata/baselines/reference/submodule/conformance/controlFlowOptionalChain.js index 6b536b047a..4748544be2 100644 --- a/testdata/baselines/reference/submodule/conformance/controlFlowOptionalChain.js +++ b/testdata/baselines/reference/submodule/conformance/controlFlowOptionalChain.js @@ -610,19 +610,20 @@ function f50(obj: Test5) { } //// [controlFlowOptionalChain.js] +var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v; let a; -o?.[a = 1]; +o === null || o === void 0 ? void 0 : o[a = 1]; a.toString(); let b; -o?.x[b = 1]; +o === null || o === void 0 ? void 0 : o.x[b = 1]; b.toString(); let c; -o?.(c = 1); +o === null || o === void 0 ? void 0 : o(c = 1); c.toString(); let d; -o?.x(d = 1); +o === null || o === void 0 ? void 0 : o.x(d = 1); d.toString(); -if (f?.(x)) { +if (f === null || f === void 0 ? void 0 : f(x)) { x; // number f; // (x: any) => x is number f(x); @@ -635,253 +636,253 @@ else { x; f; f(x); -if (o2?.f(x)) { +if (o2 === null || o2 === void 0 ? void 0 : o2.f(x)) { x; // number o2.f; // (x: any) => x is number - o2?.f; - o2?.f(x); + o2 === null || o2 === void 0 ? void 0 : o2.f; + o2 === null || o2 === void 0 ? void 0 : o2.f(x); } else { x; o2; - o2?.f; + o2 === null || o2 === void 0 ? void 0 : o2.f; o2.f; } x; o2; -o2?.f; +o2 === null || o2 === void 0 ? void 0 : o2.f; o2.f; -if (o3?.x === 1) { +if ((o3 === null || o3 === void 0 ? void 0 : o3.x) === 1) { o3; o3.x; - o3?.x; + o3 === null || o3 === void 0 ? void 0 : o3.x; } else { o3; - o3?.x; + o3 === null || o3 === void 0 ? void 0 : o3.x; o3.x; } o3; -o3?.x; +o3 === null || o3 === void 0 ? void 0 : o3.x; o3.x; -if (o4.x?.y) { +if ((_a = o4.x) === null || _a === void 0 ? void 0 : _a.y) { o4.x; // { y: boolean } o4.x.y; // true - o4.x?.y; // true + (_b = o4.x) === null || _b === void 0 ? void 0 : _b.y; // true } else { o4.x; - o4.x?.y; + (_c = o4.x) === null || _c === void 0 ? void 0 : _c.y; o4.x.y; } o4.x; -o4.x?.y; +(_d = o4.x) === null || _d === void 0 ? void 0 : _d.y; o4.x.y; -if (o5.x?.y.z?.w) { +if ((_f = (_e = o5.x) === null || _e === void 0 ? void 0 : _e.y.z) === null || _f === void 0 ? void 0 : _f.w) { o5.x; o5.x.y; o5.x.y.z; o5.x.y.z.w; // true - o5.x.y.z?.w; // true - o5.x?.y.z.w; // true - o5.x?.y.z?.w; // true + (_g = o5.x.y.z) === null || _g === void 0 ? void 0 : _g.w; // true + (_h = o5.x) === null || _h === void 0 ? void 0 : _h.y.z.w; // true + (_k = (_j = o5.x) === null || _j === void 0 ? void 0 : _j.y.z) === null || _k === void 0 ? void 0 : _k.w; // true } else { o5.x; - o5.x?.y; - o5.x?.y.z; - o5.x?.y.z?.w; + (_l = o5.x) === null || _l === void 0 ? void 0 : _l.y; + (_m = o5.x) === null || _m === void 0 ? void 0 : _m.y.z; + (_p = (_o = o5.x) === null || _o === void 0 ? void 0 : _o.y.z) === null || _p === void 0 ? void 0 : _p.w; o5.x.y; o5.x.y.z.w; } o5.x; -o5.x?.y; -o5.x?.y.z; -o5.x?.y.z?.w; +(_q = o5.x) === null || _q === void 0 ? void 0 : _q.y; +(_r = o5.x) === null || _r === void 0 ? void 0 : _r.y.z; +(_t = (_s = o5.x) === null || _s === void 0 ? void 0 : _s.y.z) === null || _t === void 0 ? void 0 : _t.w; o5.x.y; o5.x.y.z.w; -if (o6?.f()) { +if (o6 === null || o6 === void 0 ? void 0 : o6.f()) { o6; // Derived o6.f; } else { o6; - o6?.f; + o6 === null || o6 === void 0 ? void 0 : o6.f; o6.f; } o6; -o6?.f; +o6 === null || o6 === void 0 ? void 0 : o6.f; o6.f; function f01(x) { if (!!true) { - isString?.(x); + isString === null || isString === void 0 ? void 0 : isString(x); x; } if (!!true) { - maybeIsString?.(x); + maybeIsString === null || maybeIsString === void 0 ? void 0 : maybeIsString(x); x; } if (!!true) { isDefined(maybeIsString); - maybeIsString?.(x); + maybeIsString === null || maybeIsString === void 0 ? void 0 : maybeIsString(x); x; } if (!!true) { - maybeNever?.(); + maybeNever === null || maybeNever === void 0 ? void 0 : maybeNever(); x; } } function f10(o, value) { - if (o?.foo === value) { + if ((o === null || o === void 0 ? void 0 : o.foo) === value) { o.foo; } - if (o?.["foo"] === value) { + if ((o === null || o === void 0 ? void 0 : o["foo"]) === value) { o["foo"]; } - if (o?.bar() === value) { + if ((o === null || o === void 0 ? void 0 : o.bar()) === value) { o.bar; } - if (o?.foo == value) { + if ((o === null || o === void 0 ? void 0 : o.foo) == value) { o.foo; } - if (o?.["foo"] == value) { + if ((o === null || o === void 0 ? void 0 : o["foo"]) == value) { o["foo"]; } - if (o?.bar() == value) { + if ((o === null || o === void 0 ? void 0 : o.bar()) == value) { o.bar; } } function f11(o, value) { - if (o?.foo === value) { + if ((o === null || o === void 0 ? void 0 : o.foo) === value) { o.foo; } - if (o?.["foo"] === value) { + if ((o === null || o === void 0 ? void 0 : o["foo"]) === value) { o["foo"]; } - if (o?.bar() === value) { + if ((o === null || o === void 0 ? void 0 : o.bar()) === value) { o.bar; } - if (o?.foo == value) { + if ((o === null || o === void 0 ? void 0 : o.foo) == value) { o.foo; } - if (o?.["foo"] == value) { + if ((o === null || o === void 0 ? void 0 : o["foo"]) == value) { o["foo"]; } - if (o?.bar() == value) { + if ((o === null || o === void 0 ? void 0 : o.bar()) == value) { o.bar; } } function f12(o, value) { - if (o?.foo === value) { + if ((o === null || o === void 0 ? void 0 : o.foo) === value) { o.foo; // Error } - if (o?.["foo"] === value) { + if ((o === null || o === void 0 ? void 0 : o["foo"]) === value) { o["foo"]; // Error } - if (o?.bar() === value) { + if ((o === null || o === void 0 ? void 0 : o.bar()) === value) { o.bar; // Error } - if (o?.foo == value) { + if ((o === null || o === void 0 ? void 0 : o.foo) == value) { o.foo; // Error } - if (o?.["foo"] == value) { + if ((o === null || o === void 0 ? void 0 : o["foo"]) == value) { o["foo"]; // Error } - if (o?.bar() == value) { + if ((o === null || o === void 0 ? void 0 : o.bar()) == value) { o.bar; // Error } } function f12a(o, value) { - if (o?.foo === value) { + if ((o === null || o === void 0 ? void 0 : o.foo) === value) { o.foo; } - if (o?.["foo"] === value) { + if ((o === null || o === void 0 ? void 0 : o["foo"]) === value) { o["foo"]; } - if (o?.bar() === value) { + if ((o === null || o === void 0 ? void 0 : o.bar()) === value) { o.bar; } - if (o?.foo == value) { + if ((o === null || o === void 0 ? void 0 : o.foo) == value) { o.foo; // Error } - if (o?.["foo"] == value) { + if ((o === null || o === void 0 ? void 0 : o["foo"]) == value) { o["foo"]; // Error } - if (o?.bar() == value) { + if ((o === null || o === void 0 ? void 0 : o.bar()) == value) { o.bar; // Error } } function f13(o) { - if (o?.foo !== undefined) { + if ((o === null || o === void 0 ? void 0 : o.foo) !== undefined) { o.foo; } - if (o?.["foo"] !== undefined) { + if ((o === null || o === void 0 ? void 0 : o["foo"]) !== undefined) { o["foo"]; } - if (o?.bar() !== undefined) { + if ((o === null || o === void 0 ? void 0 : o.bar()) !== undefined) { o.bar; } - if (o?.foo != undefined) { + if ((o === null || o === void 0 ? void 0 : o.foo) != undefined) { o.foo; } - if (o?.["foo"] != undefined) { + if ((o === null || o === void 0 ? void 0 : o["foo"]) != undefined) { o["foo"]; } - if (o?.bar() != undefined) { + if ((o === null || o === void 0 ? void 0 : o.bar()) != undefined) { o.bar; } } function f13a(o) { - if (o?.foo !== null) { + if ((o === null || o === void 0 ? void 0 : o.foo) !== null) { o.foo; // Error } - if (o?.["foo"] !== null) { + if ((o === null || o === void 0 ? void 0 : o["foo"]) !== null) { o["foo"]; // Error } - if (o?.bar() !== null) { + if ((o === null || o === void 0 ? void 0 : o.bar()) !== null) { o.bar; // Error } - if (o?.foo != null) { + if ((o === null || o === void 0 ? void 0 : o.foo) != null) { o.foo; } - if (o?.["foo"] != null) { + if ((o === null || o === void 0 ? void 0 : o["foo"]) != null) { o["foo"]; } - if (o?.bar() != null) { + if ((o === null || o === void 0 ? void 0 : o.bar()) != null) { o.bar; } } function f14(o) { - if (o?.foo !== undefined) { + if ((o === null || o === void 0 ? void 0 : o.foo) !== undefined) { o.foo; } - if (o?.["foo"] !== undefined) { + if ((o === null || o === void 0 ? void 0 : o["foo"]) !== undefined) { o["foo"]; } - if (o?.bar() !== undefined) { + if ((o === null || o === void 0 ? void 0 : o.bar()) !== undefined) { o.bar; } } function f15(o, value) { - if (o?.foo === value) { + if ((o === null || o === void 0 ? void 0 : o.foo) === value) { o.foo; } else { o.foo; // Error } - if (o?.foo !== value) { + if ((o === null || o === void 0 ? void 0 : o.foo) !== value) { o.foo; // Error } else { o.foo; } - if (o?.foo == value) { + if ((o === null || o === void 0 ? void 0 : o.foo) == value) { o.foo; } else { o.foo; // Error } - if (o?.foo != value) { + if ((o === null || o === void 0 ? void 0 : o.foo) != value) { o.foo; // Error } else { @@ -889,25 +890,25 @@ function f15(o, value) { } } function f15a(o, value) { - if (o?.foo === value) { + if ((o === null || o === void 0 ? void 0 : o.foo) === value) { o.foo; // Error } else { o.foo; // Error } - if (o?.foo !== value) { + if ((o === null || o === void 0 ? void 0 : o.foo) !== value) { o.foo; // Error } else { o.foo; // Error } - if (o?.foo == value) { + if ((o === null || o === void 0 ? void 0 : o.foo) == value) { o.foo; // Error } else { o.foo; // Error } - if (o?.foo != value) { + if ((o === null || o === void 0 ? void 0 : o.foo) != value) { o.foo; // Error } else { @@ -915,25 +916,25 @@ function f15a(o, value) { } } function f16(o) { - if (o?.foo === undefined) { + if ((o === null || o === void 0 ? void 0 : o.foo) === undefined) { o.foo; // Error } else { o.foo; } - if (o?.foo !== undefined) { + if ((o === null || o === void 0 ? void 0 : o.foo) !== undefined) { o.foo; } else { o.foo; // Error } - if (o?.foo == undefined) { + if ((o === null || o === void 0 ? void 0 : o.foo) == undefined) { o.foo; // Error } else { o.foo; } - if (o?.foo != undefined) { + if ((o === null || o === void 0 ? void 0 : o.foo) != undefined) { o.foo; } else { @@ -941,53 +942,53 @@ function f16(o) { } } function f20(o) { - if (typeof o?.foo === "number") { + if (typeof (o === null || o === void 0 ? void 0 : o.foo) === "number") { o.foo; } - if (typeof o?.["foo"] === "number") { + if (typeof (o === null || o === void 0 ? void 0 : o["foo"]) === "number") { o["foo"]; } - if (typeof o?.bar() === "number") { + if (typeof (o === null || o === void 0 ? void 0 : o.bar()) === "number") { o.bar; } - if (o?.baz instanceof Error) { + if ((o === null || o === void 0 ? void 0 : o.baz) instanceof Error) { o.baz; } } function f21(o) { - if (typeof o?.foo === "number") { + if (typeof (o === null || o === void 0 ? void 0 : o.foo) === "number") { o.foo; } - if (typeof o?.["foo"] === "number") { + if (typeof (o === null || o === void 0 ? void 0 : o["foo"]) === "number") { o["foo"]; } - if (typeof o?.bar() === "number") { + if (typeof (o === null || o === void 0 ? void 0 : o.bar()) === "number") { o.bar; } - if (o?.baz instanceof Error) { + if ((o === null || o === void 0 ? void 0 : o.baz) instanceof Error) { o.baz; } } function f22(o) { - if (typeof o?.foo === "number") { + if (typeof (o === null || o === void 0 ? void 0 : o.foo) === "number") { o.foo; } else { o.foo; // Error } - if (typeof o?.foo !== "number") { + if (typeof (o === null || o === void 0 ? void 0 : o.foo) !== "number") { o.foo; // Error } else { o.foo; } - if (typeof o?.foo == "number") { + if (typeof (o === null || o === void 0 ? void 0 : o.foo) == "number") { o.foo; } else { o.foo; // Error } - if (typeof o?.foo != "number") { + if (typeof (o === null || o === void 0 ? void 0 : o.foo) != "number") { o.foo; // Error } else { @@ -995,25 +996,25 @@ function f22(o) { } } function f23(o) { - if (typeof o?.foo === "undefined") { + if (typeof (o === null || o === void 0 ? void 0 : o.foo) === "undefined") { o.foo; // Error } else { o.foo; } - if (typeof o?.foo !== "undefined") { + if (typeof (o === null || o === void 0 ? void 0 : o.foo) !== "undefined") { o.foo; } else { o.foo; // Error } - if (typeof o?.foo == "undefined") { + if (typeof (o === null || o === void 0 ? void 0 : o.foo) == "undefined") { o.foo; // Error } else { o.foo; } - if (typeof o?.foo != "undefined") { + if (typeof (o === null || o === void 0 ? void 0 : o.foo) != "undefined") { o.foo; } else { @@ -1022,24 +1023,24 @@ function f23(o) { } function f30(o) { if (!!true) { - assert(o?.foo); + assert(o === null || o === void 0 ? void 0 : o.foo); o.foo; } if (!!true) { - assert(o?.foo === 42); + assert((o === null || o === void 0 ? void 0 : o.foo) === 42); o.foo; } if (!!true) { - assert(typeof o?.foo === "number"); + assert(typeof (o === null || o === void 0 ? void 0 : o.foo) === "number"); o.foo; } if (!!true) { - assertNonNull(o?.foo); + assertNonNull(o === null || o === void 0 ? void 0 : o.foo); o.foo; } } function f40(o) { - switch (o?.foo) { + switch (o === null || o === void 0 ? void 0 : o.foo) { case "abc": o.foo; break; @@ -1055,7 +1056,7 @@ function f40(o) { } } function f41(o) { - switch (typeof o?.foo) { + switch (typeof (o === null || o === void 0 ? void 0 : o.foo)) { case "string": o.foo; break; @@ -1071,7 +1072,7 @@ function f41(o) { } } function getArea(shape) { - switch (shape?.type) { + switch (shape === null || shape === void 0 ? void 0 : shape.type) { case 'circle': return Math.PI * Math.pow(shape.radius, 2); case 'rectangle': @@ -1081,17 +1082,18 @@ function getArea(shape) { } } function extractCoordinates(f) { - if (f.geometry?.type !== 'test') { + var _a; + if (((_a = f.geometry) === null || _a === void 0 ? void 0 : _a.type) !== 'test') { return []; } return f.geometry.coordinates; } let lastSomeProperty; function someFunction(someOptionalObject) { - if (someOptionalObject?.someProperty !== lastSomeProperty) { + if ((someOptionalObject === null || someOptionalObject === void 0 ? void 0 : someOptionalObject.someProperty) !== lastSomeProperty) { console.log(someOptionalObject); console.log(someOptionalObject.someProperty); // Error - lastSomeProperty = someOptionalObject?.someProperty; + lastSomeProperty = someOptionalObject === null || someOptionalObject === void 0 ? void 0 : someOptionalObject.someProperty; } } const someObject = { @@ -1101,14 +1103,15 @@ someFunction(someObject); someFunction(undefined); // Repro from #35970 let i = 0; -while (arr[i]?.tag === "left") { +while (((_u = arr[i]) === null || _u === void 0 ? void 0 : _u.tag) === "left") { i += 1; - if (arr[i]?.tag === "right") { + if (((_v = arr[i]) === null || _v === void 0 ? void 0 : _v.tag) === "right") { console.log("I should ALSO be reachable"); } } function f50(obj) { - for (const key in obj.main?.childs) { + var _a; + for (const key in (_a = obj.main) === null || _a === void 0 ? void 0 : _a.childs) { if (obj.main.childs[key] === obj) { return obj; } diff --git a/testdata/baselines/reference/submodule/conformance/controlFlowOptionalChain.js.diff b/testdata/baselines/reference/submodule/conformance/controlFlowOptionalChain.js.diff index c9253999ef..1023f88382 100644 --- a/testdata/baselines/reference/submodule/conformance/controlFlowOptionalChain.js.diff +++ b/testdata/baselines/reference/submodule/conformance/controlFlowOptionalChain.js.diff @@ -5,681 +5,6 @@ //// [controlFlowOptionalChain.js] -"use strict"; --var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v; + var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v; let a; --o === null || o === void 0 ? void 0 : o[a = 1]; -+o?.[a = 1]; - a.toString(); - let b; --o === null || o === void 0 ? void 0 : o.x[b = 1]; -+o?.x[b = 1]; - b.toString(); - let c; --o === null || o === void 0 ? void 0 : o(c = 1); -+o?.(c = 1); - c.toString(); - let d; --o === null || o === void 0 ? void 0 : o.x(d = 1); -+o?.x(d = 1); - d.toString(); --if (f === null || f === void 0 ? void 0 : f(x)) { -+if (f?.(x)) { - x; // number - f; // (x: any) => x is number - f(x); -@@= skipped -27, +25 lines =@@ - x; - f; - f(x); --if (o2 === null || o2 === void 0 ? void 0 : o2.f(x)) { -+if (o2?.f(x)) { - x; // number - o2.f; // (x: any) => x is number -- o2 === null || o2 === void 0 ? void 0 : o2.f; -- o2 === null || o2 === void 0 ? void 0 : o2.f(x); -+ o2?.f; -+ o2?.f(x); - } - else { - x; - o2; -- o2 === null || o2 === void 0 ? void 0 : o2.f; -+ o2?.f; - o2.f; - } - x; - o2; --o2 === null || o2 === void 0 ? void 0 : o2.f; -+o2?.f; - o2.f; --if ((o3 === null || o3 === void 0 ? void 0 : o3.x) === 1) { -+if (o3?.x === 1) { - o3; - o3.x; -- o3 === null || o3 === void 0 ? void 0 : o3.x; -+ o3?.x; - } - else { - o3; -- o3 === null || o3 === void 0 ? void 0 : o3.x; -+ o3?.x; - o3.x; - } - o3; --o3 === null || o3 === void 0 ? void 0 : o3.x; -+o3?.x; - o3.x; --if ((_a = o4.x) === null || _a === void 0 ? void 0 : _a.y) { -+if (o4.x?.y) { - o4.x; // { y: boolean } - o4.x.y; // true -- (_b = o4.x) === null || _b === void 0 ? void 0 : _b.y; // true -+ o4.x?.y; // true - } - else { - o4.x; -- (_c = o4.x) === null || _c === void 0 ? void 0 : _c.y; -+ o4.x?.y; - o4.x.y; - } - o4.x; --(_d = o4.x) === null || _d === void 0 ? void 0 : _d.y; -+o4.x?.y; - o4.x.y; --if ((_f = (_e = o5.x) === null || _e === void 0 ? void 0 : _e.y.z) === null || _f === void 0 ? void 0 : _f.w) { -+if (o5.x?.y.z?.w) { - o5.x; - o5.x.y; - o5.x.y.z; - o5.x.y.z.w; // true -- (_g = o5.x.y.z) === null || _g === void 0 ? void 0 : _g.w; // true -- (_h = o5.x) === null || _h === void 0 ? void 0 : _h.y.z.w; // true -- (_k = (_j = o5.x) === null || _j === void 0 ? void 0 : _j.y.z) === null || _k === void 0 ? void 0 : _k.w; // true -+ o5.x.y.z?.w; // true -+ o5.x?.y.z.w; // true -+ o5.x?.y.z?.w; // true - } - else { - o5.x; -- (_l = o5.x) === null || _l === void 0 ? void 0 : _l.y; -- (_m = o5.x) === null || _m === void 0 ? void 0 : _m.y.z; -- (_p = (_o = o5.x) === null || _o === void 0 ? void 0 : _o.y.z) === null || _p === void 0 ? void 0 : _p.w; -+ o5.x?.y; -+ o5.x?.y.z; -+ o5.x?.y.z?.w; - o5.x.y; - o5.x.y.z.w; - } - o5.x; --(_q = o5.x) === null || _q === void 0 ? void 0 : _q.y; --(_r = o5.x) === null || _r === void 0 ? void 0 : _r.y.z; --(_t = (_s = o5.x) === null || _s === void 0 ? void 0 : _s.y.z) === null || _t === void 0 ? void 0 : _t.w; -+o5.x?.y; -+o5.x?.y.z; -+o5.x?.y.z?.w; - o5.x.y; - o5.x.y.z.w; --if (o6 === null || o6 === void 0 ? void 0 : o6.f()) { -+if (o6?.f()) { - o6; // Derived - o6.f; - } - else { - o6; -- o6 === null || o6 === void 0 ? void 0 : o6.f; -+ o6?.f; - o6.f; - } - o6; --o6 === null || o6 === void 0 ? void 0 : o6.f; -+o6?.f; - o6.f; - function f01(x) { - if (!!true) { -- isString === null || isString === void 0 ? void 0 : isString(x); -+ isString?.(x); - x; - } - if (!!true) { -- maybeIsString === null || maybeIsString === void 0 ? void 0 : maybeIsString(x); -+ maybeIsString?.(x); - x; - } - if (!!true) { - isDefined(maybeIsString); -- maybeIsString === null || maybeIsString === void 0 ? void 0 : maybeIsString(x); -+ maybeIsString?.(x); - x; - } - if (!!true) { -- maybeNever === null || maybeNever === void 0 ? void 0 : maybeNever(); -+ maybeNever?.(); - x; - } - } - function f10(o, value) { -- if ((o === null || o === void 0 ? void 0 : o.foo) === value) { -+ if (o?.foo === value) { - o.foo; - } -- if ((o === null || o === void 0 ? void 0 : o["foo"]) === value) { -+ if (o?.["foo"] === value) { - o["foo"]; - } -- if ((o === null || o === void 0 ? void 0 : o.bar()) === value) { -+ if (o?.bar() === value) { - o.bar; - } -- if ((o === null || o === void 0 ? void 0 : o.foo) == value) { -+ if (o?.foo == value) { - o.foo; - } -- if ((o === null || o === void 0 ? void 0 : o["foo"]) == value) { -+ if (o?.["foo"] == value) { - o["foo"]; - } -- if ((o === null || o === void 0 ? void 0 : o.bar()) == value) { -+ if (o?.bar() == value) { - o.bar; - } - } - function f11(o, value) { -- if ((o === null || o === void 0 ? void 0 : o.foo) === value) { -+ if (o?.foo === value) { - o.foo; - } -- if ((o === null || o === void 0 ? void 0 : o["foo"]) === value) { -+ if (o?.["foo"] === value) { - o["foo"]; - } -- if ((o === null || o === void 0 ? void 0 : o.bar()) === value) { -+ if (o?.bar() === value) { - o.bar; - } -- if ((o === null || o === void 0 ? void 0 : o.foo) == value) { -+ if (o?.foo == value) { - o.foo; - } -- if ((o === null || o === void 0 ? void 0 : o["foo"]) == value) { -+ if (o?.["foo"] == value) { - o["foo"]; - } -- if ((o === null || o === void 0 ? void 0 : o.bar()) == value) { -+ if (o?.bar() == value) { - o.bar; - } - } - function f12(o, value) { -- if ((o === null || o === void 0 ? void 0 : o.foo) === value) { -+ if (o?.foo === value) { - o.foo; // Error - } -- if ((o === null || o === void 0 ? void 0 : o["foo"]) === value) { -+ if (o?.["foo"] === value) { - o["foo"]; // Error - } -- if ((o === null || o === void 0 ? void 0 : o.bar()) === value) { -+ if (o?.bar() === value) { - o.bar; // Error - } -- if ((o === null || o === void 0 ? void 0 : o.foo) == value) { -+ if (o?.foo == value) { - o.foo; // Error - } -- if ((o === null || o === void 0 ? void 0 : o["foo"]) == value) { -+ if (o?.["foo"] == value) { - o["foo"]; // Error - } -- if ((o === null || o === void 0 ? void 0 : o.bar()) == value) { -+ if (o?.bar() == value) { - o.bar; // Error - } - } - function f12a(o, value) { -- if ((o === null || o === void 0 ? void 0 : o.foo) === value) { -+ if (o?.foo === value) { - o.foo; - } -- if ((o === null || o === void 0 ? void 0 : o["foo"]) === value) { -+ if (o?.["foo"] === value) { - o["foo"]; - } -- if ((o === null || o === void 0 ? void 0 : o.bar()) === value) { -+ if (o?.bar() === value) { - o.bar; - } -- if ((o === null || o === void 0 ? void 0 : o.foo) == value) { -+ if (o?.foo == value) { - o.foo; // Error - } -- if ((o === null || o === void 0 ? void 0 : o["foo"]) == value) { -+ if (o?.["foo"] == value) { - o["foo"]; // Error - } -- if ((o === null || o === void 0 ? void 0 : o.bar()) == value) { -+ if (o?.bar() == value) { - o.bar; // Error - } - } - function f13(o) { -- if ((o === null || o === void 0 ? void 0 : o.foo) !== undefined) { -+ if (o?.foo !== undefined) { - o.foo; - } -- if ((o === null || o === void 0 ? void 0 : o["foo"]) !== undefined) { -+ if (o?.["foo"] !== undefined) { - o["foo"]; - } -- if ((o === null || o === void 0 ? void 0 : o.bar()) !== undefined) { -+ if (o?.bar() !== undefined) { - o.bar; - } -- if ((o === null || o === void 0 ? void 0 : o.foo) != undefined) { -+ if (o?.foo != undefined) { - o.foo; - } -- if ((o === null || o === void 0 ? void 0 : o["foo"]) != undefined) { -+ if (o?.["foo"] != undefined) { - o["foo"]; - } -- if ((o === null || o === void 0 ? void 0 : o.bar()) != undefined) { -+ if (o?.bar() != undefined) { - o.bar; - } - } - function f13a(o) { -- if ((o === null || o === void 0 ? void 0 : o.foo) !== null) { -+ if (o?.foo !== null) { - o.foo; // Error - } -- if ((o === null || o === void 0 ? void 0 : o["foo"]) !== null) { -+ if (o?.["foo"] !== null) { - o["foo"]; // Error - } -- if ((o === null || o === void 0 ? void 0 : o.bar()) !== null) { -+ if (o?.bar() !== null) { - o.bar; // Error - } -- if ((o === null || o === void 0 ? void 0 : o.foo) != null) { -+ if (o?.foo != null) { - o.foo; - } -- if ((o === null || o === void 0 ? void 0 : o["foo"]) != null) { -+ if (o?.["foo"] != null) { - o["foo"]; - } -- if ((o === null || o === void 0 ? void 0 : o.bar()) != null) { -+ if (o?.bar() != null) { - o.bar; - } - } - function f14(o) { -- if ((o === null || o === void 0 ? void 0 : o.foo) !== undefined) { -+ if (o?.foo !== undefined) { - o.foo; - } -- if ((o === null || o === void 0 ? void 0 : o["foo"]) !== undefined) { -+ if (o?.["foo"] !== undefined) { - o["foo"]; - } -- if ((o === null || o === void 0 ? void 0 : o.bar()) !== undefined) { -+ if (o?.bar() !== undefined) { - o.bar; - } - } - function f15(o, value) { -- if ((o === null || o === void 0 ? void 0 : o.foo) === value) { -- o.foo; -- } -- else { -- o.foo; // Error -- } -- if ((o === null || o === void 0 ? void 0 : o.foo) !== value) { -- o.foo; // Error -- } -- else { -- o.foo; -- } -- if ((o === null || o === void 0 ? void 0 : o.foo) == value) { -- o.foo; -- } -- else { -- o.foo; // Error -- } -- if ((o === null || o === void 0 ? void 0 : o.foo) != value) { -+ if (o?.foo === value) { -+ o.foo; -+ } -+ else { -+ o.foo; // Error -+ } -+ if (o?.foo !== value) { -+ o.foo; // Error -+ } -+ else { -+ o.foo; -+ } -+ if (o?.foo == value) { -+ o.foo; -+ } -+ else { -+ o.foo; // Error -+ } -+ if (o?.foo != value) { - o.foo; // Error - } - else { -@@= skipped -254, +254 lines =@@ - } - } - function f15a(o, value) { -- if ((o === null || o === void 0 ? void 0 : o.foo) === value) { -- o.foo; // Error -- } -- else { -- o.foo; // Error -- } -- if ((o === null || o === void 0 ? void 0 : o.foo) !== value) { -- o.foo; // Error -- } -- else { -- o.foo; // Error -- } -- if ((o === null || o === void 0 ? void 0 : o.foo) == value) { -- o.foo; // Error -- } -- else { -- o.foo; // Error -- } -- if ((o === null || o === void 0 ? void 0 : o.foo) != value) { -+ if (o?.foo === value) { -+ o.foo; // Error -+ } -+ else { -+ o.foo; // Error -+ } -+ if (o?.foo !== value) { -+ o.foo; // Error -+ } -+ else { -+ o.foo; // Error -+ } -+ if (o?.foo == value) { -+ o.foo; // Error -+ } -+ else { -+ o.foo; // Error -+ } -+ if (o?.foo != value) { - o.foo; // Error - } - else { -@@= skipped -26, +26 lines =@@ - } - } - function f16(o) { -- if ((o === null || o === void 0 ? void 0 : o.foo) === undefined) { -- o.foo; // Error -- } -- else { -- o.foo; -- } -- if ((o === null || o === void 0 ? void 0 : o.foo) !== undefined) { -- o.foo; -- } -- else { -- o.foo; // Error -- } -- if ((o === null || o === void 0 ? void 0 : o.foo) == undefined) { -- o.foo; // Error -- } -- else { -- o.foo; -- } -- if ((o === null || o === void 0 ? void 0 : o.foo) != undefined) { -+ if (o?.foo === undefined) { -+ o.foo; // Error -+ } -+ else { -+ o.foo; -+ } -+ if (o?.foo !== undefined) { -+ o.foo; -+ } -+ else { -+ o.foo; // Error -+ } -+ if (o?.foo == undefined) { -+ o.foo; // Error -+ } -+ else { -+ o.foo; -+ } -+ if (o?.foo != undefined) { - o.foo; - } - else { -@@= skipped -26, +26 lines =@@ - } - } - function f20(o) { -- if (typeof (o === null || o === void 0 ? void 0 : o.foo) === "number") { -+ if (typeof o?.foo === "number") { - o.foo; - } -- if (typeof (o === null || o === void 0 ? void 0 : o["foo"]) === "number") { -+ if (typeof o?.["foo"] === "number") { - o["foo"]; - } -- if (typeof (o === null || o === void 0 ? void 0 : o.bar()) === "number") { -+ if (typeof o?.bar() === "number") { - o.bar; - } -- if ((o === null || o === void 0 ? void 0 : o.baz) instanceof Error) { -+ if (o?.baz instanceof Error) { - o.baz; - } - } - function f21(o) { -- if (typeof (o === null || o === void 0 ? void 0 : o.foo) === "number") { -+ if (typeof o?.foo === "number") { - o.foo; - } -- if (typeof (o === null || o === void 0 ? void 0 : o["foo"]) === "number") { -+ if (typeof o?.["foo"] === "number") { - o["foo"]; - } -- if (typeof (o === null || o === void 0 ? void 0 : o.bar()) === "number") { -+ if (typeof o?.bar() === "number") { - o.bar; - } -- if ((o === null || o === void 0 ? void 0 : o.baz) instanceof Error) { -+ if (o?.baz instanceof Error) { - o.baz; - } - } - function f22(o) { -- if (typeof (o === null || o === void 0 ? void 0 : o.foo) === "number") { -- o.foo; -- } -- else { -- o.foo; // Error -- } -- if (typeof (o === null || o === void 0 ? void 0 : o.foo) !== "number") { -- o.foo; // Error -- } -- else { -- o.foo; -- } -- if (typeof (o === null || o === void 0 ? void 0 : o.foo) == "number") { -- o.foo; -- } -- else { -- o.foo; // Error -- } -- if (typeof (o === null || o === void 0 ? void 0 : o.foo) != "number") { -+ if (typeof o?.foo === "number") { -+ o.foo; -+ } -+ else { -+ o.foo; // Error -+ } -+ if (typeof o?.foo !== "number") { -+ o.foo; // Error -+ } -+ else { -+ o.foo; -+ } -+ if (typeof o?.foo == "number") { -+ o.foo; -+ } -+ else { -+ o.foo; // Error -+ } -+ if (typeof o?.foo != "number") { - o.foo; // Error - } - else { -@@= skipped -54, +54 lines =@@ - } - } - function f23(o) { -- if (typeof (o === null || o === void 0 ? void 0 : o.foo) === "undefined") { -- o.foo; // Error -- } -- else { -- o.foo; -- } -- if (typeof (o === null || o === void 0 ? void 0 : o.foo) !== "undefined") { -- o.foo; -- } -- else { -- o.foo; // Error -- } -- if (typeof (o === null || o === void 0 ? void 0 : o.foo) == "undefined") { -- o.foo; // Error -- } -- else { -- o.foo; -- } -- if (typeof (o === null || o === void 0 ? void 0 : o.foo) != "undefined") { -+ if (typeof o?.foo === "undefined") { -+ o.foo; // Error -+ } -+ else { -+ o.foo; -+ } -+ if (typeof o?.foo !== "undefined") { -+ o.foo; -+ } -+ else { -+ o.foo; // Error -+ } -+ if (typeof o?.foo == "undefined") { -+ o.foo; // Error -+ } -+ else { -+ o.foo; -+ } -+ if (typeof o?.foo != "undefined") { - o.foo; - } - else { -@@= skipped -27, +27 lines =@@ - } - function f30(o) { - if (!!true) { -- assert(o === null || o === void 0 ? void 0 : o.foo); -- o.foo; -- } -- if (!!true) { -- assert((o === null || o === void 0 ? void 0 : o.foo) === 42); -- o.foo; -- } -- if (!!true) { -- assert(typeof (o === null || o === void 0 ? void 0 : o.foo) === "number"); -- o.foo; -- } -- if (!!true) { -- assertNonNull(o === null || o === void 0 ? void 0 : o.foo); -+ assert(o?.foo); -+ o.foo; -+ } -+ if (!!true) { -+ assert(o?.foo === 42); -+ o.foo; -+ } -+ if (!!true) { -+ assert(typeof o?.foo === "number"); -+ o.foo; -+ } -+ if (!!true) { -+ assertNonNull(o?.foo); - o.foo; - } - } - function f40(o) { -- switch (o === null || o === void 0 ? void 0 : o.foo) { -+ switch (o?.foo) { - case "abc": - o.foo; - break; -@@= skipped -33, +33 lines =@@ - } - } - function f41(o) { -- switch (typeof (o === null || o === void 0 ? void 0 : o.foo)) { -+ switch (typeof o?.foo) { - case "string": - o.foo; - break; -@@= skipped -16, +16 lines =@@ - } - } - function getArea(shape) { -- switch (shape === null || shape === void 0 ? void 0 : shape.type) { -+ switch (shape?.type) { - case 'circle': - return Math.PI * Math.pow(shape.radius, 2); - case 'rectangle': -@@= skipped -10, +10 lines =@@ - } - } - function extractCoordinates(f) { -- var _a; -- if (((_a = f.geometry) === null || _a === void 0 ? void 0 : _a.type) !== 'test') { -+ if (f.geometry?.type !== 'test') { - return []; - } - return f.geometry.coordinates; - } - let lastSomeProperty; - function someFunction(someOptionalObject) { -- if ((someOptionalObject === null || someOptionalObject === void 0 ? void 0 : someOptionalObject.someProperty) !== lastSomeProperty) { -+ if (someOptionalObject?.someProperty !== lastSomeProperty) { - console.log(someOptionalObject); - console.log(someOptionalObject.someProperty); // Error -- lastSomeProperty = someOptionalObject === null || someOptionalObject === void 0 ? void 0 : someOptionalObject.someProperty; -+ lastSomeProperty = someOptionalObject?.someProperty; - } - } - const someObject = { -@@= skipped -21, +20 lines =@@ - someFunction(undefined); - // Repro from #35970 - let i = 0; --while (((_u = arr[i]) === null || _u === void 0 ? void 0 : _u.tag) === "left") { -+while (arr[i]?.tag === "left") { - i += 1; -- if (((_v = arr[i]) === null || _v === void 0 ? void 0 : _v.tag) === "right") { -+ if (arr[i]?.tag === "right") { - console.log("I should ALSO be reachable"); - } - } - function f50(obj) { -- var _a; -- for (const key in (_a = obj.main) === null || _a === void 0 ? void 0 : _a.childs) { -+ for (const key in obj.main?.childs) { - if (obj.main.childs[key] === obj) { - return obj; - } \ No newline at end of file + o === null || o === void 0 ? void 0 : o[a = 1]; \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/controlFlowOptionalChain2.js b/testdata/baselines/reference/submodule/conformance/controlFlowOptionalChain2.js index 8c1cb84439..19876a6444 100644 --- a/testdata/baselines/reference/submodule/conformance/controlFlowOptionalChain2.js +++ b/testdata/baselines/reference/submodule/conformance/controlFlowOptionalChain2.js @@ -109,23 +109,23 @@ function f8(x: X | N | null) { //// [controlFlowOptionalChain2.js] function funcTwo(arg) { - if (arg?.type === 'B') { + if ((arg === null || arg === void 0 ? void 0 : arg.type) === 'B') { arg; // `B` return; } arg; - arg?.name; + arg === null || arg === void 0 ? void 0 : arg.name; } function funcThree(arg) { - if (arg?.type === 'B') { + if ((arg === null || arg === void 0 ? void 0 : arg.type) === 'B') { arg; // `B` return; } arg; - arg?.name; + arg === null || arg === void 0 ? void 0 : arg.name; } function f1(x) { - if (x?.kind === undefined) { + if ((x === null || x === void 0 ? void 0 : x.kind) === undefined) { x; // U | undefined } else { @@ -133,7 +133,7 @@ function f1(x) { } } function f2(x) { - if (x?.kind === undefined) { + if ((x === null || x === void 0 ? void 0 : x.kind) === undefined) { x; // undefined } else { @@ -141,7 +141,7 @@ function f2(x) { } } function f3(x) { - if (x?.kind === undefined) { + if ((x === null || x === void 0 ? void 0 : x.kind) === undefined) { x; // U | null } else { @@ -149,7 +149,7 @@ function f3(x) { } } function f4(x) { - if (x?.kind === undefined) { + if ((x === null || x === void 0 ? void 0 : x.kind) === undefined) { x; // null } else { @@ -157,7 +157,7 @@ function f4(x) { } } function f5(x) { - if (x?.kind === null) { + if ((x === null || x === void 0 ? void 0 : x.kind) === null) { x; // never } else { @@ -165,7 +165,7 @@ function f5(x) { } } function f6(x) { - if (x?.kind === null) { + if ((x === null || x === void 0 ? void 0 : x.kind) === null) { x; // N } else { @@ -173,7 +173,7 @@ function f6(x) { } } function f7(x) { - if (x?.kind === null) { + if ((x === null || x === void 0 ? void 0 : x.kind) === null) { x; // never } else { @@ -181,7 +181,7 @@ function f7(x) { } } function f8(x) { - if (x?.kind === null) { + if ((x === null || x === void 0 ? void 0 : x.kind) === null) { x; // N } else { diff --git a/testdata/baselines/reference/submodule/conformance/controlFlowOptionalChain2.js.diff b/testdata/baselines/reference/submodule/conformance/controlFlowOptionalChain2.js.diff deleted file mode 100644 index 8613f473ec..0000000000 --- a/testdata/baselines/reference/submodule/conformance/controlFlowOptionalChain2.js.diff +++ /dev/null @@ -1,94 +0,0 @@ ---- old.controlFlowOptionalChain2.js -+++ new.controlFlowOptionalChain2.js -@@= skipped -108, +108 lines =@@ - - //// [controlFlowOptionalChain2.js] - function funcTwo(arg) { -- if ((arg === null || arg === void 0 ? void 0 : arg.type) === 'B') { -+ if (arg?.type === 'B') { - arg; // `B` - return; - } - arg; -- arg === null || arg === void 0 ? void 0 : arg.name; -+ arg?.name; - } - function funcThree(arg) { -- if ((arg === null || arg === void 0 ? void 0 : arg.type) === 'B') { -+ if (arg?.type === 'B') { - arg; // `B` - return; - } - arg; -- arg === null || arg === void 0 ? void 0 : arg.name; -+ arg?.name; - } - function f1(x) { -- if ((x === null || x === void 0 ? void 0 : x.kind) === undefined) { -+ if (x?.kind === undefined) { - x; // U | undefined - } - else { -@@= skipped -24, +24 lines =@@ - } - } - function f2(x) { -- if ((x === null || x === void 0 ? void 0 : x.kind) === undefined) { -+ if (x?.kind === undefined) { - x; // undefined - } - else { -@@= skipped -8, +8 lines =@@ - } - } - function f3(x) { -- if ((x === null || x === void 0 ? void 0 : x.kind) === undefined) { -+ if (x?.kind === undefined) { - x; // U | null - } - else { -@@= skipped -8, +8 lines =@@ - } - } - function f4(x) { -- if ((x === null || x === void 0 ? void 0 : x.kind) === undefined) { -+ if (x?.kind === undefined) { - x; // null - } - else { -@@= skipped -8, +8 lines =@@ - } - } - function f5(x) { -- if ((x === null || x === void 0 ? void 0 : x.kind) === null) { -+ if (x?.kind === null) { - x; // never - } - else { -@@= skipped -8, +8 lines =@@ - } - } - function f6(x) { -- if ((x === null || x === void 0 ? void 0 : x.kind) === null) { -+ if (x?.kind === null) { - x; // N - } - else { -@@= skipped -8, +8 lines =@@ - } - } - function f7(x) { -- if ((x === null || x === void 0 ? void 0 : x.kind) === null) { -+ if (x?.kind === null) { - x; // never - } - else { -@@= skipped -8, +8 lines =@@ - } - } - function f8(x) { -- if ((x === null || x === void 0 ? void 0 : x.kind) === null) { -+ if (x?.kind === null) { - x; // N - } - else { \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/deleteChain.js b/testdata/baselines/reference/submodule/conformance/deleteChain.js index b9e586036f..fec4d370a2 100644 --- a/testdata/baselines/reference/submodule/conformance/deleteChain.js +++ b/testdata/baselines/reference/submodule/conformance/deleteChain.js @@ -27,16 +27,17 @@ delete o6.b?.['c'].d?.['e']; delete (o6.b?.['c'].d?.['e']); //// [deleteChain.js] -delete o1?.b; -delete (o1?.b); -delete o2?.b.c; -delete (o2?.b.c); -delete o3.b?.c; -delete (o3.b?.c); -delete o4.b?.c.d?.e; -delete (o4.b?.c.d)?.e; -delete (o4.b?.c.d?.e); -delete o5.b?.().c.d?.e; -delete (o5.b?.().c.d?.e); -delete o6.b?.['c'].d?.['e']; -delete (o6.b?.['c'].d?.['e']); +var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r; +o1 === null || o1 === void 0 ? true : delete o1.b; +(o1 === null || o1 === void 0 ? true : delete o1.b); +o2 === null || o2 === void 0 ? true : delete o2.b.c; +(o2 === null || o2 === void 0 ? true : delete o2.b.c); +(_a = o3.b) === null || _a === void 0 ? true : delete _a.c; +((_b = o3.b) === null || _b === void 0 ? true : delete _b.c); +(_d = (_c = o4.b) === null || _c === void 0 ? void 0 : _c.c.d) === null || _d === void 0 ? true : delete _d.e; +(_f = ((_e = o4.b) === null || _e === void 0 ? void 0 : _e.c.d)) === null || _f === void 0 ? true : delete _f.e; +((_h = (_g = o4.b) === null || _g === void 0 ? void 0 : _g.c.d) === null || _h === void 0 ? true : delete _h.e); +(_k = (_j = o5.b) === null || _j === void 0 ? void 0 : _j.call(o5).c.d) === null || _k === void 0 ? true : delete _k.e; +((_m = (_l = o5.b) === null || _l === void 0 ? void 0 : _l.call(o5).c.d) === null || _m === void 0 ? true : delete _m.e); +(_p = (_o = o6.b) === null || _o === void 0 ? void 0 : _o['c'].d) === null || _p === void 0 ? true : delete _p['e']; +((_r = (_q = o6.b) === null || _q === void 0 ? void 0 : _q['c'].d) === null || _r === void 0 ? true : delete _r['e']); diff --git a/testdata/baselines/reference/submodule/conformance/deleteChain.js.diff b/testdata/baselines/reference/submodule/conformance/deleteChain.js.diff index dfdcb88c0c..a393358242 100644 --- a/testdata/baselines/reference/submodule/conformance/deleteChain.js.diff +++ b/testdata/baselines/reference/submodule/conformance/deleteChain.js.diff @@ -5,30 +5,6 @@ //// [deleteChain.js] -"use strict"; --var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r; --o1 === null || o1 === void 0 ? true : delete o1.b; --(o1 === null || o1 === void 0 ? true : delete o1.b); --o2 === null || o2 === void 0 ? true : delete o2.b.c; --(o2 === null || o2 === void 0 ? true : delete o2.b.c); --(_a = o3.b) === null || _a === void 0 ? true : delete _a.c; --((_b = o3.b) === null || _b === void 0 ? true : delete _b.c); --(_d = (_c = o4.b) === null || _c === void 0 ? void 0 : _c.c.d) === null || _d === void 0 ? true : delete _d.e; --(_f = ((_e = o4.b) === null || _e === void 0 ? void 0 : _e.c.d)) === null || _f === void 0 ? true : delete _f.e; --((_h = (_g = o4.b) === null || _g === void 0 ? void 0 : _g.c.d) === null || _h === void 0 ? true : delete _h.e); --(_k = (_j = o5.b) === null || _j === void 0 ? void 0 : _j.call(o5).c.d) === null || _k === void 0 ? true : delete _k.e; --((_m = (_l = o5.b) === null || _l === void 0 ? void 0 : _l.call(o5).c.d) === null || _m === void 0 ? true : delete _m.e); --(_p = (_o = o6.b) === null || _o === void 0 ? void 0 : _o['c'].d) === null || _p === void 0 ? true : delete _p['e']; --((_r = (_q = o6.b) === null || _q === void 0 ? void 0 : _q['c'].d) === null || _r === void 0 ? true : delete _r['e']); -+delete o1?.b; -+delete (o1?.b); -+delete o2?.b.c; -+delete (o2?.b.c); -+delete o3.b?.c; -+delete (o3.b?.c); -+delete o4.b?.c.d?.e; -+delete (o4.b?.c.d)?.e; -+delete (o4.b?.c.d?.e); -+delete o5.b?.().c.d?.e; -+delete (o5.b?.().c.d?.e); -+delete o6.b?.['c'].d?.['e']; -+delete (o6.b?.['c'].d?.['e']); \ No newline at end of file + var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r; + o1 === null || o1 === void 0 ? true : delete o1.b; + (o1 === null || o1 === void 0 ? true : delete o1.b); \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/elementAccessChain.2.js b/testdata/baselines/reference/submodule/conformance/elementAccessChain.2.js index 4551258dd4..f2a5c526e8 100644 --- a/testdata/baselines/reference/submodule/conformance/elementAccessChain.2.js +++ b/testdata/baselines/reference/submodule/conformance/elementAccessChain.2.js @@ -14,8 +14,9 @@ o3.b?.["c"]; //// [elementAccessChain.2.js] -o1?.["b"]; -o2?.["b"].c; -o2?.b["c"]; -o3["b"]?.c; -o3.b?.["c"]; +var _a, _b; +o1 === null || o1 === void 0 ? void 0 : o1["b"]; +o2 === null || o2 === void 0 ? void 0 : o2["b"].c; +o2 === null || o2 === void 0 ? void 0 : o2.b["c"]; +(_a = o3["b"]) === null || _a === void 0 ? void 0 : _a.c; +(_b = o3.b) === null || _b === void 0 ? void 0 : _b["c"]; diff --git a/testdata/baselines/reference/submodule/conformance/elementAccessChain.2.js.diff b/testdata/baselines/reference/submodule/conformance/elementAccessChain.2.js.diff deleted file mode 100644 index 4adc766f23..0000000000 --- a/testdata/baselines/reference/submodule/conformance/elementAccessChain.2.js.diff +++ /dev/null @@ -1,17 +0,0 @@ ---- old.elementAccessChain.2.js -+++ new.elementAccessChain.2.js -@@= skipped -13, +13 lines =@@ - - - //// [elementAccessChain.2.js] --var _a, _b; --o1 === null || o1 === void 0 ? void 0 : o1["b"]; --o2 === null || o2 === void 0 ? void 0 : o2["b"].c; --o2 === null || o2 === void 0 ? void 0 : o2.b["c"]; --(_a = o3["b"]) === null || _a === void 0 ? void 0 : _a.c; --(_b = o3.b) === null || _b === void 0 ? void 0 : _b["c"]; -+o1?.["b"]; -+o2?.["b"].c; -+o2?.b["c"]; -+o3["b"]?.c; -+o3.b?.["c"]; \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/elementAccessChain.3.js b/testdata/baselines/reference/submodule/conformance/elementAccessChain.3.js index 1980cb8dbe..b3c183b138 100644 --- a/testdata/baselines/reference/submodule/conformance/elementAccessChain.3.js +++ b/testdata/baselines/reference/submodule/conformance/elementAccessChain.3.js @@ -32,29 +32,29 @@ for (obj?.a["b"] of []); //// [elementAccessChain.3.js] -obj?.["a"]++; -obj?.a["b"]++; -obj?.["a"]--; -obj?.a["b"]--; -++obj?.["a"]; -++obj?.a["b"]; ---obj?.["a"]; ---obj?.a["b"]; -obj?.["a"] = 1; -obj?.a["b"] = 1; -obj?.["a"] += 1; -obj?.a["b"] += 1; -for (obj?.["a"] in {}) +(obj === null || obj === void 0 ? void 0 : obj["a"])++; +(obj === null || obj === void 0 ? void 0 : obj.a["b"])++; +(obj === null || obj === void 0 ? void 0 : obj["a"])--; +(obj === null || obj === void 0 ? void 0 : obj.a["b"])--; +++(obj === null || obj === void 0 ? void 0 : obj["a"]); +++(obj === null || obj === void 0 ? void 0 : obj.a["b"]); +--(obj === null || obj === void 0 ? void 0 : obj["a"]); +--(obj === null || obj === void 0 ? void 0 : obj.a["b"]); +(obj === null || obj === void 0 ? void 0 : obj["a"]) = 1; +(obj === null || obj === void 0 ? void 0 : obj.a["b"]) = 1; +(obj === null || obj === void 0 ? void 0 : obj["a"]) += 1; +(obj === null || obj === void 0 ? void 0 : obj.a["b"]) += 1; +for (obj === null || obj === void 0 ? void 0 : obj["a"] in {}) ; -for (obj?.a["b"] in {}) +for (obj === null || obj === void 0 ? void 0 : obj.a["b"] in {}) ; -for (obj?.["a"] of []) +for (obj === null || obj === void 0 ? void 0 : obj["a"] of []) ; -for (obj?.a["b"] of []) +for (obj === null || obj === void 0 ? void 0 : obj.a["b"] of []) ; -({ a: obj?.["a"] } = { a: 1 }); -({ a: obj?.a["b"] } = { a: 1 }); -({ ...obj?.["a"] } = { a: 1 }); -({ ...obj?.a["b"] } = { a: 1 }); -[...obj?.["a"]] = []; -[...obj?.a["b"]] = []; +({ a: obj === null || obj === void 0 ? void 0 : obj["a"] } = { a: 1 }); +({ a: obj === null || obj === void 0 ? void 0 : obj.a["b"] } = { a: 1 }); +({ ...obj === null || obj === void 0 ? void 0 : obj["a"] } = { a: 1 }); +({ ...obj === null || obj === void 0 ? void 0 : obj.a["b"] } = { a: 1 }); +[...obj === null || obj === void 0 ? void 0 : obj["a"]] = []; +[...obj === null || obj === void 0 ? void 0 : obj.a["b"]] = []; diff --git a/testdata/baselines/reference/submodule/conformance/elementAccessChain.3.js.diff b/testdata/baselines/reference/submodule/conformance/elementAccessChain.3.js.diff index de5844fbc4..bb01ed2cc2 100644 --- a/testdata/baselines/reference/submodule/conformance/elementAccessChain.3.js.diff +++ b/testdata/baselines/reference/submodule/conformance/elementAccessChain.3.js.diff @@ -16,55 +16,31 @@ - } - return t; -}; --(obj === null || obj === void 0 ? void 0 : obj["a"])++; --(obj === null || obj === void 0 ? void 0 : obj.a["b"])++; --(obj === null || obj === void 0 ? void 0 : obj["a"])--; --(obj === null || obj === void 0 ? void 0 : obj.a["b"])--; --++(obj === null || obj === void 0 ? void 0 : obj["a"]); --++(obj === null || obj === void 0 ? void 0 : obj.a["b"]); ----(obj === null || obj === void 0 ? void 0 : obj["a"]); ----(obj === null || obj === void 0 ? void 0 : obj.a["b"]); + (obj === null || obj === void 0 ? void 0 : obj["a"])++; + (obj === null || obj === void 0 ? void 0 : obj.a["b"])++; + (obj === null || obj === void 0 ? void 0 : obj["a"])--; +@@= skipped -20, +8 lines =@@ + ++(obj === null || obj === void 0 ? void 0 : obj.a["b"]); + --(obj === null || obj === void 0 ? void 0 : obj["a"]); + --(obj === null || obj === void 0 ? void 0 : obj.a["b"]); -obj === null || obj === void 0 ? void 0 : obj["a"] = 1; -obj === null || obj === void 0 ? void 0 : obj.a["b"] = 1; -obj === null || obj === void 0 ? void 0 : obj["a"] += 1; -obj === null || obj === void 0 ? void 0 : obj.a["b"] += 1; --for (obj === null || obj === void 0 ? void 0 : obj["a"] in {}) -- ; --for (obj === null || obj === void 0 ? void 0 : obj.a["b"] in {}) -- ; --for (obj === null || obj === void 0 ? void 0 : obj["a"] of []) -- ; --for (obj === null || obj === void 0 ? void 0 : obj.a["b"] of []) -- ; --({ a: obj === null || obj === void 0 ? void 0 : obj["a"] } = { a: 1 }); --({ a: obj === null || obj === void 0 ? void 0 : obj.a["b"] } = { a: 1 }); ++(obj === null || obj === void 0 ? void 0 : obj["a"]) = 1; ++(obj === null || obj === void 0 ? void 0 : obj.a["b"]) = 1; ++(obj === null || obj === void 0 ? void 0 : obj["a"]) += 1; ++(obj === null || obj === void 0 ? void 0 : obj.a["b"]) += 1; + for (obj === null || obj === void 0 ? void 0 : obj["a"] in {}) + ; + for (obj === null || obj === void 0 ? void 0 : obj.a["b"] in {}) +@@= skipped -14, +14 lines =@@ + ; + ({ a: obj === null || obj === void 0 ? void 0 : obj["a"] } = { a: 1 }); + ({ a: obj === null || obj === void 0 ? void 0 : obj.a["b"] } = { a: 1 }); -(obj === null || obj === void 0 ? void 0 : obj["a"] = __rest({ a: 1 }, [])); -(obj === null || obj === void 0 ? void 0 : obj.a["b"] = __rest({ a: 1 }, [])); --[...obj === null || obj === void 0 ? void 0 : obj["a"]] = []; --[...obj === null || obj === void 0 ? void 0 : obj.a["b"]] = []; -+obj?.["a"]++; -+obj?.a["b"]++; -+obj?.["a"]--; -+obj?.a["b"]--; -+++obj?.["a"]; -+++obj?.a["b"]; -+--obj?.["a"]; -+--obj?.a["b"]; -+obj?.["a"] = 1; -+obj?.a["b"] = 1; -+obj?.["a"] += 1; -+obj?.a["b"] += 1; -+for (obj?.["a"] in {}) -+ ; -+for (obj?.a["b"] in {}) -+ ; -+for (obj?.["a"] of []) -+ ; -+for (obj?.a["b"] of []) -+ ; -+({ a: obj?.["a"] } = { a: 1 }); -+({ a: obj?.a["b"] } = { a: 1 }); -+({ ...obj?.["a"] } = { a: 1 }); -+({ ...obj?.a["b"] } = { a: 1 }); -+[...obj?.["a"]] = []; -+[...obj?.a["b"]] = []; \ No newline at end of file ++({ ...obj === null || obj === void 0 ? void 0 : obj["a"] } = { a: 1 }); ++({ ...obj === null || obj === void 0 ? void 0 : obj.a["b"] } = { a: 1 }); + [...obj === null || obj === void 0 ? void 0 : obj["a"]] = []; + [...obj === null || obj === void 0 ? void 0 : obj.a["b"]] = []; \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/elementAccessChain.js b/testdata/baselines/reference/submodule/conformance/elementAccessChain.js index 929aa6432d..e2a8876c43 100644 --- a/testdata/baselines/reference/submodule/conformance/elementAccessChain.js +++ b/testdata/baselines/reference/submodule/conformance/elementAccessChain.js @@ -33,20 +33,21 @@ o2?.["b"]!.c!; o2?.["b"]!["c"]!; //// [elementAccessChain.js] -o1?.["b"]; -o2?.["b"].c; -o2?.b["c"]; -o3["b"]?.c; -o3.b?.["c"]; -o4.b?.["c"].d?.e; -o4.b?.["c"].d?.["e"]; -o5.b?.()["c"].d?.e; -o5.b?.()["c"].d?.["e"]; -o5["b"]?.()["c"].d?.e; -o5["b"]?.()["c"].d?.["e"]; -o6()?.["x"]; +var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q; +o1 === null || o1 === void 0 ? void 0 : o1["b"]; +o2 === null || o2 === void 0 ? void 0 : o2["b"].c; +o2 === null || o2 === void 0 ? void 0 : o2.b["c"]; +(_a = o3["b"]) === null || _a === void 0 ? void 0 : _a.c; +(_b = o3.b) === null || _b === void 0 ? void 0 : _b["c"]; +(_d = (_c = o4.b) === null || _c === void 0 ? void 0 : _c["c"].d) === null || _d === void 0 ? void 0 : _d.e; +(_f = (_e = o4.b) === null || _e === void 0 ? void 0 : _e["c"].d) === null || _f === void 0 ? void 0 : _f["e"]; +(_h = (_g = o5.b) === null || _g === void 0 ? void 0 : _g.call(o5)["c"].d) === null || _h === void 0 ? void 0 : _h.e; +(_k = (_j = o5.b) === null || _j === void 0 ? void 0 : _j.call(o5)["c"].d) === null || _k === void 0 ? void 0 : _k["e"]; +(_m = (_l = o5["b"]) === null || _l === void 0 ? void 0 : _l.call(o5)["c"].d) === null || _m === void 0 ? void 0 : _m.e; +(_p = (_o = o5["b"]) === null || _o === void 0 ? void 0 : _o.call(o5)["c"].d) === null || _p === void 0 ? void 0 : _p["e"]; +(_q = o6()) === null || _q === void 0 ? void 0 : _q["x"]; // GH#36031 -o2?.["b"].c; -o2?.["b"]["c"]; -o2?.["b"].c; -o2?.["b"]["c"]; +o2 === null || o2 === void 0 ? void 0 : o2["b"].c; +o2 === null || o2 === void 0 ? void 0 : o2["b"]["c"]; +o2 === null || o2 === void 0 ? void 0 : o2["b"].c; +o2 === null || o2 === void 0 ? void 0 : o2["b"]["c"]; diff --git a/testdata/baselines/reference/submodule/conformance/elementAccessChain.js.diff b/testdata/baselines/reference/submodule/conformance/elementAccessChain.js.diff index 55c17c6d1a..6b2e68a5e1 100644 --- a/testdata/baselines/reference/submodule/conformance/elementAccessChain.js.diff +++ b/testdata/baselines/reference/submodule/conformance/elementAccessChain.js.diff @@ -5,37 +5,6 @@ //// [elementAccessChain.js] -"use strict"; --var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q; --o1 === null || o1 === void 0 ? void 0 : o1["b"]; --o2 === null || o2 === void 0 ? void 0 : o2["b"].c; --o2 === null || o2 === void 0 ? void 0 : o2.b["c"]; --(_a = o3["b"]) === null || _a === void 0 ? void 0 : _a.c; --(_b = o3.b) === null || _b === void 0 ? void 0 : _b["c"]; --(_d = (_c = o4.b) === null || _c === void 0 ? void 0 : _c["c"].d) === null || _d === void 0 ? void 0 : _d.e; --(_f = (_e = o4.b) === null || _e === void 0 ? void 0 : _e["c"].d) === null || _f === void 0 ? void 0 : _f["e"]; --(_h = (_g = o5.b) === null || _g === void 0 ? void 0 : _g.call(o5)["c"].d) === null || _h === void 0 ? void 0 : _h.e; --(_k = (_j = o5.b) === null || _j === void 0 ? void 0 : _j.call(o5)["c"].d) === null || _k === void 0 ? void 0 : _k["e"]; --(_m = (_l = o5["b"]) === null || _l === void 0 ? void 0 : _l.call(o5)["c"].d) === null || _m === void 0 ? void 0 : _m.e; --(_p = (_o = o5["b"]) === null || _o === void 0 ? void 0 : _o.call(o5)["c"].d) === null || _p === void 0 ? void 0 : _p["e"]; --(_q = o6()) === null || _q === void 0 ? void 0 : _q["x"]; -+o1?.["b"]; -+o2?.["b"].c; -+o2?.b["c"]; -+o3["b"]?.c; -+o3.b?.["c"]; -+o4.b?.["c"].d?.e; -+o4.b?.["c"].d?.["e"]; -+o5.b?.()["c"].d?.e; -+o5.b?.()["c"].d?.["e"]; -+o5["b"]?.()["c"].d?.e; -+o5["b"]?.()["c"].d?.["e"]; -+o6()?.["x"]; - // GH#36031 --o2 === null || o2 === void 0 ? void 0 : o2["b"].c; --o2 === null || o2 === void 0 ? void 0 : o2["b"]["c"]; --o2 === null || o2 === void 0 ? void 0 : o2["b"].c; --o2 === null || o2 === void 0 ? void 0 : o2["b"]["c"]; -+o2?.["b"].c; -+o2?.["b"]["c"]; -+o2?.["b"].c; -+o2?.["b"]["c"]; \ No newline at end of file + var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q; + o1 === null || o1 === void 0 ? void 0 : o1["b"]; + o2 === null || o2 === void 0 ? void 0 : o2["b"].c; \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/exhaustiveSwitchStatements1.js b/testdata/baselines/reference/submodule/conformance/exhaustiveSwitchStatements1.js index 7bb76446af..d90156e40b 100644 --- a/testdata/baselines/reference/submodule/conformance/exhaustiveSwitchStatements1.js +++ b/testdata/baselines/reference/submodule/conformance/exhaustiveSwitchStatements1.js @@ -441,7 +441,7 @@ var Animal; })(Animal || (Animal = {})); function expression() { var _a; - switch ((_a = zoo?.animal) !== null && _a !== void 0 ? _a : Animal.DOG) { + switch ((_a = zoo === null || zoo === void 0 ? void 0 : zoo.animal) !== null && _a !== void 0 ? _a : Animal.DOG) { case Animal.DOG: return Animal.DOG; case Animal.CAT: return Animal.CAT; } diff --git a/testdata/baselines/reference/submodule/conformance/exhaustiveSwitchStatements1.js.diff b/testdata/baselines/reference/submodule/conformance/exhaustiveSwitchStatements1.js.diff index 5ada9507ac..167c134474 100644 --- a/testdata/baselines/reference/submodule/conformance/exhaustiveSwitchStatements1.js.diff +++ b/testdata/baselines/reference/submodule/conformance/exhaustiveSwitchStatements1.js.diff @@ -8,16 +8,7 @@ function f1(x) { if (!!true) { switch (x) { -@@= skipped -190, +189 lines =@@ - })(Animal || (Animal = {})); - function expression() { - var _a; -- switch ((_a = zoo === null || zoo === void 0 ? void 0 : zoo.animal) !== null && _a !== void 0 ? _a : Animal.DOG) { -+ switch ((_a = zoo?.animal) !== null && _a !== void 0 ? _a : Animal.DOG) { - case Animal.DOG: return Animal.DOG; - case Animal.CAT: return Animal.CAT; - } -@@= skipped -38, +38 lines =@@ +@@= skipped -228, +227 lines =@@ declare function f1(x: 1 | 2): string; declare function f2(x: 1 | 2): void; declare function f3(x: 1 | 2): 10 | 20; diff --git a/testdata/baselines/reference/submodule/conformance/instantiationExpressionErrors.js b/testdata/baselines/reference/submodule/conformance/instantiationExpressionErrors.js index 04f8dd2ea0..476fdaf58c 100644 --- a/testdata/baselines/reference/submodule/conformance/instantiationExpressionErrors.js +++ b/testdata/baselines/reference/submodule/conformance/instantiationExpressionErrors.js @@ -107,7 +107,8 @@ const a = ver < (MyVer.v1 >= MyVer.v2 ? MyVer.v1 : MyVer.v2) //// [instantiationExpressionErrors.js] -var _a; +var _a, _b; +var _c; // Type arguments in member expressions const a1 = f; // { (): number; g(): U; } const a2 = f.g; // () => number @@ -121,12 +122,12 @@ const a7 = (f)['g']; const a8 = f < number > ; // Relational operator error const a9 = (f); // Error, no applicable signatures // Type arguments with `?.` token -const b1 = f?.(); // Error, `(` expected -const b2 = f?.(); -const b3 = f?.(); -const b4 = f?.(); // Error, expected no type arguments +const b1 = f === null || f === void 0 ? void 0 : f(); // Error, `(` expected +const b2 = f === null || f === void 0 ? void 0 : f(); +const b3 = (_a = f) === null || _a === void 0 ? void 0 : _a(); +const b4 = (_b = f) === null || _b === void 0 ? void 0 : _b(); // Error, expected no type arguments const c1 = g || ((x) => x); -const c2 = (_a = g) !== null && _a !== void 0 ? _a : ((x) => x); +const c2 = (_c = g) !== null && _c !== void 0 ? _c : ((x) => x); const c3 = g && ((x) => x); // Parsed as function call, even though this differs from JavaScript const x1 = f(true); diff --git a/testdata/baselines/reference/submodule/conformance/instantiationExpressionErrors.js.diff b/testdata/baselines/reference/submodule/conformance/instantiationExpressionErrors.js.diff index 3b03f7e8c0..30ad52648a 100644 --- a/testdata/baselines/reference/submodule/conformance/instantiationExpressionErrors.js.diff +++ b/testdata/baselines/reference/submodule/conformance/instantiationExpressionErrors.js.diff @@ -6,7 +6,8 @@ //// [instantiationExpressionErrors.js] -"use strict"; -var _a, _b, _c; -+var _a; ++var _a, _b; ++var _c; // Type arguments in member expressions -const a1 = (f); // { (): number; g(): U; } -const a2 = (f.g); // () => number @@ -25,24 +26,22 @@ -const a9 = ((f)); // Error, no applicable signatures +const a9 = (f); // Error, no applicable signatures // Type arguments with `?.` token --const b1 = f === null || f === void 0 ? void 0 : f(); // Error, `(` expected --const b2 = f === null || f === void 0 ? void 0 : f(); + const b1 = f === null || f === void 0 ? void 0 : f(); // Error, `(` expected + const b2 = f === null || f === void 0 ? void 0 : f(); -const b3 = (_a = (f)) === null || _a === void 0 ? void 0 : _a(); -const b4 = (_b = (f)) === null || _b === void 0 ? void 0 : _b(); // Error, expected no type arguments -const c1 = (g) || ((x) => x); -const c2 = (_c = (g)) !== null && _c !== void 0 ? _c : ((x) => x); -const c3 = (g) && ((x) => x); -+const b1 = f?.(); // Error, `(` expected -+const b2 = f?.(); -+const b3 = f?.(); -+const b4 = f?.(); // Error, expected no type arguments ++const b3 = (_a = f) === null || _a === void 0 ? void 0 : _a(); ++const b4 = (_b = f) === null || _b === void 0 ? void 0 : _b(); // Error, expected no type arguments +const c1 = g || ((x) => x); -+const c2 = (_a = g) !== null && _a !== void 0 ? _a : ((x) => x); ++const c2 = (_c = g) !== null && _c !== void 0 ? _c : ((x) => x); +const c3 = g && ((x) => x); // Parsed as function call, even though this differs from JavaScript const x1 = f(true); // Parsed as relational expressions -@@= skipped -29, +28 lines =@@ +@@= skipped -29, +29 lines =@@ const r2 = f < true > +1; const r3 = f < true > -1; // All of the following are parsed as instantiation expressions diff --git a/testdata/baselines/reference/submodule/conformance/logicalAssignment8(target=es2015).js b/testdata/baselines/reference/submodule/conformance/logicalAssignment8(target=es2015).js index 7826e41fdd..616569395c 100644 --- a/testdata/baselines/reference/submodule/conformance/logicalAssignment8(target=es2015).js +++ b/testdata/baselines/reference/submodule/conformance/logicalAssignment8(target=es2015).js @@ -19,13 +19,13 @@ function foo3(results: number[] | undefined) { //// [logicalAssignment8.js] function foo1(results) { var _a; - (results || (results = (_a = bar?.value) !== null && _a !== void 0 ? _a : [])).push(100); + (results || (results = (_a = bar === null || bar === void 0 ? void 0 : bar.value) !== null && _a !== void 0 ? _a : [])).push(100); } function foo2(results) { var _a; - (results !== null && results !== void 0 ? results : (results = (_a = bar?.value) !== null && _a !== void 0 ? _a : [])).push(100); + (results !== null && results !== void 0 ? results : (results = (_a = bar === null || bar === void 0 ? void 0 : bar.value) !== null && _a !== void 0 ? _a : [])).push(100); } function foo3(results) { var _a; - (results && (results = (_a = bar?.value) !== null && _a !== void 0 ? _a : [])).push(100); + (results && (results = (_a = bar === null || bar === void 0 ? void 0 : bar.value) !== null && _a !== void 0 ? _a : [])).push(100); } diff --git a/testdata/baselines/reference/submodule/conformance/logicalAssignment8(target=es2015).js.diff b/testdata/baselines/reference/submodule/conformance/logicalAssignment8(target=es2015).js.diff index 75a75a016e..92c51dfeeb 100644 --- a/testdata/baselines/reference/submodule/conformance/logicalAssignment8(target=es2015).js.diff +++ b/testdata/baselines/reference/submodule/conformance/logicalAssignment8(target=es2015).js.diff @@ -7,16 +7,4 @@ -"use strict"; function foo1(results) { var _a; -- (results || (results = (_a = bar === null || bar === void 0 ? void 0 : bar.value) !== null && _a !== void 0 ? _a : [])).push(100); -+ (results || (results = (_a = bar?.value) !== null && _a !== void 0 ? _a : [])).push(100); - } - function foo2(results) { - var _a; -- (results !== null && results !== void 0 ? results : (results = (_a = bar === null || bar === void 0 ? void 0 : bar.value) !== null && _a !== void 0 ? _a : [])).push(100); -+ (results !== null && results !== void 0 ? results : (results = (_a = bar?.value) !== null && _a !== void 0 ? _a : [])).push(100); - } - function foo3(results) { - var _a; -- (results && (results = (_a = bar === null || bar === void 0 ? void 0 : bar.value) !== null && _a !== void 0 ? _a : [])).push(100); -+ (results && (results = (_a = bar?.value) !== null && _a !== void 0 ? _a : [])).push(100); - } \ No newline at end of file + (results || (results = (_a = bar === null || bar === void 0 ? void 0 : bar.value) !== null && _a !== void 0 ? _a : [])).push(100); \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/noPropertyAccessFromIndexSignature1.js b/testdata/baselines/reference/submodule/conformance/noPropertyAccessFromIndexSignature1.js index cfac683bc4..d921e96cfb 100644 --- a/testdata/baselines/reference/submodule/conformance/noPropertyAccessFromIndexSignature1.js +++ b/testdata/baselines/reference/submodule/conformance/noPropertyAccessFromIndexSignature1.js @@ -58,8 +58,8 @@ c["foo"]; c.bar; c["bar"]; // optional access property -d?.foo; -d?.["foo"]; +d === null || d === void 0 ? void 0 : d.foo; +d === null || d === void 0 ? void 0 : d["foo"]; // optional access index signature -d?.bar; -d?.["bar"]; +d === null || d === void 0 ? void 0 : d.bar; +d === null || d === void 0 ? void 0 : d["bar"]; diff --git a/testdata/baselines/reference/submodule/conformance/noPropertyAccessFromIndexSignature1.js.diff b/testdata/baselines/reference/submodule/conformance/noPropertyAccessFromIndexSignature1.js.diff deleted file mode 100644 index 0ebe3ee8fe..0000000000 --- a/testdata/baselines/reference/submodule/conformance/noPropertyAccessFromIndexSignature1.js.diff +++ /dev/null @@ -1,15 +0,0 @@ ---- old.noPropertyAccessFromIndexSignature1.js -+++ new.noPropertyAccessFromIndexSignature1.js -@@= skipped -57, +57 lines =@@ - c.bar; - c["bar"]; - // optional access property --d === null || d === void 0 ? void 0 : d.foo; --d === null || d === void 0 ? void 0 : d["foo"]; -+d?.foo; -+d?.["foo"]; - // optional access index signature --d === null || d === void 0 ? void 0 : d.bar; --d === null || d === void 0 ? void 0 : d["bar"]; -+d?.bar; -+d?.["bar"]; \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/nullishCoalescingOperator12.js b/testdata/baselines/reference/submodule/conformance/nullishCoalescingOperator12.js index 7774ff8880..24a506dee7 100644 --- a/testdata/baselines/reference/submodule/conformance/nullishCoalescingOperator12.js +++ b/testdata/baselines/reference/submodule/conformance/nullishCoalescingOperator12.js @@ -8,4 +8,4 @@ for (const i of obj?.arr ?? []) { } //// [nullishCoalescingOperator12.js] var _a; const obj = { arr: [] }; -for (const i of (_a = obj?.arr) !== null && _a !== void 0 ? _a : []) { } +for (const i of (_a = obj === null || obj === void 0 ? void 0 : obj.arr) !== null && _a !== void 0 ? _a : []) { } diff --git a/testdata/baselines/reference/submodule/conformance/nullishCoalescingOperator12.js.diff b/testdata/baselines/reference/submodule/conformance/nullishCoalescingOperator12.js.diff index 62af6d2a87..4d05bb3790 100644 --- a/testdata/baselines/reference/submodule/conformance/nullishCoalescingOperator12.js.diff +++ b/testdata/baselines/reference/submodule/conformance/nullishCoalescingOperator12.js.diff @@ -7,5 +7,4 @@ -"use strict"; var _a; const obj = { arr: [] }; --for (const i of (_a = obj === null || obj === void 0 ? void 0 : obj.arr) !== null && _a !== void 0 ? _a : []) { } -+for (const i of (_a = obj?.arr) !== null && _a !== void 0 ? _a : []) { } \ No newline at end of file + for (const i of (_a = obj === null || obj === void 0 ? void 0 : obj.arr) !== null && _a !== void 0 ? _a : []) { } \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/optionalChainingInArrow.js b/testdata/baselines/reference/submodule/conformance/optionalChainingInArrow.js index e74157ed1a..bb86bff8f4 100644 --- a/testdata/baselines/reference/submodule/conformance/optionalChainingInArrow.js +++ b/testdata/baselines/reference/submodule/conformance/optionalChainingInArrow.js @@ -11,4 +11,4 @@ const test = (names: string[]) => // https://github.com/microsoft/TypeScript/issues/41814 const test = (names) => // single-line comment -names?.filter(x => x); +names === null || names === void 0 ? void 0 : names.filter(x => x); diff --git a/testdata/baselines/reference/submodule/conformance/optionalChainingInArrow.js.diff b/testdata/baselines/reference/submodule/conformance/optionalChainingInArrow.js.diff deleted file mode 100644 index e17ad8e43d..0000000000 --- a/testdata/baselines/reference/submodule/conformance/optionalChainingInArrow.js.diff +++ /dev/null @@ -1,8 +0,0 @@ ---- old.optionalChainingInArrow.js -+++ new.optionalChainingInArrow.js -@@= skipped -10, +10 lines =@@ - // https://github.com/microsoft/TypeScript/issues/41814 - const test = (names) => - // single-line comment --names === null || names === void 0 ? void 0 : names.filter(x => x); -+names?.filter(x => x); \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/optionalChainingInLoop.js b/testdata/baselines/reference/submodule/conformance/optionalChainingInLoop.js index 09609587f8..5a57e6ac84 100644 --- a/testdata/baselines/reference/submodule/conformance/optionalChainingInLoop.js +++ b/testdata/baselines/reference/submodule/conformance/optionalChainingInLoop.js @@ -11,11 +11,12 @@ for (const comp of list) { } //// [optionalChainingInLoop.js] +var _a; // https://github.com/microsoft/TypeScript/issues/40643 const list = []; for (const comp of list) { comp.sp.y = comp.sp.r.find((k) => k.c == (comp.xp ? '1' : '0')); for (const item of comp.c) { - item.v = !!item.t?.length; + item.v = !!((_a = item.t) === null || _a === void 0 ? void 0 : _a.length); } } diff --git a/testdata/baselines/reference/submodule/conformance/optionalChainingInLoop.js.diff b/testdata/baselines/reference/submodule/conformance/optionalChainingInLoop.js.diff deleted file mode 100644 index 6fb72294eb..0000000000 --- a/testdata/baselines/reference/submodule/conformance/optionalChainingInLoop.js.diff +++ /dev/null @@ -1,16 +0,0 @@ ---- old.optionalChainingInLoop.js -+++ new.optionalChainingInLoop.js -@@= skipped -10, +10 lines =@@ - } - - //// [optionalChainingInLoop.js] --var _a; - // https://github.com/microsoft/TypeScript/issues/40643 - const list = []; - for (const comp of list) { - comp.sp.y = comp.sp.r.find((k) => k.c == (comp.xp ? '1' : '0')); - for (const item of comp.c) { -- item.v = !!((_a = item.t) === null || _a === void 0 ? void 0 : _a.length); -+ item.v = !!item.t?.length; - } - } \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/optionalChainingInParameterBindingPattern(target=es2015).js b/testdata/baselines/reference/submodule/conformance/optionalChainingInParameterBindingPattern(target=es2015).js index 7b41f8c7ba..4deb650441 100644 --- a/testdata/baselines/reference/submodule/conformance/optionalChainingInParameterBindingPattern(target=es2015).js +++ b/testdata/baselines/reference/submodule/conformance/optionalChainingInParameterBindingPattern(target=es2015).js @@ -8,4 +8,4 @@ const a = (): { d: string } | undefined => undefined; //// [optionalChainingInParameterBindingPattern.js] // https://github.com/microsoft/TypeScript/issues/36295 const a = () => undefined; -(({ [a()?.d]: c = "" }) => { })(); +((_a) => { var _b; var { [(_b = a()) === null || _b === void 0 ? void 0 : _b.d]: c = "" } = _a; })(); diff --git a/testdata/baselines/reference/submodule/conformance/optionalChainingInParameterBindingPattern(target=es2015).js.diff b/testdata/baselines/reference/submodule/conformance/optionalChainingInParameterBindingPattern(target=es2015).js.diff deleted file mode 100644 index 9f46196d7e..0000000000 --- a/testdata/baselines/reference/submodule/conformance/optionalChainingInParameterBindingPattern(target=es2015).js.diff +++ /dev/null @@ -1,8 +0,0 @@ ---- old.optionalChainingInParameterBindingPattern(target=es2015).js -+++ new.optionalChainingInParameterBindingPattern(target=es2015).js -@@= skipped -7, +7 lines =@@ - //// [optionalChainingInParameterBindingPattern.js] - // https://github.com/microsoft/TypeScript/issues/36295 - const a = () => undefined; --((_a) => { var _b; var { [(_b = a()) === null || _b === void 0 ? void 0 : _b.d]: c = "" } = _a; })(); -+(({ [a()?.d]: c = "" }) => { })(); \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/optionalChainingInParameterBindingPattern(target=es5).js b/testdata/baselines/reference/submodule/conformance/optionalChainingInParameterBindingPattern(target=es5).js index 7b41f8c7ba..4deb650441 100644 --- a/testdata/baselines/reference/submodule/conformance/optionalChainingInParameterBindingPattern(target=es5).js +++ b/testdata/baselines/reference/submodule/conformance/optionalChainingInParameterBindingPattern(target=es5).js @@ -8,4 +8,4 @@ const a = (): { d: string } | undefined => undefined; //// [optionalChainingInParameterBindingPattern.js] // https://github.com/microsoft/TypeScript/issues/36295 const a = () => undefined; -(({ [a()?.d]: c = "" }) => { })(); +((_a) => { var _b; var { [(_b = a()) === null || _b === void 0 ? void 0 : _b.d]: c = "" } = _a; })(); diff --git a/testdata/baselines/reference/submodule/conformance/optionalChainingInParameterBindingPattern(target=es5).js.diff b/testdata/baselines/reference/submodule/conformance/optionalChainingInParameterBindingPattern(target=es5).js.diff index db2825db1e..7c71197c1c 100644 --- a/testdata/baselines/reference/submodule/conformance/optionalChainingInParameterBindingPattern(target=es5).js.diff +++ b/testdata/baselines/reference/submodule/conformance/optionalChainingInParameterBindingPattern(target=es5).js.diff @@ -5,4 +5,4 @@ // https://github.com/microsoft/TypeScript/issues/36295 const a = () => undefined; -(({ [(_a = a()) === null || _a === void 0 ? void 0 : _a.d]: c = "" }) => { var _a; })(); -+(({ [a()?.d]: c = "" }) => { })(); \ No newline at end of file ++((_a) => { var _b; var { [(_b = a()) === null || _b === void 0 ? void 0 : _b.d]: c = "" } = _a; })(); \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/optionalChainingInParameterInitializer(target=es2015).js b/testdata/baselines/reference/submodule/conformance/optionalChainingInParameterInitializer(target=es2015).js index 0dd40a273b..65f2d01613 100644 --- a/testdata/baselines/reference/submodule/conformance/optionalChainingInParameterInitializer(target=es2015).js +++ b/testdata/baselines/reference/submodule/conformance/optionalChainingInParameterInitializer(target=es2015).js @@ -8,4 +8,4 @@ const a = (): { d: string } | undefined => undefined; //// [optionalChainingInParameterInitializer.js] // https://github.com/microsoft/TypeScript/issues/36295 const a = () => undefined; -((b = a()?.d) => { })(); +((b) => { var _a; if (b === void 0) { b = (_a = a()) === null || _a === void 0 ? void 0 : _a.d; } })(); diff --git a/testdata/baselines/reference/submodule/conformance/optionalChainingInParameterInitializer(target=es2015).js.diff b/testdata/baselines/reference/submodule/conformance/optionalChainingInParameterInitializer(target=es2015).js.diff deleted file mode 100644 index 42384b2b1e..0000000000 --- a/testdata/baselines/reference/submodule/conformance/optionalChainingInParameterInitializer(target=es2015).js.diff +++ /dev/null @@ -1,8 +0,0 @@ ---- old.optionalChainingInParameterInitializer(target=es2015).js -+++ new.optionalChainingInParameterInitializer(target=es2015).js -@@= skipped -7, +7 lines =@@ - //// [optionalChainingInParameterInitializer.js] - // https://github.com/microsoft/TypeScript/issues/36295 - const a = () => undefined; --((b) => { var _a; if (b === void 0) { b = (_a = a()) === null || _a === void 0 ? void 0 : _a.d; } })(); -+((b = a()?.d) => { })(); \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/optionalChainingInParameterInitializer(target=es5).js b/testdata/baselines/reference/submodule/conformance/optionalChainingInParameterInitializer(target=es5).js index 0dd40a273b..65f2d01613 100644 --- a/testdata/baselines/reference/submodule/conformance/optionalChainingInParameterInitializer(target=es5).js +++ b/testdata/baselines/reference/submodule/conformance/optionalChainingInParameterInitializer(target=es5).js @@ -8,4 +8,4 @@ const a = (): { d: string } | undefined => undefined; //// [optionalChainingInParameterInitializer.js] // https://github.com/microsoft/TypeScript/issues/36295 const a = () => undefined; -((b = a()?.d) => { })(); +((b) => { var _a; if (b === void 0) { b = (_a = a()) === null || _a === void 0 ? void 0 : _a.d; } })(); diff --git a/testdata/baselines/reference/submodule/conformance/optionalChainingInParameterInitializer(target=es5).js.diff b/testdata/baselines/reference/submodule/conformance/optionalChainingInParameterInitializer(target=es5).js.diff index 27412a26d2..5d06779d69 100644 --- a/testdata/baselines/reference/submodule/conformance/optionalChainingInParameterInitializer(target=es5).js.diff +++ b/testdata/baselines/reference/submodule/conformance/optionalChainingInParameterInitializer(target=es5).js.diff @@ -5,4 +5,4 @@ // https://github.com/microsoft/TypeScript/issues/36295 const a = () => undefined; -((b = (_a = a()) === null || _a === void 0 ? void 0 : _a.d) => { var _a; })(); -+((b = a()?.d) => { })(); \ No newline at end of file ++((b) => { var _a; if (b === void 0) { b = (_a = a()) === null || _a === void 0 ? void 0 : _a.d; } })(); \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/optionalChainingInTypeAssertions(target=es2015).js b/testdata/baselines/reference/submodule/conformance/optionalChainingInTypeAssertions(target=es2015).js index 8f59b77d39..5fff692879 100644 --- a/testdata/baselines/reference/submodule/conformance/optionalChainingInTypeAssertions(target=es2015).js +++ b/testdata/baselines/reference/submodule/conformance/optionalChainingInTypeAssertions(target=es2015).js @@ -20,16 +20,17 @@ const foo = new Foo(); (foo?.["m"]).length; //// [optionalChainingInTypeAssertions.js] +var _a, _b, _c, _d; class Foo { m() { } } const foo = new Foo(); -foo.m?.(); -foo.m?.(); -/*a1*/ foo.m /*a3*/ /*a4*/?.(); -/*b1*/ foo.m /*b3*/ /*b4*/?.(); +(_a = foo.m) === null || _a === void 0 ? void 0 : _a.call(foo); +(_b = foo.m) === null || _b === void 0 ? void 0 : _b.call(foo); +/*a1*/ (_c = foo.m /*a3*/ /*a4*/) === null || _c === void 0 ? void 0 : _c.call(/*a2*/ foo); +/*b1*/ (_d = foo.m /*b3*/ /*b4*/) === null || _d === void 0 ? void 0 : _d.call(foo); // https://github.com/microsoft/TypeScript/issues/50148 -((foo?.m)).length; -((foo?.m)).length; -((foo?.["m"])).length; -((foo?.["m"])).length; +((foo === null || foo === void 0 ? void 0 : foo.m)).length; +((foo === null || foo === void 0 ? void 0 : foo.m)).length; +((foo === null || foo === void 0 ? void 0 : foo["m"])).length; +((foo === null || foo === void 0 ? void 0 : foo["m"])).length; diff --git a/testdata/baselines/reference/submodule/conformance/optionalChainingInTypeAssertions(target=es2015).js.diff b/testdata/baselines/reference/submodule/conformance/optionalChainingInTypeAssertions(target=es2015).js.diff index ec663003c1..0498705a1a 100644 --- a/testdata/baselines/reference/submodule/conformance/optionalChainingInTypeAssertions(target=es2015).js.diff +++ b/testdata/baselines/reference/submodule/conformance/optionalChainingInTypeAssertions(target=es2015).js.diff @@ -1,28 +1,19 @@ --- old.optionalChainingInTypeAssertions(target=es2015).js +++ new.optionalChainingInTypeAssertions(target=es2015).js -@@= skipped -19, +19 lines =@@ - (foo?.["m"]).length; - - //// [optionalChainingInTypeAssertions.js] --var _a, _b, _c, _d; - class Foo { - m() { } - } +@@= skipped -26, +26 lines =@@ const foo = new Foo(); --(_a = foo.m) === null || _a === void 0 ? void 0 : _a.call(foo); --(_b = foo.m) === null || _b === void 0 ? void 0 : _b.call(foo); + (_a = foo.m) === null || _a === void 0 ? void 0 : _a.call(foo); + (_b = foo.m) === null || _b === void 0 ? void 0 : _b.call(foo); -/*a1*/ (_c = /*a2*/ foo.m /*a3*/ /*a4*/) === null || _c === void 0 ? void 0 : _c.call(foo); -/*b1*/ (_d = /*b2*/ foo.m /*b3*/ /*b4*/) === null || _d === void 0 ? void 0 : _d.call(foo); -+foo.m?.(); -+foo.m?.(); -+/*a1*/ foo.m /*a3*/ /*a4*/?.(); -+/*b1*/ foo.m /*b3*/ /*b4*/?.(); ++/*a1*/ (_c = foo.m /*a3*/ /*a4*/) === null || _c === void 0 ? void 0 : _c.call(/*a2*/ foo); ++/*b1*/ (_d = foo.m /*b3*/ /*b4*/) === null || _d === void 0 ? void 0 : _d.call(foo); // https://github.com/microsoft/TypeScript/issues/50148 -(foo === null || foo === void 0 ? void 0 : foo.m).length; -(foo === null || foo === void 0 ? void 0 : foo.m).length; -(foo === null || foo === void 0 ? void 0 : foo["m"]).length; -(foo === null || foo === void 0 ? void 0 : foo["m"]).length; -+((foo?.m)).length; -+((foo?.m)).length; -+((foo?.["m"])).length; -+((foo?.["m"])).length; \ No newline at end of file ++((foo === null || foo === void 0 ? void 0 : foo.m)).length; ++((foo === null || foo === void 0 ? void 0 : foo.m)).length; ++((foo === null || foo === void 0 ? void 0 : foo["m"])).length; ++((foo === null || foo === void 0 ? void 0 : foo["m"])).length; \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/optionalChainingInference.js b/testdata/baselines/reference/submodule/conformance/optionalChainingInference.js index ed865215f9..6848f099bd 100644 --- a/testdata/baselines/reference/submodule/conformance/optionalChainingInference.js +++ b/testdata/baselines/reference/submodule/conformance/optionalChainingInference.js @@ -35,19 +35,19 @@ const v8: number = unbox(b8); //// [optionalChainingInference.js] -const b1 = { value: su?.length }; +const b1 = { value: su === null || su === void 0 ? void 0 : su.length }; const v1 = unbox(b1); -const b2 = { value: su?.length }; +const b2 = { value: su === null || su === void 0 ? void 0 : su.length }; const v2 = unbox(b2); -const b3 = { value: su?.length }; +const b3 = { value: su === null || su === void 0 ? void 0 : su.length }; const v3 = unbox(b3); -const b4 = { value: fnu?.() }; +const b4 = { value: fnu === null || fnu === void 0 ? void 0 : fnu() }; const v4 = unbox(b4); -const b5 = { value: su?.["length"] }; +const b5 = { value: su === null || su === void 0 ? void 0 : su["length"] }; const v5 = unbox(b5); -const b6 = { value: osu?.prop.length }; +const b6 = { value: osu === null || osu === void 0 ? void 0 : osu.prop.length }; const v6 = unbox(b6); -const b7 = { value: osu?.prop["length"] }; +const b7 = { value: osu === null || osu === void 0 ? void 0 : osu.prop["length"] }; const v7 = unbox(b7); -const b8 = { value: ofnu?.prop() }; +const b8 = { value: ofnu === null || ofnu === void 0 ? void 0 : ofnu.prop() }; const v8 = unbox(b8); diff --git a/testdata/baselines/reference/submodule/conformance/optionalChainingInference.js.diff b/testdata/baselines/reference/submodule/conformance/optionalChainingInference.js.diff deleted file mode 100644 index 585b39e3c2..0000000000 --- a/testdata/baselines/reference/submodule/conformance/optionalChainingInference.js.diff +++ /dev/null @@ -1,30 +0,0 @@ ---- old.optionalChainingInference.js -+++ new.optionalChainingInference.js -@@= skipped -34, +34 lines =@@ - - - //// [optionalChainingInference.js] --const b1 = { value: su === null || su === void 0 ? void 0 : su.length }; -+const b1 = { value: su?.length }; - const v1 = unbox(b1); --const b2 = { value: su === null || su === void 0 ? void 0 : su.length }; -+const b2 = { value: su?.length }; - const v2 = unbox(b2); --const b3 = { value: su === null || su === void 0 ? void 0 : su.length }; -+const b3 = { value: su?.length }; - const v3 = unbox(b3); --const b4 = { value: fnu === null || fnu === void 0 ? void 0 : fnu() }; -+const b4 = { value: fnu?.() }; - const v4 = unbox(b4); --const b5 = { value: su === null || su === void 0 ? void 0 : su["length"] }; -+const b5 = { value: su?.["length"] }; - const v5 = unbox(b5); --const b6 = { value: osu === null || osu === void 0 ? void 0 : osu.prop.length }; -+const b6 = { value: osu?.prop.length }; - const v6 = unbox(b6); --const b7 = { value: osu === null || osu === void 0 ? void 0 : osu.prop["length"] }; -+const b7 = { value: osu?.prop["length"] }; - const v7 = unbox(b7); --const b8 = { value: ofnu === null || ofnu === void 0 ? void 0 : ofnu.prop() }; -+const b8 = { value: ofnu?.prop() }; - const v8 = unbox(b8); \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/parentheses.js b/testdata/baselines/reference/submodule/conformance/parentheses.js index a674ec19cc..357ce55aba 100644 --- a/testdata/baselines/reference/submodule/conformance/parentheses.js +++ b/testdata/baselines/reference/submodule/conformance/parentheses.js @@ -13,7 +13,8 @@ declare const o4: { b: ((...args: any[]) => { c: (...args: any[]) => number } ) //// [parentheses.js] +var _a; (o1)(o1 !== null && o1 !== void 0 ? o1 : 1); -(o2?.b)(o1 !== null && o1 !== void 0 ? o1 : 1); -(o3?.b())(o1 !== null && o1 !== void 0 ? o1 : 1); -(o4?.b().c)(o1 !== null && o1 !== void 0 ? o1 : 1); +(o2 === null || o2 === void 0 ? void 0 : o2.b).call(o2, o1 !== null && o1 !== void 0 ? o1 : 1); +(o3 === null || o3 === void 0 ? void 0 : o3.b())(o1 !== null && o1 !== void 0 ? o1 : 1); +(o4 === null || o4 === void 0 ? void 0 : (_a = o4.b()).c).call(_a, o1 !== null && o1 !== void 0 ? o1 : 1); diff --git a/testdata/baselines/reference/submodule/conformance/parentheses.js.diff b/testdata/baselines/reference/submodule/conformance/parentheses.js.diff deleted file mode 100644 index a64e6cefa3..0000000000 --- a/testdata/baselines/reference/submodule/conformance/parentheses.js.diff +++ /dev/null @@ -1,14 +0,0 @@ ---- old.parentheses.js -+++ new.parentheses.js -@@= skipped -12, +12 lines =@@ - - - //// [parentheses.js] --var _a; - (o1)(o1 !== null && o1 !== void 0 ? o1 : 1); --(o2 === null || o2 === void 0 ? void 0 : o2.b).call(o2, o1 !== null && o1 !== void 0 ? o1 : 1); --(o3 === null || o3 === void 0 ? void 0 : o3.b())(o1 !== null && o1 !== void 0 ? o1 : 1); --(o4 === null || o4 === void 0 ? void 0 : (_a = o4.b()).c).call(_a, o1 !== null && o1 !== void 0 ? o1 : 1); -+(o2?.b)(o1 !== null && o1 !== void 0 ? o1 : 1); -+(o3?.b())(o1 !== null && o1 !== void 0 ? o1 : 1); -+(o4?.b().c)(o1 !== null && o1 !== void 0 ? o1 : 1); \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/privateNameFieldCallExpression.js b/testdata/baselines/reference/submodule/conformance/privateNameFieldCallExpression.js index d5d78ae34c..cee2f08b3f 100644 --- a/testdata/baselines/reference/submodule/conformance/privateNameFieldCallExpression.js +++ b/testdata/baselines/reference/submodule/conformance/privateNameFieldCallExpression.js @@ -28,8 +28,9 @@ class A { #fieldFunc2 = function (a, ...b) { }; x = 1; test() { + var _a; this.#fieldFunc(); - this.#fieldFunc?.(); + (_a = this.#fieldFunc) === null || _a === void 0 ? void 0 : _a.call(this); const func = this.#fieldFunc; func(); new this.#fieldFunc(); diff --git a/testdata/baselines/reference/submodule/conformance/privateNameFieldCallExpression.js.diff b/testdata/baselines/reference/submodule/conformance/privateNameFieldCallExpression.js.diff index 17d1aea37f..24e3f33bd1 100644 --- a/testdata/baselines/reference/submodule/conformance/privateNameFieldCallExpression.js.diff +++ b/testdata/baselines/reference/submodule/conformance/privateNameFieldCallExpression.js.diff @@ -20,13 +20,13 @@ + #fieldFunc2 = function (a, ...b) { }; + x = 1; test() { -- var _a; + var _a; - var _b; - __classPrivateFieldGet(this, _A_fieldFunc, "f").call(this); - (_a = __classPrivateFieldGet(this, _A_fieldFunc, "f")) === null || _a === void 0 ? void 0 : _a.call(this); - const func = __classPrivateFieldGet(this, _A_fieldFunc, "f"); + this.#fieldFunc(); -+ this.#fieldFunc?.(); ++ (_a = this.#fieldFunc) === null || _a === void 0 ? void 0 : _a.call(this); + const func = this.#fieldFunc; func(); - new (__classPrivateFieldGet(this, _A_fieldFunc, "f"))(); diff --git a/testdata/baselines/reference/submodule/conformance/privateNameStaticFieldCallExpression.js b/testdata/baselines/reference/submodule/conformance/privateNameStaticFieldCallExpression.js index 9ad006a032..86f38d1329 100644 --- a/testdata/baselines/reference/submodule/conformance/privateNameStaticFieldCallExpression.js +++ b/testdata/baselines/reference/submodule/conformance/privateNameStaticFieldCallExpression.js @@ -28,8 +28,9 @@ class A { static #fieldFunc2 = function (a, ...b) { }; x = 1; test() { + var _a; A.#fieldFunc(); - A.#fieldFunc?.(); + (_a = A.#fieldFunc) === null || _a === void 0 ? void 0 : _a.call(A); const func = A.#fieldFunc; func(); new A.#fieldFunc(); diff --git a/testdata/baselines/reference/submodule/conformance/privateNameStaticFieldCallExpression.js.diff b/testdata/baselines/reference/submodule/conformance/privateNameStaticFieldCallExpression.js.diff index 27830cc263..6c3aa71757 100644 --- a/testdata/baselines/reference/submodule/conformance/privateNameStaticFieldCallExpression.js.diff +++ b/testdata/baselines/reference/submodule/conformance/privateNameStaticFieldCallExpression.js.diff @@ -23,8 +23,9 @@ - __classPrivateFieldGet(_a, _a, "f", _A_fieldFunc).call(_a); - (_b = __classPrivateFieldGet(_a, _a, "f", _A_fieldFunc)) === null || _b === void 0 ? void 0 : _b.call(_a); - const func = __classPrivateFieldGet(_a, _a, "f", _A_fieldFunc); ++ var _a; + A.#fieldFunc(); -+ A.#fieldFunc?.(); ++ (_a = A.#fieldFunc) === null || _a === void 0 ? void 0 : _a.call(A); + const func = A.#fieldFunc; func(); - new (__classPrivateFieldGet(_a, _a, "f", _A_fieldFunc))(); diff --git a/testdata/baselines/reference/submodule/conformance/propertyAccessChain.2.js b/testdata/baselines/reference/submodule/conformance/propertyAccessChain.2.js index c9e7b3204c..85604709ce 100644 --- a/testdata/baselines/reference/submodule/conformance/propertyAccessChain.2.js +++ b/testdata/baselines/reference/submodule/conformance/propertyAccessChain.2.js @@ -12,6 +12,7 @@ o3.b?.c; //// [propertyAccessChain.2.js] -o1?.b; -o2?.b.c; -o3.b?.c; +var _a; +o1 === null || o1 === void 0 ? void 0 : o1.b; +o2 === null || o2 === void 0 ? void 0 : o2.b.c; +(_a = o3.b) === null || _a === void 0 ? void 0 : _a.c; diff --git a/testdata/baselines/reference/submodule/conformance/propertyAccessChain.2.js.diff b/testdata/baselines/reference/submodule/conformance/propertyAccessChain.2.js.diff deleted file mode 100644 index d42f6be3d1..0000000000 --- a/testdata/baselines/reference/submodule/conformance/propertyAccessChain.2.js.diff +++ /dev/null @@ -1,13 +0,0 @@ ---- old.propertyAccessChain.2.js -+++ new.propertyAccessChain.2.js -@@= skipped -11, +11 lines =@@ - - - //// [propertyAccessChain.2.js] --var _a; --o1 === null || o1 === void 0 ? void 0 : o1.b; --o2 === null || o2 === void 0 ? void 0 : o2.b.c; --(_a = o3.b) === null || _a === void 0 ? void 0 : _a.c; -+o1?.b; -+o2?.b.c; -+o3.b?.c; \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/propertyAccessChain.3.js b/testdata/baselines/reference/submodule/conformance/propertyAccessChain.3.js index 924cbc7420..b7ac876bcf 100644 --- a/testdata/baselines/reference/submodule/conformance/propertyAccessChain.3.js +++ b/testdata/baselines/reference/submodule/conformance/propertyAccessChain.3.js @@ -32,29 +32,29 @@ for (obj?.a.b of []); //// [propertyAccessChain.3.js] -obj?.a++; -obj?.a.b++; -obj?.a--; -obj?.a.b--; -++obj?.a; -++obj?.a.b; ---obj?.a; ---obj?.a.b; -obj?.a = 1; -obj?.a.b = 1; -obj?.a += 1; -obj?.a.b += 1; -for (obj?.a in {}) +(obj === null || obj === void 0 ? void 0 : obj.a)++; +(obj === null || obj === void 0 ? void 0 : obj.a.b)++; +(obj === null || obj === void 0 ? void 0 : obj.a)--; +(obj === null || obj === void 0 ? void 0 : obj.a.b)--; +++(obj === null || obj === void 0 ? void 0 : obj.a); +++(obj === null || obj === void 0 ? void 0 : obj.a.b); +--(obj === null || obj === void 0 ? void 0 : obj.a); +--(obj === null || obj === void 0 ? void 0 : obj.a.b); +(obj === null || obj === void 0 ? void 0 : obj.a) = 1; +(obj === null || obj === void 0 ? void 0 : obj.a.b) = 1; +(obj === null || obj === void 0 ? void 0 : obj.a) += 1; +(obj === null || obj === void 0 ? void 0 : obj.a.b) += 1; +for (obj === null || obj === void 0 ? void 0 : obj.a in {}) ; -for (obj?.a.b in {}) +for (obj === null || obj === void 0 ? void 0 : obj.a.b in {}) ; -for (obj?.a of []) +for (obj === null || obj === void 0 ? void 0 : obj.a of []) ; -for (obj?.a.b of []) +for (obj === null || obj === void 0 ? void 0 : obj.a.b of []) ; -({ a: obj?.a } = { a: 1 }); -({ a: obj?.a.b } = { a: 1 }); -({ ...obj?.a } = { a: 1 }); -({ ...obj?.a.b } = { a: 1 }); -[...obj?.a] = []; -[...obj?.a.b] = []; +({ a: obj === null || obj === void 0 ? void 0 : obj.a } = { a: 1 }); +({ a: obj === null || obj === void 0 ? void 0 : obj.a.b } = { a: 1 }); +({ ...obj === null || obj === void 0 ? void 0 : obj.a } = { a: 1 }); +({ ...obj === null || obj === void 0 ? void 0 : obj.a.b } = { a: 1 }); +[...obj === null || obj === void 0 ? void 0 : obj.a] = []; +[...obj === null || obj === void 0 ? void 0 : obj.a.b] = []; diff --git a/testdata/baselines/reference/submodule/conformance/propertyAccessChain.3.js.diff b/testdata/baselines/reference/submodule/conformance/propertyAccessChain.3.js.diff index b2d734a5b5..063462ee25 100644 --- a/testdata/baselines/reference/submodule/conformance/propertyAccessChain.3.js.diff +++ b/testdata/baselines/reference/submodule/conformance/propertyAccessChain.3.js.diff @@ -16,55 +16,31 @@ - } - return t; -}; --(obj === null || obj === void 0 ? void 0 : obj.a)++; --(obj === null || obj === void 0 ? void 0 : obj.a.b)++; --(obj === null || obj === void 0 ? void 0 : obj.a)--; --(obj === null || obj === void 0 ? void 0 : obj.a.b)--; --++(obj === null || obj === void 0 ? void 0 : obj.a); --++(obj === null || obj === void 0 ? void 0 : obj.a.b); ----(obj === null || obj === void 0 ? void 0 : obj.a); ----(obj === null || obj === void 0 ? void 0 : obj.a.b); + (obj === null || obj === void 0 ? void 0 : obj.a)++; + (obj === null || obj === void 0 ? void 0 : obj.a.b)++; + (obj === null || obj === void 0 ? void 0 : obj.a)--; +@@= skipped -20, +8 lines =@@ + ++(obj === null || obj === void 0 ? void 0 : obj.a.b); + --(obj === null || obj === void 0 ? void 0 : obj.a); + --(obj === null || obj === void 0 ? void 0 : obj.a.b); -obj === null || obj === void 0 ? void 0 : obj.a = 1; -obj === null || obj === void 0 ? void 0 : obj.a.b = 1; -obj === null || obj === void 0 ? void 0 : obj.a += 1; -obj === null || obj === void 0 ? void 0 : obj.a.b += 1; --for (obj === null || obj === void 0 ? void 0 : obj.a in {}) -- ; --for (obj === null || obj === void 0 ? void 0 : obj.a.b in {}) -- ; --for (obj === null || obj === void 0 ? void 0 : obj.a of []) -- ; --for (obj === null || obj === void 0 ? void 0 : obj.a.b of []) -- ; --({ a: obj === null || obj === void 0 ? void 0 : obj.a } = { a: 1 }); --({ a: obj === null || obj === void 0 ? void 0 : obj.a.b } = { a: 1 }); ++(obj === null || obj === void 0 ? void 0 : obj.a) = 1; ++(obj === null || obj === void 0 ? void 0 : obj.a.b) = 1; ++(obj === null || obj === void 0 ? void 0 : obj.a) += 1; ++(obj === null || obj === void 0 ? void 0 : obj.a.b) += 1; + for (obj === null || obj === void 0 ? void 0 : obj.a in {}) + ; + for (obj === null || obj === void 0 ? void 0 : obj.a.b in {}) +@@= skipped -14, +14 lines =@@ + ; + ({ a: obj === null || obj === void 0 ? void 0 : obj.a } = { a: 1 }); + ({ a: obj === null || obj === void 0 ? void 0 : obj.a.b } = { a: 1 }); -(obj === null || obj === void 0 ? void 0 : obj.a = __rest({ a: 1 }, [])); -(obj === null || obj === void 0 ? void 0 : obj.a.b = __rest({ a: 1 }, [])); --[...obj === null || obj === void 0 ? void 0 : obj.a] = []; --[...obj === null || obj === void 0 ? void 0 : obj.a.b] = []; -+obj?.a++; -+obj?.a.b++; -+obj?.a--; -+obj?.a.b--; -+++obj?.a; -+++obj?.a.b; -+--obj?.a; -+--obj?.a.b; -+obj?.a = 1; -+obj?.a.b = 1; -+obj?.a += 1; -+obj?.a.b += 1; -+for (obj?.a in {}) -+ ; -+for (obj?.a.b in {}) -+ ; -+for (obj?.a of []) -+ ; -+for (obj?.a.b of []) -+ ; -+({ a: obj?.a } = { a: 1 }); -+({ a: obj?.a.b } = { a: 1 }); -+({ ...obj?.a } = { a: 1 }); -+({ ...obj?.a.b } = { a: 1 }); -+[...obj?.a] = []; -+[...obj?.a.b] = []; \ No newline at end of file ++({ ...obj === null || obj === void 0 ? void 0 : obj.a } = { a: 1 }); ++({ ...obj === null || obj === void 0 ? void 0 : obj.a.b } = { a: 1 }); + [...obj === null || obj === void 0 ? void 0 : obj.a] = []; + [...obj === null || obj === void 0 ? void 0 : obj.a.b] = []; \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/propertyAccessChain.js b/testdata/baselines/reference/submodule/conformance/propertyAccessChain.js index adf2e8a392..f24285c355 100644 --- a/testdata/baselines/reference/submodule/conformance/propertyAccessChain.js +++ b/testdata/baselines/reference/submodule/conformance/propertyAccessChain.js @@ -28,14 +28,15 @@ o2?.b!.c; o2?.b!.c!; //// [propertyAccessChain.js] -o1?.b; -o2?.b.c; -o3.b?.c; -o4.b?.c.d?.e; -o5.b?.().c.d?.e; -o6()?.x; +var _a, _b, _c, _d, _e, _f; +o1 === null || o1 === void 0 ? void 0 : o1.b; +o2 === null || o2 === void 0 ? void 0 : o2.b.c; +(_a = o3.b) === null || _a === void 0 ? void 0 : _a.c; +(_c = (_b = o4.b) === null || _b === void 0 ? void 0 : _b.c.d) === null || _c === void 0 ? void 0 : _c.e; +(_e = (_d = o5.b) === null || _d === void 0 ? void 0 : _d.call(o5).c.d) === null || _e === void 0 ? void 0 : _e.e; +(_f = o6()) === null || _f === void 0 ? void 0 : _f.x; // GH#34109 -o1?.b ? 1 : 0; +(o1 === null || o1 === void 0 ? void 0 : o1.b) ? 1 : 0; // GH#36031 -o2?.b.c; -o2?.b.c; +o2 === null || o2 === void 0 ? void 0 : o2.b.c; +o2 === null || o2 === void 0 ? void 0 : o2.b.c; diff --git a/testdata/baselines/reference/submodule/conformance/propertyAccessChain.js.diff b/testdata/baselines/reference/submodule/conformance/propertyAccessChain.js.diff index 93333f13bf..4eefae7a85 100644 --- a/testdata/baselines/reference/submodule/conformance/propertyAccessChain.js.diff +++ b/testdata/baselines/reference/submodule/conformance/propertyAccessChain.js.diff @@ -5,24 +5,6 @@ //// [propertyAccessChain.js] -"use strict"; --var _a, _b, _c, _d, _e, _f; --o1 === null || o1 === void 0 ? void 0 : o1.b; --o2 === null || o2 === void 0 ? void 0 : o2.b.c; --(_a = o3.b) === null || _a === void 0 ? void 0 : _a.c; --(_c = (_b = o4.b) === null || _b === void 0 ? void 0 : _b.c.d) === null || _c === void 0 ? void 0 : _c.e; --(_e = (_d = o5.b) === null || _d === void 0 ? void 0 : _d.call(o5).c.d) === null || _e === void 0 ? void 0 : _e.e; --(_f = o6()) === null || _f === void 0 ? void 0 : _f.x; -+o1?.b; -+o2?.b.c; -+o3.b?.c; -+o4.b?.c.d?.e; -+o5.b?.().c.d?.e; -+o6()?.x; - // GH#34109 --(o1 === null || o1 === void 0 ? void 0 : o1.b) ? 1 : 0; -+o1?.b ? 1 : 0; - // GH#36031 --o2 === null || o2 === void 0 ? void 0 : o2.b.c; --o2 === null || o2 === void 0 ? void 0 : o2.b.c; -+o2?.b.c; -+o2?.b.c; \ No newline at end of file + var _a, _b, _c, _d, _e, _f; + o1 === null || o1 === void 0 ? void 0 : o1.b; + o2 === null || o2 === void 0 ? void 0 : o2.b.c; \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/superMethodCall.js b/testdata/baselines/reference/submodule/conformance/superMethodCall.js index 12eaffcd35..25cd8a0890 100644 --- a/testdata/baselines/reference/submodule/conformance/superMethodCall.js +++ b/testdata/baselines/reference/submodule/conformance/superMethodCall.js @@ -21,9 +21,11 @@ class Base { } class Derived extends Base { method() { - return super.method?.(); + var _a; + return (_a = super.method) === null || _a === void 0 ? void 0 : _a.call(this); } async asyncMethod() { - return super.method?.(); + var _a; + return (_a = super.method) === null || _a === void 0 ? void 0 : _a.call(this); } } diff --git a/testdata/baselines/reference/submodule/conformance/superMethodCall.js.diff b/testdata/baselines/reference/submodule/conformance/superMethodCall.js.diff index b604994449..4fe90e06ad 100644 --- a/testdata/baselines/reference/submodule/conformance/superMethodCall.js.diff +++ b/testdata/baselines/reference/submodule/conformance/superMethodCall.js.diff @@ -17,11 +17,9 @@ class Base { method() { } } - class Derived extends Base { - method() { -- var _a; -- return (_a = super.method) === null || _a === void 0 ? void 0 : _a.call(this); -+ return super.method?.(); +@@= skipped -18, +8 lines =@@ + var _a; + return (_a = super.method) === null || _a === void 0 ? void 0 : _a.call(this); } - asyncMethod() { - const _super = Object.create(null, { @@ -32,6 +30,7 @@ - return (_a = _super.method) === null || _a === void 0 ? void 0 : _a.call(this); - }); + async asyncMethod() { -+ return super.method?.(); ++ var _a; ++ return (_a = super.method) === null || _a === void 0 ? void 0 : _a.call(this); } } \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/thisAndSuperInStaticMembers1(target=es2015).js b/testdata/baselines/reference/submodule/conformance/thisAndSuperInStaticMembers1(target=es2015).js index c48a39165e..1ed7df38df 100644 --- a/testdata/baselines/reference/submodule/conformance/thisAndSuperInStaticMembers1(target=es2015).js +++ b/testdata/baselines/reference/submodule/conformance/thisAndSuperInStaticMembers1(target=es2015).js @@ -46,9 +46,9 @@ class C extends B { static x = undefined; static y1 = this.x; static y2 = this.x(); - static y3 = this?.x(); + static y3 = this === null || this === void 0 ? void 0 : this.x(); static y4 = this[("x")](); - static y5 = this?.[("x")](); + static y5 = this === null || this === void 0 ? void 0 : this[("x")](); static z1 = super.a; static z2 = super["a"]; static z3 = super.f(); diff --git a/testdata/baselines/reference/submodule/conformance/thisAndSuperInStaticMembers1(target=es2015).js.diff b/testdata/baselines/reference/submodule/conformance/thisAndSuperInStaticMembers1(target=es2015).js.diff index f5b34c9e88..23a2b96902 100644 --- a/testdata/baselines/reference/submodule/conformance/thisAndSuperInStaticMembers1(target=es2015).js.diff +++ b/testdata/baselines/reference/submodule/conformance/thisAndSuperInStaticMembers1(target=es2015).js.diff @@ -44,9 +44,9 @@ + static x = undefined; + static y1 = this.x; + static y2 = this.x(); -+ static y3 = this?.x(); ++ static y3 = this === null || this === void 0 ? void 0 : this.x(); + static y4 = this[("x")](); -+ static y5 = this?.[("x")](); ++ static y5 = this === null || this === void 0 ? void 0 : this[("x")](); + static z1 = super.a; + static z2 = super["a"]; + static z3 = super.f(); diff --git a/testdata/baselines/reference/submodule/conformance/thisAndSuperInStaticMembers2(target=es2015).js b/testdata/baselines/reference/submodule/conformance/thisAndSuperInStaticMembers2(target=es2015).js index 9d03053244..fa69f47702 100644 --- a/testdata/baselines/reference/submodule/conformance/thisAndSuperInStaticMembers2(target=es2015).js +++ b/testdata/baselines/reference/submodule/conformance/thisAndSuperInStaticMembers2(target=es2015).js @@ -46,9 +46,9 @@ class C extends B { static x = undefined; static y1 = this.x; static y2 = this.x(); - static y3 = this?.x(); + static y3 = this === null || this === void 0 ? void 0 : this.x(); static y4 = this[("x")](); - static y5 = this?.[("x")](); + static y5 = this === null || this === void 0 ? void 0 : this[("x")](); static z1 = super.a; static z2 = super["a"]; static z3 = super.f(); diff --git a/testdata/baselines/reference/submodule/conformance/thisAndSuperInStaticMembers2(target=es2015).js.diff b/testdata/baselines/reference/submodule/conformance/thisAndSuperInStaticMembers2(target=es2015).js.diff index 470ebbe0d6..5f39f02ee6 100644 --- a/testdata/baselines/reference/submodule/conformance/thisAndSuperInStaticMembers2(target=es2015).js.diff +++ b/testdata/baselines/reference/submodule/conformance/thisAndSuperInStaticMembers2(target=es2015).js.diff @@ -29,9 +29,9 @@ + static x = undefined; + static y1 = this.x; + static y2 = this.x(); -+ static y3 = this?.x(); ++ static y3 = this === null || this === void 0 ? void 0 : this.x(); + static y4 = this[("x")](); -+ static y5 = this?.[("x")](); ++ static y5 = this === null || this === void 0 ? void 0 : this[("x")](); + static z1 = super.a; + static z2 = super["a"]; + static z3 = super.f(); diff --git a/testdata/baselines/reference/submodule/conformance/thisAndSuperInStaticMembers3.js b/testdata/baselines/reference/submodule/conformance/thisAndSuperInStaticMembers3.js index 962a82ef8d..d5ce284aeb 100644 --- a/testdata/baselines/reference/submodule/conformance/thisAndSuperInStaticMembers3.js +++ b/testdata/baselines/reference/submodule/conformance/thisAndSuperInStaticMembers3.js @@ -29,9 +29,9 @@ class C extends B { static x = undefined; static y1 = this.x; static y2 = this.x(); - static y3 = this?.x(); + static y3 = this === null || this === void 0 ? void 0 : this.x(); static y4 = this[("x")](); - static y5 = this?.[("x")](); + static y5 = this === null || this === void 0 ? void 0 : this[("x")](); static z3 = super.f(); static z4 = super["f"](); // these should be unaffected diff --git a/testdata/baselines/reference/submodule/conformance/thisAndSuperInStaticMembers3.js.diff b/testdata/baselines/reference/submodule/conformance/thisAndSuperInStaticMembers3.js.diff index 3c2b5481f4..38a5430dc3 100644 --- a/testdata/baselines/reference/submodule/conformance/thisAndSuperInStaticMembers3.js.diff +++ b/testdata/baselines/reference/submodule/conformance/thisAndSuperInStaticMembers3.js.diff @@ -85,9 +85,9 @@ + static x = undefined; + static y1 = this.x; + static y2 = this.x(); -+ static y3 = this?.x(); ++ static y3 = this === null || this === void 0 ? void 0 : this.x(); + static y4 = this[("x")](); -+ static y5 = this?.[("x")](); ++ static y5 = this === null || this === void 0 ? void 0 : this[("x")](); + static z3 = super.f(); + static z4 = super["f"](); + // these should be unaffected diff --git a/testdata/baselines/reference/submodule/conformance/thisAndSuperInStaticMembers4.js b/testdata/baselines/reference/submodule/conformance/thisAndSuperInStaticMembers4.js index 7fce361b32..7305aefb2f 100644 --- a/testdata/baselines/reference/submodule/conformance/thisAndSuperInStaticMembers4.js +++ b/testdata/baselines/reference/submodule/conformance/thisAndSuperInStaticMembers4.js @@ -29,9 +29,9 @@ class C extends B { static x = undefined; static y1 = this.x; static y2 = this.x(); - static y3 = this?.x(); + static y3 = this === null || this === void 0 ? void 0 : this.x(); static y4 = this[("x")](); - static y5 = this?.[("x")](); + static y5 = this === null || this === void 0 ? void 0 : this[("x")](); static z3 = super.f(); static z4 = super["f"](); // these should be unaffected diff --git a/testdata/baselines/reference/submodule/conformance/thisAndSuperInStaticMembers4.js.diff b/testdata/baselines/reference/submodule/conformance/thisAndSuperInStaticMembers4.js.diff index 08b10a0a4b..5c975be518 100644 --- a/testdata/baselines/reference/submodule/conformance/thisAndSuperInStaticMembers4.js.diff +++ b/testdata/baselines/reference/submodule/conformance/thisAndSuperInStaticMembers4.js.diff @@ -30,9 +30,9 @@ + static x = undefined; + static y1 = this.x; + static y2 = this.x(); -+ static y3 = this?.x(); ++ static y3 = this === null || this === void 0 ? void 0 : this.x(); + static y4 = this[("x")](); -+ static y5 = this?.[("x")](); ++ static y5 = this === null || this === void 0 ? void 0 : this[("x")](); + static z3 = super.f(); + static z4 = super["f"](); + // these should be unaffected diff --git a/testdata/baselines/reference/submodule/conformance/thisMethodCall.js b/testdata/baselines/reference/submodule/conformance/thisMethodCall.js index e4243fcca5..b23f2d6d8e 100644 --- a/testdata/baselines/reference/submodule/conformance/thisMethodCall.js +++ b/testdata/baselines/reference/submodule/conformance/thisMethodCall.js @@ -12,6 +12,7 @@ class C { class C { method() { } other() { - this.method?.(); + var _a; + (_a = this.method) === null || _a === void 0 ? void 0 : _a.call(this); } } diff --git a/testdata/baselines/reference/submodule/conformance/thisMethodCall.js.diff b/testdata/baselines/reference/submodule/conformance/thisMethodCall.js.diff index deafd7ad83..ac38755036 100644 --- a/testdata/baselines/reference/submodule/conformance/thisMethodCall.js.diff +++ b/testdata/baselines/reference/submodule/conformance/thisMethodCall.js.diff @@ -7,9 +7,4 @@ -"use strict"; class C { method() { } - other() { -- var _a; -- (_a = this.method) === null || _a === void 0 ? void 0 : _a.call(this); -+ this.method?.(); - } - } \ No newline at end of file + other() { \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/thisTypeOptionalCall.js b/testdata/baselines/reference/submodule/conformance/thisTypeOptionalCall.js index d0056216f8..9ff45ed863 100644 --- a/testdata/baselines/reference/submodule/conformance/thisTypeOptionalCall.js +++ b/testdata/baselines/reference/submodule/conformance/thisTypeOptionalCall.js @@ -7,5 +7,5 @@ function maybeBind(obj: T, fn: ((this: T, ...args: A) => //// [thisTypeOptionalCall.js] function maybeBind(obj, fn) { - return fn?.bind(obj); + return fn === null || fn === void 0 ? void 0 : fn.bind(obj); } diff --git a/testdata/baselines/reference/submodule/conformance/thisTypeOptionalCall.js.diff b/testdata/baselines/reference/submodule/conformance/thisTypeOptionalCall.js.diff deleted file mode 100644 index 34c9696784..0000000000 --- a/testdata/baselines/reference/submodule/conformance/thisTypeOptionalCall.js.diff +++ /dev/null @@ -1,9 +0,0 @@ ---- old.thisTypeOptionalCall.js -+++ new.thisTypeOptionalCall.js -@@= skipped -6, +6 lines =@@ - - //// [thisTypeOptionalCall.js] - function maybeBind(obj, fn) { -- return fn === null || fn === void 0 ? void 0 : fn.bind(obj); -+ return fn?.bind(obj); - } \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/typeOfThisInstanceMemberNarrowedWithLoopAntecedent.js b/testdata/baselines/reference/submodule/conformance/typeOfThisInstanceMemberNarrowedWithLoopAntecedent.js index 92d7b5ddee..11828d5ff0 100644 --- a/testdata/baselines/reference/submodule/conformance/typeOfThisInstanceMemberNarrowedWithLoopAntecedent.js +++ b/testdata/baselines/reference/submodule/conformance/typeOfThisInstanceMemberNarrowedWithLoopAntecedent.js @@ -47,11 +47,12 @@ class SomeClass { class SomeClass2 { state; method() { + var _a; const c = false; while (c) { } if (this.state.type === "numberVariant") { this.state.data; } - let n = this.state?.data; // This should be an error + let n = (_a = this.state) === null || _a === void 0 ? void 0 : _a.data; // This should be an error } } diff --git a/testdata/baselines/reference/submodule/conformance/typeOfThisInstanceMemberNarrowedWithLoopAntecedent.js.diff b/testdata/baselines/reference/submodule/conformance/typeOfThisInstanceMemberNarrowedWithLoopAntecedent.js.diff index e4fde4c7c2..0937c0224a 100644 --- a/testdata/baselines/reference/submodule/conformance/typeOfThisInstanceMemberNarrowedWithLoopAntecedent.js.diff +++ b/testdata/baselines/reference/submodule/conformance/typeOfThisInstanceMemberNarrowedWithLoopAntecedent.js.diff @@ -14,13 +14,5 @@ class SomeClass2 { + state; method() { -- var _a; - const c = false; - while (c) { } - if (this.state.type === "numberVariant") { - this.state.data; - } -- let n = (_a = this.state) === null || _a === void 0 ? void 0 : _a.data; // This should be an error -+ let n = this.state?.data; // This should be an error - } - } \ No newline at end of file + var _a; + const c = false; \ No newline at end of file