From 425f57f7d9e615b723011cfc84c487218cfdb7b2 Mon Sep 17 00:00:00 2001 From: Oleksandr Tarasiuk Date: Sat, 6 Dec 2025 16:30:15 +0200 Subject: [PATCH] fix(2212): make enum constant inlining consistent with Strada behavior --- internal/binder/referenceresolver.go | 12 + internal/checker/emitresolver.go | 1 + .../tstransforms/runtimesyntax.go | 270 +++--------------- .../tstransforms/runtimesyntax_test.go | 80 +++--- ...iablesUseBeforeDef_verbatimModuleSyntax.js | 4 +- ...sUseBeforeDef_verbatimModuleSyntax.js.diff | 19 ++ ...tacticallyString(isolatedmodules=false).js | 12 +- ...callyString(isolatedmodules=false).js.diff | 24 -- ...ntacticallyString(isolatedmodules=true).js | 12 +- ...icallyString(isolatedmodules=true).js.diff | 24 -- ...acticallyString2(isolatedmodules=false).js | 33 +-- ...allyString2(isolatedmodules=false).js.diff | 40 --- ...tacticallyString2(isolatedmodules=true).js | 33 +-- ...callyString2(isolatedmodules=true).js.diff | 40 --- .../compiler/computedEnumTypeWidening.js | 12 +- .../compiler/computedEnumTypeWidening.js.diff | 21 +- .../submodule/compiler/declFileEnums.js | 3 +- .../submodule/compiler/declFileEnums.js.diff | 12 - .../submodule/compiler/enumBasics2.js | 21 +- .../submodule/compiler/enumBasics2.js.diff | 31 -- .../submodule/compiler/enumBasics3.js | 9 +- .../submodule/compiler/enumBasics3.js.diff | 25 -- ...InitializerFollowsNonLiteralInitializer.js | 12 +- ...alizerFollowsNonLiteralInitializer.js.diff | 29 -- .../submodule/compiler/enumNumbering1.js | 3 +- .../submodule/compiler/enumNumbering1.js.diff | 12 - .../enumPropertyAccessBeforeInitalisation.js | 12 +- ...mPropertyAccessBeforeInitalisation.js.diff | 19 -- .../compiler/enumWithComputedMember.js | 8 +- .../compiler/enumWithComputedMember.js.diff | 15 - .../submodule/compiler/enumWithExport.js | 3 +- .../submodule/compiler/enumWithExport.js.diff | 10 - .../enumWithNonLiteralStringInitializer.js | 6 +- ...numWithNonLiteralStringInitializer.js.diff | 22 -- .../submodule/compiler/fakeInfinity2.js | 4 +- .../submodule/compiler/fakeInfinity2.js.diff | 13 - .../submodule/compiler/fakeInfinity3.js | 4 +- .../submodule/compiler/fakeInfinity3.js.diff | 13 - .../submodule/compiler/forwardRefInEnum.js | 12 +- .../compiler/forwardRefInEnum.js.diff | 22 -- .../submodule/compiler/importElisionEnum.js | 3 +- .../compiler/importElisionEnum.js.diff | 10 - .../isolatedDeclarationErrorsEnums.js | 33 +-- .../isolatedDeclarationErrorsEnums.js.diff | 57 +--- ...isolatedModulesGlobalNamespacesAndEnums.js | 12 +- ...tedModulesGlobalNamespacesAndEnums.js.diff | 19 -- .../submodule/compiler/mergedDeclarations2.js | 3 +- .../compiler/mergedDeclarations2.js.diff | 12 - .../compiler/mergedEnumDeclarationCodeGen.js | 3 +- .../mergedEnumDeclarationCodeGen.js.diff | 10 - .../compiler/methodContainingLocalFunction.js | 5 +- .../methodContainingLocalFunction.js.diff | 16 -- .../compiler/mixedTypeEnumComparison.js | 3 +- .../compiler/mixedTypeEnumComparison.js.diff | 12 - .../compiler/numericEnumMappedType.js | 12 +- .../compiler/numericEnumMappedType.js.diff | 24 -- .../this_inside-enum-should-not-be-allowed.js | 6 +- ..._inside-enum-should-not-be-allowed.js.diff | 19 -- .../conformance/arrowFunctionContexts.js | 12 +- .../conformance/arrowFunctionContexts.js.diff | 28 -- .../submodule/conformance/awaitAndYield.js | 6 +- .../conformance/awaitAndYield.js.diff | 10 +- .../disallowLineTerminatorBeforeArrow.js | 3 +- .../disallowLineTerminatorBeforeArrow.js.diff | 8 +- .../submodule/conformance/enumBasics.js | 15 +- .../submodule/conformance/enumBasics.js.diff | 42 --- .../conformance/enumClassification.js | 12 +- .../conformance/enumClassification.js.diff | 20 -- .../enumConstantMemberWithString.js | 3 +- .../enumConstantMemberWithString.js.diff | 12 - .../enumConstantMemberWithTemplateLiterals.js | 9 +- ...ConstantMemberWithTemplateLiterals.js.diff | 22 -- ...mberWithTemplateLiteralsEmitDeclaration.js | 3 +- ...ithTemplateLiteralsEmitDeclaration.js.diff | 11 - .../conformance/enumConstantMembers.js | 17 +- .../conformance/enumConstantMembers.js.diff | 27 +- ...umErrorOnConstantBindingWithInitializer.js | 3 +- ...orOnConstantBindingWithInitializer.js.diff | 10 - .../submodule/conformance/enumErrors.js | 36 +-- .../submodule/conformance/enumErrors.js.diff | 62 ---- .../conformance/enumExportMergingES6.js | 3 +- .../conformance/enumExportMergingES6.js.diff | 8 - .../submodule/conformance/enumMerging.js | 18 +- .../submodule/conformance/enumMerging.js.diff | 29 +- .../conformance/enumMergingErrors.js | 9 +- .../conformance/enumMergingErrors.js.diff | 28 -- .../conformance/enumShadowedInfinityNaN.js | 6 +- .../enumShadowedInfinityNaN.js.diff | 20 -- .../parserComputedPropertyName26.js | 3 +- .../parserComputedPropertyName26.js.diff | 10 - .../parserComputedPropertyName30.js | 3 +- .../parserComputedPropertyName30.js.diff | 11 - .../parserComputedPropertyName34.js | 3 +- .../parserComputedPropertyName34.js.diff | 11 - .../conformance/thisInInvalidContexts.js | 6 +- .../conformance/thisInInvalidContexts.js.diff | 13 +- .../thisInInvalidContextsExternalModule.js | 6 +- ...hisInInvalidContextsExternalModule.js.diff | 14 +- .../verbatimModuleSyntaxConstEnumUsage.js | 10 +- ...verbatimModuleSyntaxConstEnumUsage.js.diff | 12 +- 100 files changed, 295 insertions(+), 1515 deletions(-) create mode 100644 testdata/baselines/reference/submodule/compiler/blockScopedEnumVariablesUseBeforeDef_verbatimModuleSyntax.js.diff delete mode 100644 testdata/baselines/reference/submodule/compiler/computedEnumMemberSyntacticallyString(isolatedmodules=false).js.diff delete mode 100644 testdata/baselines/reference/submodule/compiler/computedEnumMemberSyntacticallyString(isolatedmodules=true).js.diff delete mode 100644 testdata/baselines/reference/submodule/compiler/computedEnumMemberSyntacticallyString2(isolatedmodules=false).js.diff delete mode 100644 testdata/baselines/reference/submodule/compiler/computedEnumMemberSyntacticallyString2(isolatedmodules=true).js.diff delete mode 100644 testdata/baselines/reference/submodule/compiler/declFileEnums.js.diff delete mode 100644 testdata/baselines/reference/submodule/compiler/enumBasics2.js.diff delete mode 100644 testdata/baselines/reference/submodule/compiler/enumBasics3.js.diff delete mode 100644 testdata/baselines/reference/submodule/compiler/enumNoInitializerFollowsNonLiteralInitializer.js.diff delete mode 100644 testdata/baselines/reference/submodule/compiler/enumNumbering1.js.diff delete mode 100644 testdata/baselines/reference/submodule/compiler/enumPropertyAccessBeforeInitalisation.js.diff delete mode 100644 testdata/baselines/reference/submodule/compiler/enumWithComputedMember.js.diff delete mode 100644 testdata/baselines/reference/submodule/compiler/enumWithExport.js.diff delete mode 100644 testdata/baselines/reference/submodule/compiler/enumWithNonLiteralStringInitializer.js.diff delete mode 100644 testdata/baselines/reference/submodule/compiler/fakeInfinity2.js.diff delete mode 100644 testdata/baselines/reference/submodule/compiler/fakeInfinity3.js.diff delete mode 100644 testdata/baselines/reference/submodule/compiler/forwardRefInEnum.js.diff delete mode 100644 testdata/baselines/reference/submodule/compiler/importElisionEnum.js.diff delete mode 100644 testdata/baselines/reference/submodule/compiler/isolatedModulesGlobalNamespacesAndEnums.js.diff delete mode 100644 testdata/baselines/reference/submodule/compiler/mergedDeclarations2.js.diff delete mode 100644 testdata/baselines/reference/submodule/compiler/mergedEnumDeclarationCodeGen.js.diff delete mode 100644 testdata/baselines/reference/submodule/compiler/methodContainingLocalFunction.js.diff delete mode 100644 testdata/baselines/reference/submodule/compiler/mixedTypeEnumComparison.js.diff delete mode 100644 testdata/baselines/reference/submodule/compiler/numericEnumMappedType.js.diff delete mode 100644 testdata/baselines/reference/submodule/compiler/this_inside-enum-should-not-be-allowed.js.diff delete mode 100644 testdata/baselines/reference/submodule/conformance/arrowFunctionContexts.js.diff delete mode 100644 testdata/baselines/reference/submodule/conformance/enumBasics.js.diff delete mode 100644 testdata/baselines/reference/submodule/conformance/enumClassification.js.diff delete mode 100644 testdata/baselines/reference/submodule/conformance/enumConstantMemberWithString.js.diff delete mode 100644 testdata/baselines/reference/submodule/conformance/enumConstantMemberWithTemplateLiterals.js.diff delete mode 100644 testdata/baselines/reference/submodule/conformance/enumConstantMemberWithTemplateLiteralsEmitDeclaration.js.diff delete mode 100644 testdata/baselines/reference/submodule/conformance/enumErrorOnConstantBindingWithInitializer.js.diff delete mode 100644 testdata/baselines/reference/submodule/conformance/enumErrors.js.diff delete mode 100644 testdata/baselines/reference/submodule/conformance/enumMergingErrors.js.diff delete mode 100644 testdata/baselines/reference/submodule/conformance/enumShadowedInfinityNaN.js.diff delete mode 100644 testdata/baselines/reference/submodule/conformance/parserComputedPropertyName26.js.diff delete mode 100644 testdata/baselines/reference/submodule/conformance/parserComputedPropertyName30.js.diff delete mode 100644 testdata/baselines/reference/submodule/conformance/parserComputedPropertyName34.js.diff diff --git a/internal/binder/referenceresolver.go b/internal/binder/referenceresolver.go index 2e428044a7..f5cbb43042 100644 --- a/internal/binder/referenceresolver.go +++ b/internal/binder/referenceresolver.go @@ -4,6 +4,7 @@ import ( "github.com/microsoft/typescript-go/internal/ast" "github.com/microsoft/typescript-go/internal/core" "github.com/microsoft/typescript-go/internal/diagnostics" + "github.com/microsoft/typescript-go/internal/evaluator" ) type ReferenceResolver interface { @@ -12,6 +13,7 @@ type ReferenceResolver interface { GetReferencedValueDeclaration(node *ast.IdentifierNode) *ast.Declaration GetReferencedValueDeclarations(node *ast.IdentifierNode) []*ast.Declaration GetElementAccessExpressionName(expression *ast.ElementAccessExpression) string + GetEnumMemberValue(node *ast.Node) evaluator.Result } type ReferenceResolverHooks struct { @@ -23,6 +25,7 @@ type ReferenceResolverHooks struct { GetTypeOnlyAliasDeclaration func(symbol *ast.Symbol, include ast.SymbolFlags) *ast.Declaration GetExportSymbolOfValueSymbolIfExported func(*ast.Symbol) *ast.Symbol GetElementAccessExpressionName func(*ast.ElementAccessExpression) (string, bool) + GetEnumMemberValue func(node *ast.Node) evaluator.Result } var _ ReferenceResolver = &referenceResolver{} @@ -249,3 +252,12 @@ func (r *referenceResolver) GetElementAccessExpressionName(expression *ast.Eleme } return "" } + +func (r *referenceResolver) GetEnumMemberValue(node *ast.Node) evaluator.Result { + if node != nil { + if r.hooks.GetEnumMemberValue != nil { + return r.hooks.GetEnumMemberValue(node) + } + } + return evaluator.NewResult(nil, false, false, false) +} diff --git a/internal/checker/emitresolver.go b/internal/checker/emitresolver.go index 877f2d1831..25a98ee777 100644 --- a/internal/checker/emitresolver.go +++ b/internal/checker/emitresolver.go @@ -835,6 +835,7 @@ func (r *EmitResolver) getReferenceResolver() binder.ReferenceResolver { GetTypeOnlyAliasDeclaration: r.checker.getTypeOnlyAliasDeclarationEx, GetExportSymbolOfValueSymbolIfExported: r.checker.getExportSymbolOfValueSymbolIfExported, GetElementAccessExpressionName: r.checker.tryGetElementAccessExpressionName, + GetEnumMemberValue: r.checker.getEnumMemberValue, }) } return r.referenceResolver diff --git a/internal/transformers/tstransforms/runtimesyntax.go b/internal/transformers/tstransforms/runtimesyntax.go index 8c3ad6a817..09d3cd0d53 100644 --- a/internal/transformers/tstransforms/runtimesyntax.go +++ b/internal/transformers/tstransforms/runtimesyntax.go @@ -10,7 +10,6 @@ import ( "github.com/microsoft/typescript-go/internal/ast" "github.com/microsoft/typescript-go/internal/binder" "github.com/microsoft/typescript-go/internal/core" - "github.com/microsoft/typescript-go/internal/evaluator" "github.com/microsoft/typescript-go/internal/jsnum" "github.com/microsoft/typescript-go/internal/printer" "github.com/microsoft/typescript-go/internal/transformers" @@ -28,8 +27,6 @@ type RuntimeSyntaxTransformer struct { currentEnum *ast.EnumDeclarationNode currentNamespace *ast.ModuleDeclarationNode resolver binder.ReferenceResolver - evaluator evaluator.Evaluator - enumMemberCache map[*ast.EnumDeclarationNode]map[string]evaluator.Result } func NewRuntimeSyntaxTransformer(opt *transformers.TransformOptions) *transformers.Transformer { @@ -199,22 +196,6 @@ func (tx *RuntimeSyntaxTransformer) getExpressionForPropertyName(member *ast.Enu } } -// Gets an expression like `E.A` or `E["A"]` that references an enum member. -func (tx *RuntimeSyntaxTransformer) getEnumQualifiedReference(enum *ast.EnumDeclaration, member *ast.EnumMember) *ast.Expression { - if ast.IsIdentifier(member.Name()) { - return tx.getEnumQualifiedProperty(enum, member) - } else { - return tx.getEnumQualifiedElement(enum, member) - } -} - -// Gets an expression like `E.A` that references an enum member. -func (tx *RuntimeSyntaxTransformer) getEnumQualifiedProperty(enum *ast.EnumDeclaration, member *ast.EnumMember) *ast.Expression { - prop := tx.getNamespaceQualifiedProperty(tx.getNamespaceContainerName(enum.AsNode()), member.Name().Clone(tx.Factory())) - tx.EmitContext().AddEmitFlags(prop, printer.EFNoComments|printer.EFNoNestedComments|printer.EFNoSourceMap|printer.EFNoNestedSourceMaps) - return prop -} - // Gets an expression like `E["A"]` that references an enum member. func (tx *RuntimeSyntaxTransformer) getEnumQualifiedElement(enum *ast.EnumDeclaration, member *ast.EnumMember) *ast.Expression { prop := tx.getNamespaceQualifiedElement(tx.getNamespaceContainerName(enum.AsNode()), tx.getExpressionForPropertyName(member)) @@ -364,29 +345,12 @@ func (tx *RuntimeSyntaxTransformer) transformEnumBody(node *ast.EnumDeclaration) savedCurrentEnum := tx.currentEnum tx.currentEnum = node.AsNode() - // visit the children of `node` in advance to capture any references to enum members - node = tx.Visitor().VisitEachChild(node.AsNode()).AsEnumDeclaration() - statements := []*ast.Statement{} if len(node.Members.Nodes) > 0 { tx.EmitContext().StartVariableEnvironment() - - var autoValue jsnum.Number - var autoVar *ast.IdentifierNode - var useAutoVar bool - for i := range len(node.Members.Nodes) { - // E[E["A"] = 0] = "A"; - statements = tx.transformEnumMember( - statements, - node, - i, - &autoValue, - &autoVar, - &useAutoVar, - ) - autoValue++ + for _, member := range node.Members.Nodes { + statements = append(statements, tx.transformEnumMember(member.AsEnumMember())) } - statements = tx.EmitContext().EndAndMergeVariableEnvironment(statements) } @@ -397,163 +361,35 @@ func (tx *RuntimeSyntaxTransformer) transformEnumBody(node *ast.EnumDeclaration) return tx.Factory().NewBlock(statementList, true /*multiline*/) } -// Transforms an enum member into a statement. It is expected that `enum` has already been visited. -func (tx *RuntimeSyntaxTransformer) transformEnumMember( - statements []*ast.Statement, - enum *ast.EnumDeclaration, - index int, - autoValue *jsnum.Number, - autoVar **ast.IdentifierNode, - useAutoVar *bool, -) []*ast.Statement { - memberNode := enum.Members.Nodes[index] - member := memberNode.AsEnumMember() - - var memberName string - if ast.IsIdentifier(member.Name()) || ast.IsStringLiteralLike(member.Name()) { - memberName = member.Name().Text() - } - +func (tx *RuntimeSyntaxTransformer) transformEnumMember(member *ast.EnumMember) *ast.Statement { savedParent := tx.parentNode - tx.parentNode = tx.currentNode - tx.currentNode = memberNode - - // E[E["A"] = x] = "A"; - // ^ - expression := member.Initializer // NOTE: already visited - - var useConditionalReverseMapping bool - var useExplicitReverseMapping bool - if expression == nil { - // Enum members without an initializer are auto-numbered. We will use constant values if there was no preceding - // initialized member, or if the preceding initialized member was a numeric literal. - if *useAutoVar { - // If you are using an auto-numbered member following a non-numeric literal, we assume the previous member - // produced a valid numeric value. This assumption is intended to be validated by the type checker prior to - // emit. - // E[E["A"] = ++auto] = "A"; - // ^^^^^^ - expression = tx.Factory().NewPrefixUnaryExpression(ast.KindPlusPlusToken, *autoVar) - useExplicitReverseMapping = true - } else { - // If the preceding auto value is a finite number, we can emit a numeric literal for the member initializer: - // E[E["A"] = 0] = "A"; - // ^ - // If not, we cannot emit a valid numeric literal for the member initializer and emit `void 0` instead: - // E["A"] = void 0; - // ^^^^^^ - expression = constantExpression(*autoValue, tx.Factory()) - if expression != nil { - useExplicitReverseMapping = true - if len(memberName) > 0 { - tx.cacheEnumMemberValue(enum.AsNode(), memberName, evaluator.NewResult(*autoValue, false, false, false)) - } - } else { - expression = tx.Factory().NewVoidZeroExpression() - } - } - } else { - // Enum members with an initializer may restore auto-numbering if the initializer is a numeric literal. If we - // cannot syntactically determine the initializer value and the following enum member is auto-numbered, we will - // use an `auto` variable to perform the remaining auto-numbering at runtime. - if tx.evaluator == nil { - tx.evaluator = evaluator.NewEvaluator(tx.evaluateEntity, ast.OEKAll) - } - - var hasNumericInitializer, hasStringInitializer bool - result := tx.evaluator(expression, enum.AsNode()) - switch value := result.Value.(type) { - case jsnum.Number: - hasNumericInitializer = true - *autoValue = value - expression = core.Coalesce(constantExpression(value, tx.Factory()), expression) // TODO: preserve original expression after Strada migration - tx.cacheEnumMemberValue(enum.AsNode(), memberName, result) - case string: - hasStringInitializer = true - *autoValue = jsnum.NaN() - expression = core.Coalesce(constantExpression(value, tx.Factory()), expression) // TODO: preserve original expression after Strada migration - tx.cacheEnumMemberValue(enum.AsNode(), memberName, result) - default: - *autoValue = jsnum.NaN() - } - nextIsAuto := index+1 < len(enum.Members.Nodes) && enum.Members.Nodes[index+1].AsEnumMember().Initializer == nil - useExplicitReverseMapping = hasNumericInitializer || !hasStringInitializer && nextIsAuto - useConditionalReverseMapping = !hasNumericInitializer && !hasStringInitializer && !nextIsAuto - if *useAutoVar = nextIsAuto && !hasNumericInitializer && !hasStringInitializer; *useAutoVar { - // E[E["A"] = auto = x] = "A"; - // ^^^^^^^^ - if *autoVar == nil { - *autoVar = tx.Factory().NewUniqueNameEx("auto", printer.AutoGenerateOptions{Flags: printer.GeneratedIdentifierFlagsOptimistic}) - tx.EmitContext().AddVariableDeclaration(*autoVar) - } - expression = tx.Factory().NewAssignmentExpression(*autoVar, expression) - } - } + tx.parentNode = tx.currentNode + tx.currentNode = member.AsNode() - // Define the enum member property: - // E[E["A"] = ++auto] = "A"; - // ^^^^^^^^--_____ - expression = tx.Factory().NewAssignmentExpression( - tx.getEnumQualifiedElement(enum, member), - expression, - ) + evaluated := tx.resolver.GetEnumMemberValue(tx.EmitContext().MostOriginal(member.AsNode())) + name := tx.getExpressionForPropertyName(member) + value := tx.transformEnumMemberDeclarationValue(member, evaluated.Value) + innerAssignment := tx.Factory().NewAssignmentExpression(tx.getEnumQualifiedElement(tx.currentEnum.AsEnumDeclaration(), member), value) - // If this is syntactically a numeric literal initializer, or is auto numbered, then we unconditionally define the - // reverse mapping for the enum member. - if useExplicitReverseMapping { - // E[E["A"] = A = ++auto] = "A"; - // ^^-------------------^^^^^^^ - expression = tx.Factory().NewAssignmentExpression( - tx.Factory().NewElementAccessExpression( - tx.getNamespaceContainerName(enum.AsNode()), - nil, /*questionDotToken*/ - expression, - ast.NodeFlagsNone, - ), - tx.getExpressionForPropertyName(member), + var outerAssignment *ast.Expression + if _, isString := evaluated.Value.(string); isString || evaluated.IsSyntacticallyString { + outerAssignment = innerAssignment + } else { + outerAssignment = tx.Factory().NewAssignmentExpression( + tx.Factory().NewElementAccessExpression(tx.getNamespaceContainerName(tx.currentEnum.AsNode()), nil /*questionDotToken*/, innerAssignment, ast.NodeFlagsNone), + name, ) + tx.EmitContext().AssignCommentAndSourceMapRanges(outerAssignment, member.AsNode()) } - memberStatement := tx.Factory().NewExpressionStatement(expression) - tx.EmitContext().AssignCommentAndSourceMapRanges(expression, member.AsNode()) - tx.EmitContext().AssignCommentAndSourceMapRanges(memberStatement, member.AsNode()) - statements = append(statements, memberStatement) - - // If this is not auto numbered and is not syntactically a string or numeric literal initializer, then we - // conditionally define the reverse mapping for the enum member. - if useConditionalReverseMapping { - // E["A"] = x; - // if (typeof E.A !== "string") E.A = "A"; - // ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - - ifStatement := tx.Factory().NewIfStatement( - tx.Factory().NewStrictInequalityExpression( - tx.Factory().NewTypeOfExpression(tx.getEnumQualifiedReference(enum, member)), - tx.Factory().NewStringLiteral("string"), - ), - tx.Factory().NewExpressionStatement( - tx.Factory().NewAssignmentExpression( - tx.Factory().NewElementAccessExpression( - tx.getNamespaceContainerName(enum.AsNode()), - nil, /*questionDotToken*/ - tx.getEnumQualifiedReference(enum, member), - ast.NodeFlagsNone, - ), - tx.getExpressionForPropertyName(member), - ), - ), - nil, - ) - - tx.EmitContext().AddEmitFlags(ifStatement, printer.EFSingleLine) - tx.EmitContext().AssignSourceMapRange(ifStatement, member.Initializer) - statements = append(statements, ifStatement) - } + statement := tx.Factory().NewExpressionStatement(outerAssignment) + tx.EmitContext().AssignCommentAndSourceMapRanges(statement, member.AsNode()) tx.currentNode = tx.parentNode tx.parentNode = savedParent - return statements + + return statement } func (tx *RuntimeSyntaxTransformer) visitModuleDeclaration(node *ast.ModuleDeclaration) *ast.Node { @@ -1092,52 +928,6 @@ func (tx *RuntimeSyntaxTransformer) createExportStatement(name *ast.IdentifierNo return exportStatement } -func (tx *RuntimeSyntaxTransformer) cacheEnumMemberValue(enum *ast.EnumDeclarationNode, memberName string, result evaluator.Result) { - if tx.enumMemberCache == nil { - tx.enumMemberCache = make(map[*ast.EnumDeclarationNode]map[string]evaluator.Result) - } - memberCache := tx.enumMemberCache[enum] - if memberCache == nil { - memberCache = make(map[string]evaluator.Result) - tx.enumMemberCache[enum] = memberCache - } - memberCache[memberName] = result -} - -func (tx *RuntimeSyntaxTransformer) isReferenceToEnum(reference *ast.IdentifierNode, enum *ast.EnumDeclarationNode) bool { - if transformers.IsGeneratedIdentifier(tx.EmitContext(), reference) { - originalEnum := tx.EmitContext().MostOriginal(enum) - return tx.EmitContext().GetNodeForGeneratedName(reference) == originalEnum - } - return reference.Text() == enum.Name().Text() -} - -func (tx *RuntimeSyntaxTransformer) evaluateEntity(node *ast.Node, location *ast.Node) evaluator.Result { - var result evaluator.Result - if ast.IsEnumDeclaration(location) { - memberCache := tx.enumMemberCache[location] - if memberCache != nil { - switch { - case ast.IsIdentifier(node): - result = memberCache[node.Text()] - case ast.IsPropertyAccessExpression(node): - access := node.AsPropertyAccessExpression() - expression := access.Expression - if ast.IsIdentifier(expression) && tx.isReferenceToEnum(expression, location) { - result = memberCache[access.Name().Text()] - } - case ast.IsElementAccessExpression(node): - access := node.AsElementAccessExpression() - expression := access.Expression - if ast.IsIdentifier(expression) && tx.isReferenceToEnum(expression, location) && ast.IsStringLiteralLike(access.ArgumentExpression) { - result = memberCache[access.ArgumentExpression.Text()] - } - } - } - } - return result -} - func (tx *RuntimeSyntaxTransformer) shouldEmitEnumDeclaration(node *ast.EnumDeclaration) bool { return !ast.IsEnumConst(node.AsNode()) || tx.compilerOptions.ShouldPreserveConstEnums() } @@ -1157,3 +947,21 @@ func getInnermostModuleDeclarationFromDottedModule(moduleDeclaration *ast.Module } return moduleDeclaration } + +func (tx *RuntimeSyntaxTransformer) transformEnumMemberDeclarationValue(member *ast.EnumMember, evaluatedValue any) *ast.Node { + switch value := evaluatedValue.(type) { + case jsnum.Number: + if value >= 0 { + return tx.Factory().NewNumericLiteral(value.String()) + } else { + return tx.Factory().NewPrefixUnaryExpression(ast.KindMinusToken, tx.Factory().NewNumericLiteral((-value).String())) + } + case string: + return tx.Factory().NewStringLiteral(value) + default: + if member.Initializer == nil { + return tx.Factory().NewVoidZeroExpression() + } + return tx.Visitor().VisitNode(member.Initializer) + } +} diff --git a/internal/transformers/tstransforms/runtimesyntax_test.go b/internal/transformers/tstransforms/runtimesyntax_test.go index deb8704666..17f1610142 100644 --- a/internal/transformers/tstransforms/runtimesyntax_test.go +++ b/internal/transformers/tstransforms/runtimesyntax_test.go @@ -3,7 +3,9 @@ package tstransforms_test import ( "testing" + "github.com/microsoft/typescript-go/internal/ast" "github.com/microsoft/typescript-go/internal/binder" + "github.com/microsoft/typescript-go/internal/checker" "github.com/microsoft/typescript-go/internal/core" "github.com/microsoft/typescript-go/internal/printer" "github.com/microsoft/typescript-go/internal/testutil/emittestutil" @@ -49,29 +51,23 @@ func TestEnumTransformer(t *testing.T) { {title: "autonumber enum #4", input: "enum E {A = x,B,C}", output: `var E; (function (E) { - var auto; - E[E["A"] = auto = x] = "A"; - E[E["B"] = ++auto] = "B"; - E[E["C"] = ++auto] = "C"; + E[E["A"] = x] = "A"; + E[E["B"] = void 0] = "B"; + E[E["C"] = void 0] = "C"; })(E || (E = {}));`}, {title: "autonumber enum #5", input: "enum E {A = x,B,C = y}", output: `var E; (function (E) { - var auto; - E[E["A"] = auto = x] = "A"; - E[E["B"] = ++auto] = "B"; - E["C"] = y; - if (typeof E.C !== "string") E[E.C] = "C"; + E[E["A"] = x] = "A"; + E[E["B"] = void 0] = "B"; + E[E["C"] = y] = "C"; })(E || (E = {}));`}, {title: "autonumber enum #6", input: "enum E {A = x,B = y,C = z}", output: `var E; (function (E) { - E["A"] = x; - if (typeof E.A !== "string") E[E.A] = "A"; - E["B"] = y; - if (typeof E.B !== "string") E[E.B] = "B"; - E["C"] = z; - if (typeof E.C !== "string") E[E.C] = "C"; + E[E["A"] = x] = "A"; + E[E["B"] = y] = "B"; + E[E["C"] = z] = "C"; })(E || (E = {}));`}, {title: "autonumber enum #7", input: "enum E {A = 1,B,C,D='x'}", output: `var E; @@ -98,20 +94,18 @@ func TestEnumTransformer(t *testing.T) { {title: "autonumber enum #10", input: "enum E {A='x',B=y,C}", output: `var E; (function (E) { - var auto; E["A"] = "x"; - E[E["B"] = auto = y] = "B"; - E[E["C"] = ++auto] = "C"; + E[E["B"] = y] = "B"; + E[E["C"] = void 0] = "C"; })(E || (E = {}));`}, {title: "autonumber enum #11", input: "enum E {A='x',B=1,C,D=y,E,F=3,G}", output: `var E; (function (E) { - var auto; E["A"] = "x"; E[E["B"] = 1] = "B"; E[E["C"] = 2] = "C"; - E[E["D"] = auto = y] = "D"; - E[E["E"] = ++auto] = "E"; + E[E["D"] = y] = "D"; + E[E["E"] = void 0] = "E"; E[E["F"] = 3] = "F"; E[E["G"] = 4] = "G"; })(E || (E = {}));`}, @@ -125,7 +119,7 @@ func TestEnumTransformer(t *testing.T) { {title: "autonumber enum #13", input: "enum E {A='x',B}", output: `var E; (function (E) { E["A"] = "x"; - E["B"] = void 0; + E[E["B"] = void 0] = "B"; })(E || (E = {}));`}, {title: "autonumber enum #14", input: "enum E {A,B,C=A|B,D}", output: `var E; @@ -165,26 +159,20 @@ func TestEnumTransformer(t *testing.T) { {title: "enum self reference #2", input: "enum E {A=x,B=A}", output: `var E; (function (E) { - E["A"] = x; - if (typeof E.A !== "string") E[E.A] = "A"; - E["B"] = E.A; - if (typeof E.B !== "string") E[E.B] = "B"; + E[E["A"] = x] = "A"; + E[E["B"] = E.A] = "B"; })(E || (E = {}));`}, {title: "enum self reference #3", input: "enum E {'A'=x,B=A}", output: `var E; (function (E) { - E["A"] = x; - if (typeof E["A"] !== "string") E[E["A"]] = "A"; - E["B"] = E.A; - if (typeof E.B !== "string") E[E.B] = "B"; + E[E["A"] = x] = "A"; + E[E["B"] = E.A] = "B"; })(E || (E = {}));`}, {title: "enum self reference #4", input: "enum E {'A'=x,'B '=A}", output: `var E; (function (E) { - E["A"] = x; - if (typeof E["A"] !== "string") E[E["A"]] = "A"; - E["B "] = E.A; - if (typeof E["B "] !== "string") E[E["B "]] = "B "; + E[E["A"] = x] = "A"; + E[E["B "] = E.A] = "B "; })(E || (E = {}));`}, {title: "enum self reference #5", input: "enum E {A,B=E.A}", output: `var E; @@ -207,8 +195,7 @@ var E; E[E["A"] = 0] = "A"; })(E || (E = {})); (function (E) { - E["B"] = A; - if (typeof E.B !== "string") E[E.B] = "B"; + E[E["B"] = 0] = "B"; })(E || (E = {}));`}, {title: "reverse map enum", input: `enum E { @@ -233,7 +220,7 @@ var E; parsetestutil.CheckDiagnostics(t, file) binder.BindSourceFile(file) emitContext := printer.NewEmitContext() - resolver := binder.NewReferenceResolver(options, binder.ReferenceResolverHooks{}) + resolver := GetEmitResolver(options, file) emittestutil.CheckEmit(t, emitContext, tstransforms.NewRuntimeSyntaxTransformer(&transformers.TransformOptions{CompilerOptions: options, Context: emitContext, Resolver: resolver}).TransformSourceFile(file), rec.output) }) } @@ -399,7 +386,7 @@ func TestNamespaceTransformer(t *testing.T) { parsetestutil.CheckDiagnostics(t, file) binder.BindSourceFile(file) emitContext := printer.NewEmitContext() - resolver := binder.NewReferenceResolver(options, binder.ReferenceResolverHooks{}) + resolver := GetEmitResolver(options, file) emittestutil.CheckEmit(t, emitContext, tstransforms.NewRuntimeSyntaxTransformer(&transformers.TransformOptions{CompilerOptions: options, Context: emitContext, Resolver: resolver}).TransformSourceFile(file), rec.output) }) } @@ -435,7 +422,7 @@ func TestParameterPropertyTransformer(t *testing.T) { parsetestutil.CheckDiagnostics(t, file) binder.BindSourceFile(file) emitContext := printer.NewEmitContext() - resolver := binder.NewReferenceResolver(options, binder.ReferenceResolverHooks{}) + resolver := GetEmitResolver(options, file) opts := &transformers.TransformOptions{Context: emitContext, CompilerOptions: options, Resolver: resolver} file = tstransforms.NewTypeEraserTransformer(opts).TransformSourceFile(file) file = tstransforms.NewRuntimeSyntaxTransformer(opts).TransformSourceFile(file) @@ -443,3 +430,18 @@ func TestParameterPropertyTransformer(t *testing.T) { }) } } + +func GetEmitResolver(options *core.CompilerOptions, sourceFile *ast.SourceFile) binder.ReferenceResolver { + c, _ := checker.NewChecker(&fakeProgram{ + singleThreaded: true, + compilerOptions: options, + files: []*ast.SourceFile{sourceFile}, + getEmitModuleFormatOfFile: func(sourceFile ast.HasFileName) core.ModuleKind { + return core.ModuleKindESNext + }, + getImpliedNodeFormatForEmit: func(sourceFile ast.HasFileName) core.ModuleKind { + return core.ModuleKindESNext + }, + }) + return c.GetEmitResolver() +} diff --git a/testdata/baselines/reference/submodule/compiler/blockScopedEnumVariablesUseBeforeDef_verbatimModuleSyntax.js b/testdata/baselines/reference/submodule/compiler/blockScopedEnumVariablesUseBeforeDef_verbatimModuleSyntax.js index 508dc616c1..b81a3dcf92 100644 --- a/testdata/baselines/reference/submodule/compiler/blockScopedEnumVariablesUseBeforeDef_verbatimModuleSyntax.js +++ b/testdata/baselines/reference/submodule/compiler/blockScopedEnumVariablesUseBeforeDef_verbatimModuleSyntax.js @@ -25,14 +25,14 @@ function foo1() { return E.A; let E; (function (E) { - E[E["A"] = 0] = "A"; + E[E["A"] = void 0] = "A"; })(E || (E = {})); } function foo2() { return E.A; let E; (function (E) { - E[E["A"] = 0] = "A"; + E[E["A"] = void 0] = "A"; })(E || (E = {})); } const config = { diff --git a/testdata/baselines/reference/submodule/compiler/blockScopedEnumVariablesUseBeforeDef_verbatimModuleSyntax.js.diff b/testdata/baselines/reference/submodule/compiler/blockScopedEnumVariablesUseBeforeDef_verbatimModuleSyntax.js.diff new file mode 100644 index 0000000000..da55cc4e45 --- /dev/null +++ b/testdata/baselines/reference/submodule/compiler/blockScopedEnumVariablesUseBeforeDef_verbatimModuleSyntax.js.diff @@ -0,0 +1,19 @@ +--- old.blockScopedEnumVariablesUseBeforeDef_verbatimModuleSyntax.js ++++ new.blockScopedEnumVariablesUseBeforeDef_verbatimModuleSyntax.js +@@= skipped -24, +24 lines =@@ + return E.A; + let E; + (function (E) { +- E[E["A"] = 0] = "A"; ++ E[E["A"] = void 0] = "A"; + })(E || (E = {})); + } + function foo2() { + return E.A; + let E; + (function (E) { +- E[E["A"] = 0] = "A"; ++ E[E["A"] = void 0] = "A"; + })(E || (E = {})); + } + const config = { \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/computedEnumMemberSyntacticallyString(isolatedmodules=false).js b/testdata/baselines/reference/submodule/compiler/computedEnumMemberSyntacticallyString(isolatedmodules=false).js index 7b9e0d574f..38c360bdf0 100644 --- a/testdata/baselines/reference/submodule/compiler/computedEnumMemberSyntacticallyString(isolatedmodules=false).js +++ b/testdata/baselines/reference/submodule/compiler/computedEnumMemberSyntacticallyString(isolatedmodules=false).js @@ -22,19 +22,11 @@ const BAR = 2..toFixed(0); var Foo; (function (Foo) { Foo["A"] = `${BAR}`; - if (typeof Foo.A !== "string") Foo[Foo.A] = "A"; Foo["B"] = "2" + BAR; - if (typeof Foo.B !== "string") Foo[Foo.B] = "B"; Foo["C"] = (`${BAR}`); - if (typeof Foo.C !== "string") Foo[Foo.C] = "C"; - Foo["F"] = BAR; - if (typeof Foo.F !== "string") Foo[Foo.F] = "F"; - Foo["G"] = 2 + BAR; - if (typeof Foo.G !== "string") Foo[Foo.G] = "G"; + Foo[Foo["F"] = BAR] = "F"; + Foo[Foo["G"] = 2 + BAR] = "G"; Foo["H"] = Foo.A; - if (typeof Foo.H !== "string") Foo[Foo.H] = "H"; Foo["I"] = Foo.H + BAR; - if (typeof Foo.I !== "string") Foo[Foo.I] = "I"; Foo["J"] = Foo.H; - if (typeof Foo.J !== "string") Foo[Foo.J] = "J"; })(Foo || (Foo = {})); diff --git a/testdata/baselines/reference/submodule/compiler/computedEnumMemberSyntacticallyString(isolatedmodules=false).js.diff b/testdata/baselines/reference/submodule/compiler/computedEnumMemberSyntacticallyString(isolatedmodules=false).js.diff deleted file mode 100644 index c534e864f7..0000000000 --- a/testdata/baselines/reference/submodule/compiler/computedEnumMemberSyntacticallyString(isolatedmodules=false).js.diff +++ /dev/null @@ -1,24 +0,0 @@ ---- old.computedEnumMemberSyntacticallyString(isolatedmodules=false).js -+++ new.computedEnumMemberSyntacticallyString(isolatedmodules=false).js -@@= skipped -21, +21 lines =@@ - var Foo; - (function (Foo) { - Foo["A"] = `${BAR}`; -+ if (typeof Foo.A !== "string") Foo[Foo.A] = "A"; - Foo["B"] = "2" + BAR; -+ if (typeof Foo.B !== "string") Foo[Foo.B] = "B"; - Foo["C"] = (`${BAR}`); -- Foo[Foo["F"] = BAR] = "F"; -- Foo[Foo["G"] = 2 + BAR] = "G"; -+ if (typeof Foo.C !== "string") Foo[Foo.C] = "C"; -+ Foo["F"] = BAR; -+ if (typeof Foo.F !== "string") Foo[Foo.F] = "F"; -+ Foo["G"] = 2 + BAR; -+ if (typeof Foo.G !== "string") Foo[Foo.G] = "G"; - Foo["H"] = Foo.A; -+ if (typeof Foo.H !== "string") Foo[Foo.H] = "H"; - Foo["I"] = Foo.H + BAR; -+ if (typeof Foo.I !== "string") Foo[Foo.I] = "I"; - Foo["J"] = Foo.H; -+ if (typeof Foo.J !== "string") Foo[Foo.J] = "J"; - })(Foo || (Foo = {})); \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/computedEnumMemberSyntacticallyString(isolatedmodules=true).js b/testdata/baselines/reference/submodule/compiler/computedEnumMemberSyntacticallyString(isolatedmodules=true).js index 7b9e0d574f..38c360bdf0 100644 --- a/testdata/baselines/reference/submodule/compiler/computedEnumMemberSyntacticallyString(isolatedmodules=true).js +++ b/testdata/baselines/reference/submodule/compiler/computedEnumMemberSyntacticallyString(isolatedmodules=true).js @@ -22,19 +22,11 @@ const BAR = 2..toFixed(0); var Foo; (function (Foo) { Foo["A"] = `${BAR}`; - if (typeof Foo.A !== "string") Foo[Foo.A] = "A"; Foo["B"] = "2" + BAR; - if (typeof Foo.B !== "string") Foo[Foo.B] = "B"; Foo["C"] = (`${BAR}`); - if (typeof Foo.C !== "string") Foo[Foo.C] = "C"; - Foo["F"] = BAR; - if (typeof Foo.F !== "string") Foo[Foo.F] = "F"; - Foo["G"] = 2 + BAR; - if (typeof Foo.G !== "string") Foo[Foo.G] = "G"; + Foo[Foo["F"] = BAR] = "F"; + Foo[Foo["G"] = 2 + BAR] = "G"; Foo["H"] = Foo.A; - if (typeof Foo.H !== "string") Foo[Foo.H] = "H"; Foo["I"] = Foo.H + BAR; - if (typeof Foo.I !== "string") Foo[Foo.I] = "I"; Foo["J"] = Foo.H; - if (typeof Foo.J !== "string") Foo[Foo.J] = "J"; })(Foo || (Foo = {})); diff --git a/testdata/baselines/reference/submodule/compiler/computedEnumMemberSyntacticallyString(isolatedmodules=true).js.diff b/testdata/baselines/reference/submodule/compiler/computedEnumMemberSyntacticallyString(isolatedmodules=true).js.diff deleted file mode 100644 index bc17fd2cec..0000000000 --- a/testdata/baselines/reference/submodule/compiler/computedEnumMemberSyntacticallyString(isolatedmodules=true).js.diff +++ /dev/null @@ -1,24 +0,0 @@ ---- old.computedEnumMemberSyntacticallyString(isolatedmodules=true).js -+++ new.computedEnumMemberSyntacticallyString(isolatedmodules=true).js -@@= skipped -21, +21 lines =@@ - var Foo; - (function (Foo) { - Foo["A"] = `${BAR}`; -+ if (typeof Foo.A !== "string") Foo[Foo.A] = "A"; - Foo["B"] = "2" + BAR; -+ if (typeof Foo.B !== "string") Foo[Foo.B] = "B"; - Foo["C"] = (`${BAR}`); -- Foo[Foo["F"] = BAR] = "F"; -- Foo[Foo["G"] = 2 + BAR] = "G"; -+ if (typeof Foo.C !== "string") Foo[Foo.C] = "C"; -+ Foo["F"] = BAR; -+ if (typeof Foo.F !== "string") Foo[Foo.F] = "F"; -+ Foo["G"] = 2 + BAR; -+ if (typeof Foo.G !== "string") Foo[Foo.G] = "G"; - Foo["H"] = Foo.A; -+ if (typeof Foo.H !== "string") Foo[Foo.H] = "H"; - Foo["I"] = Foo.H + BAR; -+ if (typeof Foo.I !== "string") Foo[Foo.I] = "I"; - Foo["J"] = Foo.H; -+ if (typeof Foo.J !== "string") Foo[Foo.J] = "J"; - })(Foo || (Foo = {})); \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/computedEnumMemberSyntacticallyString2(isolatedmodules=false).js b/testdata/baselines/reference/submodule/compiler/computedEnumMemberSyntacticallyString2(isolatedmodules=false).js index 2b368dc853..132fda6791 100644 --- a/testdata/baselines/reference/submodule/compiler/computedEnumMemberSyntacticallyString2(isolatedmodules=false).js +++ b/testdata/baselines/reference/submodule/compiler/computedEnumMemberSyntacticallyString2(isolatedmodules=false).js @@ -32,26 +32,15 @@ import { BAR } from './bar'; const LOCAL = 'LOCAL'; var Foo; (function (Foo) { - Foo["A"] = `${BAR}`; - if (typeof Foo.A !== "string") Foo[Foo.A] = "A"; - Foo["B"] = LOCAL; - if (typeof Foo.B !== "string") Foo[Foo.B] = "B"; - Foo["C"] = Foo.B; - if (typeof Foo.C !== "string") Foo[Foo.C] = "C"; - Foo["D"] = Foo.C + 'BAR'; - if (typeof Foo.D !== "string") Foo[Foo.D] = "D"; - Foo["E1"] = (`${BAR}`); - if (typeof Foo.E1 !== "string") Foo[Foo.E1] = "E1"; - Foo["E2"] = `${BAR}`; - if (typeof Foo.E2 !== "string") Foo[Foo.E2] = "E2"; - Foo["F"] = BAR; - if (typeof Foo.F !== "string") Foo[Foo.F] = "F"; - Foo["G"] = 2 + BAR; - if (typeof Foo.G !== "string") Foo[Foo.G] = "G"; - Foo["H"] = Foo.A; - if (typeof Foo.H !== "string") Foo[Foo.H] = "H"; - Foo["I"] = Foo.H + BAR; - if (typeof Foo.I !== "string") Foo[Foo.I] = "I"; - Foo["J"] = Foo.H; - if (typeof Foo.J !== "string") Foo[Foo.J] = "J"; + Foo["A"] = "bar"; + Foo["B"] = "LOCAL"; + Foo["C"] = "LOCAL"; + Foo["D"] = "LOCALBAR"; + Foo[Foo["E1"] = (`${BAR}`)] = "E1"; + Foo[Foo["E2"] = `${BAR}`] = "E2"; + Foo["F"] = "bar"; + Foo["G"] = "2bar"; + Foo["H"] = "bar"; + Foo["I"] = "barbar"; + Foo["J"] = "bar"; })(Foo || (Foo = {})); diff --git a/testdata/baselines/reference/submodule/compiler/computedEnumMemberSyntacticallyString2(isolatedmodules=false).js.diff b/testdata/baselines/reference/submodule/compiler/computedEnumMemberSyntacticallyString2(isolatedmodules=false).js.diff deleted file mode 100644 index 4e4a6aa742..0000000000 --- a/testdata/baselines/reference/submodule/compiler/computedEnumMemberSyntacticallyString2(isolatedmodules=false).js.diff +++ /dev/null @@ -1,40 +0,0 @@ ---- old.computedEnumMemberSyntacticallyString2(isolatedmodules=false).js -+++ new.computedEnumMemberSyntacticallyString2(isolatedmodules=false).js -@@= skipped -31, +31 lines =@@ - const LOCAL = 'LOCAL'; - var Foo; - (function (Foo) { -- Foo["A"] = "bar"; -- Foo["B"] = "LOCAL"; -- Foo["C"] = "LOCAL"; -- Foo["D"] = "LOCALBAR"; -- Foo[Foo["E1"] = (`${BAR}`)] = "E1"; -- Foo[Foo["E2"] = `${BAR}`] = "E2"; -- Foo["F"] = "bar"; -- Foo["G"] = "2bar"; -- Foo["H"] = "bar"; -- Foo["I"] = "barbar"; -- Foo["J"] = "bar"; -+ Foo["A"] = `${BAR}`; -+ if (typeof Foo.A !== "string") Foo[Foo.A] = "A"; -+ Foo["B"] = LOCAL; -+ if (typeof Foo.B !== "string") Foo[Foo.B] = "B"; -+ Foo["C"] = Foo.B; -+ if (typeof Foo.C !== "string") Foo[Foo.C] = "C"; -+ Foo["D"] = Foo.C + 'BAR'; -+ if (typeof Foo.D !== "string") Foo[Foo.D] = "D"; -+ Foo["E1"] = (`${BAR}`); -+ if (typeof Foo.E1 !== "string") Foo[Foo.E1] = "E1"; -+ Foo["E2"] = `${BAR}`; -+ if (typeof Foo.E2 !== "string") Foo[Foo.E2] = "E2"; -+ Foo["F"] = BAR; -+ if (typeof Foo.F !== "string") Foo[Foo.F] = "F"; -+ Foo["G"] = 2 + BAR; -+ if (typeof Foo.G !== "string") Foo[Foo.G] = "G"; -+ Foo["H"] = Foo.A; -+ if (typeof Foo.H !== "string") Foo[Foo.H] = "H"; -+ Foo["I"] = Foo.H + BAR; -+ if (typeof Foo.I !== "string") Foo[Foo.I] = "I"; -+ Foo["J"] = Foo.H; -+ if (typeof Foo.J !== "string") Foo[Foo.J] = "J"; - })(Foo || (Foo = {})); \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/computedEnumMemberSyntacticallyString2(isolatedmodules=true).js b/testdata/baselines/reference/submodule/compiler/computedEnumMemberSyntacticallyString2(isolatedmodules=true).js index 2b368dc853..132fda6791 100644 --- a/testdata/baselines/reference/submodule/compiler/computedEnumMemberSyntacticallyString2(isolatedmodules=true).js +++ b/testdata/baselines/reference/submodule/compiler/computedEnumMemberSyntacticallyString2(isolatedmodules=true).js @@ -32,26 +32,15 @@ import { BAR } from './bar'; const LOCAL = 'LOCAL'; var Foo; (function (Foo) { - Foo["A"] = `${BAR}`; - if (typeof Foo.A !== "string") Foo[Foo.A] = "A"; - Foo["B"] = LOCAL; - if (typeof Foo.B !== "string") Foo[Foo.B] = "B"; - Foo["C"] = Foo.B; - if (typeof Foo.C !== "string") Foo[Foo.C] = "C"; - Foo["D"] = Foo.C + 'BAR'; - if (typeof Foo.D !== "string") Foo[Foo.D] = "D"; - Foo["E1"] = (`${BAR}`); - if (typeof Foo.E1 !== "string") Foo[Foo.E1] = "E1"; - Foo["E2"] = `${BAR}`; - if (typeof Foo.E2 !== "string") Foo[Foo.E2] = "E2"; - Foo["F"] = BAR; - if (typeof Foo.F !== "string") Foo[Foo.F] = "F"; - Foo["G"] = 2 + BAR; - if (typeof Foo.G !== "string") Foo[Foo.G] = "G"; - Foo["H"] = Foo.A; - if (typeof Foo.H !== "string") Foo[Foo.H] = "H"; - Foo["I"] = Foo.H + BAR; - if (typeof Foo.I !== "string") Foo[Foo.I] = "I"; - Foo["J"] = Foo.H; - if (typeof Foo.J !== "string") Foo[Foo.J] = "J"; + Foo["A"] = "bar"; + Foo["B"] = "LOCAL"; + Foo["C"] = "LOCAL"; + Foo["D"] = "LOCALBAR"; + Foo[Foo["E1"] = (`${BAR}`)] = "E1"; + Foo[Foo["E2"] = `${BAR}`] = "E2"; + Foo["F"] = "bar"; + Foo["G"] = "2bar"; + Foo["H"] = "bar"; + Foo["I"] = "barbar"; + Foo["J"] = "bar"; })(Foo || (Foo = {})); diff --git a/testdata/baselines/reference/submodule/compiler/computedEnumMemberSyntacticallyString2(isolatedmodules=true).js.diff b/testdata/baselines/reference/submodule/compiler/computedEnumMemberSyntacticallyString2(isolatedmodules=true).js.diff deleted file mode 100644 index f557aa6dd9..0000000000 --- a/testdata/baselines/reference/submodule/compiler/computedEnumMemberSyntacticallyString2(isolatedmodules=true).js.diff +++ /dev/null @@ -1,40 +0,0 @@ ---- old.computedEnumMemberSyntacticallyString2(isolatedmodules=true).js -+++ new.computedEnumMemberSyntacticallyString2(isolatedmodules=true).js -@@= skipped -31, +31 lines =@@ - const LOCAL = 'LOCAL'; - var Foo; - (function (Foo) { -- Foo["A"] = "bar"; -- Foo["B"] = "LOCAL"; -- Foo["C"] = "LOCAL"; -- Foo["D"] = "LOCALBAR"; -- Foo[Foo["E1"] = (`${BAR}`)] = "E1"; -- Foo[Foo["E2"] = `${BAR}`] = "E2"; -- Foo["F"] = "bar"; -- Foo["G"] = "2bar"; -- Foo["H"] = "bar"; -- Foo["I"] = "barbar"; -- Foo["J"] = "bar"; -+ Foo["A"] = `${BAR}`; -+ if (typeof Foo.A !== "string") Foo[Foo.A] = "A"; -+ Foo["B"] = LOCAL; -+ if (typeof Foo.B !== "string") Foo[Foo.B] = "B"; -+ Foo["C"] = Foo.B; -+ if (typeof Foo.C !== "string") Foo[Foo.C] = "C"; -+ Foo["D"] = Foo.C + 'BAR'; -+ if (typeof Foo.D !== "string") Foo[Foo.D] = "D"; -+ Foo["E1"] = (`${BAR}`); -+ if (typeof Foo.E1 !== "string") Foo[Foo.E1] = "E1"; -+ Foo["E2"] = `${BAR}`; -+ if (typeof Foo.E2 !== "string") Foo[Foo.E2] = "E2"; -+ Foo["F"] = BAR; -+ if (typeof Foo.F !== "string") Foo[Foo.F] = "F"; -+ Foo["G"] = 2 + BAR; -+ if (typeof Foo.G !== "string") Foo[Foo.G] = "G"; -+ Foo["H"] = Foo.A; -+ if (typeof Foo.H !== "string") Foo[Foo.H] = "H"; -+ Foo["I"] = Foo.H + BAR; -+ if (typeof Foo.I !== "string") Foo[Foo.I] = "I"; -+ Foo["J"] = Foo.H; -+ if (typeof Foo.J !== "string") Foo[Foo.J] = "J"; - })(Foo || (Foo = {})); \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/computedEnumTypeWidening.js b/testdata/baselines/reference/submodule/compiler/computedEnumTypeWidening.js index 90143e71ec..930e3c4478 100644 --- a/testdata/baselines/reference/submodule/compiler/computedEnumTypeWidening.js +++ b/testdata/baselines/reference/submodule/compiler/computedEnumTypeWidening.js @@ -83,14 +83,10 @@ val2 = MyDeclaredEnum.B; "use strict"; var E; (function (E) { - E["A"] = computed(0); - if (typeof E.A !== "string") E[E.A] = "A"; - E["B"] = computed(1); - if (typeof E.B !== "string") E[E.B] = "B"; - E["C"] = computed(2); - if (typeof E.C !== "string") E[E.C] = "C"; - E["D"] = computed(3); - if (typeof E.D !== "string") E[E.D] = "D"; + E[E["A"] = computed(0)] = "A"; + E[E["B"] = computed(1)] = "B"; + E[E["C"] = computed(2)] = "C"; + E[E["D"] = computed(3)] = "D"; })(E || (E = {})); function f1() { const c1 = E.B; // Fresh E.B diff --git a/testdata/baselines/reference/submodule/compiler/computedEnumTypeWidening.js.diff b/testdata/baselines/reference/submodule/compiler/computedEnumTypeWidening.js.diff index 9d27aebdce..a8ecb579c1 100644 --- a/testdata/baselines/reference/submodule/compiler/computedEnumTypeWidening.js.diff +++ b/testdata/baselines/reference/submodule/compiler/computedEnumTypeWidening.js.diff @@ -1,25 +1,6 @@ --- old.computedEnumTypeWidening.js +++ new.computedEnumTypeWidening.js -@@= skipped -82, +82 lines =@@ - "use strict"; - var E; - (function (E) { -- E[E["A"] = computed(0)] = "A"; -- E[E["B"] = computed(1)] = "B"; -- E[E["C"] = computed(2)] = "C"; -- E[E["D"] = computed(3)] = "D"; -+ E["A"] = computed(0); -+ if (typeof E.A !== "string") E[E.A] = "A"; -+ E["B"] = computed(1); -+ if (typeof E.B !== "string") E[E.B] = "B"; -+ E["C"] = computed(2); -+ if (typeof E.C !== "string") E[E.C] = "C"; -+ E["D"] = computed(3); -+ if (typeof E.D !== "string") E[E.D] = "D"; - })(E || (E = {})); - function f1() { - const c1 = E.B; // Fresh E.B -@@= skipped -48, +52 lines =@@ +@@= skipped -130, +130 lines =@@ let v1 = E.B; let v2 = E.B; class C { diff --git a/testdata/baselines/reference/submodule/compiler/declFileEnums.js b/testdata/baselines/reference/submodule/compiler/declFileEnums.js index 201cd3d068..f4fba9f5b3 100644 --- a/testdata/baselines/reference/submodule/compiler/declFileEnums.js +++ b/testdata/baselines/reference/submodule/compiler/declFileEnums.js @@ -53,8 +53,7 @@ var e2; var e3; (function (e3) { e3[e3["a"] = 10] = "a"; - e3["b"] = Math.PI; - if (typeof e3.b !== "string") e3[e3.b] = "b"; + e3[e3["b"] = Math.PI] = "b"; e3[e3["c"] = 13] = "c"; })(e3 || (e3 = {})); var e4; diff --git a/testdata/baselines/reference/submodule/compiler/declFileEnums.js.diff b/testdata/baselines/reference/submodule/compiler/declFileEnums.js.diff deleted file mode 100644 index 3cd49b95f1..0000000000 --- a/testdata/baselines/reference/submodule/compiler/declFileEnums.js.diff +++ /dev/null @@ -1,12 +0,0 @@ ---- old.declFileEnums.js -+++ new.declFileEnums.js -@@= skipped -52, +52 lines =@@ - var e3; - (function (e3) { - e3[e3["a"] = 10] = "a"; -- e3[e3["b"] = Math.PI] = "b"; -+ e3["b"] = Math.PI; -+ if (typeof e3.b !== "string") e3[e3.b] = "b"; - e3[e3["c"] = 13] = "c"; - })(e3 || (e3 = {})); - var e4; \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/enumBasics2.js b/testdata/baselines/reference/submodule/compiler/enumBasics2.js index 3d0fc5ece9..dae06d0378 100644 --- a/testdata/baselines/reference/submodule/compiler/enumBasics2.js +++ b/testdata/baselines/reference/submodule/compiler/enumBasics2.js @@ -22,21 +22,14 @@ var Foo; (function (Foo) { Foo[Foo["a"] = 2] = "a"; Foo[Foo["b"] = 3] = "b"; - Foo["x"] = Foo.a.b; - if (typeof Foo.x !== "string") Foo[Foo.x] = "x"; - Foo["y"] = Foo.b.a; - if (typeof Foo.y !== "string") Foo[Foo.y] = "y"; - Foo["z"] = Foo.y.x * Foo.a.x; - if (typeof Foo.z !== "string") Foo[Foo.z] = "z"; + Foo[Foo["x"] = Foo.a.b] = "x"; + Foo[Foo["y"] = Foo.b.a] = "y"; + Foo[Foo["z"] = Foo.y.x * Foo.a.x] = "z"; })(Foo || (Foo = {})); var Bar; (function (Bar) { - Bar["a"] = (1).valueOf(); - if (typeof Bar.a !== "string") Bar[Bar.a] = "a"; - Bar["b"] = Foo.a; - if (typeof Bar.b !== "string") Bar[Bar.b] = "b"; - Bar["c"] = Foo.a.valueOf(); - if (typeof Bar.c !== "string") Bar[Bar.c] = "c"; - Bar["d"] = Foo.a.a; - if (typeof Bar.d !== "string") Bar[Bar.d] = "d"; + Bar[Bar["a"] = (1).valueOf()] = "a"; + Bar[Bar["b"] = 2] = "b"; + Bar[Bar["c"] = Foo.a.valueOf()] = "c"; + Bar[Bar["d"] = Foo.a.a] = "d"; })(Bar || (Bar = {})); diff --git a/testdata/baselines/reference/submodule/compiler/enumBasics2.js.diff b/testdata/baselines/reference/submodule/compiler/enumBasics2.js.diff deleted file mode 100644 index 2418bf871e..0000000000 --- a/testdata/baselines/reference/submodule/compiler/enumBasics2.js.diff +++ /dev/null @@ -1,31 +0,0 @@ ---- old.enumBasics2.js -+++ new.enumBasics2.js -@@= skipped -21, +21 lines =@@ - (function (Foo) { - Foo[Foo["a"] = 2] = "a"; - Foo[Foo["b"] = 3] = "b"; -- Foo[Foo["x"] = Foo.a.b] = "x"; -- Foo[Foo["y"] = Foo.b.a] = "y"; -- Foo[Foo["z"] = Foo.y.x * Foo.a.x] = "z"; -+ Foo["x"] = Foo.a.b; -+ if (typeof Foo.x !== "string") Foo[Foo.x] = "x"; -+ Foo["y"] = Foo.b.a; -+ if (typeof Foo.y !== "string") Foo[Foo.y] = "y"; -+ Foo["z"] = Foo.y.x * Foo.a.x; -+ if (typeof Foo.z !== "string") Foo[Foo.z] = "z"; - })(Foo || (Foo = {})); - var Bar; - (function (Bar) { -- Bar[Bar["a"] = (1).valueOf()] = "a"; -- Bar[Bar["b"] = 2] = "b"; -- Bar[Bar["c"] = Foo.a.valueOf()] = "c"; -- Bar[Bar["d"] = Foo.a.a] = "d"; -+ Bar["a"] = (1).valueOf(); -+ if (typeof Bar.a !== "string") Bar[Bar.a] = "a"; -+ Bar["b"] = Foo.a; -+ if (typeof Bar.b !== "string") Bar[Bar.b] = "b"; -+ Bar["c"] = Foo.a.valueOf(); -+ if (typeof Bar.c !== "string") Bar[Bar.c] = "c"; -+ Bar["d"] = Foo.a.a; -+ if (typeof Bar.d !== "string") Bar[Bar.d] = "d"; - })(Bar || (Bar = {})); \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/enumBasics3.js b/testdata/baselines/reference/submodule/compiler/enumBasics3.js index 4f87ae6fb9..0d14687111 100644 --- a/testdata/baselines/reference/submodule/compiler/enumBasics3.js +++ b/testdata/baselines/reference/submodule/compiler/enumBasics3.js @@ -28,8 +28,7 @@ var M; let E1; (function (E1) { E1[E1["a"] = 1] = "a"; - E1["b"] = E1.a.a; - if (typeof E1.b !== "string") E1[E1.b] = "b"; + E1[E1["b"] = E1.a.a] = "b"; })(E1 = N.E1 || (N.E1 = {})); })(N = M.N || (M.N = {})); })(M || (M = {})); @@ -38,10 +37,8 @@ var M; (function (N) { let E2; (function (E2) { - E2["b"] = M.N.E1.a; - if (typeof E2.b !== "string") E2[E2.b] = "b"; - E2["c"] = M.N.E1.a.a; - if (typeof E2.c !== "string") E2[E2.c] = "c"; + E2[E2["b"] = 1] = "b"; + E2[E2["c"] = M.N.E1.a.a] = "c"; })(E2 = N.E2 || (N.E2 = {})); })(N = M.N || (M.N = {})); })(M || (M = {})); diff --git a/testdata/baselines/reference/submodule/compiler/enumBasics3.js.diff b/testdata/baselines/reference/submodule/compiler/enumBasics3.js.diff deleted file mode 100644 index 26b73e2291..0000000000 --- a/testdata/baselines/reference/submodule/compiler/enumBasics3.js.diff +++ /dev/null @@ -1,25 +0,0 @@ ---- old.enumBasics3.js -+++ new.enumBasics3.js -@@= skipped -27, +27 lines =@@ - let E1; - (function (E1) { - E1[E1["a"] = 1] = "a"; -- E1[E1["b"] = E1.a.a] = "b"; -+ E1["b"] = E1.a.a; -+ if (typeof E1.b !== "string") E1[E1.b] = "b"; - })(E1 = N.E1 || (N.E1 = {})); - })(N = M.N || (M.N = {})); - })(M || (M = {})); -@@= skipped -9, +10 lines =@@ - (function (N) { - let E2; - (function (E2) { -- E2[E2["b"] = 1] = "b"; -- E2[E2["c"] = M.N.E1.a.a] = "c"; -+ E2["b"] = M.N.E1.a; -+ if (typeof E2.b !== "string") E2[E2.b] = "b"; -+ E2["c"] = M.N.E1.a.a; -+ if (typeof E2.c !== "string") E2[E2.c] = "c"; - })(E2 = N.E2 || (N.E2 = {})); - })(N = M.N || (M.N = {})); - })(M || (M = {})); \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/enumNoInitializerFollowsNonLiteralInitializer.js b/testdata/baselines/reference/submodule/compiler/enumNoInitializerFollowsNonLiteralInitializer.js index 0edd8cb8c4..0e493f79bf 100644 --- a/testdata/baselines/reference/submodule/compiler/enumNoInitializerFollowsNonLiteralInitializer.js +++ b/testdata/baselines/reference/submodule/compiler/enumNoInitializerFollowsNonLiteralInitializer.js @@ -52,12 +52,11 @@ Object.defineProperty(exports, "__esModule", { value: true }); const helpers_1 = require("./helpers"); var A; (function (A) { - var auto; - A[A["a"] = auto = helpers_1.foo] = "a"; - A[A["b"] = ++auto] = "b"; + A[A["a"] = 2] = "a"; + A[A["b"] = 3] = "b"; A[A["c"] = 10] = "c"; - A[A["d"] = 10] = "d"; - A[A["e"] = 11] = "e"; + A[A["d"] = (A.c)] = "d"; + A[A["e"] = void 0] = "e"; })(A || (A = {})); //// [good.js] "use strict"; @@ -65,8 +64,7 @@ Object.defineProperty(exports, "__esModule", { value: true }); const helpers_1 = require("./helpers"); var A; (function (A) { - A["a"] = helpers_1.foo; - if (typeof A.a !== "string") A[A.a] = "a"; + A[A["a"] = 2] = "a"; A[A["b"] = 3] = "b"; })(A || (A = {})); var B; diff --git a/testdata/baselines/reference/submodule/compiler/enumNoInitializerFollowsNonLiteralInitializer.js.diff b/testdata/baselines/reference/submodule/compiler/enumNoInitializerFollowsNonLiteralInitializer.js.diff deleted file mode 100644 index bb593297ee..0000000000 --- a/testdata/baselines/reference/submodule/compiler/enumNoInitializerFollowsNonLiteralInitializer.js.diff +++ /dev/null @@ -1,29 +0,0 @@ ---- old.enumNoInitializerFollowsNonLiteralInitializer.js -+++ new.enumNoInitializerFollowsNonLiteralInitializer.js -@@= skipped -51, +51 lines =@@ - const helpers_1 = require("./helpers"); - var A; - (function (A) { -- A[A["a"] = 2] = "a"; -- A[A["b"] = 3] = "b"; -+ var auto; -+ A[A["a"] = auto = helpers_1.foo] = "a"; -+ A[A["b"] = ++auto] = "b"; - A[A["c"] = 10] = "c"; -- A[A["d"] = (A.c)] = "d"; -- A[A["e"] = void 0] = "e"; -+ A[A["d"] = 10] = "d"; -+ A[A["e"] = 11] = "e"; - })(A || (A = {})); - //// [good.js] - "use strict"; -@@= skipped -12, +13 lines =@@ - const helpers_1 = require("./helpers"); - var A; - (function (A) { -- A[A["a"] = 2] = "a"; -+ A["a"] = helpers_1.foo; -+ if (typeof A.a !== "string") A[A.a] = "a"; - A[A["b"] = 3] = "b"; - })(A || (A = {})); - var B; \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/enumNumbering1.js b/testdata/baselines/reference/submodule/compiler/enumNumbering1.js index 8638a91f89..dcecaea5e2 100644 --- a/testdata/baselines/reference/submodule/compiler/enumNumbering1.js +++ b/testdata/baselines/reference/submodule/compiler/enumNumbering1.js @@ -15,8 +15,7 @@ var Test; (function (Test) { Test[Test["A"] = 0] = "A"; Test[Test["B"] = 1] = "B"; - Test["C"] = Math.floor(Math.random() * 1000); - if (typeof Test.C !== "string") Test[Test.C] = "C"; + Test[Test["C"] = Math.floor(Math.random() * 1000)] = "C"; Test[Test["D"] = 10] = "D"; Test[Test["E"] = 11] = "E"; // Error but shouldn't be })(Test || (Test = {})); diff --git a/testdata/baselines/reference/submodule/compiler/enumNumbering1.js.diff b/testdata/baselines/reference/submodule/compiler/enumNumbering1.js.diff deleted file mode 100644 index 433579af37..0000000000 --- a/testdata/baselines/reference/submodule/compiler/enumNumbering1.js.diff +++ /dev/null @@ -1,12 +0,0 @@ ---- old.enumNumbering1.js -+++ new.enumNumbering1.js -@@= skipped -14, +14 lines =@@ - (function (Test) { - Test[Test["A"] = 0] = "A"; - Test[Test["B"] = 1] = "B"; -- Test[Test["C"] = Math.floor(Math.random() * 1000)] = "C"; -+ Test["C"] = Math.floor(Math.random() * 1000); -+ if (typeof Test.C !== "string") Test[Test.C] = "C"; - Test[Test["D"] = 10] = "D"; - Test[Test["E"] = 11] = "E"; // Error but shouldn't be - })(Test || (Test = {})); \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/enumPropertyAccessBeforeInitalisation.js b/testdata/baselines/reference/submodule/compiler/enumPropertyAccessBeforeInitalisation.js index 0f294a0707..7d6bb9bc90 100644 --- a/testdata/baselines/reference/submodule/compiler/enumPropertyAccessBeforeInitalisation.js +++ b/testdata/baselines/reference/submodule/compiler/enumPropertyAccessBeforeInitalisation.js @@ -12,12 +12,8 @@ enum E { //// [enumPropertyAccessBeforeInitalisation.js] var E; (function (E) { - E["A"] = E.A; - if (typeof E.A !== "string") E[E.A] = "A"; - E["B"] = E.B; - if (typeof E.B !== "string") E[E.B] = "B"; - E["C"] = E["C"]; - if (typeof E.C !== "string") E[E.C] = "C"; - E["D"] = 1 + E.D; - if (typeof E.D !== "string") E[E.D] = "D"; + E[E["A"] = E.A] = "A"; + E[E["B"] = E.B] = "B"; + E[E["C"] = E["C"]] = "C"; + E[E["D"] = 1 + E.D] = "D"; })(E || (E = {})); diff --git a/testdata/baselines/reference/submodule/compiler/enumPropertyAccessBeforeInitalisation.js.diff b/testdata/baselines/reference/submodule/compiler/enumPropertyAccessBeforeInitalisation.js.diff deleted file mode 100644 index b278d486b6..0000000000 --- a/testdata/baselines/reference/submodule/compiler/enumPropertyAccessBeforeInitalisation.js.diff +++ /dev/null @@ -1,19 +0,0 @@ ---- old.enumPropertyAccessBeforeInitalisation.js -+++ new.enumPropertyAccessBeforeInitalisation.js -@@= skipped -11, +11 lines =@@ - //// [enumPropertyAccessBeforeInitalisation.js] - var E; - (function (E) { -- E[E["A"] = E.A] = "A"; -- E[E["B"] = E.B] = "B"; -- E[E["C"] = E["C"]] = "C"; -- E[E["D"] = 1 + E.D] = "D"; -+ E["A"] = E.A; -+ if (typeof E.A !== "string") E[E.A] = "A"; -+ E["B"] = E.B; -+ if (typeof E.B !== "string") E[E.B] = "B"; -+ E["C"] = E["C"]; -+ if (typeof E.C !== "string") E[E.C] = "C"; -+ E["D"] = 1 + E.D; -+ if (typeof E.D !== "string") E[E.D] = "D"; - })(E || (E = {})); \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/enumWithComputedMember.js b/testdata/baselines/reference/submodule/compiler/enumWithComputedMember.js index af8b7e8d26..9db30dec9a 100644 --- a/testdata/baselines/reference/submodule/compiler/enumWithComputedMember.js +++ b/testdata/baselines/reference/submodule/compiler/enumWithComputedMember.js @@ -11,9 +11,7 @@ enum A { //// [enumWithComputedMember.js] var A; (function (A) { - var auto; - A["X"] = "".length; - if (typeof A.X !== "string") A[A.X] = "X"; - A[A["Y"] = auto = A.X] = "Y"; - A[A["Z"] = ++auto] = "Z"; + A[A["X"] = "".length] = "X"; + A[A["Y"] = A.X] = "Y"; + A[A["Z"] = void 0] = "Z"; })(A || (A = {})); diff --git a/testdata/baselines/reference/submodule/compiler/enumWithComputedMember.js.diff b/testdata/baselines/reference/submodule/compiler/enumWithComputedMember.js.diff deleted file mode 100644 index c6b051357d..0000000000 --- a/testdata/baselines/reference/submodule/compiler/enumWithComputedMember.js.diff +++ /dev/null @@ -1,15 +0,0 @@ ---- old.enumWithComputedMember.js -+++ new.enumWithComputedMember.js -@@= skipped -10, +10 lines =@@ - //// [enumWithComputedMember.js] - var A; - (function (A) { -- A[A["X"] = "".length] = "X"; -- A[A["Y"] = A.X] = "Y"; -- A[A["Z"] = void 0] = "Z"; -+ var auto; -+ A["X"] = "".length; -+ if (typeof A.X !== "string") A[A.X] = "X"; -+ A[A["Y"] = auto = A.X] = "Y"; -+ A[A["Z"] = ++auto] = "Z"; - })(A || (A = {})); \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/enumWithExport.js b/testdata/baselines/reference/submodule/compiler/enumWithExport.js index 23d5f585d6..51b2dcd1d4 100644 --- a/testdata/baselines/reference/submodule/compiler/enumWithExport.js +++ b/testdata/baselines/reference/submodule/compiler/enumWithExport.js @@ -14,6 +14,5 @@ var x; x.y = 123; })(x || (x = {})); (function (x) { - x["z"] = y; - if (typeof x.z !== "string") x[x.z] = "z"; + x[x["z"] = y] = "z"; })(x || (x = {})); diff --git a/testdata/baselines/reference/submodule/compiler/enumWithExport.js.diff b/testdata/baselines/reference/submodule/compiler/enumWithExport.js.diff deleted file mode 100644 index a6c50dd3c1..0000000000 --- a/testdata/baselines/reference/submodule/compiler/enumWithExport.js.diff +++ /dev/null @@ -1,10 +0,0 @@ ---- old.enumWithExport.js -+++ new.enumWithExport.js -@@= skipped -13, +13 lines =@@ - x.y = 123; - })(x || (x = {})); - (function (x) { -- x[x["z"] = y] = "z"; -+ x["z"] = y; -+ if (typeof x.z !== "string") x[x.z] = "z"; - })(x || (x = {})); \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/enumWithNonLiteralStringInitializer.js b/testdata/baselines/reference/submodule/compiler/enumWithNonLiteralStringInitializer.js index c65981cf50..6f3cb58028 100644 --- a/testdata/baselines/reference/submodule/compiler/enumWithNonLiteralStringInitializer.js +++ b/testdata/baselines/reference/submodule/compiler/enumWithNonLiteralStringInitializer.js @@ -32,8 +32,7 @@ Object.defineProperty(exports, "__esModule", { value: true }); const helpers_1 = require("./helpers"); var A; (function (A) { - A["a"] = helpers_1.bar; - if (typeof A.a !== "string") A[A.a] = "a"; + A["a"] = "bar"; })(A || (A = {})); //// [good.js] "use strict"; @@ -41,8 +40,7 @@ Object.defineProperty(exports, "__esModule", { value: true }); const helpers_1 = require("./helpers"); var A; (function (A) { - A["a"] = `${helpers_1.foo}`; - if (typeof A.a !== "string") A[A.a] = "a"; + A["a"] = "2"; A["b"] = "2"; A["c"] = "2"; A["d"] = "foo"; diff --git a/testdata/baselines/reference/submodule/compiler/enumWithNonLiteralStringInitializer.js.diff b/testdata/baselines/reference/submodule/compiler/enumWithNonLiteralStringInitializer.js.diff deleted file mode 100644 index 74bfbd0128..0000000000 --- a/testdata/baselines/reference/submodule/compiler/enumWithNonLiteralStringInitializer.js.diff +++ /dev/null @@ -1,22 +0,0 @@ ---- old.enumWithNonLiteralStringInitializer.js -+++ new.enumWithNonLiteralStringInitializer.js -@@= skipped -31, +31 lines =@@ - const helpers_1 = require("./helpers"); - var A; - (function (A) { -- A["a"] = "bar"; -+ A["a"] = helpers_1.bar; -+ if (typeof A.a !== "string") A[A.a] = "a"; - })(A || (A = {})); - //// [good.js] - "use strict"; -@@= skipped -8, +9 lines =@@ - const helpers_1 = require("./helpers"); - var A; - (function (A) { -- A["a"] = "2"; -+ A["a"] = `${helpers_1.foo}`; -+ if (typeof A.a !== "string") A[A.a] = "a"; - A["b"] = "2"; - A["c"] = "2"; - A["d"] = "foo"; \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/fakeInfinity2.js b/testdata/baselines/reference/submodule/compiler/fakeInfinity2.js index 7d6b53bf31..779b0f421d 100644 --- a/testdata/baselines/reference/submodule/compiler/fakeInfinity2.js +++ b/testdata/baselines/reference/submodule/compiler/fakeInfinity2.js @@ -24,8 +24,8 @@ Object.defineProperty(exports, "__esModule", { value: true }); exports.m = exports.Foo = void 0; var Foo; (function (Foo) { - Foo[Foo["A"] = 1e999] = "A"; - Foo[Foo["B"] = -1e999] = "B"; + Foo[Foo["A"] = Infinity] = "A"; + Foo[Foo["B"] = -Infinity] = "B"; })(Foo || (exports.Foo = Foo = {})); var X; (function (X) { diff --git a/testdata/baselines/reference/submodule/compiler/fakeInfinity2.js.diff b/testdata/baselines/reference/submodule/compiler/fakeInfinity2.js.diff deleted file mode 100644 index 960f5fa4b1..0000000000 --- a/testdata/baselines/reference/submodule/compiler/fakeInfinity2.js.diff +++ /dev/null @@ -1,13 +0,0 @@ ---- old.fakeInfinity2.js -+++ new.fakeInfinity2.js -@@= skipped -23, +23 lines =@@ - exports.m = exports.Foo = void 0; - var Foo; - (function (Foo) { -- Foo[Foo["A"] = Infinity] = "A"; -- Foo[Foo["B"] = -Infinity] = "B"; -+ Foo[Foo["A"] = 1e999] = "A"; -+ Foo[Foo["B"] = -1e999] = "B"; - })(Foo || (exports.Foo = Foo = {})); - var X; - (function (X) { \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/fakeInfinity3.js b/testdata/baselines/reference/submodule/compiler/fakeInfinity3.js index 1fa84499ea..dbde9c2ce7 100644 --- a/testdata/baselines/reference/submodule/compiler/fakeInfinity3.js +++ b/testdata/baselines/reference/submodule/compiler/fakeInfinity3.js @@ -26,8 +26,8 @@ Object.defineProperty(exports, "__esModule", { value: true }); exports.Infinity = exports.m = exports.Foo = void 0; var Foo; (function (Foo) { - Foo[Foo["A"] = 1e999] = "A"; - Foo[Foo["B"] = -1e999] = "B"; + Foo[Foo["A"] = Infinity] = "A"; + Foo[Foo["B"] = -Infinity] = "B"; })(Foo || (exports.Foo = Foo = {})); var X; (function (X) { diff --git a/testdata/baselines/reference/submodule/compiler/fakeInfinity3.js.diff b/testdata/baselines/reference/submodule/compiler/fakeInfinity3.js.diff deleted file mode 100644 index 907869fe62..0000000000 --- a/testdata/baselines/reference/submodule/compiler/fakeInfinity3.js.diff +++ /dev/null @@ -1,13 +0,0 @@ ---- old.fakeInfinity3.js -+++ new.fakeInfinity3.js -@@= skipped -25, +25 lines =@@ - exports.Infinity = exports.m = exports.Foo = void 0; - var Foo; - (function (Foo) { -- Foo[Foo["A"] = Infinity] = "A"; -- Foo[Foo["B"] = -Infinity] = "B"; -+ Foo[Foo["A"] = 1e999] = "A"; -+ Foo[Foo["B"] = -1e999] = "B"; - })(Foo || (exports.Foo = Foo = {})); - var X; - (function (X) { \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/forwardRefInEnum.js b/testdata/baselines/reference/submodule/compiler/forwardRefInEnum.js index d37f89ceae..ac5e142d2d 100644 --- a/testdata/baselines/reference/submodule/compiler/forwardRefInEnum.js +++ b/testdata/baselines/reference/submodule/compiler/forwardRefInEnum.js @@ -21,15 +21,11 @@ var E1; (function (E1) { // illegal case // forward reference to the element of the same enum - E1["X"] = E1.Y; - if (typeof E1.X !== "string") E1[E1.X] = "X"; - E1["X1"] = E1["Y"]; - if (typeof E1.X1 !== "string") E1[E1.X1] = "X1"; + E1[E1["X"] = 0] = "X"; + E1[E1["X1"] = 0] = "X1"; // forward reference to the element of the same enum - E1["Y"] = E1.Z; - if (typeof E1.Y !== "string") E1[E1.Y] = "Y"; - E1["Y1"] = E1["Z"]; - if (typeof E1.Y1 !== "string") E1[E1.Y1] = "Y1"; + E1[E1["Y"] = 0] = "Y"; + E1[E1["Y1"] = 0] = "Y1"; })(E1 || (E1 = {})); (function (E1) { E1[E1["Z"] = 4] = "Z"; diff --git a/testdata/baselines/reference/submodule/compiler/forwardRefInEnum.js.diff b/testdata/baselines/reference/submodule/compiler/forwardRefInEnum.js.diff deleted file mode 100644 index fc0a3a51db..0000000000 --- a/testdata/baselines/reference/submodule/compiler/forwardRefInEnum.js.diff +++ /dev/null @@ -1,22 +0,0 @@ ---- old.forwardRefInEnum.js -+++ new.forwardRefInEnum.js -@@= skipped -20, +20 lines =@@ - (function (E1) { - // illegal case - // forward reference to the element of the same enum -- E1[E1["X"] = 0] = "X"; -- E1[E1["X1"] = 0] = "X1"; -+ E1["X"] = E1.Y; -+ if (typeof E1.X !== "string") E1[E1.X] = "X"; -+ E1["X1"] = E1["Y"]; -+ if (typeof E1.X1 !== "string") E1[E1.X1] = "X1"; - // forward reference to the element of the same enum -- E1[E1["Y"] = 0] = "Y"; -- E1[E1["Y1"] = 0] = "Y1"; -+ E1["Y"] = E1.Z; -+ if (typeof E1.Y !== "string") E1[E1.Y] = "Y"; -+ E1["Y1"] = E1["Z"]; -+ if (typeof E1.Y1 !== "string") E1[E1.Y1] = "Y1"; - })(E1 || (E1 = {})); - (function (E1) { - E1[E1["Z"] = 4] = "Z"; \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/importElisionEnum.js b/testdata/baselines/reference/submodule/compiler/importElisionEnum.js index 3f4b0e4715..cf267467aa 100644 --- a/testdata/baselines/reference/submodule/compiler/importElisionEnum.js +++ b/testdata/baselines/reference/submodule/compiler/importElisionEnum.js @@ -31,6 +31,5 @@ var MyEnum; Object.defineProperty(exports, "__esModule", { value: true }); var MyEnum; (function (MyEnum) { - MyEnum["a"] = enum_1.MyEnum.a; - if (typeof MyEnum.a !== "string") MyEnum[MyEnum.a] = "a"; + MyEnum[MyEnum["a"] = 0] = "a"; })(MyEnum || (MyEnum = {})); diff --git a/testdata/baselines/reference/submodule/compiler/importElisionEnum.js.diff b/testdata/baselines/reference/submodule/compiler/importElisionEnum.js.diff deleted file mode 100644 index 4547909657..0000000000 --- a/testdata/baselines/reference/submodule/compiler/importElisionEnum.js.diff +++ /dev/null @@ -1,10 +0,0 @@ ---- old.importElisionEnum.js -+++ new.importElisionEnum.js -@@= skipped -30, +30 lines =@@ - Object.defineProperty(exports, "__esModule", { value: true }); - var MyEnum; - (function (MyEnum) { -- MyEnum[MyEnum["a"] = 0] = "a"; -+ MyEnum["a"] = enum_1.MyEnum.a; -+ if (typeof MyEnum.a !== "string") MyEnum[MyEnum.a] = "a"; - })(MyEnum || (MyEnum = {})); \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/isolatedDeclarationErrorsEnums.js b/testdata/baselines/reference/submodule/compiler/isolatedDeclarationErrorsEnums.js index ab579cc40e..d9aa65be0d 100644 --- a/testdata/baselines/reference/submodule/compiler/isolatedDeclarationErrorsEnums.js +++ b/testdata/baselines/reference/submodule/compiler/isolatedDeclarationErrorsEnums.js @@ -52,21 +52,15 @@ enum StrExt { "use strict"; var E; (function (E) { - E["A"] = computed(0); - if (typeof E.A !== "string") E[E.A] = "A"; - E["B"] = computed(1); - if (typeof E.B !== "string") E[E.B] = "B"; - E["C"] = computed(2); - if (typeof E.C !== "string") E[E.C] = "C"; - E["D"] = computed(3); - if (typeof E.D !== "string") E[E.D] = "D"; + E[E["A"] = computed(0)] = "A"; + E[E["B"] = computed(1)] = "B"; + E[E["C"] = computed(2)] = "C"; + E[E["D"] = computed(3)] = "D"; })(E || (E = {})); var F; (function (F) { - F["A"] = E.A; - if (typeof F.A !== "string") F[F.A] = "A"; - F["B"] = F.A; - if (typeof F.B !== "string") F[F.B] = "B"; + F[F["A"] = E.A] = "A"; + F[F["B"] = F.A] = "B"; })(F || (F = {})); var Flag; (function (Flag) { @@ -81,12 +75,9 @@ const EV = 1; var ExtFlags; (function (ExtFlags) { ExtFlags[ExtFlags["D"] = 2] = "D"; - ExtFlags["E"] = EV; - if (typeof ExtFlags.E !== "string") ExtFlags[ExtFlags.E] = "E"; - ExtFlags["ABCD"] = Flag.ABC | ExtFlags.D; - if (typeof ExtFlags.ABCD !== "string") ExtFlags[ExtFlags.ABCD] = "ABCD"; - ExtFlags["AC"] = Flag["A"] | ExtFlags.D; - if (typeof ExtFlags.AC !== "string") ExtFlags[ExtFlags.AC] = "AC"; + ExtFlags[ExtFlags["E"] = 1] = "E"; + ExtFlags[ExtFlags["ABCD"] = 2] = "ABCD"; + ExtFlags[ExtFlags["AC"] = 2] = "AC"; })(ExtFlags || (ExtFlags = {})); var Str; (function (Str) { @@ -97,10 +88,8 @@ var Str; var StrExt; (function (StrExt) { StrExt["D"] = "D"; - StrExt["ABD"] = Str.AB + StrExt.D; - if (typeof StrExt.ABD !== "string") StrExt[StrExt.ABD] = "ABD"; - StrExt["AD"] = Str["A"] + StrExt.D; - if (typeof StrExt.AD !== "string") StrExt[StrExt.AD] = "AD"; + StrExt["ABD"] = "ABD"; + StrExt["AD"] = "AD"; })(StrExt || (StrExt = {})); diff --git a/testdata/baselines/reference/submodule/compiler/isolatedDeclarationErrorsEnums.js.diff b/testdata/baselines/reference/submodule/compiler/isolatedDeclarationErrorsEnums.js.diff index e9658fda0b..ddbfa0da1f 100644 --- a/testdata/baselines/reference/submodule/compiler/isolatedDeclarationErrorsEnums.js.diff +++ b/testdata/baselines/reference/submodule/compiler/isolatedDeclarationErrorsEnums.js.diff @@ -1,59 +1,8 @@ --- old.isolatedDeclarationErrorsEnums.js +++ new.isolatedDeclarationErrorsEnums.js -@@= skipped -51, +51 lines =@@ - "use strict"; - var E; - (function (E) { -- E[E["A"] = computed(0)] = "A"; -- E[E["B"] = computed(1)] = "B"; -- E[E["C"] = computed(2)] = "C"; -- E[E["D"] = computed(3)] = "D"; -+ E["A"] = computed(0); -+ if (typeof E.A !== "string") E[E.A] = "A"; -+ E["B"] = computed(1); -+ if (typeof E.B !== "string") E[E.B] = "B"; -+ E["C"] = computed(2); -+ if (typeof E.C !== "string") E[E.C] = "C"; -+ E["D"] = computed(3); -+ if (typeof E.D !== "string") E[E.D] = "D"; - })(E || (E = {})); - var F; - (function (F) { -- F[F["A"] = E.A] = "A"; -- F[F["B"] = F.A] = "B"; -+ F["A"] = E.A; -+ if (typeof F.A !== "string") F[F.A] = "A"; -+ F["B"] = F.A; -+ if (typeof F.B !== "string") F[F.B] = "B"; - })(F || (F = {})); - var Flag; - (function (Flag) { -@@= skipped -23, +29 lines =@@ - var ExtFlags; - (function (ExtFlags) { - ExtFlags[ExtFlags["D"] = 2] = "D"; -- ExtFlags[ExtFlags["E"] = 1] = "E"; -- ExtFlags[ExtFlags["ABCD"] = 2] = "ABCD"; -- ExtFlags[ExtFlags["AC"] = 2] = "AC"; -+ ExtFlags["E"] = EV; -+ if (typeof ExtFlags.E !== "string") ExtFlags[ExtFlags.E] = "E"; -+ ExtFlags["ABCD"] = Flag.ABC | ExtFlags.D; -+ if (typeof ExtFlags.ABCD !== "string") ExtFlags[ExtFlags.ABCD] = "ABCD"; -+ ExtFlags["AC"] = Flag["A"] | ExtFlags.D; -+ if (typeof ExtFlags.AC !== "string") ExtFlags[ExtFlags.AC] = "AC"; - })(ExtFlags || (ExtFlags = {})); - var Str; - (function (Str) { -@@= skipped -13, +16 lines =@@ - var StrExt; - (function (StrExt) { - StrExt["D"] = "D"; -- StrExt["ABD"] = "ABD"; -- StrExt["AD"] = "AD"; -+ StrExt["ABD"] = Str.AB + StrExt.D; -+ if (typeof StrExt.ABD !== "string") StrExt[StrExt.ABD] = "ABD"; -+ StrExt["AD"] = Str["A"] + StrExt.D; -+ if (typeof StrExt.AD !== "string") StrExt[StrExt.AD] = "AD"; +@@= skipped -90, +90 lines =@@ + StrExt["ABD"] = "ABD"; + StrExt["AD"] = "AD"; })(StrExt || (StrExt = {})); + + diff --git a/testdata/baselines/reference/submodule/compiler/isolatedModulesGlobalNamespacesAndEnums.js b/testdata/baselines/reference/submodule/compiler/isolatedModulesGlobalNamespacesAndEnums.js index 2464829b2a..fbd0a8a80e 100644 --- a/testdata/baselines/reference/submodule/compiler/isolatedModulesGlobalNamespacesAndEnums.js +++ b/testdata/baselines/reference/submodule/compiler/isolatedModulesGlobalNamespacesAndEnums.js @@ -57,12 +57,8 @@ const d = 'd'; //// [enum2.js] var Enum; (function (Enum) { - Enum["D"] = d; - if (typeof Enum.D !== "string") Enum[Enum.D] = "D"; - Enum["E"] = A; - if (typeof Enum.E !== "string") Enum[Enum.E] = "E"; - Enum["Y"] = X; - if (typeof Enum.Y !== "string") Enum[Enum.Y] = "Y"; - Enum["Z"] = Enum.A; - if (typeof Enum.Z !== "string") Enum[Enum.Z] = "Z"; + Enum["D"] = "d"; + Enum[Enum["E"] = 0] = "E"; + Enum[Enum["Y"] = 1000000] = "Y"; + Enum[Enum["Z"] = 0] = "Z"; })(Enum || (Enum = {})); diff --git a/testdata/baselines/reference/submodule/compiler/isolatedModulesGlobalNamespacesAndEnums.js.diff b/testdata/baselines/reference/submodule/compiler/isolatedModulesGlobalNamespacesAndEnums.js.diff deleted file mode 100644 index 84245da38a..0000000000 --- a/testdata/baselines/reference/submodule/compiler/isolatedModulesGlobalNamespacesAndEnums.js.diff +++ /dev/null @@ -1,19 +0,0 @@ ---- old.isolatedModulesGlobalNamespacesAndEnums.js -+++ new.isolatedModulesGlobalNamespacesAndEnums.js -@@= skipped -56, +56 lines =@@ - //// [enum2.js] - var Enum; - (function (Enum) { -- Enum["D"] = "d"; -- Enum[Enum["E"] = 0] = "E"; -- Enum[Enum["Y"] = 1000000] = "Y"; -- Enum[Enum["Z"] = 0] = "Z"; -+ Enum["D"] = d; -+ if (typeof Enum.D !== "string") Enum[Enum.D] = "D"; -+ Enum["E"] = A; -+ if (typeof Enum.E !== "string") Enum[Enum.E] = "E"; -+ Enum["Y"] = X; -+ if (typeof Enum.Y !== "string") Enum[Enum.Y] = "Y"; -+ Enum["Z"] = Enum.A; -+ if (typeof Enum.Z !== "string") Enum[Enum.Z] = "Z"; - })(Enum || (Enum = {})); \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/mergedDeclarations2.js b/testdata/baselines/reference/submodule/compiler/mergedDeclarations2.js index 3386bd6fc2..b12581beed 100644 --- a/testdata/baselines/reference/submodule/compiler/mergedDeclarations2.js +++ b/testdata/baselines/reference/submodule/compiler/mergedDeclarations2.js @@ -18,8 +18,7 @@ var Foo; Foo[Foo["b"] = 0] = "b"; })(Foo || (Foo = {})); (function (Foo) { - Foo["a"] = b; - if (typeof Foo.a !== "string") Foo[Foo.a] = "a"; + Foo[Foo["a"] = 0] = "a"; })(Foo || (Foo = {})); (function (Foo) { Foo.x = b; diff --git a/testdata/baselines/reference/submodule/compiler/mergedDeclarations2.js.diff b/testdata/baselines/reference/submodule/compiler/mergedDeclarations2.js.diff deleted file mode 100644 index 686dad40a7..0000000000 --- a/testdata/baselines/reference/submodule/compiler/mergedDeclarations2.js.diff +++ /dev/null @@ -1,12 +0,0 @@ ---- old.mergedDeclarations2.js -+++ new.mergedDeclarations2.js -@@= skipped -17, +17 lines =@@ - Foo[Foo["b"] = 0] = "b"; - })(Foo || (Foo = {})); - (function (Foo) { -- Foo[Foo["a"] = 0] = "a"; -+ Foo["a"] = b; -+ if (typeof Foo.a !== "string") Foo[Foo.a] = "a"; - })(Foo || (Foo = {})); - (function (Foo) { - Foo.x = b; \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/mergedEnumDeclarationCodeGen.js b/testdata/baselines/reference/submodule/compiler/mergedEnumDeclarationCodeGen.js index 91fe04a8b6..ba996221a7 100644 --- a/testdata/baselines/reference/submodule/compiler/mergedEnumDeclarationCodeGen.js +++ b/testdata/baselines/reference/submodule/compiler/mergedEnumDeclarationCodeGen.js @@ -16,6 +16,5 @@ var E; E[E["b"] = 0] = "b"; })(E || (E = {})); (function (E) { - E["c"] = a; - if (typeof E.c !== "string") E[E.c] = "c"; + E[E["c"] = 0] = "c"; })(E || (E = {})); diff --git a/testdata/baselines/reference/submodule/compiler/mergedEnumDeclarationCodeGen.js.diff b/testdata/baselines/reference/submodule/compiler/mergedEnumDeclarationCodeGen.js.diff deleted file mode 100644 index 5a24164b45..0000000000 --- a/testdata/baselines/reference/submodule/compiler/mergedEnumDeclarationCodeGen.js.diff +++ /dev/null @@ -1,10 +0,0 @@ ---- old.mergedEnumDeclarationCodeGen.js -+++ new.mergedEnumDeclarationCodeGen.js -@@= skipped -15, +15 lines =@@ - E[E["b"] = 0] = "b"; - })(E || (E = {})); - (function (E) { -- E[E["c"] = 0] = "c"; -+ E["c"] = a; -+ if (typeof E.c !== "string") E[E.c] = "c"; - })(E || (E = {})); \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/methodContainingLocalFunction.js b/testdata/baselines/reference/submodule/compiler/methodContainingLocalFunction.js index 9877dadbd1..cd5bd2a00a 100644 --- a/testdata/baselines/reference/submodule/compiler/methodContainingLocalFunction.js +++ b/testdata/baselines/reference/submodule/compiler/methodContainingLocalFunction.js @@ -94,11 +94,10 @@ var M; })(M || (M = {})); var E; (function (E) { - E["A"] = (() => { + E[E["A"] = (() => { function localFunction() { } var x; x = localFunction; return 0; - })(); - if (typeof E.A !== "string") E[E.A] = "A"; + })()] = "A"; })(E || (E = {})); diff --git a/testdata/baselines/reference/submodule/compiler/methodContainingLocalFunction.js.diff b/testdata/baselines/reference/submodule/compiler/methodContainingLocalFunction.js.diff deleted file mode 100644 index 5641b45f83..0000000000 --- a/testdata/baselines/reference/submodule/compiler/methodContainingLocalFunction.js.diff +++ /dev/null @@ -1,16 +0,0 @@ ---- old.methodContainingLocalFunction.js -+++ new.methodContainingLocalFunction.js -@@= skipped -93, +93 lines =@@ - })(M || (M = {})); - var E; - (function (E) { -- E[E["A"] = (() => { -+ E["A"] = (() => { - function localFunction() { } - var x; - x = localFunction; - return 0; -- })()] = "A"; -+ })(); -+ if (typeof E.A !== "string") E[E.A] = "A"; - })(E || (E = {})); \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/mixedTypeEnumComparison.js b/testdata/baselines/reference/submodule/compiler/mixedTypeEnumComparison.js index e13412ddb1..88e2261fc8 100644 --- a/testdata/baselines/reference/submodule/compiler/mixedTypeEnumComparison.js +++ b/testdata/baselines/reference/submodule/compiler/mixedTypeEnumComparison.js @@ -56,8 +56,7 @@ var E2; (function (E2) { E2["S1"] = "foo"; E2[E2["N1"] = 1000] = "N1"; - E2["C1"] = someValue(); - if (typeof E2.C1 !== "string") E2[E2.C1] = "C1"; + E2[E2["C1"] = someValue()] = "C1"; })(E2 || (E2 = {})); someString > E2.S1; someNumber > E2.N1; diff --git a/testdata/baselines/reference/submodule/compiler/mixedTypeEnumComparison.js.diff b/testdata/baselines/reference/submodule/compiler/mixedTypeEnumComparison.js.diff deleted file mode 100644 index 3cbee3f35d..0000000000 --- a/testdata/baselines/reference/submodule/compiler/mixedTypeEnumComparison.js.diff +++ /dev/null @@ -1,12 +0,0 @@ ---- old.mixedTypeEnumComparison.js -+++ new.mixedTypeEnumComparison.js -@@= skipped -55, +55 lines =@@ - (function (E2) { - E2["S1"] = "foo"; - E2[E2["N1"] = 1000] = "N1"; -- E2[E2["C1"] = someValue()] = "C1"; -+ E2["C1"] = someValue(); -+ if (typeof E2.C1 !== "string") E2[E2.C1] = "C1"; - })(E2 || (E2 = {})); - someString > E2.S1; - someNumber > E2.N1; \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/numericEnumMappedType.js b/testdata/baselines/reference/submodule/compiler/numericEnumMappedType.js index e5aaf976c2..23d43ee208 100644 --- a/testdata/baselines/reference/submodule/compiler/numericEnumMappedType.js +++ b/testdata/baselines/reference/submodule/compiler/numericEnumMappedType.js @@ -58,17 +58,13 @@ b2[1] = "a"; b2[e2] = "b"; var N1; (function (N1) { - N1["A"] = val(); - if (typeof N1.A !== "string") N1[N1.A] = "A"; - N1["B"] = val(); - if (typeof N1.B !== "string") N1[N1.B] = "B"; + N1[N1["A"] = val()] = "A"; + N1[N1["B"] = val()] = "B"; })(N1 || (N1 = {})); var N2; (function (N2) { - N2["C"] = val(); - if (typeof N2.C !== "string") N2[N2.C] = "C"; - N2["D"] = val(); - if (typeof N2.D !== "string") N2[N2.D] = "D"; + N2[N2["C"] = val()] = "C"; + N2[N2["D"] = val()] = "D"; })(N2 || (N2 = {})); const e = E.ONE; const x = e; diff --git a/testdata/baselines/reference/submodule/compiler/numericEnumMappedType.js.diff b/testdata/baselines/reference/submodule/compiler/numericEnumMappedType.js.diff deleted file mode 100644 index c1b501329b..0000000000 --- a/testdata/baselines/reference/submodule/compiler/numericEnumMappedType.js.diff +++ /dev/null @@ -1,24 +0,0 @@ ---- old.numericEnumMappedType.js -+++ new.numericEnumMappedType.js -@@= skipped -57, +57 lines =@@ - b2[e2] = "b"; - var N1; - (function (N1) { -- N1[N1["A"] = val()] = "A"; -- N1[N1["B"] = val()] = "B"; -+ N1["A"] = val(); -+ if (typeof N1.A !== "string") N1[N1.A] = "A"; -+ N1["B"] = val(); -+ if (typeof N1.B !== "string") N1[N1.B] = "B"; - })(N1 || (N1 = {})); - var N2; - (function (N2) { -- N2[N2["C"] = val()] = "C"; -- N2[N2["D"] = val()] = "D"; -+ N2["C"] = val(); -+ if (typeof N2.C !== "string") N2[N2.C] = "C"; -+ N2["D"] = val(); -+ if (typeof N2.D !== "string") N2[N2.D] = "D"; - })(N2 || (N2 = {})); - const e = E.ONE; - const x = e; \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/this_inside-enum-should-not-be-allowed.js b/testdata/baselines/reference/submodule/compiler/this_inside-enum-should-not-be-allowed.js index e9a8621ca7..14e161f6b9 100644 --- a/testdata/baselines/reference/submodule/compiler/this_inside-enum-should-not-be-allowed.js +++ b/testdata/baselines/reference/submodule/compiler/this_inside-enum-should-not-be-allowed.js @@ -14,14 +14,12 @@ module ModuleEnum { //// [this_inside-enum-should-not-be-allowed.js] var TopLevelEnum; (function (TopLevelEnum) { - TopLevelEnum["ThisWasAllowedButShouldNotBe"] = this; // Should not be allowed - if (typeof TopLevelEnum.ThisWasAllowedButShouldNotBe !== "string") TopLevelEnum[TopLevelEnum.ThisWasAllowedButShouldNotBe] = "ThisWasAllowedButShouldNotBe"; + TopLevelEnum[TopLevelEnum["ThisWasAllowedButShouldNotBe"] = this] = "ThisWasAllowedButShouldNotBe"; // Should not be allowed })(TopLevelEnum || (TopLevelEnum = {})); var ModuleEnum; (function (ModuleEnum) { let EnumInModule; (function (EnumInModule) { - EnumInModule["WasADifferentError"] = this; // this was handled as if this was in a module - if (typeof EnumInModule.WasADifferentError !== "string") EnumInModule[EnumInModule.WasADifferentError] = "WasADifferentError"; + EnumInModule[EnumInModule["WasADifferentError"] = this] = "WasADifferentError"; // this was handled as if this was in a module })(EnumInModule || (EnumInModule = {})); })(ModuleEnum || (ModuleEnum = {})); diff --git a/testdata/baselines/reference/submodule/compiler/this_inside-enum-should-not-be-allowed.js.diff b/testdata/baselines/reference/submodule/compiler/this_inside-enum-should-not-be-allowed.js.diff deleted file mode 100644 index 226edd5fe0..0000000000 --- a/testdata/baselines/reference/submodule/compiler/this_inside-enum-should-not-be-allowed.js.diff +++ /dev/null @@ -1,19 +0,0 @@ ---- old.this_inside-enum-should-not-be-allowed.js -+++ new.this_inside-enum-should-not-be-allowed.js -@@= skipped -13, +13 lines =@@ - //// [this_inside-enum-should-not-be-allowed.js] - var TopLevelEnum; - (function (TopLevelEnum) { -- TopLevelEnum[TopLevelEnum["ThisWasAllowedButShouldNotBe"] = this] = "ThisWasAllowedButShouldNotBe"; // Should not be allowed -+ TopLevelEnum["ThisWasAllowedButShouldNotBe"] = this; // Should not be allowed -+ if (typeof TopLevelEnum.ThisWasAllowedButShouldNotBe !== "string") TopLevelEnum[TopLevelEnum.ThisWasAllowedButShouldNotBe] = "ThisWasAllowedButShouldNotBe"; - })(TopLevelEnum || (TopLevelEnum = {})); - var ModuleEnum; - (function (ModuleEnum) { - let EnumInModule; - (function (EnumInModule) { -- EnumInModule[EnumInModule["WasADifferentError"] = this] = "WasADifferentError"; // this was handled as if this was in a module -+ EnumInModule["WasADifferentError"] = this; // this was handled as if this was in a module -+ if (typeof EnumInModule.WasADifferentError !== "string") EnumInModule[EnumInModule.WasADifferentError] = "WasADifferentError"; - })(EnumInModule || (EnumInModule = {})); - })(ModuleEnum || (ModuleEnum = {})); \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/arrowFunctionContexts.js b/testdata/baselines/reference/submodule/conformance/arrowFunctionContexts.js index b8ace3a6a2..aa2188fcfc 100644 --- a/testdata/baselines/reference/submodule/conformance/arrowFunctionContexts.js +++ b/testdata/baselines/reference/submodule/conformance/arrowFunctionContexts.js @@ -121,10 +121,8 @@ var arr; // Incorrect error here (bug 829597) // Arrow function as enum value var E; (function (E) { - E["x"] = () => 4; - if (typeof E.x !== "string") E[E.x] = "x"; - E["y"] = (() => this).length; // error, can't use this in enum - if (typeof E.y !== "string") E[E.y] = "y"; + E[E["x"] = () => 4] = "x"; + E[E["y"] = (() => this).length] = "y"; // error, can't use this in enum })(E || (E = {})); // Arrow function as module variable initializer var M; @@ -158,10 +156,8 @@ var M2; // Arrow function as enum value let E; (function (E) { - E["x"] = () => 4; - if (typeof E.x !== "string") E[E.x] = "x"; - E["y"] = (() => this).length; - if (typeof E.y !== "string") E[E.y] = "y"; + E[E["x"] = () => 4] = "x"; + E[E["y"] = (() => this).length] = "y"; })(E || (E = {})); // Arrow function as module variable initializer let M; diff --git a/testdata/baselines/reference/submodule/conformance/arrowFunctionContexts.js.diff b/testdata/baselines/reference/submodule/conformance/arrowFunctionContexts.js.diff deleted file mode 100644 index 71e5729310..0000000000 --- a/testdata/baselines/reference/submodule/conformance/arrowFunctionContexts.js.diff +++ /dev/null @@ -1,28 +0,0 @@ ---- old.arrowFunctionContexts.js -+++ new.arrowFunctionContexts.js -@@= skipped -120, +120 lines =@@ - // Arrow function as enum value - var E; - (function (E) { -- E[E["x"] = () => 4] = "x"; -- E[E["y"] = (() => this).length] = "y"; // error, can't use this in enum -+ E["x"] = () => 4; -+ if (typeof E.x !== "string") E[E.x] = "x"; -+ E["y"] = (() => this).length; // error, can't use this in enum -+ if (typeof E.y !== "string") E[E.y] = "y"; - })(E || (E = {})); - // Arrow function as module variable initializer - var M; -@@= skipped -35, +37 lines =@@ - // Arrow function as enum value - let E; - (function (E) { -- E[E["x"] = () => 4] = "x"; -- E[E["y"] = (() => this).length] = "y"; -+ E["x"] = () => 4; -+ if (typeof E.x !== "string") E[E.x] = "x"; -+ E["y"] = (() => this).length; -+ if (typeof E.y !== "string") E[E.y] = "y"; - })(E || (E = {})); - // Arrow function as module variable initializer - let M; \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/awaitAndYield.js b/testdata/baselines/reference/submodule/conformance/awaitAndYield.js index 1f68efdfd0..2c21d0a7ff 100644 --- a/testdata/baselines/reference/submodule/conformance/awaitAndYield.js +++ b/testdata/baselines/reference/submodule/conformance/awaitAndYield.js @@ -12,9 +12,7 @@ async function* test(x: Promise) { async function* test(x) { let E; (function (E) { - E["foo"] = await x; - if (typeof E.foo !== "string") E[E.foo] = "foo"; - E["baz"] = (yield 1); - if (typeof E.baz !== "string") E[E.baz] = "baz"; + E[E["foo"] = await x] = "foo"; + E[E["baz"] = (yield 1)] = "baz"; })(E || (E = {})); } diff --git a/testdata/baselines/reference/submodule/conformance/awaitAndYield.js.diff b/testdata/baselines/reference/submodule/conformance/awaitAndYield.js.diff index 4d2171274e..aebe0f1b35 100644 --- a/testdata/baselines/reference/submodule/conformance/awaitAndYield.js.diff +++ b/testdata/baselines/reference/submodule/conformance/awaitAndYield.js.diff @@ -1,14 +1,10 @@ --- old.awaitAndYield.js +++ new.awaitAndYield.js -@@= skipped -11, +11 lines =@@ - async function* test(x) { +@@= skipped -12, +12 lines =@@ let E; (function (E) { -- E[E["foo"] = await x] = "foo"; + E[E["foo"] = await x] = "foo"; - E[E["baz"] = yield 1] = "baz"; -+ E["foo"] = await x; -+ if (typeof E.foo !== "string") E[E.foo] = "foo"; -+ E["baz"] = (yield 1); -+ if (typeof E.baz !== "string") E[E.baz] = "baz"; ++ E[E["baz"] = (yield 1)] = "baz"; })(E || (E = {})); } \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/disallowLineTerminatorBeforeArrow.js b/testdata/baselines/reference/submodule/conformance/disallowLineTerminatorBeforeArrow.js index 3bfb0e8265..dfca58f723 100644 --- a/testdata/baselines/reference/submodule/conformance/disallowLineTerminatorBeforeArrow.js +++ b/testdata/baselines/reference/submodule/conformance/disallowLineTerminatorBeforeArrow.js @@ -113,8 +113,7 @@ var m; } let Enum; (function (Enum) { - Enum["claw"] = (() => 10)(); - if (typeof Enum.claw !== "string") Enum[Enum.claw] = "claw"; + Enum[Enum["claw"] = (() => 10)()] = "claw"; })(Enum = m.Enum || (m.Enum = {})); m.v = x => new City(Enum.claw); })(m || (m = {})); diff --git a/testdata/baselines/reference/submodule/conformance/disallowLineTerminatorBeforeArrow.js.diff b/testdata/baselines/reference/submodule/conformance/disallowLineTerminatorBeforeArrow.js.diff index eac617052f..2d5775837d 100644 --- a/testdata/baselines/reference/submodule/conformance/disallowLineTerminatorBeforeArrow.js.diff +++ b/testdata/baselines/reference/submodule/conformance/disallowLineTerminatorBeforeArrow.js.diff @@ -9,10 +9,4 @@ + m = () => 2 * 2 * 2; } let Enum; - (function (Enum) { -- Enum[Enum["claw"] = (() => 10)()] = "claw"; -+ Enum["claw"] = (() => 10)(); -+ if (typeof Enum.claw !== "string") Enum[Enum.claw] = "claw"; - })(Enum = m.Enum || (m.Enum = {})); - m.v = x => new City(Enum.claw); - })(m || (m = {})); \ No newline at end of file + (function (Enum) { \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/enumBasics.js b/testdata/baselines/reference/submodule/conformance/enumBasics.js index 3610eff94f..b1b0ba8a41 100644 --- a/testdata/baselines/reference/submodule/conformance/enumBasics.js +++ b/testdata/baselines/reference/submodule/conformance/enumBasics.js @@ -109,19 +109,16 @@ var E2; // Enum with only computed members var E3; (function (E3) { - E3["X"] = 'foo'.length; - if (typeof E3.X !== "string") E3[E3.X] = "X"; + E3[E3["X"] = 'foo'.length] = "X"; E3[E3["Y"] = 7] = "Y"; - E3["Z"] = +'foo'; - if (typeof E3.Z !== "string") E3[E3.Z] = "Z"; + E3[E3["Z"] = +'foo'] = "Z"; })(E3 || (E3 = {})); // Enum with constant members followed by computed members var E4; (function (E4) { E4[E4["X"] = 0] = "X"; E4[E4["Y"] = 1] = "Y"; - E4["Z"] = 'foo'.length; - if (typeof E4.Z !== "string") E4[E4.Z] = "Z"; + E4[E4["Z"] = 'foo'.length] = "Z"; })(E4 || (E4 = {})); // Enum with > 2 constant members with no initializer for first member, non zero initializer for second element var E5; @@ -139,14 +136,12 @@ var E6; // Enum with computed member initializer of type 'any' var E7; (function (E7) { - E7["A"] = 'foo'['foo']; - if (typeof E7.A !== "string") E7[E7.A] = "A"; + E7[E7["A"] = 'foo'['foo']] = "A"; })(E7 || (E7 = {})); // Enum with computed member initializer of type number var E8; (function (E8) { - E8["B"] = 'foo'['foo']; - if (typeof E8.B !== "string") E8[E8.B] = "B"; + E8[E8["B"] = 'foo'['foo']] = "B"; })(E8 || (E8 = {})); //Enum with computed member intializer of same enum type var E9; diff --git a/testdata/baselines/reference/submodule/conformance/enumBasics.js.diff b/testdata/baselines/reference/submodule/conformance/enumBasics.js.diff deleted file mode 100644 index bc8b9b78d4..0000000000 --- a/testdata/baselines/reference/submodule/conformance/enumBasics.js.diff +++ /dev/null @@ -1,42 +0,0 @@ ---- old.enumBasics.js -+++ new.enumBasics.js -@@= skipped -108, +108 lines =@@ - // Enum with only computed members - var E3; - (function (E3) { -- E3[E3["X"] = 'foo'.length] = "X"; -+ E3["X"] = 'foo'.length; -+ if (typeof E3.X !== "string") E3[E3.X] = "X"; - E3[E3["Y"] = 7] = "Y"; -- E3[E3["Z"] = +'foo'] = "Z"; -+ E3["Z"] = +'foo'; -+ if (typeof E3.Z !== "string") E3[E3.Z] = "Z"; - })(E3 || (E3 = {})); - // Enum with constant members followed by computed members - var E4; - (function (E4) { - E4[E4["X"] = 0] = "X"; - E4[E4["Y"] = 1] = "Y"; -- E4[E4["Z"] = 'foo'.length] = "Z"; -+ E4["Z"] = 'foo'.length; -+ if (typeof E4.Z !== "string") E4[E4.Z] = "Z"; - })(E4 || (E4 = {})); - // Enum with > 2 constant members with no initializer for first member, non zero initializer for second element - var E5; -@@= skipped -27, +30 lines =@@ - // Enum with computed member initializer of type 'any' - var E7; - (function (E7) { -- E7[E7["A"] = 'foo'['foo']] = "A"; -+ E7["A"] = 'foo'['foo']; -+ if (typeof E7.A !== "string") E7[E7.A] = "A"; - })(E7 || (E7 = {})); - // Enum with computed member initializer of type number - var E8; - (function (E8) { -- E8[E8["B"] = 'foo'['foo']] = "B"; -+ E8["B"] = 'foo'['foo']; -+ if (typeof E8.B !== "string") E8[E8.B] = "B"; - })(E8 || (E8 = {})); - //Enum with computed member intializer of same enum type - var E9; \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/enumClassification.js b/testdata/baselines/reference/submodule/conformance/enumClassification.js index 714b52d02c..bbf165352e 100644 --- a/testdata/baselines/reference/submodule/conformance/enumClassification.js +++ b/testdata/baselines/reference/submodule/conformance/enumClassification.js @@ -153,14 +153,10 @@ var E12; // Examples of numeric enum types with constant and computed members var E20; (function (E20) { - E20["A"] = "foo".length; - if (typeof E20.A !== "string") E20[E20.A] = "A"; - E20["B"] = E20.A + 1; - if (typeof E20.B !== "string") E20[E20.B] = "B"; - E20["C"] = +"123"; - if (typeof E20.C !== "string") E20[E20.C] = "C"; - E20["D"] = Math.sin(1); - if (typeof E20.D !== "string") E20[E20.D] = "D"; + E20[E20["A"] = "foo".length] = "A"; + E20[E20["B"] = E20.A + 1] = "B"; + E20[E20["C"] = +"123"] = "C"; + E20[E20["D"] = Math.sin(1)] = "D"; })(E20 || (E20 = {})); diff --git a/testdata/baselines/reference/submodule/conformance/enumClassification.js.diff b/testdata/baselines/reference/submodule/conformance/enumClassification.js.diff deleted file mode 100644 index 89469d82a7..0000000000 --- a/testdata/baselines/reference/submodule/conformance/enumClassification.js.diff +++ /dev/null @@ -1,20 +0,0 @@ ---- old.enumClassification.js -+++ new.enumClassification.js -@@= skipped -152, +152 lines =@@ - // Examples of numeric enum types with constant and computed members - var E20; - (function (E20) { -- E20[E20["A"] = "foo".length] = "A"; -- E20[E20["B"] = E20.A + 1] = "B"; -- E20[E20["C"] = +"123"] = "C"; -- E20[E20["D"] = Math.sin(1)] = "D"; -+ E20["A"] = "foo".length; -+ if (typeof E20.A !== "string") E20[E20.A] = "A"; -+ E20["B"] = E20.A + 1; -+ if (typeof E20.B !== "string") E20[E20.B] = "B"; -+ E20["C"] = +"123"; -+ if (typeof E20.C !== "string") E20[E20.C] = "C"; -+ E20["D"] = Math.sin(1); -+ if (typeof E20.D !== "string") E20[E20.D] = "D"; - })(E20 || (E20 = {})); - diff --git a/testdata/baselines/reference/submodule/conformance/enumConstantMemberWithString.js b/testdata/baselines/reference/submodule/conformance/enumConstantMemberWithString.js index 8142bdb704..693dbf90e5 100644 --- a/testdata/baselines/reference/submodule/conformance/enumConstantMemberWithString.js +++ b/testdata/baselines/reference/submodule/conformance/enumConstantMemberWithString.js @@ -41,8 +41,7 @@ var T1; T1["a"] = "1"; T1["b"] = "12"; T1["c"] = "123"; - T1["d"] = "a" - "a"; - if (typeof T1.d !== "string") T1[T1.d] = "d"; + T1[T1["d"] = "a" - "a"] = "d"; T1["e"] = "a1"; })(T1 || (T1 = {})); var T2; diff --git a/testdata/baselines/reference/submodule/conformance/enumConstantMemberWithString.js.diff b/testdata/baselines/reference/submodule/conformance/enumConstantMemberWithString.js.diff deleted file mode 100644 index 8948ff0845..0000000000 --- a/testdata/baselines/reference/submodule/conformance/enumConstantMemberWithString.js.diff +++ /dev/null @@ -1,12 +0,0 @@ ---- old.enumConstantMemberWithString.js -+++ new.enumConstantMemberWithString.js -@@= skipped -40, +40 lines =@@ - T1["a"] = "1"; - T1["b"] = "12"; - T1["c"] = "123"; -- T1[T1["d"] = "a" - "a"] = "d"; -+ T1["d"] = "a" - "a"; -+ if (typeof T1.d !== "string") T1[T1.d] = "d"; - T1["e"] = "a1"; - })(T1 || (T1 = {})); - var T2; \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/enumConstantMemberWithTemplateLiterals.js b/testdata/baselines/reference/submodule/conformance/enumConstantMemberWithTemplateLiterals.js index 8f72e63b8c..22256736ce 100644 --- a/testdata/baselines/reference/submodule/conformance/enumConstantMemberWithTemplateLiterals.js +++ b/testdata/baselines/reference/submodule/conformance/enumConstantMemberWithTemplateLiterals.js @@ -75,16 +75,13 @@ var T5; T5["b"] = "12"; T5["c"] = "123"; T5[T5["d"] = 1] = "d"; - T5["e"] = `1` - `1`; - if (typeof T5.e !== "string") T5[T5.e] = "e"; + T5[T5["e"] = `1` - `1`] = "e"; T5["f"] = "11"; T5["g"] = "123"; - T5["h"] = `1`.length; - if (typeof T5.h !== "string") T5[T5.h] = "h"; + T5[T5["h"] = `1`.length] = "h"; })(T5 || (T5 = {})); var T6; (function (T6) { T6[T6["a"] = 1] = "a"; - T6["b"] = `12`.length; - if (typeof T6.b !== "string") T6[T6.b] = "b"; + T6[T6["b"] = `12`.length] = "b"; })(T6 || (T6 = {})); diff --git a/testdata/baselines/reference/submodule/conformance/enumConstantMemberWithTemplateLiterals.js.diff b/testdata/baselines/reference/submodule/conformance/enumConstantMemberWithTemplateLiterals.js.diff deleted file mode 100644 index 4e56fa2875..0000000000 --- a/testdata/baselines/reference/submodule/conformance/enumConstantMemberWithTemplateLiterals.js.diff +++ /dev/null @@ -1,22 +0,0 @@ ---- old.enumConstantMemberWithTemplateLiterals.js -+++ new.enumConstantMemberWithTemplateLiterals.js -@@= skipped -74, +74 lines =@@ - T5["b"] = "12"; - T5["c"] = "123"; - T5[T5["d"] = 1] = "d"; -- T5[T5["e"] = `1` - `1`] = "e"; -+ T5["e"] = `1` - `1`; -+ if (typeof T5.e !== "string") T5[T5.e] = "e"; - T5["f"] = "11"; - T5["g"] = "123"; -- T5[T5["h"] = `1`.length] = "h"; -+ T5["h"] = `1`.length; -+ if (typeof T5.h !== "string") T5[T5.h] = "h"; - })(T5 || (T5 = {})); - var T6; - (function (T6) { - T6[T6["a"] = 1] = "a"; -- T6[T6["b"] = `12`.length] = "b"; -+ T6["b"] = `12`.length; -+ if (typeof T6.b !== "string") T6[T6.b] = "b"; - })(T6 || (T6 = {})); \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/enumConstantMemberWithTemplateLiteralsEmitDeclaration.js b/testdata/baselines/reference/submodule/conformance/enumConstantMemberWithTemplateLiteralsEmitDeclaration.js index cae48ede73..d6a418ba9a 100644 --- a/testdata/baselines/reference/submodule/conformance/enumConstantMemberWithTemplateLiteralsEmitDeclaration.js +++ b/testdata/baselines/reference/submodule/conformance/enumConstantMemberWithTemplateLiteralsEmitDeclaration.js @@ -75,8 +75,7 @@ var T5; var T6; (function (T6) { T6[T6["a"] = 1] = "a"; - T6["b"] = `12`.length; - if (typeof T6.b !== "string") T6[T6.b] = "b"; + T6[T6["b"] = `12`.length] = "b"; })(T6 || (T6 = {})); diff --git a/testdata/baselines/reference/submodule/conformance/enumConstantMemberWithTemplateLiteralsEmitDeclaration.js.diff b/testdata/baselines/reference/submodule/conformance/enumConstantMemberWithTemplateLiteralsEmitDeclaration.js.diff deleted file mode 100644 index f3c004a4c5..0000000000 --- a/testdata/baselines/reference/submodule/conformance/enumConstantMemberWithTemplateLiteralsEmitDeclaration.js.diff +++ /dev/null @@ -1,11 +0,0 @@ ---- old.enumConstantMemberWithTemplateLiteralsEmitDeclaration.js -+++ new.enumConstantMemberWithTemplateLiteralsEmitDeclaration.js -@@= skipped -74, +74 lines =@@ - var T6; - (function (T6) { - T6[T6["a"] = 1] = "a"; -- T6[T6["b"] = `12`.length] = "b"; -+ T6["b"] = `12`.length; -+ if (typeof T6.b !== "string") T6[T6.b] = "b"; - })(T6 || (T6 = {})); - diff --git a/testdata/baselines/reference/submodule/conformance/enumConstantMembers.js b/testdata/baselines/reference/submodule/conformance/enumConstantMembers.js index 6247b6f700..ef5f63f3ff 100644 --- a/testdata/baselines/reference/submodule/conformance/enumConstantMembers.js +++ b/testdata/baselines/reference/submodule/conformance/enumConstantMembers.js @@ -61,14 +61,11 @@ var E3; })(E3 || (E3 = {})); var E5; (function (E5) { - E5[E5["a"] = 1 / 0] = "a"; - E5[E5["b"] = 2 / 0.0] = "b"; - E5[E5["c"] = 1.0 / 0.0] = "c"; - E5[E5["d"] = 0.0 / 0.0] = "d"; - E5["e"] = NaN; - if (typeof E5.e !== "string") E5[E5.e] = "e"; - E5["f"] = Infinity; - if (typeof E5.f !== "string") E5[E5.f] = "f"; - E5["g"] = -Infinity; - if (typeof E5.g !== "string") E5[E5.g] = "g"; + E5[E5["a"] = Infinity] = "a"; + E5[E5["b"] = Infinity] = "b"; + E5[E5["c"] = Infinity] = "c"; + E5[E5["d"] = -NaN] = "d"; + E5[E5["e"] = -NaN] = "e"; + E5[E5["f"] = Infinity] = "f"; + E5[E5["g"] = -Infinity] = "g"; })(E5 || (E5 = {})); diff --git a/testdata/baselines/reference/submodule/conformance/enumConstantMembers.js.diff b/testdata/baselines/reference/submodule/conformance/enumConstantMembers.js.diff index 508b9d2c7f..262b38e19d 100644 --- a/testdata/baselines/reference/submodule/conformance/enumConstantMembers.js.diff +++ b/testdata/baselines/reference/submodule/conformance/enumConstantMembers.js.diff @@ -1,24 +1,13 @@ --- old.enumConstantMembers.js +++ new.enumConstantMembers.js -@@= skipped -60, +60 lines =@@ - })(E3 || (E3 = {})); - var E5; - (function (E5) { -- E5[E5["a"] = Infinity] = "a"; -- E5[E5["b"] = Infinity] = "b"; -- E5[E5["c"] = Infinity] = "c"; +@@= skipped -63, +63 lines =@@ + E5[E5["a"] = Infinity] = "a"; + E5[E5["b"] = Infinity] = "b"; + E5[E5["c"] = Infinity] = "c"; - E5[E5["d"] = NaN] = "d"; - E5[E5["e"] = NaN] = "e"; -- E5[E5["f"] = Infinity] = "f"; -- E5[E5["g"] = -Infinity] = "g"; -+ E5[E5["a"] = 1 / 0] = "a"; -+ E5[E5["b"] = 2 / 0.0] = "b"; -+ E5[E5["c"] = 1.0 / 0.0] = "c"; -+ E5[E5["d"] = 0.0 / 0.0] = "d"; -+ E5["e"] = NaN; -+ if (typeof E5.e !== "string") E5[E5.e] = "e"; -+ E5["f"] = Infinity; -+ if (typeof E5.f !== "string") E5[E5.f] = "f"; -+ E5["g"] = -Infinity; -+ if (typeof E5.g !== "string") E5[E5.g] = "g"; ++ E5[E5["d"] = -NaN] = "d"; ++ E5[E5["e"] = -NaN] = "e"; + E5[E5["f"] = Infinity] = "f"; + E5[E5["g"] = -Infinity] = "g"; })(E5 || (E5 = {})); \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/enumErrorOnConstantBindingWithInitializer.js b/testdata/baselines/reference/submodule/conformance/enumErrorOnConstantBindingWithInitializer.js index f4f4c0052a..5b7add3961 100644 --- a/testdata/baselines/reference/submodule/conformance/enumErrorOnConstantBindingWithInitializer.js +++ b/testdata/baselines/reference/submodule/conformance/enumErrorOnConstantBindingWithInitializer.js @@ -18,6 +18,5 @@ enum E { const { value = "123" } = thing; var E; (function (E) { - E["test"] = value; - if (typeof E.test !== "string") E[E.test] = "test"; + E[E["test"] = value] = "test"; })(E || (E = {})); diff --git a/testdata/baselines/reference/submodule/conformance/enumErrorOnConstantBindingWithInitializer.js.diff b/testdata/baselines/reference/submodule/conformance/enumErrorOnConstantBindingWithInitializer.js.diff deleted file mode 100644 index e7d127b21f..0000000000 --- a/testdata/baselines/reference/submodule/conformance/enumErrorOnConstantBindingWithInitializer.js.diff +++ /dev/null @@ -1,10 +0,0 @@ ---- old.enumErrorOnConstantBindingWithInitializer.js -+++ new.enumErrorOnConstantBindingWithInitializer.js -@@= skipped -17, +17 lines =@@ - const { value = "123" } = thing; - var E; - (function (E) { -- E[E["test"] = value] = "test"; -+ E["test"] = value; -+ if (typeof E.test !== "string") E[E.test] = "test"; - })(E || (E = {})); \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/enumErrors.js b/testdata/baselines/reference/submodule/conformance/enumErrors.js index 251ec2a11b..68aede3f50 100644 --- a/testdata/baselines/reference/submodule/conformance/enumErrors.js +++ b/testdata/baselines/reference/submodule/conformance/enumErrors.js @@ -73,8 +73,7 @@ var boolean; // Enum with computed member initializer of type Number var E5; (function (E5) { - E5["C"] = new Number(30); - if (typeof E5.C !== "string") E5[E5.C] = "C"; + E5[E5["C"] = new Number(30)] = "C"; })(E5 || (E5 = {})); var E9; (function (E9) { @@ -85,38 +84,27 @@ var E9; // Bug 707850: This should be allowed var E10; (function (E10) { - E10["A"] = E9.A; - if (typeof E10.A !== "string") E10[E10.A] = "A"; - E10["B"] = E9.B; - if (typeof E10.B !== "string") E10[E10.B] = "B"; + E10[E10["A"] = 0] = "A"; + E10[E10["B"] = 0] = "B"; })(E10 || (E10 = {})); // Enum with computed member intializer of other types var E11; (function (E11) { - E11["A"] = true; - if (typeof E11.A !== "string") E11[E11.A] = "A"; - E11["B"] = new Date(); - if (typeof E11.B !== "string") E11[E11.B] = "B"; - E11["C"] = window; - if (typeof E11.C !== "string") E11[E11.C] = "C"; - E11["D"] = {}; - if (typeof E11.D !== "string") E11[E11.D] = "D"; - E11["E"] = (() => 'foo')(); - if (typeof E11.E !== "string") E11[E11.E] = "E"; + E11[E11["A"] = true] = "A"; + E11[E11["B"] = new Date()] = "B"; + E11[E11["C"] = window] = "C"; + E11[E11["D"] = {}] = "D"; + E11[E11["E"] = (() => 'foo')()] = "E"; })(E11 || (E11 = {})); // Enum with string valued member and computed member initializers var E12; (function (E12) { E12["A"] = ""; - E12["B"] = new Date(); - if (typeof E12.B !== "string") E12[E12.B] = "B"; - E12["C"] = window; - if (typeof E12.C !== "string") E12[E12.C] = "C"; - E12["D"] = {}; - if (typeof E12.D !== "string") E12[E12.D] = "D"; + E12[E12["B"] = new Date()] = "B"; + E12[E12["C"] = window] = "C"; + E12[E12["D"] = {}] = "D"; E12[E12["E"] = 2] = "E"; - E12["F"] = (() => 'foo')(); - if (typeof E12.F !== "string") E12[E12.F] = "F"; + E12[E12["F"] = (() => 'foo')()] = "F"; })(E12 || (E12 = {})); // Enum with incorrect syntax var E13; diff --git a/testdata/baselines/reference/submodule/conformance/enumErrors.js.diff b/testdata/baselines/reference/submodule/conformance/enumErrors.js.diff deleted file mode 100644 index 08d7c27fe1..0000000000 --- a/testdata/baselines/reference/submodule/conformance/enumErrors.js.diff +++ /dev/null @@ -1,62 +0,0 @@ ---- old.enumErrors.js -+++ new.enumErrors.js -@@= skipped -72, +72 lines =@@ - // Enum with computed member initializer of type Number - var E5; - (function (E5) { -- E5[E5["C"] = new Number(30)] = "C"; -+ E5["C"] = new Number(30); -+ if (typeof E5.C !== "string") E5[E5.C] = "C"; - })(E5 || (E5 = {})); - var E9; - (function (E9) { -@@= skipped -11, +12 lines =@@ - // Bug 707850: This should be allowed - var E10; - (function (E10) { -- E10[E10["A"] = 0] = "A"; -- E10[E10["B"] = 0] = "B"; -+ E10["A"] = E9.A; -+ if (typeof E10.A !== "string") E10[E10.A] = "A"; -+ E10["B"] = E9.B; -+ if (typeof E10.B !== "string") E10[E10.B] = "B"; - })(E10 || (E10 = {})); - // Enum with computed member intializer of other types - var E11; - (function (E11) { -- E11[E11["A"] = true] = "A"; -- E11[E11["B"] = new Date()] = "B"; -- E11[E11["C"] = window] = "C"; -- E11[E11["D"] = {}] = "D"; -- E11[E11["E"] = (() => 'foo')()] = "E"; -+ E11["A"] = true; -+ if (typeof E11.A !== "string") E11[E11.A] = "A"; -+ E11["B"] = new Date(); -+ if (typeof E11.B !== "string") E11[E11.B] = "B"; -+ E11["C"] = window; -+ if (typeof E11.C !== "string") E11[E11.C] = "C"; -+ E11["D"] = {}; -+ if (typeof E11.D !== "string") E11[E11.D] = "D"; -+ E11["E"] = (() => 'foo')(); -+ if (typeof E11.E !== "string") E11[E11.E] = "E"; - })(E11 || (E11 = {})); - // Enum with string valued member and computed member initializers - var E12; - (function (E12) { - E12["A"] = ""; -- E12[E12["B"] = new Date()] = "B"; -- E12[E12["C"] = window] = "C"; -- E12[E12["D"] = {}] = "D"; -+ E12["B"] = new Date(); -+ if (typeof E12.B !== "string") E12[E12.B] = "B"; -+ E12["C"] = window; -+ if (typeof E12.C !== "string") E12[E12.C] = "C"; -+ E12["D"] = {}; -+ if (typeof E12.D !== "string") E12[E12.D] = "D"; - E12[E12["E"] = 2] = "E"; -- E12[E12["F"] = (() => 'foo')()] = "F"; -+ E12["F"] = (() => 'foo')(); -+ if (typeof E12.F !== "string") E12[E12.F] = "F"; - })(E12 || (E12 = {})); - // Enum with incorrect syntax - var E13; \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/enumExportMergingES6.js b/testdata/baselines/reference/submodule/conformance/enumExportMergingES6.js index 5252b1ddae..62b8f547ae 100644 --- a/testdata/baselines/reference/submodule/conformance/enumExportMergingES6.js +++ b/testdata/baselines/reference/submodule/conformance/enumExportMergingES6.js @@ -22,6 +22,5 @@ var Animals; Animals[Animals["Dog"] = 2] = "Dog"; })(Animals || (Animals = {})); (function (Animals) { - Animals["CatDog"] = Cat | Dog; - if (typeof Animals.CatDog !== "string") Animals[Animals.CatDog] = "CatDog"; + Animals[Animals["CatDog"] = 3] = "CatDog"; })(Animals || (Animals = {})); diff --git a/testdata/baselines/reference/submodule/conformance/enumExportMergingES6.js.diff b/testdata/baselines/reference/submodule/conformance/enumExportMergingES6.js.diff index 8a659dfe7c..00d240b188 100644 --- a/testdata/baselines/reference/submodule/conformance/enumExportMergingES6.js.diff +++ b/testdata/baselines/reference/submodule/conformance/enumExportMergingES6.js.diff @@ -9,12 +9,4 @@ +var Animals; (function (Animals) { Animals[Animals["Cat"] = 1] = "Cat"; - })(Animals || (Animals = {})); -@@= skipped -8, +9 lines =@@ - Animals[Animals["Dog"] = 2] = "Dog"; - })(Animals || (Animals = {})); - (function (Animals) { -- Animals[Animals["CatDog"] = 3] = "CatDog"; -+ Animals["CatDog"] = Cat | Dog; -+ if (typeof Animals.CatDog !== "string") Animals[Animals.CatDog] = "CatDog"; })(Animals || (Animals = {})); \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/enumMerging.js b/testdata/baselines/reference/submodule/conformance/enumMerging.js index b959206a56..99aea08e8c 100644 --- a/testdata/baselines/reference/submodule/conformance/enumMerging.js +++ b/testdata/baselines/reference/submodule/conformance/enumMerging.js @@ -102,20 +102,14 @@ var M2; (function (M2) { let EComp2; (function (EComp2) { - EComp2["A"] = 'foo'.length; - if (typeof EComp2.A !== "string") EComp2[EComp2.A] = "A"; - EComp2["B"] = 'foo'.length; - if (typeof EComp2.B !== "string") EComp2[EComp2.B] = "B"; - EComp2["C"] = 'foo'.length; - if (typeof EComp2.C !== "string") EComp2[EComp2.C] = "C"; + EComp2[EComp2["A"] = 'foo'.length] = "A"; + EComp2[EComp2["B"] = 'foo'.length] = "B"; + EComp2[EComp2["C"] = 'foo'.length] = "C"; })(EComp2 = M2.EComp2 || (M2.EComp2 = {})); (function (EComp2) { - EComp2["D"] = 'foo'.length; - if (typeof EComp2.D !== "string") EComp2[EComp2.D] = "D"; - EComp2["E"] = 'foo'.length; - if (typeof EComp2.E !== "string") EComp2[EComp2.E] = "E"; - EComp2["F"] = 'foo'.length; - if (typeof EComp2.F !== "string") EComp2[EComp2.F] = "F"; + EComp2[EComp2["D"] = 'foo'.length] = "D"; + EComp2[EComp2["E"] = 'foo'.length] = "E"; + EComp2[EComp2["F"] = 'foo'.length] = "F"; })(EComp2 = M2.EComp2 || (M2.EComp2 = {})); var x = [EComp2.A, EComp2.B, EComp2.C, EComp2.D, EComp2.E, EComp2.F]; })(M2 || (M2 = {})); diff --git a/testdata/baselines/reference/submodule/conformance/enumMerging.js.diff b/testdata/baselines/reference/submodule/conformance/enumMerging.js.diff index 7420e13a7e..6c53842105 100644 --- a/testdata/baselines/reference/submodule/conformance/enumMerging.js.diff +++ b/testdata/baselines/reference/submodule/conformance/enumMerging.js.diff @@ -1,33 +1,6 @@ --- old.enumMerging.js +++ new.enumMerging.js -@@= skipped -101, +101 lines =@@ - (function (M2) { - let EComp2; - (function (EComp2) { -- EComp2[EComp2["A"] = 'foo'.length] = "A"; -- EComp2[EComp2["B"] = 'foo'.length] = "B"; -- EComp2[EComp2["C"] = 'foo'.length] = "C"; -+ EComp2["A"] = 'foo'.length; -+ if (typeof EComp2.A !== "string") EComp2[EComp2.A] = "A"; -+ EComp2["B"] = 'foo'.length; -+ if (typeof EComp2.B !== "string") EComp2[EComp2.B] = "B"; -+ EComp2["C"] = 'foo'.length; -+ if (typeof EComp2.C !== "string") EComp2[EComp2.C] = "C"; - })(EComp2 = M2.EComp2 || (M2.EComp2 = {})); - (function (EComp2) { -- EComp2[EComp2["D"] = 'foo'.length] = "D"; -- EComp2[EComp2["E"] = 'foo'.length] = "E"; -- EComp2[EComp2["F"] = 'foo'.length] = "F"; -+ EComp2["D"] = 'foo'.length; -+ if (typeof EComp2.D !== "string") EComp2[EComp2.D] = "D"; -+ EComp2["E"] = 'foo'.length; -+ if (typeof EComp2.E !== "string") EComp2[EComp2.E] = "E"; -+ EComp2["F"] = 'foo'.length; -+ if (typeof EComp2.F !== "string") EComp2[EComp2.F] = "F"; - })(EComp2 = M2.EComp2 || (M2.EComp2 = {})); - var x = [EComp2.A, EComp2.B, EComp2.C, EComp2.D, EComp2.E, EComp2.F]; - })(M2 || (M2 = {})); -@@= skipped -46, +52 lines =@@ +@@= skipped -147, +147 lines =@@ })(M5 || (M5 = {})); var M6; (function (M6) { diff --git a/testdata/baselines/reference/submodule/conformance/enumMergingErrors.js b/testdata/baselines/reference/submodule/conformance/enumMergingErrors.js index 5224e3914f..6bd3b30cee 100644 --- a/testdata/baselines/reference/submodule/conformance/enumMergingErrors.js +++ b/testdata/baselines/reference/submodule/conformance/enumMergingErrors.js @@ -64,13 +64,11 @@ var M; (function (M) { let E1; (function (E1) { - E1["B"] = 'foo'.length; - if (typeof E1.B !== "string") E1[E1.B] = "B"; + E1[E1["B"] = 'foo'.length] = "B"; })(E1 = M.E1 || (M.E1 = {})); let E2; (function (E2) { - E2["B"] = 'foo'.length; - if (typeof E2.B !== "string") E2[E2.B] = "B"; + E2[E2["B"] = 'foo'.length] = "B"; })(E2 = M.E2 || (M.E2 = {})); let E3; (function (E3) { @@ -88,8 +86,7 @@ var M; })(E2 = M.E2 || (M.E2 = {})); let E3; (function (E3) { - E3["B"] = 'foo'.length; - if (typeof E3.B !== "string") E3[E3.B] = "B"; + E3[E3["B"] = 'foo'.length] = "B"; })(E3 = M.E3 || (M.E3 = {})); })(M || (M = {})); // Enum with no initializer in either declaration with constant members with the same root module diff --git a/testdata/baselines/reference/submodule/conformance/enumMergingErrors.js.diff b/testdata/baselines/reference/submodule/conformance/enumMergingErrors.js.diff deleted file mode 100644 index b22fe43a6b..0000000000 --- a/testdata/baselines/reference/submodule/conformance/enumMergingErrors.js.diff +++ /dev/null @@ -1,28 +0,0 @@ ---- old.enumMergingErrors.js -+++ new.enumMergingErrors.js -@@= skipped -63, +63 lines =@@ - (function (M) { - let E1; - (function (E1) { -- E1[E1["B"] = 'foo'.length] = "B"; -+ E1["B"] = 'foo'.length; -+ if (typeof E1.B !== "string") E1[E1.B] = "B"; - })(E1 = M.E1 || (M.E1 = {})); - let E2; - (function (E2) { -- E2[E2["B"] = 'foo'.length] = "B"; -+ E2["B"] = 'foo'.length; -+ if (typeof E2.B !== "string") E2[E2.B] = "B"; - })(E2 = M.E2 || (M.E2 = {})); - let E3; - (function (E3) { -@@= skipped -22, +24 lines =@@ - })(E2 = M.E2 || (M.E2 = {})); - let E3; - (function (E3) { -- E3[E3["B"] = 'foo'.length] = "B"; -+ E3["B"] = 'foo'.length; -+ if (typeof E3.B !== "string") E3[E3.B] = "B"; - })(E3 = M.E3 || (M.E3 = {})); - })(M || (M = {})); - // Enum with no initializer in either declaration with constant members with the same root module \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/enumShadowedInfinityNaN.js b/testdata/baselines/reference/submodule/conformance/enumShadowedInfinityNaN.js index 28a3ac9acb..9afc179ac4 100644 --- a/testdata/baselines/reference/submodule/conformance/enumShadowedInfinityNaN.js +++ b/testdata/baselines/reference/submodule/conformance/enumShadowedInfinityNaN.js @@ -24,15 +24,13 @@ let Infinity = {}; let En; (function (En) { - En["X"] = Infinity; - if (typeof En.X !== "string") En[En.X] = "X"; + En[En["X"] = Infinity] = "X"; })(En || (En = {})); } { let NaN = {}; let En; (function (En) { - En["X"] = NaN; - if (typeof En.X !== "string") En[En.X] = "X"; + En[En["X"] = NaN] = "X"; })(En || (En = {})); } diff --git a/testdata/baselines/reference/submodule/conformance/enumShadowedInfinityNaN.js.diff b/testdata/baselines/reference/submodule/conformance/enumShadowedInfinityNaN.js.diff deleted file mode 100644 index bc8606748f..0000000000 --- a/testdata/baselines/reference/submodule/conformance/enumShadowedInfinityNaN.js.diff +++ /dev/null @@ -1,20 +0,0 @@ ---- old.enumShadowedInfinityNaN.js -+++ new.enumShadowedInfinityNaN.js -@@= skipped -23, +23 lines =@@ - let Infinity = {}; - let En; - (function (En) { -- En[En["X"] = Infinity] = "X"; -+ En["X"] = Infinity; -+ if (typeof En.X !== "string") En[En.X] = "X"; - })(En || (En = {})); - } - { - let NaN = {}; - let En; - (function (En) { -- En[En["X"] = NaN] = "X"; -+ En["X"] = NaN; -+ if (typeof En.X !== "string") En[En.X] = "X"; - })(En || (En = {})); - } \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/parserComputedPropertyName26.js b/testdata/baselines/reference/submodule/conformance/parserComputedPropertyName26.js index 80109dfe42..3b50e41835 100644 --- a/testdata/baselines/reference/submodule/conformance/parserComputedPropertyName26.js +++ b/testdata/baselines/reference/submodule/conformance/parserComputedPropertyName26.js @@ -11,6 +11,5 @@ enum E { var E; (function (E) { // No ASI - E[e] = 0[e2] = 1; - if (typeof E[e] !== "string") E[E[e]] = e; + E[E[e] = 0[e2] = 1] = e; })(E || (E = {})); diff --git a/testdata/baselines/reference/submodule/conformance/parserComputedPropertyName26.js.diff b/testdata/baselines/reference/submodule/conformance/parserComputedPropertyName26.js.diff deleted file mode 100644 index bf21732aea..0000000000 --- a/testdata/baselines/reference/submodule/conformance/parserComputedPropertyName26.js.diff +++ /dev/null @@ -1,10 +0,0 @@ ---- old.parserComputedPropertyName26.js -+++ new.parserComputedPropertyName26.js -@@= skipped -10, +10 lines =@@ - var E; - (function (E) { - // No ASI -- E[E[e] = 0[e2] = 1] = e; -+ E[e] = 0[e2] = 1; -+ if (typeof E[e] !== "string") E[E[e]] = e; - })(E || (E = {})); \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/parserComputedPropertyName30.js b/testdata/baselines/reference/submodule/conformance/parserComputedPropertyName30.js index a20b4a111c..f2b58bcddc 100644 --- a/testdata/baselines/reference/submodule/conformance/parserComputedPropertyName30.js +++ b/testdata/baselines/reference/submodule/conformance/parserComputedPropertyName30.js @@ -11,7 +11,6 @@ enum E { var E; (function (E) { // no ASI, comma expected - E[e] = id++; - if (typeof E[e] !== "string") E[E[e]] = e; + E[E[e] = id++] = e; E[E[e2] = 1] = e2; })(E || (E = {})); diff --git a/testdata/baselines/reference/submodule/conformance/parserComputedPropertyName30.js.diff b/testdata/baselines/reference/submodule/conformance/parserComputedPropertyName30.js.diff deleted file mode 100644 index ffef2e608f..0000000000 --- a/testdata/baselines/reference/submodule/conformance/parserComputedPropertyName30.js.diff +++ /dev/null @@ -1,11 +0,0 @@ ---- old.parserComputedPropertyName30.js -+++ new.parserComputedPropertyName30.js -@@= skipped -10, +10 lines =@@ - var E; - (function (E) { - // no ASI, comma expected -- E[E[e] = id++] = e; -+ E[e] = id++; -+ if (typeof E[e] !== "string") E[E[e]] = e; - E[E[e2] = 1] = e2; - })(E || (E = {})); \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/parserComputedPropertyName34.js b/testdata/baselines/reference/submodule/conformance/parserComputedPropertyName34.js index 47b4fa80a6..a332ed4d63 100644 --- a/testdata/baselines/reference/submodule/conformance/parserComputedPropertyName34.js +++ b/testdata/baselines/reference/submodule/conformance/parserComputedPropertyName34.js @@ -11,7 +11,6 @@ enum E { var E; (function (E) { // no ASI, comma expected - E[e] = id++; - if (typeof E[e] !== "string") E[E[e]] = e; + E[E[e] = id++] = e; E[E[e2] = 1] = e2; })(E || (E = {})); diff --git a/testdata/baselines/reference/submodule/conformance/parserComputedPropertyName34.js.diff b/testdata/baselines/reference/submodule/conformance/parserComputedPropertyName34.js.diff deleted file mode 100644 index 2ec8f27208..0000000000 --- a/testdata/baselines/reference/submodule/conformance/parserComputedPropertyName34.js.diff +++ /dev/null @@ -1,11 +0,0 @@ ---- old.parserComputedPropertyName34.js -+++ new.parserComputedPropertyName34.js -@@= skipped -10, +10 lines =@@ - var E; - (function (E) { - // no ASI, comma expected -- E[E[e] = id++] = e; -+ E[e] = id++; -+ if (typeof E[e] !== "string") E[E[e]] = e; - E[E[e2] = 1] = e2; - })(E || (E = {})); \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/thisInInvalidContexts.js b/testdata/baselines/reference/submodule/conformance/thisInInvalidContexts.js index ee2257df1f..10b199699a 100644 --- a/testdata/baselines/reference/submodule/conformance/thisInInvalidContexts.js +++ b/testdata/baselines/reference/submodule/conformance/thisInInvalidContexts.js @@ -78,8 +78,6 @@ class ErrClass3 extends this { //'this' as a computed enum value var SomeEnum; (function (SomeEnum) { - SomeEnum["A"] = this; - if (typeof SomeEnum.A !== "string") SomeEnum[SomeEnum.A] = "A"; - SomeEnum["B"] = this.spaaaace; // Also should not be allowed - if (typeof SomeEnum.B !== "string") SomeEnum[SomeEnum.B] = "B"; + SomeEnum[SomeEnum["A"] = this] = "A"; + SomeEnum[SomeEnum["B"] = this.spaaaace] = "B"; // Also should not be allowed })(SomeEnum || (SomeEnum = {})); diff --git a/testdata/baselines/reference/submodule/conformance/thisInInvalidContexts.js.diff b/testdata/baselines/reference/submodule/conformance/thisInInvalidContexts.js.diff index 357a551f44..140ad3ab2f 100644 --- a/testdata/baselines/reference/submodule/conformance/thisInInvalidContexts.js.diff +++ b/testdata/baselines/reference/submodule/conformance/thisInInvalidContexts.js.diff @@ -18,15 +18,4 @@ - this.t = 4; } } - var M; -@@= skipped -27, +28 lines =@@ - //'this' as a computed enum value - var SomeEnum; - (function (SomeEnum) { -- SomeEnum[SomeEnum["A"] = this] = "A"; -- SomeEnum[SomeEnum["B"] = this.spaaaace] = "B"; // Also should not be allowed -+ SomeEnum["A"] = this; -+ if (typeof SomeEnum.A !== "string") SomeEnum[SomeEnum.A] = "A"; -+ SomeEnum["B"] = this.spaaaace; // Also should not be allowed -+ if (typeof SomeEnum.B !== "string") SomeEnum[SomeEnum.B] = "B"; - })(SomeEnum || (SomeEnum = {})); \ No newline at end of file + var M; \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/thisInInvalidContextsExternalModule.js b/testdata/baselines/reference/submodule/conformance/thisInInvalidContextsExternalModule.js index bf1f420dc9..fade6af0d6 100644 --- a/testdata/baselines/reference/submodule/conformance/thisInInvalidContextsExternalModule.js +++ b/testdata/baselines/reference/submodule/conformance/thisInInvalidContextsExternalModule.js @@ -79,9 +79,7 @@ class ErrClass3 extends this { //'this' as a computed enum value var SomeEnum; (function (SomeEnum) { - SomeEnum["A"] = this; - if (typeof SomeEnum.A !== "string") SomeEnum[SomeEnum.A] = "A"; - SomeEnum["B"] = this.spaaaace; // Also should not be allowed - if (typeof SomeEnum.B !== "string") SomeEnum[SomeEnum.B] = "B"; + SomeEnum[SomeEnum["A"] = this] = "A"; + SomeEnum[SomeEnum["B"] = this.spaaaace] = "B"; // Also should not be allowed })(SomeEnum || (SomeEnum = {})); module.exports = this; diff --git a/testdata/baselines/reference/submodule/conformance/thisInInvalidContextsExternalModule.js.diff b/testdata/baselines/reference/submodule/conformance/thisInInvalidContextsExternalModule.js.diff index 1c2b981505..6ee4cb6c9c 100644 --- a/testdata/baselines/reference/submodule/conformance/thisInInvalidContextsExternalModule.js.diff +++ b/testdata/baselines/reference/submodule/conformance/thisInInvalidContextsExternalModule.js.diff @@ -18,16 +18,4 @@ - this.t = 4; } } - var M; -@@= skipped -27, +28 lines =@@ - //'this' as a computed enum value - var SomeEnum; - (function (SomeEnum) { -- SomeEnum[SomeEnum["A"] = this] = "A"; -- SomeEnum[SomeEnum["B"] = this.spaaaace] = "B"; // Also should not be allowed -+ SomeEnum["A"] = this; -+ if (typeof SomeEnum.A !== "string") SomeEnum[SomeEnum.A] = "A"; -+ SomeEnum["B"] = this.spaaaace; // Also should not be allowed -+ if (typeof SomeEnum.B !== "string") SomeEnum[SomeEnum.B] = "B"; - })(SomeEnum || (SomeEnum = {})); - module.exports = this; \ No newline at end of file + var M; \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/verbatimModuleSyntaxConstEnumUsage.js b/testdata/baselines/reference/submodule/conformance/verbatimModuleSyntaxConstEnumUsage.js index bcaaeb3815..7d5c9d2049 100644 --- a/testdata/baselines/reference/submodule/conformance/verbatimModuleSyntaxConstEnumUsage.js +++ b/testdata/baselines/reference/submodule/conformance/verbatimModuleSyntaxConstEnumUsage.js @@ -21,17 +21,15 @@ export { Foo }; var Foo; (function (Foo) { Foo[Foo["a"] = 1] = "a"; - Foo[Foo["b"] = 2] = "b"; - Foo[Foo["c"] = 3] = "c"; + Foo[Foo["b"] = void 0] = "b"; + Foo[Foo["c"] = void 0] = "c"; })(Foo || (Foo = {})); //// [bar.js] import { Foo } from './foo.js'; export { Bar }; var Bar; (function (Bar) { - Bar["a"] = Foo.a; - if (typeof Bar.a !== "string") Bar[Bar.a] = "a"; - Bar["c"] = Foo.c; - if (typeof Bar.c !== "string") Bar[Bar.c] = "c"; + Bar[Bar["a"] = Foo.a] = "a"; + Bar[Bar["c"] = Foo.c] = "c"; Bar[Bar["e"] = 5] = "e"; })(Bar || (Bar = {})); diff --git a/testdata/baselines/reference/submodule/conformance/verbatimModuleSyntaxConstEnumUsage.js.diff b/testdata/baselines/reference/submodule/conformance/verbatimModuleSyntaxConstEnumUsage.js.diff index 8a044e26e5..b8ffa6f02a 100644 --- a/testdata/baselines/reference/submodule/conformance/verbatimModuleSyntaxConstEnumUsage.js.diff +++ b/testdata/baselines/reference/submodule/conformance/verbatimModuleSyntaxConstEnumUsage.js.diff @@ -9,8 +9,10 @@ +var Foo; (function (Foo) { Foo[Foo["a"] = 1] = "a"; - Foo[Foo["b"] = 2] = "b"; -@@= skipped -8, +9 lines =@@ +- Foo[Foo["b"] = 2] = "b"; +- Foo[Foo["c"] = 3] = "c"; ++ Foo[Foo["b"] = void 0] = "b"; ++ Foo[Foo["c"] = void 0] = "c"; })(Foo || (Foo = {})); //// [bar.js] import { Foo } from './foo.js'; @@ -20,9 +22,7 @@ (function (Bar) { - Bar[Bar["a"] = 1] = "a"; - Bar[Bar["c"] = 3] = "c"; -+ Bar["a"] = Foo.a; -+ if (typeof Bar.a !== "string") Bar[Bar.a] = "a"; -+ Bar["c"] = Foo.c; -+ if (typeof Bar.c !== "string") Bar[Bar.c] = "c"; ++ Bar[Bar["a"] = Foo.a] = "a"; ++ Bar[Bar["c"] = Foo.c] = "c"; Bar[Bar["e"] = 5] = "e"; })(Bar || (Bar = {})); \ No newline at end of file