From f9cf8216c6e9e1339a79e81d772799190c10fa49 Mon Sep 17 00:00:00 2001 From: Ron Buckton Date: Thu, 22 Jun 2023 17:02:56 -0400 Subject: [PATCH] Support `using` and `await using` declarations (#54505) --- src/compiler/_namespaces/ts.ts | 2 + src/compiler/binder.ts | 2 +- src/compiler/checker.ts | 271 ++- src/compiler/commandLineParser.ts | 1 + src/compiler/diagnosticMessages.json | 56 +- src/compiler/emitter.ts | 15 +- src/compiler/factory/emitHelpers.ts | 91 +- src/compiler/factory/nodeConverters.ts | 23 +- src/compiler/factory/nodeFactory.ts | 135 +- src/compiler/factory/utilities.ts | 3 + src/compiler/parser.ts | 65 +- src/compiler/program.ts | 8 +- src/compiler/scanner.ts | 1 + src/compiler/transformer.ts | 13 +- src/compiler/transformers/classFields.ts | 470 +++-- src/compiler/transformers/classThis.ts | 148 ++ src/compiler/transformers/declarations.ts | 17 +- src/compiler/transformers/es2015.ts | 358 ++-- src/compiler/transformers/esDecorators.ts | 455 +++-- src/compiler/transformers/esnext.ts | 882 ++++++++- src/compiler/transformers/legacyDecorators.ts | 45 +- src/compiler/transformers/module/module.ts | 69 +- src/compiler/transformers/module/system.ts | 67 +- src/compiler/transformers/namedEvaluation.ts | 478 +++++ src/compiler/transformers/ts.ts | 95 +- src/compiler/transformers/utilities.ts | 130 +- src/compiler/types.ts | 83 +- src/compiler/utilities.ts | 40 +- src/compiler/utilitiesPublic.ts | 15 +- src/harness/evaluatorImpl.ts | 297 ++- src/lib/esnext.d.ts | 1 + src/lib/esnext.disposable.d.ts | 167 ++ src/lib/libs.json | 1 + .../codefixes/addEmptyExportDeclaration.ts | 1 + .../codefixes/fixAwaitInSyncFunction.ts | 1 + .../codefixes/fixModuleAndTargetOptions.ts | 1 + src/testRunner/tests.ts | 2 + .../evaluation/awaitUsingDeclarations.ts | 1672 +++++++++++++++++ .../unittests/evaluation/usingDeclarations.ts | 1661 ++++++++++++++++ .../amdImportNotAsPrimaryExpression.js | 3 +- .../reference/api/tsserverlibrary.d.ts | 501 ++--- tests/baselines/reference/api/typescript.d.ts | 501 ++--- ...ngDeclarations.1(target=es2015).errors.txt | 145 ++ ...awaitUsingDeclarations.1(target=es2015).js | 540 ++++++ ...awaitUsingDeclarations.1(target=es2017).js | 485 +++++ ...awaitUsingDeclarations.1(target=es2022).js | 467 +++++ ...UsingDeclarations.1(target=es5).errors.txt | 145 ++ .../awaitUsingDeclarations.1(target=es5).js | 711 +++++++ ...awaitUsingDeclarations.1(target=esnext).js | 180 ++ .../awaitUsingDeclarations.10.errors.txt | 12 + .../reference/awaitUsingDeclarations.10.js | 16 + .../awaitUsingDeclarations.11.errors.txt | 12 + .../reference/awaitUsingDeclarations.11.js | 9 + .../awaitUsingDeclarations.12.errors.txt | 9 + .../reference/awaitUsingDeclarations.12.js | 11 + .../awaitUsingDeclarations.13.errors.txt | 15 + .../reference/awaitUsingDeclarations.13.js | 14 + .../awaitUsingDeclarations.14.errors.txt | 18 + .../reference/awaitUsingDeclarations.14.js | 22 + .../reference/awaitUsingDeclarations.15.js | 11 + ...ngDeclarations.2(target=es2015).errors.txt | 12 + ...awaitUsingDeclarations.2(target=es2015).js | 85 + ...awaitUsingDeclarations.2(target=es2017).js | 72 + ...awaitUsingDeclarations.2(target=es2022).js | 72 + ...UsingDeclarations.2(target=es5).errors.txt | 12 + .../awaitUsingDeclarations.2(target=es5).js | 117 ++ ...awaitUsingDeclarations.2(target=esnext).js | 15 + ...ngDeclarations.3(target=es2015).errors.txt | 14 + ...awaitUsingDeclarations.3(target=es2015).js | 85 + ...awaitUsingDeclarations.3(target=es2017).js | 74 + ...awaitUsingDeclarations.3(target=es2022).js | 74 + ...UsingDeclarations.3(target=es5).errors.txt | 14 + .../awaitUsingDeclarations.3(target=es5).js | 115 ++ ...awaitUsingDeclarations.3(target=esnext).js | 17 + .../awaitUsingDeclarations.4.errors.txt | 17 + .../reference/awaitUsingDeclarations.4.js | 15 + .../awaitUsingDeclarations.5.errors.txt | 16 + .../reference/awaitUsingDeclarations.5.js | 16 + .../awaitUsingDeclarations.6.errors.txt | 15 + .../reference/awaitUsingDeclarations.6.js | 15 + .../awaitUsingDeclarations.7.errors.txt | 17 + .../reference/awaitUsingDeclarations.7.js | 13 + .../awaitUsingDeclarations.8.errors.txt | 11 + .../reference/awaitUsingDeclarations.8.js | 14 + .../awaitUsingDeclarations.9.errors.txt | 12 + .../reference/awaitUsingDeclarations.9.js | 14 + ...itUsingDeclarationsInFor(target=es2015).js | 89 + ...itUsingDeclarationsInFor(target=es2017).js | 76 + ...itUsingDeclarationsInFor(target=es2022).js | 76 + ...awaitUsingDeclarationsInFor(target=es5).js | 130 ++ ...itUsingDeclarationsInFor(target=esnext).js | 16 + ...DeclarationsInForAwaitOf(target=es2015).js | 104 + ...DeclarationsInForAwaitOf(target=es2017).js | 91 + ...DeclarationsInForAwaitOf(target=es2022).js | 71 + ...ingDeclarationsInForAwaitOf(target=es5).js | 162 ++ ...DeclarationsInForAwaitOf(target=esnext).js | 13 + .../awaitUsingDeclarationsInForIn.errors.txt | 11 + .../awaitUsingDeclarationsInForIn.js | 14 + ...ingDeclarationsInForOf.1(target=es2015).js | 85 + ...ingDeclarationsInForOf.1(target=es2017).js | 72 + ...ingDeclarationsInForOf.1(target=es2022).js | 72 + ...tUsingDeclarationsInForOf.1(target=es5).js | 134 ++ ...ingDeclarationsInForOf.1(target=esnext).js | 14 + ...awaitUsingDeclarationsInForOf.2.errors.txt | 20 + .../awaitUsingDeclarationsInForOf.2.js | 14 + ...awaitUsingDeclarationsInForOf.3.errors.txt | 11 + .../awaitUsingDeclarationsInForOf.3.js | 14 + ...ationsTopLevelOfModule.1(module=esnext).js | 40 + ...ationsTopLevelOfModule.1(module=system).js | 46 + ...ngDeclarationsWithImportHelpers.errors.txt | 11 + ...awaitUsingDeclarationsWithImportHelpers.js | 14 + ...assStaticBlock23(target=es2022).errors.txt | 8 +- ...assStaticBlock23(target=esnext).errors.txt | 8 +- ...assStaticBlock26(target=es2022).errors.txt | 32 +- ...assStaticBlock26(target=esnext).errors.txt | 32 +- .../classStaticBlock5(target=es5).js | 1 - .../reference/classStaticBlock6.errors.txt | 12 +- .../reference/classStaticBlock7.errors.txt | 8 +- .../commonJSImportAsPrimaryExpression.js | 3 +- .../commonJSImportNotAsPrimaryExpression.js | 3 +- ...poundExponentiationAssignmentLHSIsValue.js | 3 +- .../Parse --lib option with extra comma.js | 2 +- ... --lib option with trailing white-space.js | 2 +- .../Parse invalid option of library flags.js | 2 +- ...array to compiler-options with json api.js | 2 +- ...ompiler-options with jsonSourceFile api.js | 2 +- ... libs to compiler-options with json api.js | 2 +- ...ompiler-options with jsonSourceFile api.js | 2 +- ... libs to compiler-options with json api.js | 2 +- ...ompiler-options with jsonSourceFile api.js | 2 +- ... libs to compiler-options with json api.js | 2 +- ...ompiler-options with jsonSourceFile api.js | 2 +- .../customTransforms/before+decorators.js | 3 +- ...arationEmitLocalClassHasRequiredDeclare.js | 3 +- .../decoratedClassExportsCommonJS1.js | 3 +- .../decoratedClassExportsCommonJS2.js | 3 +- .../reference/decoratedClassExportsSystem1.js | 5 +- .../reference/decoratedClassExportsSystem2.js | 5 +- .../decoratorMetadataGenericTypeVariable.js | 3 +- ...ratorMetadataGenericTypeVariableDefault.js | 3 +- ...ratorMetadataGenericTypeVariableInScope.js | 3 +- ...oratorMetadataNoLibIsolatedModulesTypes.js | 3 +- .../decoratorMetadataOnInferredType.js | 3 +- ...orMetadataRestParameterWithImportedType.js | 3 +- .../decoratorMetadataWithConstructorType.js | 3 +- .../decoratorMetadataWithTypeOnlyImport2.js | 3 +- .../reference/decoratorOnClass2.es6.js | 3 +- .../baselines/reference/decoratorOnClass2.js | 3 +- .../baselines/reference/decoratorOnClass3.js | 3 +- .../reference/decoratorOnClass6.es6.js | 3 +- .../reference/decoratorOnClass8.es6.js | 5 +- .../reference/decoratorOnClassConstructor2.js | 3 +- .../reference/decoratorOnClassConstructor3.js | 3 +- .../reference/derivedClassSuperProperties.js | 10 +- .../derivedClassSuperStatementPosition.js | 4 +- ...tHelpersWithLocalCollisions(module=amd).js | 3 +- ...ersWithLocalCollisions(module=commonjs).js | 3 +- ...lpersWithLocalCollisions(module=es2020).js | 3 +- ...lpersWithLocalCollisions(module=es2022).js | 3 +- ...tHelpersWithLocalCollisions(module=es6).js | 3 +- ...lpersWithLocalCollisions(module=esnext).js | 3 +- ...lpersWithLocalCollisions(module=node16).js | 3 +- ...ersWithLocalCollisions(module=nodenext).js | 3 +- ...HelpersWithLocalCollisions(module=none).js | 3 +- ...lpersWithLocalCollisions(module=system).js | 5 +- ...tHelpersWithLocalCollisions(module=umd).js | 3 +- .../reference/es3defaultAliasIsQuoted.js | 3 +- .../reference/es6modulekindWithES5Target.js | 6 +- ...aration-accessors-nonStatic(target=es5).js | 1 - ...eclaration-accessors-static(target=es5).js | 1 - ...-accessors-staticPrivate(target=es2015).js | 10 +- ...-accessors-staticPrivate(target=es2022).js | 11 +- ...ecorators-classDeclaration-classSuper.1.js | 3 +- ...ecorators-classDeclaration-classSuper.2.js | 49 +- ...ecorators-classDeclaration-classSuper.3.js | 3 +- ...ecorators-classDeclaration-classSuper.4.js | 3 +- ...ecorators-classDeclaration-classSuper.5.js | 81 +- ...ecorators-classDeclaration-classSuper.6.js | 3 +- ...ecorators-classDeclaration-classSuper.7.js | 12 +- ...ation-classThisReference(target=es2015).js | 8 +- ...ation-classThisReference(target=es2022).js | 11 +- ...classDeclaration-classThisReference.es5.js | 1 - ...ervation(module=commonjs,target=es2015).js | 86 +- ...ervation(module=commonjs,target=es2022).js | 73 +- ...eservation(module=esnext,target=es2015).js | 91 +- ...eservation(module=esnext,target=es2022).js | 78 +- ...eclaration-commonjs-classNamespaceMerge.js | 6 +- .../esDecorators-classDeclaration-commonjs.js | 6 +- ...on-fields-staticAccessor(target=es2015).js | 8 +- ...on-fields-staticAccessor(target=es2022).js | 11 +- ...ion-fields-staticPrivate(target=es2015).js | 8 +- ...ion-fields-staticPrivate(target=es2022).js | 11 +- ...ds-staticPrivateAccessor(target=es2015).js | 14 +- ...ds-staticPrivateAccessor(target=es2022).js | 13 +- ...claration-methods-nonStatic(target=es5).js | 1 - ...sDeclaration-methods-static(target=es5).js | 1 - ...on-methods-staticPrivate(target=es2015).js | 4 +- ...on-methods-staticPrivate(target=es2022).js | 7 +- ...ion-missingEmitHelpers-classDecorator.1.js | 3 +- ...ion-missingEmitHelpers-classDecorator.2.js | 5 +- ...ion-missingEmitHelpers-classDecorator.3.js | 7 +- ...ation-multipleDecorators(target=es2022).js | 3 +- ...laration-multipleDecorators(target=es5).js | 1 - ...ation-outerThisReference(target=es2015).js | 58 +- ...ation-outerThisReference(target=es2021).js | 58 +- ...ation-outerThisReference(target=es2022).js | 49 +- ...rget=es5,usedefineforclassfields=false).js | 1 - ...arget=es5,usedefineforclassfields=true).js | 1 - ...laration-setFunctionName(target=es2015).js | 5 +- ...laration-setFunctionName(target=es2022).js | 14 +- ...Declaration-setFunctionName(target=es5).js | 8 +- ...ion-simpleTransformation(target=es2022).js | 3 +- ...ration-simpleTransformation(target=es5).js | 1 - ...assDeclaration-sourceMap(target=es2015).js | 34 +- ...eclaration-sourceMap(target=es2015).js.map | 4 +- ...ion-sourceMap(target=es2015).sourcemap.txt | 174 +- ...assDeclaration-sourceMap(target=es2022).js | 21 +- ...eclaration-sourceMap(target=es2022).js.map | 4 +- ...ion-sourceMap(target=es2022).sourcemap.txt | 407 ++-- ...Decorators-classExpression-classSuper.1.js | 3 +- ...Decorators-classExpression-classSuper.2.js | 49 +- ...Decorators-classExpression-classSuper.3.js | 3 +- ...Decorators-classExpression-classSuper.4.js | 3 +- ...Decorators-classExpression-classSuper.5.js | 81 +- ...Decorators-classExpression-classSuper.6.js | 3 +- ...sion-commentPreservation(target=es2015).js | 34 +- ...sion-commentPreservation(target=es2022).js | 27 +- ...ion-missingEmitHelpers-classDecorator.1.js | 5 +- ...on-missingEmitHelpers-classDecorator.10.js | 5 +- ...on-missingEmitHelpers-classDecorator.11.js | 5 +- ...on-missingEmitHelpers-classDecorator.12.js | 5 +- ...on-missingEmitHelpers-classDecorator.13.js | 5 +- ...on-missingEmitHelpers-classDecorator.14.js | 5 +- ...on-missingEmitHelpers-classDecorator.15.js | 5 +- ...on-missingEmitHelpers-classDecorator.16.js | 5 +- ...on-missingEmitHelpers-classDecorator.17.js | 5 +- ...ion-missingEmitHelpers-classDecorator.2.js | 3 +- ...ion-missingEmitHelpers-classDecorator.3.js | 5 +- ...ion-missingEmitHelpers-classDecorator.4.js | 5 +- ...ion-missingEmitHelpers-classDecorator.5.js | 5 +- ...ion-missingEmitHelpers-classDecorator.6.js | 5 +- ...ion-missingEmitHelpers-classDecorator.7.js | 5 +- ...ion-missingEmitHelpers-classDecorator.8.js | 5 +- ...ion-missingEmitHelpers-classDecorator.9.js | 5 +- ...ators-classExpression-namedEvaluation.1.js | 88 +- ...tors-classExpression-namedEvaluation.10.js | 226 +-- ...tors-classExpression-namedEvaluation.11.js | 28 +- ...ators-classExpression-namedEvaluation.2.js | 199 +- ...ators-classExpression-namedEvaluation.3.js | 61 +- ...ators-classExpression-namedEvaluation.4.js | 61 +- ...ators-classExpression-namedEvaluation.5.js | 7 +- ...ators-classExpression-namedEvaluation.6.js | 7 +- ...ators-classExpression-namedEvaluation.7.js | 7 +- ...ators-classExpression-namedEvaluation.8.js | 7 +- ...ators-classExpression-namedEvaluation.9.js | 5 +- ...rs-emitDecoratorMetadata(target=es2015).js | 44 +- ...rs-emitDecoratorMetadata(target=es2022).js | 42 +- ...ators-emitDecoratorMetadata(target=es5).js | 45 +- .../esnextmodulekindWithES5Target.js | 6 +- .../for-of-excess-declarations.errors.txt | 15 + .../reference/for-of-excess-declarations.js | 10 + .../for-of-excess-declarations.symbols | 8 + .../for-of-excess-declarations.types | 11 + tests/baselines/reference/importHelpersES6.js | 3 +- ...tHelpersWithLocalCollisions(module=amd).js | 3 +- ...ersWithLocalCollisions(module=commonjs).js | 3 +- ...lpersWithLocalCollisions(module=es2015).js | 3 +- ...lpersWithLocalCollisions(module=system).js | 5 +- .../reference/importImportOnlyModule.js | 3 +- .../javascriptThisAssignmentInStaticBlock.js | 1 - .../reference/jsDeclarationsClasses.js | 9 +- .../reference/jsDeclarationsComputedNames.js | 3 +- ...letDeclarations-invalidContexts.errors.txt | 32 +- .../baselines/reference/metadataImportType.js | 3 +- .../reference/metadataOfClassFromAlias.js | 3 +- .../reference/metadataOfClassFromAlias2.js | 3 +- .../reference/metadataOfEventAlias.js | 3 +- .../metadataReferencedWithinFilteredUnion.js | 3 +- .../reference/plainJSGrammarErrors.errors.txt | 8 +- .../privacyCannotNameVarTypeDeclFile.js | 6 +- .../amd/main.js | 3 +- .../node/main.js | 3 +- .../amd/main.js | 3 +- .../node/main.js | 3 +- .../emitDecoratorMetadataSystemJS/amd/main.js | 3 +- .../node/main.js | 3 +- .../amd/main.js | 3 +- .../node/main.js | 3 +- .../amd/main.js | 3 +- .../node/main.js | 3 +- .../staticFieldWithInterfaceContext.js | 10 +- .../reference/strictModeInConstructor.js | 4 +- ...rgetEs6DecoratorMetadataImportNotElided.js | 3 +- .../templateLiteralsAndDecoratorMetadata.js | 3 +- .../reference/thisInConstructorParameter2.js | 2 +- ...does-not-add-color-when-NO_COLOR-is-set.js | 2 +- ...-when-host-can't-provide-terminal-width.js | 2 +- ...tatus.DiagnosticsPresent_OutputsSkipped.js | 2 +- ...tes-diagnostics-and-emit-for-decorators.js | 9 +- .../reference/tslibReExportHelpers.js | 3 +- .../telemetry/does-not-expose-paths.js | 2 +- .../typesVersions.ambientModules.trace.json | 12 + .../typesVersions.emptyTypes.trace.json | 13 + .../typesVersions.justIndex.trace.json | 13 + .../typesVersions.multiFile.trace.json | 12 + ...VersionsDeclarationEmit.ambient.trace.json | 12 + ...rsionsDeclarationEmit.multiFile.trace.json | 12 + ...it.multiFileBackReferenceToSelf.trace.json | 12 + ...ultiFileBackReferenceToUnmapped.trace.json | 12 + .../usingDeclarations.1(target=es2015).js | 665 +++++++ .../usingDeclarations.1(target=es2017).js | 652 +++++++ .../usingDeclarations.1(target=es2022).js | 634 +++++++ .../usingDeclarations.1(target=es5).js | 814 ++++++++ .../usingDeclarations.1(target=esnext).js | 278 +++ .../reference/usingDeclarations.10.errors.txt | 9 + .../reference/usingDeclarations.10.js | 10 + .../reference/usingDeclarations.11.js | 202 ++ ...tions.12(usedefineforclassfields=false).js | 81 + ...ations.12(usedefineforclassfields=true).js | 86 + .../reference/usingDeclarations.13.errors.txt | 12 + .../reference/usingDeclarations.13.js | 9 + .../reference/usingDeclarations.14.errors.txt | 10 + .../reference/usingDeclarations.14.js | 7 + .../reference/usingDeclarations.15.js | 10 + .../usingDeclarations.2(target=es2015).js | 68 + .../usingDeclarations.2(target=es2017).js | 68 + .../usingDeclarations.2(target=es2022).js | 68 + .../usingDeclarations.2(target=es5).js | 69 + .../usingDeclarations.2(target=esnext).js | 13 + .../usingDeclarations.3(target=es2015).js | 70 + .../usingDeclarations.3(target=es2017).js | 70 + .../usingDeclarations.3(target=es2022).js | 70 + .../usingDeclarations.3(target=es5).js | 71 + .../usingDeclarations.3(target=esnext).js | 15 + .../reference/usingDeclarations.4.errors.txt | 12 + .../reference/usingDeclarations.4.js | 11 + .../reference/usingDeclarations.5.errors.txt | 15 + .../reference/usingDeclarations.5.js | 14 + .../reference/usingDeclarations.6.errors.txt | 13 + .../reference/usingDeclarations.6.js | 12 + .../reference/usingDeclarations.7.errors.txt | 14 + .../reference/usingDeclarations.7.js | 13 + .../reference/usingDeclarations.8.errors.txt | 9 + .../reference/usingDeclarations.8.js | 11 + .../reference/usingDeclarations.9.errors.txt | 8 + .../reference/usingDeclarations.9.js | 11 + .../usingDeclarationsDeclarationEmit.1.js | 26 + .../usingDeclarationsDeclarationEmit.2.js | 26 + .../usingDeclarationsInFor(target=es2015).js | 68 + .../usingDeclarationsInFor(target=es2017).js | 68 + .../usingDeclarationsInFor(target=es2022).js | 68 + .../usingDeclarationsInFor(target=es5).js | 69 + .../usingDeclarationsInFor(target=esnext).js | 10 + ...DeclarationsInForAwaitOf(target=es2015).js | 101 + ...DeclarationsInForAwaitOf(target=es2017).js | 90 + ...DeclarationsInForAwaitOf(target=es2022).js | 70 + ...ingDeclarationsInForAwaitOf(target=es5).js | 152 ++ ...DeclarationsInForAwaitOf(target=esnext).js | 14 + .../usingDeclarationsInForIn.errors.txt | 9 + .../reference/usingDeclarationsInForIn.js | 10 + ...ingDeclarationsInForOf.1(target=es2015).js | 66 + ...ingDeclarationsInForOf.1(target=es2017).js | 66 + ...ingDeclarationsInForOf.1(target=es2022).js | 66 + .../usingDeclarationsInForOf.1(target=es5).js | 68 + ...ingDeclarationsInForOf.1(target=esnext).js | 10 + .../usingDeclarationsInForOf.2.errors.txt | 15 + .../reference/usingDeclarationsInForOf.2.js | 10 + .../usingDeclarationsInForOf.3.errors.txt | 9 + .../reference/usingDeclarationsInForOf.3.js | 10 + ...NamedEvaluationDecoratorsAndClassFields.js | 171 ++ ...larationsTopLevelOfModule.1(module=amd).js | 40 + ...ionsTopLevelOfModule.1(module=commonjs).js | 38 + ...ationsTopLevelOfModule.1(module=esnext).js | 38 + ...ationsTopLevelOfModule.1(module=system).js | 44 + ...larationsTopLevelOfModule.2(module=amd).js | 31 + ...ionsTopLevelOfModule.2(module=commonjs).js | 29 + ...larationsTopLevelOfModule.3(module=amd).js | 42 + ...ionsTopLevelOfModule.3(module=commonjs).js | 40 + ...ationsTopLevelOfModule.3(module=esnext).js | 37 + ...ationsTopLevelOfModule.3(module=system).js | 46 + ...rators.1(module=commonjs,target=es2015).js | 44 + ...ecorators.1(module=commonjs,target=es5).js | 47 + ...rators.1(module=commonjs,target=esnext).js | 21 + ...corators.1(module=esnext,target=es2015).js | 43 + ...sDecorators.1(module=esnext,target=es5).js | 46 + ...corators.1(module=esnext,target=esnext).js | 20 + ...corators.1(module=system,target=es2015).js | 51 + ...sDecorators.1(module=system,target=es5).js | 54 + ...corators.1(module=system,target=esnext).js | 30 + ...ators.10(module=commonjs,target=es2015).js | 44 + ...corators.10(module=commonjs,target=es5).js | 48 + ...ators.10(module=commonjs,target=esnext).js | 22 + ...orators.10(module=esnext,target=es2015).js | 42 + ...Decorators.10(module=esnext,target=es5).js | 46 + ...orators.10(module=esnext,target=esnext).js | 19 + ...orators.10(module=system,target=es2015).js | 51 + ...Decorators.10(module=system,target=es5).js | 55 + ...orators.10(module=system,target=esnext).js | 31 + ...ators.11(module=commonjs,target=es2015).js | 48 + ...corators.11(module=commonjs,target=es5).js | 51 + ...ators.11(module=commonjs,target=esnext).js | 25 + ...orators.11(module=esnext,target=es2015).js | 45 + ...Decorators.11(module=esnext,target=es5).js | 48 + ...orators.11(module=esnext,target=esnext).js | 22 + ...orators.11(module=system,target=es2015).js | 54 + ...Decorators.11(module=system,target=es5).js | 57 + ...orators.11(module=system,target=esnext).js | 33 + ...ators.12(module=commonjs,target=es2015).js | 48 + ...corators.12(module=commonjs,target=es5).js | 51 + ...ators.12(module=commonjs,target=esnext).js | 25 + ...orators.12(module=esnext,target=es2015).js | 45 + ...Decorators.12(module=esnext,target=es5).js | 48 + ...orators.12(module=esnext,target=esnext).js | 22 + ...orators.12(module=system,target=es2015).js | 54 + ...Decorators.12(module=system,target=es5).js | 57 + ...orators.12(module=system,target=esnext).js | 33 + ...rators.2(module=commonjs,target=es2015).js | 45 + ...ecorators.2(module=commonjs,target=es5).js | 48 + ...rators.2(module=commonjs,target=esnext).js | 23 + ...corators.2(module=esnext,target=es2015).js | 43 + ...sDecorators.2(module=esnext,target=es5).js | 46 + ...corators.2(module=esnext,target=esnext).js | 19 + ...corators.2(module=system,target=es2015).js | 51 + ...sDecorators.2(module=system,target=es5).js | 54 + ...corators.2(module=system,target=esnext).js | 31 + ...rators.3(module=commonjs,target=es2015).js | 47 + ...ecorators.3(module=commonjs,target=es5).js | 51 + ...rators.3(module=commonjs,target=esnext).js | 24 + ...corators.3(module=esnext,target=es2015).js | 45 + ...sDecorators.3(module=esnext,target=es5).js | 49 + ...corators.3(module=esnext,target=esnext).js | 21 + ...corators.3(module=system,target=es2015).js | 53 + ...sDecorators.3(module=system,target=es5).js | 57 + ...corators.3(module=system,target=esnext).js | 33 + ...rators.4(module=commonjs,target=es2015).js | 45 + ...ecorators.4(module=commonjs,target=es5).js | 49 + ...rators.4(module=commonjs,target=esnext).js | 22 + ...corators.4(module=esnext,target=es2015).js | 43 + ...sDecorators.4(module=esnext,target=es5).js | 47 + ...corators.4(module=esnext,target=esnext).js | 19 + ...corators.4(module=system,target=es2015).js | 51 + ...sDecorators.4(module=system,target=es5).js | 55 + ...corators.4(module=system,target=esnext).js | 31 + ...rators.5(module=commonjs,target=es2015).js | 46 + ...ecorators.5(module=commonjs,target=es5).js | 49 + ...rators.5(module=commonjs,target=esnext).js | 24 + ...corators.5(module=esnext,target=es2015).js | 44 + ...sDecorators.5(module=esnext,target=es5).js | 47 + ...corators.5(module=esnext,target=esnext).js | 21 + ...corators.5(module=system,target=es2015).js | 52 + ...sDecorators.5(module=system,target=es5).js | 55 + ...corators.5(module=system,target=esnext).js | 32 + ...rators.6(module=commonjs,target=es2015).js | 46 + ...ecorators.6(module=commonjs,target=es5).js | 49 + ...rators.6(module=commonjs,target=esnext).js | 24 + ...corators.6(module=esnext,target=es2015).js | 44 + ...sDecorators.6(module=esnext,target=es5).js | 47 + ...corators.6(module=esnext,target=esnext).js | 21 + ...corators.6(module=system,target=es2015).js | 52 + ...sDecorators.6(module=system,target=es5).js | 55 + ...corators.6(module=system,target=esnext).js | 32 + ...rators.7(module=commonjs,target=es2015).js | 45 + ...ecorators.7(module=commonjs,target=es5).js | 48 + ...rators.7(module=commonjs,target=esnext).js | 22 + ...corators.7(module=esnext,target=es2015).js | 44 + ...sDecorators.7(module=esnext,target=es5).js | 47 + ...corators.7(module=esnext,target=esnext).js | 21 + ...corators.7(module=system,target=es2015).js | 52 + ...sDecorators.7(module=system,target=es5).js | 55 + ...corators.7(module=system,target=esnext).js | 31 + ...rators.8(module=commonjs,target=es2015).js | 46 + ...ecorators.8(module=commonjs,target=es5).js | 49 + ...rators.8(module=commonjs,target=esnext).js | 23 + ...corators.8(module=esnext,target=es2015).js | 43 + ...sDecorators.8(module=esnext,target=es5).js | 46 + ...corators.8(module=esnext,target=esnext).js | 19 + ...corators.8(module=system,target=es2015).js | 52 + ...sDecorators.8(module=system,target=es5).js | 55 + ...corators.8(module=system,target=esnext).js | 31 + ...rators.9(module=commonjs,target=es2015).js | 49 + ...ecorators.9(module=commonjs,target=es5).js | 52 + ...rators.9(module=commonjs,target=esnext).js | 26 + ...corators.9(module=esnext,target=es2015).js | 47 + ...sDecorators.9(module=esnext,target=es5).js | 50 + ...corators.9(module=esnext,target=esnext).js | 23 + ...corators.9(module=system,target=es2015).js | 56 + ...sDecorators.9(module=system,target=es5).js | 59 + ...corators.9(module=system,target=esnext).js | 35 + ...ngDeclarationsWithImportHelpers.errors.txt | 11 + .../usingDeclarationsWithImportHelpers.js | 14 + ...rators.1(module=commonjs,target=es2015).js | 34 + ...ecorators.1(module=commonjs,target=es5).js | 37 + ...rators.1(module=commonjs,target=esnext).js | 23 + ...corators.1(module=esnext,target=es2015).js | 33 + ...sDecorators.1(module=esnext,target=es5).js | 36 + ...corators.1(module=esnext,target=esnext).js | 22 + ...corators.1(module=system,target=es2015).js | 41 + ...sDecorators.1(module=system,target=es5).js | 44 + ...corators.1(module=system,target=esnext).js | 31 + ...ators.10(module=commonjs,target=es2015).js | 35 + ...corators.10(module=commonjs,target=es5).js | 38 + ...ators.10(module=commonjs,target=esnext).js | 24 + ...orators.10(module=esnext,target=es2015).js | 33 + ...Decorators.10(module=esnext,target=es5).js | 36 + ...orators.10(module=esnext,target=esnext).js | 22 + ...orators.10(module=system,target=es2015).js | 42 + ...Decorators.10(module=system,target=es5).js | 45 + ...orators.10(module=system,target=esnext).js | 32 + ...ators.11(module=commonjs,target=es2015).js | 38 + ...corators.11(module=commonjs,target=es5).js | 41 + ...ators.11(module=commonjs,target=esnext).js | 27 + ...orators.11(module=esnext,target=es2015).js | 35 + ...Decorators.11(module=esnext,target=es5).js | 38 + ...orators.11(module=esnext,target=esnext).js | 24 + ...orators.11(module=system,target=es2015).js | 44 + ...Decorators.11(module=system,target=es5).js | 47 + ...orators.11(module=system,target=esnext).js | 34 + ...ators.12(module=commonjs,target=es2015).js | 38 + ...corators.12(module=commonjs,target=es5).js | 41 + ...ators.12(module=commonjs,target=esnext).js | 27 + ...orators.12(module=esnext,target=es2015).js | 35 + ...Decorators.12(module=esnext,target=es5).js | 38 + ...orators.12(module=esnext,target=esnext).js | 24 + ...orators.12(module=system,target=es2015).js | 44 + ...Decorators.12(module=system,target=es5).js | 47 + ...orators.12(module=system,target=esnext).js | 34 + ...rators.2(module=commonjs,target=es2015).js | 35 + ...ecorators.2(module=commonjs,target=es5).js | 38 + ...rators.2(module=commonjs,target=esnext).js | 25 + ...corators.2(module=esnext,target=es2015).js | 33 + ...sDecorators.2(module=esnext,target=es5).js | 36 + ...corators.2(module=esnext,target=esnext).js | 22 + ...corators.2(module=system,target=es2015).js | 41 + ...sDecorators.2(module=system,target=es5).js | 44 + ...corators.2(module=system,target=esnext).js | 32 + ...rators.3(module=commonjs,target=es2015).js | 36 + ...ecorators.3(module=commonjs,target=es5).js | 39 + ...rators.3(module=commonjs,target=esnext).js | 24 + ...corators.3(module=esnext,target=es2015).js | 34 + ...sDecorators.3(module=esnext,target=es5).js | 37 + ...corators.3(module=esnext,target=esnext).js | 22 + ...corators.3(module=system,target=es2015).js | 42 + ...sDecorators.3(module=system,target=es5).js | 45 + ...corators.3(module=system,target=esnext).js | 32 + ...rators.4(module=commonjs,target=es2015).js | 36 + ...ecorators.4(module=commonjs,target=es5).js | 39 + ...rators.4(module=commonjs,target=esnext).js | 24 + ...corators.4(module=esnext,target=es2015).js | 34 + ...sDecorators.4(module=esnext,target=es5).js | 37 + ...corators.4(module=esnext,target=esnext).js | 22 + ...corators.4(module=system,target=es2015).js | 42 + ...sDecorators.4(module=system,target=es5).js | 45 + ...corators.4(module=system,target=esnext).js | 32 + ...rators.5(module=commonjs,target=es2015).js | 36 + ...ecorators.5(module=commonjs,target=es5).js | 39 + ...rators.5(module=commonjs,target=esnext).js | 26 + ...corators.5(module=esnext,target=es2015).js | 34 + ...sDecorators.5(module=esnext,target=es5).js | 37 + ...corators.5(module=esnext,target=esnext).js | 23 + ...corators.5(module=system,target=es2015).js | 42 + ...sDecorators.5(module=system,target=es5).js | 45 + ...corators.5(module=system,target=esnext).js | 33 + ...rators.6(module=commonjs,target=es2015).js | 36 + ...ecorators.6(module=commonjs,target=es5).js | 39 + ...rators.6(module=commonjs,target=esnext).js | 26 + ...corators.6(module=esnext,target=es2015).js | 34 + ...sDecorators.6(module=esnext,target=es5).js | 37 + ...corators.6(module=esnext,target=esnext).js | 23 + ...corators.6(module=system,target=es2015).js | 42 + ...sDecorators.6(module=system,target=es5).js | 45 + ...corators.6(module=system,target=esnext).js | 33 + ...rators.7(module=commonjs,target=es2015).js | 34 + ...ecorators.7(module=commonjs,target=es5).js | 37 + ...rators.7(module=commonjs,target=esnext).js | 23 + ...corators.7(module=esnext,target=es2015).js | 33 + ...sDecorators.7(module=esnext,target=es5).js | 36 + ...corators.7(module=esnext,target=esnext).js | 22 + ...corators.7(module=system,target=es2015).js | 41 + ...sDecorators.7(module=system,target=es5).js | 44 + ...corators.7(module=system,target=esnext).js | 31 + ...rators.8(module=commonjs,target=es2015).js | 36 + ...ecorators.8(module=commonjs,target=es5).js | 39 + ...rators.8(module=commonjs,target=esnext).js | 25 + ...corators.8(module=esnext,target=es2015).js | 33 + ...sDecorators.8(module=esnext,target=es5).js | 36 + ...corators.8(module=esnext,target=esnext).js | 22 + ...corators.8(module=system,target=es2015).js | 42 + ...sDecorators.8(module=system,target=es5).js | 45 + ...corators.8(module=system,target=esnext).js | 32 + ...rators.9(module=commonjs,target=es2015).js | 35 + ...ecorators.9(module=commonjs,target=es5).js | 38 + ...rators.9(module=commonjs,target=esnext).js | 24 + ...corators.9(module=esnext,target=es2015).js | 33 + ...sDecorators.9(module=esnext,target=es5).js | 36 + ...corators.9(module=esnext,target=esnext).js | 22 + ...corators.9(module=system,target=es2015).js | 42 + ...sDecorators.9(module=system,target=es5).js | 45 + ...corators.9(module=system,target=esnext).js | 32 + .../for-of-excess-declarations.ts | 4 + .../awaitUsingDeclarations.1.ts | 102 + .../awaitUsingDeclarations.10.ts | 11 + .../awaitUsingDeclarations.11.ts | 7 + .../awaitUsingDeclarations.12.ts | 8 + .../awaitUsingDeclarations.13.ts | 10 + .../awaitUsingDeclarations.14.ts | 13 + .../awaitUsingDeclarations.15.ts | 9 + .../awaitUsingDeclarations.2.ts | 11 + .../awaitUsingDeclarations.3.ts | 13 + .../awaitUsingDeclarations.4.ts | 10 + .../awaitUsingDeclarations.5.ts | 12 + .../awaitUsingDeclarations.6.ts | 11 + .../awaitUsingDeclarations.7.ts | 10 + .../awaitUsingDeclarations.8.ts | 10 + .../awaitUsingDeclarations.9.ts | 10 + .../awaitUsingDeclarationsInFor.ts | 11 + .../awaitUsingDeclarationsInForAwaitOf.ts | 8 + .../awaitUsingDeclarationsInForIn.ts | 9 + .../awaitUsingDeclarationsInForOf.1.ts | 9 + .../awaitUsingDeclarationsInForOf.2.ts | 9 + .../awaitUsingDeclarationsInForOf.3.ts | 9 + ...waitUsingDeclarationsTopLevelOfModule.1.ts | 18 + ...awaitUsingDeclarationsWithImportHelpers.ts | 11 + .../usingDeclarations/usingDeclarations.1.ts | 156 ++ .../usingDeclarations/usingDeclarations.10.ts | 7 + .../usingDeclarations/usingDeclarations.11.ts | 38 + .../usingDeclarations/usingDeclarations.12.ts | 17 + .../usingDeclarations/usingDeclarations.13.ts | 7 + .../usingDeclarations/usingDeclarations.14.ts | 6 + .../usingDeclarations/usingDeclarations.15.ts | 9 + .../usingDeclarations/usingDeclarations.2.ts | 9 + .../usingDeclarations/usingDeclarations.3.ts | 11 + .../usingDeclarations/usingDeclarations.4.ts | 8 + .../usingDeclarations/usingDeclarations.5.ts | 10 + .../usingDeclarations/usingDeclarations.6.ts | 8 + .../usingDeclarations/usingDeclarations.7.ts | 10 + .../usingDeclarations/usingDeclarations.8.ts | 8 + .../usingDeclarations/usingDeclarations.9.ts | 8 + .../usingDeclarationsDeclarationEmit.1.ts | 10 + .../usingDeclarationsDeclarationEmit.2.ts | 10 + .../usingDeclarationsInFor.ts | 7 + .../usingDeclarationsInForAwaitOf.ts | 9 + .../usingDeclarationsInForIn.ts | 7 + .../usingDeclarationsInForOf.1.ts | 7 + .../usingDeclarationsInForOf.2.ts | 7 + .../usingDeclarationsInForOf.3.ts | 7 + ...NamedEvaluationDecoratorsAndClassFields.ts | 26 + .../usingDeclarationsTopLevelOfModule.1.ts | 18 + .../usingDeclarationsTopLevelOfModule.2.ts | 12 + .../usingDeclarationsTopLevelOfModule.3.ts | 18 + ...singDeclarationsWithESClassDecorators.1.ts | 15 + ...ingDeclarationsWithESClassDecorators.10.ts | 15 + ...ingDeclarationsWithESClassDecorators.11.ts | 17 + ...ingDeclarationsWithESClassDecorators.12.ts | 17 + ...singDeclarationsWithESClassDecorators.2.ts | 15 + ...singDeclarationsWithESClassDecorators.3.ts | 17 + ...singDeclarationsWithESClassDecorators.4.ts | 15 + ...singDeclarationsWithESClassDecorators.5.ts | 17 + ...singDeclarationsWithESClassDecorators.6.ts | 17 + ...singDeclarationsWithESClassDecorators.7.ts | 16 + ...singDeclarationsWithESClassDecorators.8.ts | 15 + ...singDeclarationsWithESClassDecorators.9.ts | 18 + .../usingDeclarationsWithImportHelpers.ts | 11 + ...DeclarationsWithLegacyClassDecorators.1.ts | 15 + ...eclarationsWithLegacyClassDecorators.10.ts | 15 + ...eclarationsWithLegacyClassDecorators.11.ts | 17 + ...eclarationsWithLegacyClassDecorators.12.ts | 17 + ...DeclarationsWithLegacyClassDecorators.2.ts | 15 + ...DeclarationsWithLegacyClassDecorators.3.ts | 15 + ...DeclarationsWithLegacyClassDecorators.4.ts | 15 + ...DeclarationsWithLegacyClassDecorators.5.ts | 17 + ...DeclarationsWithLegacyClassDecorators.6.ts | 17 + ...DeclarationsWithLegacyClassDecorators.7.ts | 15 + ...DeclarationsWithLegacyClassDecorators.8.ts | 15 + ...DeclarationsWithLegacyClassDecorators.9.ts | 15 + 674 files changed, 29610 insertions(+), 2826 deletions(-) create mode 100644 src/compiler/transformers/classThis.ts create mode 100644 src/compiler/transformers/namedEvaluation.ts create mode 100644 src/lib/esnext.disposable.d.ts create mode 100644 src/testRunner/unittests/evaluation/awaitUsingDeclarations.ts create mode 100644 src/testRunner/unittests/evaluation/usingDeclarations.ts create mode 100644 tests/baselines/reference/awaitUsingDeclarations.1(target=es2015).errors.txt create mode 100644 tests/baselines/reference/awaitUsingDeclarations.1(target=es2015).js create mode 100644 tests/baselines/reference/awaitUsingDeclarations.1(target=es2017).js create mode 100644 tests/baselines/reference/awaitUsingDeclarations.1(target=es2022).js create mode 100644 tests/baselines/reference/awaitUsingDeclarations.1(target=es5).errors.txt create mode 100644 tests/baselines/reference/awaitUsingDeclarations.1(target=es5).js create mode 100644 tests/baselines/reference/awaitUsingDeclarations.1(target=esnext).js create mode 100644 tests/baselines/reference/awaitUsingDeclarations.10.errors.txt create mode 100644 tests/baselines/reference/awaitUsingDeclarations.10.js create mode 100644 tests/baselines/reference/awaitUsingDeclarations.11.errors.txt create mode 100644 tests/baselines/reference/awaitUsingDeclarations.11.js create mode 100644 tests/baselines/reference/awaitUsingDeclarations.12.errors.txt create mode 100644 tests/baselines/reference/awaitUsingDeclarations.12.js create mode 100644 tests/baselines/reference/awaitUsingDeclarations.13.errors.txt create mode 100644 tests/baselines/reference/awaitUsingDeclarations.13.js create mode 100644 tests/baselines/reference/awaitUsingDeclarations.14.errors.txt create mode 100644 tests/baselines/reference/awaitUsingDeclarations.14.js create mode 100644 tests/baselines/reference/awaitUsingDeclarations.15.js create mode 100644 tests/baselines/reference/awaitUsingDeclarations.2(target=es2015).errors.txt create mode 100644 tests/baselines/reference/awaitUsingDeclarations.2(target=es2015).js create mode 100644 tests/baselines/reference/awaitUsingDeclarations.2(target=es2017).js create mode 100644 tests/baselines/reference/awaitUsingDeclarations.2(target=es2022).js create mode 100644 tests/baselines/reference/awaitUsingDeclarations.2(target=es5).errors.txt create mode 100644 tests/baselines/reference/awaitUsingDeclarations.2(target=es5).js create mode 100644 tests/baselines/reference/awaitUsingDeclarations.2(target=esnext).js create mode 100644 tests/baselines/reference/awaitUsingDeclarations.3(target=es2015).errors.txt create mode 100644 tests/baselines/reference/awaitUsingDeclarations.3(target=es2015).js create mode 100644 tests/baselines/reference/awaitUsingDeclarations.3(target=es2017).js create mode 100644 tests/baselines/reference/awaitUsingDeclarations.3(target=es2022).js create mode 100644 tests/baselines/reference/awaitUsingDeclarations.3(target=es5).errors.txt create mode 100644 tests/baselines/reference/awaitUsingDeclarations.3(target=es5).js create mode 100644 tests/baselines/reference/awaitUsingDeclarations.3(target=esnext).js create mode 100644 tests/baselines/reference/awaitUsingDeclarations.4.errors.txt create mode 100644 tests/baselines/reference/awaitUsingDeclarations.4.js create mode 100644 tests/baselines/reference/awaitUsingDeclarations.5.errors.txt create mode 100644 tests/baselines/reference/awaitUsingDeclarations.5.js create mode 100644 tests/baselines/reference/awaitUsingDeclarations.6.errors.txt create mode 100644 tests/baselines/reference/awaitUsingDeclarations.6.js create mode 100644 tests/baselines/reference/awaitUsingDeclarations.7.errors.txt create mode 100644 tests/baselines/reference/awaitUsingDeclarations.7.js create mode 100644 tests/baselines/reference/awaitUsingDeclarations.8.errors.txt create mode 100644 tests/baselines/reference/awaitUsingDeclarations.8.js create mode 100644 tests/baselines/reference/awaitUsingDeclarations.9.errors.txt create mode 100644 tests/baselines/reference/awaitUsingDeclarations.9.js create mode 100644 tests/baselines/reference/awaitUsingDeclarationsInFor(target=es2015).js create mode 100644 tests/baselines/reference/awaitUsingDeclarationsInFor(target=es2017).js create mode 100644 tests/baselines/reference/awaitUsingDeclarationsInFor(target=es2022).js create mode 100644 tests/baselines/reference/awaitUsingDeclarationsInFor(target=es5).js create mode 100644 tests/baselines/reference/awaitUsingDeclarationsInFor(target=esnext).js create mode 100644 tests/baselines/reference/awaitUsingDeclarationsInForAwaitOf(target=es2015).js create mode 100644 tests/baselines/reference/awaitUsingDeclarationsInForAwaitOf(target=es2017).js create mode 100644 tests/baselines/reference/awaitUsingDeclarationsInForAwaitOf(target=es2022).js create mode 100644 tests/baselines/reference/awaitUsingDeclarationsInForAwaitOf(target=es5).js create mode 100644 tests/baselines/reference/awaitUsingDeclarationsInForAwaitOf(target=esnext).js create mode 100644 tests/baselines/reference/awaitUsingDeclarationsInForIn.errors.txt create mode 100644 tests/baselines/reference/awaitUsingDeclarationsInForIn.js create mode 100644 tests/baselines/reference/awaitUsingDeclarationsInForOf.1(target=es2015).js create mode 100644 tests/baselines/reference/awaitUsingDeclarationsInForOf.1(target=es2017).js create mode 100644 tests/baselines/reference/awaitUsingDeclarationsInForOf.1(target=es2022).js create mode 100644 tests/baselines/reference/awaitUsingDeclarationsInForOf.1(target=es5).js create mode 100644 tests/baselines/reference/awaitUsingDeclarationsInForOf.1(target=esnext).js create mode 100644 tests/baselines/reference/awaitUsingDeclarationsInForOf.2.errors.txt create mode 100644 tests/baselines/reference/awaitUsingDeclarationsInForOf.2.js create mode 100644 tests/baselines/reference/awaitUsingDeclarationsInForOf.3.errors.txt create mode 100644 tests/baselines/reference/awaitUsingDeclarationsInForOf.3.js create mode 100644 tests/baselines/reference/awaitUsingDeclarationsTopLevelOfModule.1(module=esnext).js create mode 100644 tests/baselines/reference/awaitUsingDeclarationsTopLevelOfModule.1(module=system).js create mode 100644 tests/baselines/reference/awaitUsingDeclarationsWithImportHelpers.errors.txt create mode 100644 tests/baselines/reference/awaitUsingDeclarationsWithImportHelpers.js create mode 100644 tests/baselines/reference/for-of-excess-declarations.errors.txt create mode 100644 tests/baselines/reference/for-of-excess-declarations.js create mode 100644 tests/baselines/reference/for-of-excess-declarations.symbols create mode 100644 tests/baselines/reference/for-of-excess-declarations.types create mode 100644 tests/baselines/reference/usingDeclarations.1(target=es2015).js create mode 100644 tests/baselines/reference/usingDeclarations.1(target=es2017).js create mode 100644 tests/baselines/reference/usingDeclarations.1(target=es2022).js create mode 100644 tests/baselines/reference/usingDeclarations.1(target=es5).js create mode 100644 tests/baselines/reference/usingDeclarations.1(target=esnext).js create mode 100644 tests/baselines/reference/usingDeclarations.10.errors.txt create mode 100644 tests/baselines/reference/usingDeclarations.10.js create mode 100644 tests/baselines/reference/usingDeclarations.11.js create mode 100644 tests/baselines/reference/usingDeclarations.12(usedefineforclassfields=false).js create mode 100644 tests/baselines/reference/usingDeclarations.12(usedefineforclassfields=true).js create mode 100644 tests/baselines/reference/usingDeclarations.13.errors.txt create mode 100644 tests/baselines/reference/usingDeclarations.13.js create mode 100644 tests/baselines/reference/usingDeclarations.14.errors.txt create mode 100644 tests/baselines/reference/usingDeclarations.14.js create mode 100644 tests/baselines/reference/usingDeclarations.15.js create mode 100644 tests/baselines/reference/usingDeclarations.2(target=es2015).js create mode 100644 tests/baselines/reference/usingDeclarations.2(target=es2017).js create mode 100644 tests/baselines/reference/usingDeclarations.2(target=es2022).js create mode 100644 tests/baselines/reference/usingDeclarations.2(target=es5).js create mode 100644 tests/baselines/reference/usingDeclarations.2(target=esnext).js create mode 100644 tests/baselines/reference/usingDeclarations.3(target=es2015).js create mode 100644 tests/baselines/reference/usingDeclarations.3(target=es2017).js create mode 100644 tests/baselines/reference/usingDeclarations.3(target=es2022).js create mode 100644 tests/baselines/reference/usingDeclarations.3(target=es5).js create mode 100644 tests/baselines/reference/usingDeclarations.3(target=esnext).js create mode 100644 tests/baselines/reference/usingDeclarations.4.errors.txt create mode 100644 tests/baselines/reference/usingDeclarations.4.js create mode 100644 tests/baselines/reference/usingDeclarations.5.errors.txt create mode 100644 tests/baselines/reference/usingDeclarations.5.js create mode 100644 tests/baselines/reference/usingDeclarations.6.errors.txt create mode 100644 tests/baselines/reference/usingDeclarations.6.js create mode 100644 tests/baselines/reference/usingDeclarations.7.errors.txt create mode 100644 tests/baselines/reference/usingDeclarations.7.js create mode 100644 tests/baselines/reference/usingDeclarations.8.errors.txt create mode 100644 tests/baselines/reference/usingDeclarations.8.js create mode 100644 tests/baselines/reference/usingDeclarations.9.errors.txt create mode 100644 tests/baselines/reference/usingDeclarations.9.js create mode 100644 tests/baselines/reference/usingDeclarationsDeclarationEmit.1.js create mode 100644 tests/baselines/reference/usingDeclarationsDeclarationEmit.2.js create mode 100644 tests/baselines/reference/usingDeclarationsInFor(target=es2015).js create mode 100644 tests/baselines/reference/usingDeclarationsInFor(target=es2017).js create mode 100644 tests/baselines/reference/usingDeclarationsInFor(target=es2022).js create mode 100644 tests/baselines/reference/usingDeclarationsInFor(target=es5).js create mode 100644 tests/baselines/reference/usingDeclarationsInFor(target=esnext).js create mode 100644 tests/baselines/reference/usingDeclarationsInForAwaitOf(target=es2015).js create mode 100644 tests/baselines/reference/usingDeclarationsInForAwaitOf(target=es2017).js create mode 100644 tests/baselines/reference/usingDeclarationsInForAwaitOf(target=es2022).js create mode 100644 tests/baselines/reference/usingDeclarationsInForAwaitOf(target=es5).js create mode 100644 tests/baselines/reference/usingDeclarationsInForAwaitOf(target=esnext).js create mode 100644 tests/baselines/reference/usingDeclarationsInForIn.errors.txt create mode 100644 tests/baselines/reference/usingDeclarationsInForIn.js create mode 100644 tests/baselines/reference/usingDeclarationsInForOf.1(target=es2015).js create mode 100644 tests/baselines/reference/usingDeclarationsInForOf.1(target=es2017).js create mode 100644 tests/baselines/reference/usingDeclarationsInForOf.1(target=es2022).js create mode 100644 tests/baselines/reference/usingDeclarationsInForOf.1(target=es5).js create mode 100644 tests/baselines/reference/usingDeclarationsInForOf.1(target=esnext).js create mode 100644 tests/baselines/reference/usingDeclarationsInForOf.2.errors.txt create mode 100644 tests/baselines/reference/usingDeclarationsInForOf.2.js create mode 100644 tests/baselines/reference/usingDeclarationsInForOf.3.errors.txt create mode 100644 tests/baselines/reference/usingDeclarationsInForOf.3.js create mode 100644 tests/baselines/reference/usingDeclarationsNamedEvaluationDecoratorsAndClassFields.js create mode 100644 tests/baselines/reference/usingDeclarationsTopLevelOfModule.1(module=amd).js create mode 100644 tests/baselines/reference/usingDeclarationsTopLevelOfModule.1(module=commonjs).js create mode 100644 tests/baselines/reference/usingDeclarationsTopLevelOfModule.1(module=esnext).js create mode 100644 tests/baselines/reference/usingDeclarationsTopLevelOfModule.1(module=system).js create mode 100644 tests/baselines/reference/usingDeclarationsTopLevelOfModule.2(module=amd).js create mode 100644 tests/baselines/reference/usingDeclarationsTopLevelOfModule.2(module=commonjs).js create mode 100644 tests/baselines/reference/usingDeclarationsTopLevelOfModule.3(module=amd).js create mode 100644 tests/baselines/reference/usingDeclarationsTopLevelOfModule.3(module=commonjs).js create mode 100644 tests/baselines/reference/usingDeclarationsTopLevelOfModule.3(module=esnext).js create mode 100644 tests/baselines/reference/usingDeclarationsTopLevelOfModule.3(module=system).js create mode 100644 tests/baselines/reference/usingDeclarationsWithESClassDecorators.1(module=commonjs,target=es2015).js create mode 100644 tests/baselines/reference/usingDeclarationsWithESClassDecorators.1(module=commonjs,target=es5).js create mode 100644 tests/baselines/reference/usingDeclarationsWithESClassDecorators.1(module=commonjs,target=esnext).js create mode 100644 tests/baselines/reference/usingDeclarationsWithESClassDecorators.1(module=esnext,target=es2015).js create mode 100644 tests/baselines/reference/usingDeclarationsWithESClassDecorators.1(module=esnext,target=es5).js create mode 100644 tests/baselines/reference/usingDeclarationsWithESClassDecorators.1(module=esnext,target=esnext).js create mode 100644 tests/baselines/reference/usingDeclarationsWithESClassDecorators.1(module=system,target=es2015).js create mode 100644 tests/baselines/reference/usingDeclarationsWithESClassDecorators.1(module=system,target=es5).js create mode 100644 tests/baselines/reference/usingDeclarationsWithESClassDecorators.1(module=system,target=esnext).js create mode 100644 tests/baselines/reference/usingDeclarationsWithESClassDecorators.10(module=commonjs,target=es2015).js create mode 100644 tests/baselines/reference/usingDeclarationsWithESClassDecorators.10(module=commonjs,target=es5).js create mode 100644 tests/baselines/reference/usingDeclarationsWithESClassDecorators.10(module=commonjs,target=esnext).js create mode 100644 tests/baselines/reference/usingDeclarationsWithESClassDecorators.10(module=esnext,target=es2015).js create mode 100644 tests/baselines/reference/usingDeclarationsWithESClassDecorators.10(module=esnext,target=es5).js create mode 100644 tests/baselines/reference/usingDeclarationsWithESClassDecorators.10(module=esnext,target=esnext).js create mode 100644 tests/baselines/reference/usingDeclarationsWithESClassDecorators.10(module=system,target=es2015).js create mode 100644 tests/baselines/reference/usingDeclarationsWithESClassDecorators.10(module=system,target=es5).js create mode 100644 tests/baselines/reference/usingDeclarationsWithESClassDecorators.10(module=system,target=esnext).js create mode 100644 tests/baselines/reference/usingDeclarationsWithESClassDecorators.11(module=commonjs,target=es2015).js create mode 100644 tests/baselines/reference/usingDeclarationsWithESClassDecorators.11(module=commonjs,target=es5).js create mode 100644 tests/baselines/reference/usingDeclarationsWithESClassDecorators.11(module=commonjs,target=esnext).js create mode 100644 tests/baselines/reference/usingDeclarationsWithESClassDecorators.11(module=esnext,target=es2015).js create mode 100644 tests/baselines/reference/usingDeclarationsWithESClassDecorators.11(module=esnext,target=es5).js create mode 100644 tests/baselines/reference/usingDeclarationsWithESClassDecorators.11(module=esnext,target=esnext).js create mode 100644 tests/baselines/reference/usingDeclarationsWithESClassDecorators.11(module=system,target=es2015).js create mode 100644 tests/baselines/reference/usingDeclarationsWithESClassDecorators.11(module=system,target=es5).js create mode 100644 tests/baselines/reference/usingDeclarationsWithESClassDecorators.11(module=system,target=esnext).js create mode 100644 tests/baselines/reference/usingDeclarationsWithESClassDecorators.12(module=commonjs,target=es2015).js create mode 100644 tests/baselines/reference/usingDeclarationsWithESClassDecorators.12(module=commonjs,target=es5).js create mode 100644 tests/baselines/reference/usingDeclarationsWithESClassDecorators.12(module=commonjs,target=esnext).js create mode 100644 tests/baselines/reference/usingDeclarationsWithESClassDecorators.12(module=esnext,target=es2015).js create mode 100644 tests/baselines/reference/usingDeclarationsWithESClassDecorators.12(module=esnext,target=es5).js create mode 100644 tests/baselines/reference/usingDeclarationsWithESClassDecorators.12(module=esnext,target=esnext).js create mode 100644 tests/baselines/reference/usingDeclarationsWithESClassDecorators.12(module=system,target=es2015).js create mode 100644 tests/baselines/reference/usingDeclarationsWithESClassDecorators.12(module=system,target=es5).js create mode 100644 tests/baselines/reference/usingDeclarationsWithESClassDecorators.12(module=system,target=esnext).js create mode 100644 tests/baselines/reference/usingDeclarationsWithESClassDecorators.2(module=commonjs,target=es2015).js create mode 100644 tests/baselines/reference/usingDeclarationsWithESClassDecorators.2(module=commonjs,target=es5).js create mode 100644 tests/baselines/reference/usingDeclarationsWithESClassDecorators.2(module=commonjs,target=esnext).js create mode 100644 tests/baselines/reference/usingDeclarationsWithESClassDecorators.2(module=esnext,target=es2015).js create mode 100644 tests/baselines/reference/usingDeclarationsWithESClassDecorators.2(module=esnext,target=es5).js create mode 100644 tests/baselines/reference/usingDeclarationsWithESClassDecorators.2(module=esnext,target=esnext).js create mode 100644 tests/baselines/reference/usingDeclarationsWithESClassDecorators.2(module=system,target=es2015).js create mode 100644 tests/baselines/reference/usingDeclarationsWithESClassDecorators.2(module=system,target=es5).js create mode 100644 tests/baselines/reference/usingDeclarationsWithESClassDecorators.2(module=system,target=esnext).js create mode 100644 tests/baselines/reference/usingDeclarationsWithESClassDecorators.3(module=commonjs,target=es2015).js create mode 100644 tests/baselines/reference/usingDeclarationsWithESClassDecorators.3(module=commonjs,target=es5).js create mode 100644 tests/baselines/reference/usingDeclarationsWithESClassDecorators.3(module=commonjs,target=esnext).js create mode 100644 tests/baselines/reference/usingDeclarationsWithESClassDecorators.3(module=esnext,target=es2015).js create mode 100644 tests/baselines/reference/usingDeclarationsWithESClassDecorators.3(module=esnext,target=es5).js create mode 100644 tests/baselines/reference/usingDeclarationsWithESClassDecorators.3(module=esnext,target=esnext).js create mode 100644 tests/baselines/reference/usingDeclarationsWithESClassDecorators.3(module=system,target=es2015).js create mode 100644 tests/baselines/reference/usingDeclarationsWithESClassDecorators.3(module=system,target=es5).js create mode 100644 tests/baselines/reference/usingDeclarationsWithESClassDecorators.3(module=system,target=esnext).js create mode 100644 tests/baselines/reference/usingDeclarationsWithESClassDecorators.4(module=commonjs,target=es2015).js create mode 100644 tests/baselines/reference/usingDeclarationsWithESClassDecorators.4(module=commonjs,target=es5).js create mode 100644 tests/baselines/reference/usingDeclarationsWithESClassDecorators.4(module=commonjs,target=esnext).js create mode 100644 tests/baselines/reference/usingDeclarationsWithESClassDecorators.4(module=esnext,target=es2015).js create mode 100644 tests/baselines/reference/usingDeclarationsWithESClassDecorators.4(module=esnext,target=es5).js create mode 100644 tests/baselines/reference/usingDeclarationsWithESClassDecorators.4(module=esnext,target=esnext).js create mode 100644 tests/baselines/reference/usingDeclarationsWithESClassDecorators.4(module=system,target=es2015).js create mode 100644 tests/baselines/reference/usingDeclarationsWithESClassDecorators.4(module=system,target=es5).js create mode 100644 tests/baselines/reference/usingDeclarationsWithESClassDecorators.4(module=system,target=esnext).js create mode 100644 tests/baselines/reference/usingDeclarationsWithESClassDecorators.5(module=commonjs,target=es2015).js create mode 100644 tests/baselines/reference/usingDeclarationsWithESClassDecorators.5(module=commonjs,target=es5).js create mode 100644 tests/baselines/reference/usingDeclarationsWithESClassDecorators.5(module=commonjs,target=esnext).js create mode 100644 tests/baselines/reference/usingDeclarationsWithESClassDecorators.5(module=esnext,target=es2015).js create mode 100644 tests/baselines/reference/usingDeclarationsWithESClassDecorators.5(module=esnext,target=es5).js create mode 100644 tests/baselines/reference/usingDeclarationsWithESClassDecorators.5(module=esnext,target=esnext).js create mode 100644 tests/baselines/reference/usingDeclarationsWithESClassDecorators.5(module=system,target=es2015).js create mode 100644 tests/baselines/reference/usingDeclarationsWithESClassDecorators.5(module=system,target=es5).js create mode 100644 tests/baselines/reference/usingDeclarationsWithESClassDecorators.5(module=system,target=esnext).js create mode 100644 tests/baselines/reference/usingDeclarationsWithESClassDecorators.6(module=commonjs,target=es2015).js create mode 100644 tests/baselines/reference/usingDeclarationsWithESClassDecorators.6(module=commonjs,target=es5).js create mode 100644 tests/baselines/reference/usingDeclarationsWithESClassDecorators.6(module=commonjs,target=esnext).js create mode 100644 tests/baselines/reference/usingDeclarationsWithESClassDecorators.6(module=esnext,target=es2015).js create mode 100644 tests/baselines/reference/usingDeclarationsWithESClassDecorators.6(module=esnext,target=es5).js create mode 100644 tests/baselines/reference/usingDeclarationsWithESClassDecorators.6(module=esnext,target=esnext).js create mode 100644 tests/baselines/reference/usingDeclarationsWithESClassDecorators.6(module=system,target=es2015).js create mode 100644 tests/baselines/reference/usingDeclarationsWithESClassDecorators.6(module=system,target=es5).js create mode 100644 tests/baselines/reference/usingDeclarationsWithESClassDecorators.6(module=system,target=esnext).js create mode 100644 tests/baselines/reference/usingDeclarationsWithESClassDecorators.7(module=commonjs,target=es2015).js create mode 100644 tests/baselines/reference/usingDeclarationsWithESClassDecorators.7(module=commonjs,target=es5).js create mode 100644 tests/baselines/reference/usingDeclarationsWithESClassDecorators.7(module=commonjs,target=esnext).js create mode 100644 tests/baselines/reference/usingDeclarationsWithESClassDecorators.7(module=esnext,target=es2015).js create mode 100644 tests/baselines/reference/usingDeclarationsWithESClassDecorators.7(module=esnext,target=es5).js create mode 100644 tests/baselines/reference/usingDeclarationsWithESClassDecorators.7(module=esnext,target=esnext).js create mode 100644 tests/baselines/reference/usingDeclarationsWithESClassDecorators.7(module=system,target=es2015).js create mode 100644 tests/baselines/reference/usingDeclarationsWithESClassDecorators.7(module=system,target=es5).js create mode 100644 tests/baselines/reference/usingDeclarationsWithESClassDecorators.7(module=system,target=esnext).js create mode 100644 tests/baselines/reference/usingDeclarationsWithESClassDecorators.8(module=commonjs,target=es2015).js create mode 100644 tests/baselines/reference/usingDeclarationsWithESClassDecorators.8(module=commonjs,target=es5).js create mode 100644 tests/baselines/reference/usingDeclarationsWithESClassDecorators.8(module=commonjs,target=esnext).js create mode 100644 tests/baselines/reference/usingDeclarationsWithESClassDecorators.8(module=esnext,target=es2015).js create mode 100644 tests/baselines/reference/usingDeclarationsWithESClassDecorators.8(module=esnext,target=es5).js create mode 100644 tests/baselines/reference/usingDeclarationsWithESClassDecorators.8(module=esnext,target=esnext).js create mode 100644 tests/baselines/reference/usingDeclarationsWithESClassDecorators.8(module=system,target=es2015).js create mode 100644 tests/baselines/reference/usingDeclarationsWithESClassDecorators.8(module=system,target=es5).js create mode 100644 tests/baselines/reference/usingDeclarationsWithESClassDecorators.8(module=system,target=esnext).js create mode 100644 tests/baselines/reference/usingDeclarationsWithESClassDecorators.9(module=commonjs,target=es2015).js create mode 100644 tests/baselines/reference/usingDeclarationsWithESClassDecorators.9(module=commonjs,target=es5).js create mode 100644 tests/baselines/reference/usingDeclarationsWithESClassDecorators.9(module=commonjs,target=esnext).js create mode 100644 tests/baselines/reference/usingDeclarationsWithESClassDecorators.9(module=esnext,target=es2015).js create mode 100644 tests/baselines/reference/usingDeclarationsWithESClassDecorators.9(module=esnext,target=es5).js create mode 100644 tests/baselines/reference/usingDeclarationsWithESClassDecorators.9(module=esnext,target=esnext).js create mode 100644 tests/baselines/reference/usingDeclarationsWithESClassDecorators.9(module=system,target=es2015).js create mode 100644 tests/baselines/reference/usingDeclarationsWithESClassDecorators.9(module=system,target=es5).js create mode 100644 tests/baselines/reference/usingDeclarationsWithESClassDecorators.9(module=system,target=esnext).js create mode 100644 tests/baselines/reference/usingDeclarationsWithImportHelpers.errors.txt create mode 100644 tests/baselines/reference/usingDeclarationsWithImportHelpers.js create mode 100644 tests/baselines/reference/usingDeclarationsWithLegacyClassDecorators.1(module=commonjs,target=es2015).js create mode 100644 tests/baselines/reference/usingDeclarationsWithLegacyClassDecorators.1(module=commonjs,target=es5).js create mode 100644 tests/baselines/reference/usingDeclarationsWithLegacyClassDecorators.1(module=commonjs,target=esnext).js create mode 100644 tests/baselines/reference/usingDeclarationsWithLegacyClassDecorators.1(module=esnext,target=es2015).js create mode 100644 tests/baselines/reference/usingDeclarationsWithLegacyClassDecorators.1(module=esnext,target=es5).js create mode 100644 tests/baselines/reference/usingDeclarationsWithLegacyClassDecorators.1(module=esnext,target=esnext).js create mode 100644 tests/baselines/reference/usingDeclarationsWithLegacyClassDecorators.1(module=system,target=es2015).js create mode 100644 tests/baselines/reference/usingDeclarationsWithLegacyClassDecorators.1(module=system,target=es5).js create mode 100644 tests/baselines/reference/usingDeclarationsWithLegacyClassDecorators.1(module=system,target=esnext).js create mode 100644 tests/baselines/reference/usingDeclarationsWithLegacyClassDecorators.10(module=commonjs,target=es2015).js create mode 100644 tests/baselines/reference/usingDeclarationsWithLegacyClassDecorators.10(module=commonjs,target=es5).js create mode 100644 tests/baselines/reference/usingDeclarationsWithLegacyClassDecorators.10(module=commonjs,target=esnext).js create mode 100644 tests/baselines/reference/usingDeclarationsWithLegacyClassDecorators.10(module=esnext,target=es2015).js create mode 100644 tests/baselines/reference/usingDeclarationsWithLegacyClassDecorators.10(module=esnext,target=es5).js create mode 100644 tests/baselines/reference/usingDeclarationsWithLegacyClassDecorators.10(module=esnext,target=esnext).js create mode 100644 tests/baselines/reference/usingDeclarationsWithLegacyClassDecorators.10(module=system,target=es2015).js create mode 100644 tests/baselines/reference/usingDeclarationsWithLegacyClassDecorators.10(module=system,target=es5).js create mode 100644 tests/baselines/reference/usingDeclarationsWithLegacyClassDecorators.10(module=system,target=esnext).js create mode 100644 tests/baselines/reference/usingDeclarationsWithLegacyClassDecorators.11(module=commonjs,target=es2015).js create mode 100644 tests/baselines/reference/usingDeclarationsWithLegacyClassDecorators.11(module=commonjs,target=es5).js create mode 100644 tests/baselines/reference/usingDeclarationsWithLegacyClassDecorators.11(module=commonjs,target=esnext).js create mode 100644 tests/baselines/reference/usingDeclarationsWithLegacyClassDecorators.11(module=esnext,target=es2015).js create mode 100644 tests/baselines/reference/usingDeclarationsWithLegacyClassDecorators.11(module=esnext,target=es5).js create mode 100644 tests/baselines/reference/usingDeclarationsWithLegacyClassDecorators.11(module=esnext,target=esnext).js create mode 100644 tests/baselines/reference/usingDeclarationsWithLegacyClassDecorators.11(module=system,target=es2015).js create mode 100644 tests/baselines/reference/usingDeclarationsWithLegacyClassDecorators.11(module=system,target=es5).js create mode 100644 tests/baselines/reference/usingDeclarationsWithLegacyClassDecorators.11(module=system,target=esnext).js create mode 100644 tests/baselines/reference/usingDeclarationsWithLegacyClassDecorators.12(module=commonjs,target=es2015).js create mode 100644 tests/baselines/reference/usingDeclarationsWithLegacyClassDecorators.12(module=commonjs,target=es5).js create mode 100644 tests/baselines/reference/usingDeclarationsWithLegacyClassDecorators.12(module=commonjs,target=esnext).js create mode 100644 tests/baselines/reference/usingDeclarationsWithLegacyClassDecorators.12(module=esnext,target=es2015).js create mode 100644 tests/baselines/reference/usingDeclarationsWithLegacyClassDecorators.12(module=esnext,target=es5).js create mode 100644 tests/baselines/reference/usingDeclarationsWithLegacyClassDecorators.12(module=esnext,target=esnext).js create mode 100644 tests/baselines/reference/usingDeclarationsWithLegacyClassDecorators.12(module=system,target=es2015).js create mode 100644 tests/baselines/reference/usingDeclarationsWithLegacyClassDecorators.12(module=system,target=es5).js create mode 100644 tests/baselines/reference/usingDeclarationsWithLegacyClassDecorators.12(module=system,target=esnext).js create mode 100644 tests/baselines/reference/usingDeclarationsWithLegacyClassDecorators.2(module=commonjs,target=es2015).js create mode 100644 tests/baselines/reference/usingDeclarationsWithLegacyClassDecorators.2(module=commonjs,target=es5).js create mode 100644 tests/baselines/reference/usingDeclarationsWithLegacyClassDecorators.2(module=commonjs,target=esnext).js create mode 100644 tests/baselines/reference/usingDeclarationsWithLegacyClassDecorators.2(module=esnext,target=es2015).js create mode 100644 tests/baselines/reference/usingDeclarationsWithLegacyClassDecorators.2(module=esnext,target=es5).js create mode 100644 tests/baselines/reference/usingDeclarationsWithLegacyClassDecorators.2(module=esnext,target=esnext).js create mode 100644 tests/baselines/reference/usingDeclarationsWithLegacyClassDecorators.2(module=system,target=es2015).js create mode 100644 tests/baselines/reference/usingDeclarationsWithLegacyClassDecorators.2(module=system,target=es5).js create mode 100644 tests/baselines/reference/usingDeclarationsWithLegacyClassDecorators.2(module=system,target=esnext).js create mode 100644 tests/baselines/reference/usingDeclarationsWithLegacyClassDecorators.3(module=commonjs,target=es2015).js create mode 100644 tests/baselines/reference/usingDeclarationsWithLegacyClassDecorators.3(module=commonjs,target=es5).js create mode 100644 tests/baselines/reference/usingDeclarationsWithLegacyClassDecorators.3(module=commonjs,target=esnext).js create mode 100644 tests/baselines/reference/usingDeclarationsWithLegacyClassDecorators.3(module=esnext,target=es2015).js create mode 100644 tests/baselines/reference/usingDeclarationsWithLegacyClassDecorators.3(module=esnext,target=es5).js create mode 100644 tests/baselines/reference/usingDeclarationsWithLegacyClassDecorators.3(module=esnext,target=esnext).js create mode 100644 tests/baselines/reference/usingDeclarationsWithLegacyClassDecorators.3(module=system,target=es2015).js create mode 100644 tests/baselines/reference/usingDeclarationsWithLegacyClassDecorators.3(module=system,target=es5).js create mode 100644 tests/baselines/reference/usingDeclarationsWithLegacyClassDecorators.3(module=system,target=esnext).js create mode 100644 tests/baselines/reference/usingDeclarationsWithLegacyClassDecorators.4(module=commonjs,target=es2015).js create mode 100644 tests/baselines/reference/usingDeclarationsWithLegacyClassDecorators.4(module=commonjs,target=es5).js create mode 100644 tests/baselines/reference/usingDeclarationsWithLegacyClassDecorators.4(module=commonjs,target=esnext).js create mode 100644 tests/baselines/reference/usingDeclarationsWithLegacyClassDecorators.4(module=esnext,target=es2015).js create mode 100644 tests/baselines/reference/usingDeclarationsWithLegacyClassDecorators.4(module=esnext,target=es5).js create mode 100644 tests/baselines/reference/usingDeclarationsWithLegacyClassDecorators.4(module=esnext,target=esnext).js create mode 100644 tests/baselines/reference/usingDeclarationsWithLegacyClassDecorators.4(module=system,target=es2015).js create mode 100644 tests/baselines/reference/usingDeclarationsWithLegacyClassDecorators.4(module=system,target=es5).js create mode 100644 tests/baselines/reference/usingDeclarationsWithLegacyClassDecorators.4(module=system,target=esnext).js create mode 100644 tests/baselines/reference/usingDeclarationsWithLegacyClassDecorators.5(module=commonjs,target=es2015).js create mode 100644 tests/baselines/reference/usingDeclarationsWithLegacyClassDecorators.5(module=commonjs,target=es5).js create mode 100644 tests/baselines/reference/usingDeclarationsWithLegacyClassDecorators.5(module=commonjs,target=esnext).js create mode 100644 tests/baselines/reference/usingDeclarationsWithLegacyClassDecorators.5(module=esnext,target=es2015).js create mode 100644 tests/baselines/reference/usingDeclarationsWithLegacyClassDecorators.5(module=esnext,target=es5).js create mode 100644 tests/baselines/reference/usingDeclarationsWithLegacyClassDecorators.5(module=esnext,target=esnext).js create mode 100644 tests/baselines/reference/usingDeclarationsWithLegacyClassDecorators.5(module=system,target=es2015).js create mode 100644 tests/baselines/reference/usingDeclarationsWithLegacyClassDecorators.5(module=system,target=es5).js create mode 100644 tests/baselines/reference/usingDeclarationsWithLegacyClassDecorators.5(module=system,target=esnext).js create mode 100644 tests/baselines/reference/usingDeclarationsWithLegacyClassDecorators.6(module=commonjs,target=es2015).js create mode 100644 tests/baselines/reference/usingDeclarationsWithLegacyClassDecorators.6(module=commonjs,target=es5).js create mode 100644 tests/baselines/reference/usingDeclarationsWithLegacyClassDecorators.6(module=commonjs,target=esnext).js create mode 100644 tests/baselines/reference/usingDeclarationsWithLegacyClassDecorators.6(module=esnext,target=es2015).js create mode 100644 tests/baselines/reference/usingDeclarationsWithLegacyClassDecorators.6(module=esnext,target=es5).js create mode 100644 tests/baselines/reference/usingDeclarationsWithLegacyClassDecorators.6(module=esnext,target=esnext).js create mode 100644 tests/baselines/reference/usingDeclarationsWithLegacyClassDecorators.6(module=system,target=es2015).js create mode 100644 tests/baselines/reference/usingDeclarationsWithLegacyClassDecorators.6(module=system,target=es5).js create mode 100644 tests/baselines/reference/usingDeclarationsWithLegacyClassDecorators.6(module=system,target=esnext).js create mode 100644 tests/baselines/reference/usingDeclarationsWithLegacyClassDecorators.7(module=commonjs,target=es2015).js create mode 100644 tests/baselines/reference/usingDeclarationsWithLegacyClassDecorators.7(module=commonjs,target=es5).js create mode 100644 tests/baselines/reference/usingDeclarationsWithLegacyClassDecorators.7(module=commonjs,target=esnext).js create mode 100644 tests/baselines/reference/usingDeclarationsWithLegacyClassDecorators.7(module=esnext,target=es2015).js create mode 100644 tests/baselines/reference/usingDeclarationsWithLegacyClassDecorators.7(module=esnext,target=es5).js create mode 100644 tests/baselines/reference/usingDeclarationsWithLegacyClassDecorators.7(module=esnext,target=esnext).js create mode 100644 tests/baselines/reference/usingDeclarationsWithLegacyClassDecorators.7(module=system,target=es2015).js create mode 100644 tests/baselines/reference/usingDeclarationsWithLegacyClassDecorators.7(module=system,target=es5).js create mode 100644 tests/baselines/reference/usingDeclarationsWithLegacyClassDecorators.7(module=system,target=esnext).js create mode 100644 tests/baselines/reference/usingDeclarationsWithLegacyClassDecorators.8(module=commonjs,target=es2015).js create mode 100644 tests/baselines/reference/usingDeclarationsWithLegacyClassDecorators.8(module=commonjs,target=es5).js create mode 100644 tests/baselines/reference/usingDeclarationsWithLegacyClassDecorators.8(module=commonjs,target=esnext).js create mode 100644 tests/baselines/reference/usingDeclarationsWithLegacyClassDecorators.8(module=esnext,target=es2015).js create mode 100644 tests/baselines/reference/usingDeclarationsWithLegacyClassDecorators.8(module=esnext,target=es5).js create mode 100644 tests/baselines/reference/usingDeclarationsWithLegacyClassDecorators.8(module=esnext,target=esnext).js create mode 100644 tests/baselines/reference/usingDeclarationsWithLegacyClassDecorators.8(module=system,target=es2015).js create mode 100644 tests/baselines/reference/usingDeclarationsWithLegacyClassDecorators.8(module=system,target=es5).js create mode 100644 tests/baselines/reference/usingDeclarationsWithLegacyClassDecorators.8(module=system,target=esnext).js create mode 100644 tests/baselines/reference/usingDeclarationsWithLegacyClassDecorators.9(module=commonjs,target=es2015).js create mode 100644 tests/baselines/reference/usingDeclarationsWithLegacyClassDecorators.9(module=commonjs,target=es5).js create mode 100644 tests/baselines/reference/usingDeclarationsWithLegacyClassDecorators.9(module=commonjs,target=esnext).js create mode 100644 tests/baselines/reference/usingDeclarationsWithLegacyClassDecorators.9(module=esnext,target=es2015).js create mode 100644 tests/baselines/reference/usingDeclarationsWithLegacyClassDecorators.9(module=esnext,target=es5).js create mode 100644 tests/baselines/reference/usingDeclarationsWithLegacyClassDecorators.9(module=esnext,target=esnext).js create mode 100644 tests/baselines/reference/usingDeclarationsWithLegacyClassDecorators.9(module=system,target=es2015).js create mode 100644 tests/baselines/reference/usingDeclarationsWithLegacyClassDecorators.9(module=system,target=es5).js create mode 100644 tests/baselines/reference/usingDeclarationsWithLegacyClassDecorators.9(module=system,target=esnext).js create mode 100644 tests/cases/conformance/es6/for-ofStatements/for-of-excess-declarations.ts create mode 100644 tests/cases/conformance/statements/VariableStatements/usingDeclarations/awaitUsingDeclarations.1.ts create mode 100644 tests/cases/conformance/statements/VariableStatements/usingDeclarations/awaitUsingDeclarations.10.ts create mode 100644 tests/cases/conformance/statements/VariableStatements/usingDeclarations/awaitUsingDeclarations.11.ts create mode 100644 tests/cases/conformance/statements/VariableStatements/usingDeclarations/awaitUsingDeclarations.12.ts create mode 100644 tests/cases/conformance/statements/VariableStatements/usingDeclarations/awaitUsingDeclarations.13.ts create mode 100644 tests/cases/conformance/statements/VariableStatements/usingDeclarations/awaitUsingDeclarations.14.ts create mode 100644 tests/cases/conformance/statements/VariableStatements/usingDeclarations/awaitUsingDeclarations.15.ts create mode 100644 tests/cases/conformance/statements/VariableStatements/usingDeclarations/awaitUsingDeclarations.2.ts create mode 100644 tests/cases/conformance/statements/VariableStatements/usingDeclarations/awaitUsingDeclarations.3.ts create mode 100644 tests/cases/conformance/statements/VariableStatements/usingDeclarations/awaitUsingDeclarations.4.ts create mode 100644 tests/cases/conformance/statements/VariableStatements/usingDeclarations/awaitUsingDeclarations.5.ts create mode 100644 tests/cases/conformance/statements/VariableStatements/usingDeclarations/awaitUsingDeclarations.6.ts create mode 100644 tests/cases/conformance/statements/VariableStatements/usingDeclarations/awaitUsingDeclarations.7.ts create mode 100644 tests/cases/conformance/statements/VariableStatements/usingDeclarations/awaitUsingDeclarations.8.ts create mode 100644 tests/cases/conformance/statements/VariableStatements/usingDeclarations/awaitUsingDeclarations.9.ts create mode 100644 tests/cases/conformance/statements/VariableStatements/usingDeclarations/awaitUsingDeclarationsInFor.ts create mode 100644 tests/cases/conformance/statements/VariableStatements/usingDeclarations/awaitUsingDeclarationsInForAwaitOf.ts create mode 100644 tests/cases/conformance/statements/VariableStatements/usingDeclarations/awaitUsingDeclarationsInForIn.ts create mode 100644 tests/cases/conformance/statements/VariableStatements/usingDeclarations/awaitUsingDeclarationsInForOf.1.ts create mode 100644 tests/cases/conformance/statements/VariableStatements/usingDeclarations/awaitUsingDeclarationsInForOf.2.ts create mode 100644 tests/cases/conformance/statements/VariableStatements/usingDeclarations/awaitUsingDeclarationsInForOf.3.ts create mode 100644 tests/cases/conformance/statements/VariableStatements/usingDeclarations/awaitUsingDeclarationsTopLevelOfModule.1.ts create mode 100644 tests/cases/conformance/statements/VariableStatements/usingDeclarations/awaitUsingDeclarationsWithImportHelpers.ts create mode 100644 tests/cases/conformance/statements/VariableStatements/usingDeclarations/usingDeclarations.1.ts create mode 100644 tests/cases/conformance/statements/VariableStatements/usingDeclarations/usingDeclarations.10.ts create mode 100644 tests/cases/conformance/statements/VariableStatements/usingDeclarations/usingDeclarations.11.ts create mode 100644 tests/cases/conformance/statements/VariableStatements/usingDeclarations/usingDeclarations.12.ts create mode 100644 tests/cases/conformance/statements/VariableStatements/usingDeclarations/usingDeclarations.13.ts create mode 100644 tests/cases/conformance/statements/VariableStatements/usingDeclarations/usingDeclarations.14.ts create mode 100644 tests/cases/conformance/statements/VariableStatements/usingDeclarations/usingDeclarations.15.ts create mode 100644 tests/cases/conformance/statements/VariableStatements/usingDeclarations/usingDeclarations.2.ts create mode 100644 tests/cases/conformance/statements/VariableStatements/usingDeclarations/usingDeclarations.3.ts create mode 100644 tests/cases/conformance/statements/VariableStatements/usingDeclarations/usingDeclarations.4.ts create mode 100644 tests/cases/conformance/statements/VariableStatements/usingDeclarations/usingDeclarations.5.ts create mode 100644 tests/cases/conformance/statements/VariableStatements/usingDeclarations/usingDeclarations.6.ts create mode 100644 tests/cases/conformance/statements/VariableStatements/usingDeclarations/usingDeclarations.7.ts create mode 100644 tests/cases/conformance/statements/VariableStatements/usingDeclarations/usingDeclarations.8.ts create mode 100644 tests/cases/conformance/statements/VariableStatements/usingDeclarations/usingDeclarations.9.ts create mode 100644 tests/cases/conformance/statements/VariableStatements/usingDeclarations/usingDeclarationsDeclarationEmit.1.ts create mode 100644 tests/cases/conformance/statements/VariableStatements/usingDeclarations/usingDeclarationsDeclarationEmit.2.ts create mode 100644 tests/cases/conformance/statements/VariableStatements/usingDeclarations/usingDeclarationsInFor.ts create mode 100644 tests/cases/conformance/statements/VariableStatements/usingDeclarations/usingDeclarationsInForAwaitOf.ts create mode 100644 tests/cases/conformance/statements/VariableStatements/usingDeclarations/usingDeclarationsInForIn.ts create mode 100644 tests/cases/conformance/statements/VariableStatements/usingDeclarations/usingDeclarationsInForOf.1.ts create mode 100644 tests/cases/conformance/statements/VariableStatements/usingDeclarations/usingDeclarationsInForOf.2.ts create mode 100644 tests/cases/conformance/statements/VariableStatements/usingDeclarations/usingDeclarationsInForOf.3.ts create mode 100644 tests/cases/conformance/statements/VariableStatements/usingDeclarations/usingDeclarationsNamedEvaluationDecoratorsAndClassFields.ts create mode 100644 tests/cases/conformance/statements/VariableStatements/usingDeclarations/usingDeclarationsTopLevelOfModule.1.ts create mode 100644 tests/cases/conformance/statements/VariableStatements/usingDeclarations/usingDeclarationsTopLevelOfModule.2.ts create mode 100644 tests/cases/conformance/statements/VariableStatements/usingDeclarations/usingDeclarationsTopLevelOfModule.3.ts create mode 100644 tests/cases/conformance/statements/VariableStatements/usingDeclarations/usingDeclarationsWithESClassDecorators.1.ts create mode 100644 tests/cases/conformance/statements/VariableStatements/usingDeclarations/usingDeclarationsWithESClassDecorators.10.ts create mode 100644 tests/cases/conformance/statements/VariableStatements/usingDeclarations/usingDeclarationsWithESClassDecorators.11.ts create mode 100644 tests/cases/conformance/statements/VariableStatements/usingDeclarations/usingDeclarationsWithESClassDecorators.12.ts create mode 100644 tests/cases/conformance/statements/VariableStatements/usingDeclarations/usingDeclarationsWithESClassDecorators.2.ts create mode 100644 tests/cases/conformance/statements/VariableStatements/usingDeclarations/usingDeclarationsWithESClassDecorators.3.ts create mode 100644 tests/cases/conformance/statements/VariableStatements/usingDeclarations/usingDeclarationsWithESClassDecorators.4.ts create mode 100644 tests/cases/conformance/statements/VariableStatements/usingDeclarations/usingDeclarationsWithESClassDecorators.5.ts create mode 100644 tests/cases/conformance/statements/VariableStatements/usingDeclarations/usingDeclarationsWithESClassDecorators.6.ts create mode 100644 tests/cases/conformance/statements/VariableStatements/usingDeclarations/usingDeclarationsWithESClassDecorators.7.ts create mode 100644 tests/cases/conformance/statements/VariableStatements/usingDeclarations/usingDeclarationsWithESClassDecorators.8.ts create mode 100644 tests/cases/conformance/statements/VariableStatements/usingDeclarations/usingDeclarationsWithESClassDecorators.9.ts create mode 100644 tests/cases/conformance/statements/VariableStatements/usingDeclarations/usingDeclarationsWithImportHelpers.ts create mode 100644 tests/cases/conformance/statements/VariableStatements/usingDeclarations/usingDeclarationsWithLegacyClassDecorators.1.ts create mode 100644 tests/cases/conformance/statements/VariableStatements/usingDeclarations/usingDeclarationsWithLegacyClassDecorators.10.ts create mode 100644 tests/cases/conformance/statements/VariableStatements/usingDeclarations/usingDeclarationsWithLegacyClassDecorators.11.ts create mode 100644 tests/cases/conformance/statements/VariableStatements/usingDeclarations/usingDeclarationsWithLegacyClassDecorators.12.ts create mode 100644 tests/cases/conformance/statements/VariableStatements/usingDeclarations/usingDeclarationsWithLegacyClassDecorators.2.ts create mode 100644 tests/cases/conformance/statements/VariableStatements/usingDeclarations/usingDeclarationsWithLegacyClassDecorators.3.ts create mode 100644 tests/cases/conformance/statements/VariableStatements/usingDeclarations/usingDeclarationsWithLegacyClassDecorators.4.ts create mode 100644 tests/cases/conformance/statements/VariableStatements/usingDeclarations/usingDeclarationsWithLegacyClassDecorators.5.ts create mode 100644 tests/cases/conformance/statements/VariableStatements/usingDeclarations/usingDeclarationsWithLegacyClassDecorators.6.ts create mode 100644 tests/cases/conformance/statements/VariableStatements/usingDeclarations/usingDeclarationsWithLegacyClassDecorators.7.ts create mode 100644 tests/cases/conformance/statements/VariableStatements/usingDeclarations/usingDeclarationsWithLegacyClassDecorators.8.ts create mode 100644 tests/cases/conformance/statements/VariableStatements/usingDeclarations/usingDeclarationsWithLegacyClassDecorators.9.ts diff --git a/src/compiler/_namespaces/ts.ts b/src/compiler/_namespaces/ts.ts index 5a01767f96d44..34d731e880695 100644 --- a/src/compiler/_namespaces/ts.ts +++ b/src/compiler/_namespaces/ts.ts @@ -33,6 +33,8 @@ export * from "../visitorPublic"; export * from "../sourcemap"; export * from "../transformers/utilities"; export * from "../transformers/destructuring"; +export * from "../transformers/classThis"; +export * from "../transformers/namedEvaluation"; export * from "../transformers/taggedTemplate"; export * from "../transformers/ts"; export * from "../transformers/classFields"; diff --git a/src/compiler/binder.ts b/src/compiler/binder.ts index 4ebea0c522de0..21122302c3838 100644 --- a/src/compiler/binder.ts +++ b/src/compiler/binder.ts @@ -3727,7 +3727,7 @@ function isExecutableStatement(s: Statement): boolean { // Don't remove statements that can validly be used before they appear. return !isFunctionDeclaration(s) && !isPurelyTypeDeclaration(s) && !isEnumDeclaration(s) && // `var x;` may declare a variable used above - !(isVariableStatement(s) && !(getCombinedNodeFlags(s) & (NodeFlags.Let | NodeFlags.Const)) && s.declarationList.declarations.some(d => !d.initializer)); + !(isVariableStatement(s) && !(getCombinedNodeFlags(s) & (NodeFlags.BlockScoped)) && s.declarationList.declarations.some(d => !d.initializer)); } function isPurelyTypeDeclaration(s: Statement): boolean { diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index bbda1c5760ef9..31a927d63de62 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -609,7 +609,6 @@ import { isKnownSymbol, isLateVisibilityPaintedStatement, isLeftHandSideExpression, - isLet, isLineBreak, isLiteralComputedPropertyDeclarationName, isLiteralExpression, @@ -734,7 +733,6 @@ import { isValidESSymbolDeclaration, isValidTypeOnlyAliasUseSite, isValueSignatureDeclaration, - isVarConst, isVariableDeclaration, isVariableDeclarationInitializedToBareOrAccessedRequire, isVariableDeclarationInVariableStatement, @@ -1471,6 +1469,11 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker { /** This will be set during calls to `getResolvedSignature` where services determines an apparent number of arguments greater than what is actually provided. */ var apparentArgumentCount: number | undefined; + var lastGetCombinedNodeFlagsNode: Node | undefined; + var lastGetCombinedNodeFlagsResult = NodeFlags.None; + var lastGetCombinedModifierFlagsNode: Declaration | undefined; + var lastGetCombinedModifierFlagsResult = ModifierFlags.None; + // for public members that accept a Node or one of its subtypes, we must guard against // synthetic nodes created during transformations by calling `getParseTreeNode`. // for most of these, we perform the guard only on `checker` to avoid any possible @@ -2115,6 +2118,8 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker { var deferredGlobalImportMetaType: ObjectType; var deferredGlobalImportMetaExpressionType: ObjectType; var deferredGlobalImportCallOptionsType: ObjectType | undefined; + var deferredGlobalDisposableType: ObjectType | undefined; + var deferredGlobalAsyncDisposableType: ObjectType | undefined; var deferredGlobalExtractSymbol: Symbol | undefined; var deferredGlobalOmitSymbol: Symbol | undefined; var deferredGlobalAwaitedSymbol: Symbol | undefined; @@ -2395,7 +2400,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker { } function isDeprecatedDeclaration(declaration: Declaration) { - return !!(getCombinedNodeFlags(declaration) & NodeFlags.Deprecated); + return !!(getCombinedNodeFlagsCached(declaration) & NodeFlags.Deprecated); } function addDeprecatedSuggestion(location: Node, declarations: Node[], deprecatedEntity: string) { @@ -8682,7 +8687,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker { ? symbol.parent?.valueDeclaration && isSourceFile(symbol.parent?.valueDeclaration) ? NodeFlags.Const // exports are immutable in es6, which is what we emulate and check; so it's safe to mark all exports as `const` (there's no difference to consumers, but it allows unique symbol type declarations) : undefined - : isConstVariable(symbol) + : isConstantVariable(symbol) ? NodeFlags.Const : NodeFlags.Let; const name = (needsPostExportDefault || !(symbol.flags & SymbolFlags.Property)) ? localName : getUnusedName(localName, symbol); @@ -9957,7 +9962,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker { } const parent = getDeclarationContainer(node); // If the node is not exported or it is not ambient module element (except import declaration) - if (!(getCombinedModifierFlags(node as Declaration) & ModifierFlags.Export) && + if (!(getCombinedModifierFlagsCached(node as Declaration) & ModifierFlags.Export) && !(node.kind !== SyntaxKind.ImportEqualsDeclaration && parent.kind !== SyntaxKind.SourceFile && parent.flags & NodeFlags.Ambient)) { return isGlobalSourceFile(parent); } @@ -10483,11 +10488,11 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker { if ((noImplicitAny || isInJSFile(declaration)) && isVariableDeclaration(declaration) && !isBindingPattern(declaration.name) && - !(getCombinedModifierFlags(declaration) & ModifierFlags.Export) && !(declaration.flags & NodeFlags.Ambient)) { + !(getCombinedModifierFlagsCached(declaration) & ModifierFlags.Export) && !(declaration.flags & NodeFlags.Ambient)) { // If --noImplicitAny is on or the declaration is in a Javascript file, // use control flow tracked 'any' type for non-ambient, non-exported var or let variables with no // initializer or a 'null' or 'undefined' initializer. - if (!(getCombinedNodeFlags(declaration) & NodeFlags.Const) && (!declaration.initializer || isNullOrUndefined(declaration.initializer))) { + if (!(getCombinedNodeFlagsCached(declaration) & NodeFlags.Constant) && (!declaration.initializer || isNullOrUndefined(declaration.initializer))) { return autoType; } // Use control flow tracked 'any[]' type for non-ambient, non-exported variables with an empty array @@ -15836,6 +15841,14 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker { return (deferredGlobalIteratorReturnResultType ||= getGlobalType("IteratorReturnResult" as __String, /*arity*/ 1, reportErrors)) || emptyGenericType; } + function getGlobalDisposableType(reportErrors: boolean) { + return (deferredGlobalDisposableType ||= getGlobalType("Disposable" as __String, /*arity*/ 0, reportErrors)) || emptyObjectType; + } + + function getGlobalAsyncDisposableType(reportErrors: boolean) { + return (deferredGlobalAsyncDisposableType ||= getGlobalType("AsyncDisposable" as __String, /*arity*/ 0, reportErrors)) || emptyObjectType; + } + function getGlobalTypeOrUndefined(name: __String, arity = 0): ObjectType | undefined { const symbol = getGlobalSymbol(name, SymbolFlags.Type, /*diagnostic*/ undefined); return symbol && getTypeOfGlobalSymbol(symbol, arity) as GenericType; @@ -17316,7 +17329,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker { if (isCallLikeExpression(parent)) { return isCallOrNewExpression(parent) && isIdentifier(node) && hasMatchingArgument(parent, node); } - return every(symbol.declarations, d => !isFunctionLike(d) || !!(getCombinedNodeFlags(d) & NodeFlags.Deprecated)); + return every(symbol.declarations, d => !isFunctionLike(d) || isDeprecatedDeclaration(d)); } return true; } @@ -25475,7 +25488,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker { function tryGetNameFromEntityNameExpression(node: EntityNameOrEntityNameExpression) { const symbol = resolveEntityName(node, SymbolFlags.Value, /*ignoreErrors*/ true); - if (!symbol || !(isConstVariable(symbol) || (symbol.flags & SymbolFlags.EnumMember))) return undefined; + if (!symbol || !(isConstantVariable(symbol) || (symbol.flags & SymbolFlags.EnumMember))) return undefined; const declaration = symbol.valueDeclaration; if (declaration === undefined) return undefined; @@ -26490,7 +26503,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker { case SyntaxKind.Identifier: if (!isThisInTypeQuery(node)) { const symbol = getResolvedSymbol(node as Identifier); - return isConstVariable(symbol) || isParameterOrCatchClauseVariable(symbol) && !isSymbolAssigned(symbol); + return isConstantVariable(symbol) || isParameterOrCatchClauseVariable(symbol) && !isSymbolAssigned(symbol); } break; case SyntaxKind.PropertyAccessExpression: @@ -26674,7 +26687,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker { } // A matching dotted name might also be an expando property on a function *expression*, // in which case we continue control flow analysis back to the function's declaration - if (isVariableDeclaration(node) && (isInJSFile(node) || isVarConst(node))) { + if (isVariableDeclaration(node) && (isInJSFile(node) || isVarConstLike(node))) { const init = getDeclaredExpandoInitializer(node); if (init && (init.kind === SyntaxKind.FunctionExpression || init.kind === SyntaxKind.ArrowFunction)) { return getTypeAtFlowNode(flow.antecedent); @@ -26983,7 +26996,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker { } else if (isIdentifier(expr)) { const symbol = getResolvedSymbol(expr); - if (isConstVariable(symbol)) { + if (isConstantVariable(symbol)) { const declaration = symbol.valueDeclaration!; // Given 'const x = obj.kind', allow 'x' as an alias for 'obj.kind' if (isVariableDeclaration(declaration) && !declaration.type && declaration.initializer && isAccessExpression(declaration.initializer) && @@ -27575,7 +27588,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker { // up to five levels of aliased conditional expressions that are themselves declared as const variables. if (!isMatchingReference(reference, expr) && inlineLevel < 5) { const symbol = getResolvedSymbol(expr as Identifier); - if (isConstVariable(symbol)) { + if (isConstantVariable(symbol)) { const declaration = symbol.valueDeclaration; if (declaration && isVariableDeclaration(declaration) && !declaration.type && declaration.initializer && isConstantReference(reference)) { inlineLevel++; @@ -27691,8 +27704,8 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker { } } - function isConstVariable(symbol: Symbol) { - return symbol.flags & SymbolFlags.Variable && (getDeclarationNodeFlagsFromSymbol(symbol) & NodeFlags.Const) !== 0; + function isConstantVariable(symbol: Symbol) { + return symbol.flags & SymbolFlags.Variable && (getDeclarationNodeFlagsFromSymbol(symbol) & NodeFlags.Constant) !== 0; } function parameterInitializerContainsUndefined(declaration: ParameterDeclaration): boolean { @@ -27847,7 +27860,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker { // destructuring from the narrowed parent type. if (isBindingElement(declaration) && !declaration.initializer && !declaration.dotDotDotToken && declaration.parent.elements.length >= 2) { const parent = declaration.parent.parent; - if (parent.kind === SyntaxKind.VariableDeclaration && getCombinedNodeFlags(declaration) & NodeFlags.Const || parent.kind === SyntaxKind.Parameter) { + if (parent.kind === SyntaxKind.VariableDeclaration && getCombinedNodeFlagsCached(declaration) & NodeFlags.Constant || parent.kind === SyntaxKind.Parameter) { const links = getNodeLinks(parent); if (!(links.flags & NodeCheckFlags.InCheckIdentifier)) { links.flags |= NodeCheckFlags.InCheckIdentifier; @@ -28053,7 +28066,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker { // analysis to include the immediately enclosing function. while (flowContainer !== declarationContainer && (flowContainer.kind === SyntaxKind.FunctionExpression || flowContainer.kind === SyntaxKind.ArrowFunction || isObjectLiteralOrClassExpressionMethodOrAccessor(flowContainer)) && - (isConstVariable(localOrExportSymbol) && type !== autoArrayType || isParameter && !isSymbolAssigned(localOrExportSymbol))) { + (isConstantVariable(localOrExportSymbol) && type !== autoArrayType || isParameter && !isSymbolAssigned(localOrExportSymbol))) { flowContainer = getControlFlowContainer(flowContainer); } // We only look for uninitialized variables in strict null checking mode, and only when we can analyze @@ -31083,7 +31096,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker { } function getDeclarationNodeFlagsFromSymbol(s: Symbol): NodeFlags { - return s.valueDeclaration ? getCombinedNodeFlags(s.valueDeclaration) : 0; + return s.valueDeclaration ? getCombinedNodeFlagsCached(s.valueDeclaration) : 0; } /** @@ -31611,7 +31624,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker { if (compilerOptions.noPropertyAccessFromIndexSignature && isPropertyAccessExpression(node)) { error(right, Diagnostics.Property_0_comes_from_an_index_signature_so_it_must_be_accessed_with_0, unescapeLeadingUnderscores(right.escapedText)); } - if (indexInfo.declaration && getCombinedNodeFlags(indexInfo.declaration) & NodeFlags.Deprecated) { + if (indexInfo.declaration && isDeprecatedDeclaration(indexInfo.declaration)) { addDeprecatedSuggestion(right, [indexInfo.declaration], right.escapedText as string); } } @@ -31716,7 +31729,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker { && !isOptionalPropertyDeclaration(valueDeclaration) && !(isAccessExpression(node) && isAccessExpression(node.expression)) && !isBlockScopedNameDeclaredBeforeUse(valueDeclaration, right) - && !(isMethodDeclaration(valueDeclaration) && getCombinedModifierFlags(valueDeclaration) & ModifierFlags.Static) + && !(isMethodDeclaration(valueDeclaration) && getCombinedModifierFlagsCached(valueDeclaration) & ModifierFlags.Static) && (compilerOptions.useDefineForClassFields || !isPropertyDeclaredInAncestorClass(prop))) { diagnosticMessage = error(right, Diagnostics.Property_0_is_used_before_its_initialization, declarationName); } @@ -34241,7 +34254,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker { let name: Expression | BindingName | undefined; let decl: Node | undefined; if (isVariableDeclaration(node.parent) && node.parent.initializer === node) { - if (!isInJSFile(node) && !(isVarConst(node.parent) && isFunctionLikeDeclaration(node))) { + if (!isInJSFile(node) && !(isVarConstLike(node.parent) && isFunctionLikeDeclaration(node))) { return undefined; } name = node.parent.name; @@ -36079,7 +36092,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker { // Unions and intersections of the above (unions and intersections eagerly set isReadonly on creation) return !!(getCheckFlags(symbol) & CheckFlags.Readonly || symbol.flags & SymbolFlags.Property && getDeclarationModifierFlagsFromSymbol(symbol) & ModifierFlags.Readonly || - symbol.flags & SymbolFlags.Variable && getDeclarationNodeFlagsFromSymbol(symbol) & NodeFlags.Const || + symbol.flags & SymbolFlags.Variable && getDeclarationNodeFlagsFromSymbol(symbol) & NodeFlags.Constant || symbol.flags & SymbolFlags.Accessor && !(symbol.flags & SymbolFlags.SetAccessor) || symbol.flags & SymbolFlags.EnumMember || some(symbol.declarations, isReadonlyAssignmentDeclaration) @@ -36185,11 +36198,16 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker { return undefinedWideningType; } - function checkAwaitExpressionGrammar(node: AwaitExpression): void { + function checkAwaitGrammar(node: AwaitExpression | VariableDeclarationList): boolean { // Grammar checking + let hasError = false; const container = getContainingFunctionOrClassStaticBlock(node); if (container && isClassStaticBlockDeclaration(container)) { - error(node, Diagnostics.Await_expression_cannot_be_used_inside_a_class_static_block); + // NOTE: We report this regardless as to whether there are parse diagnostics. + const message = isAwaitExpression(node) ? Diagnostics.await_expression_cannot_be_used_inside_a_class_static_block : + Diagnostics.await_using_statements_cannot_be_used_inside_a_class_static_block; + error(node, message); + hasError = true; } else if (!(node.flags & NodeFlags.AwaitContext)) { if (isInTopLevelContext(node)) { @@ -36198,9 +36216,11 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker { let span: TextSpan | undefined; if (!isEffectiveExternalModule(sourceFile, compilerOptions)) { span ??= getSpanOfTokenAtPosition(sourceFile, node.pos); - const diagnostic = createFileDiagnostic(sourceFile, span.start, span.length, - Diagnostics.await_expressions_are_only_allowed_at_the_top_level_of_a_file_when_that_file_is_a_module_but_this_file_has_no_imports_or_exports_Consider_adding_an_empty_export_to_make_this_file_a_module); + const message = isAwaitExpression(node) ? Diagnostics.await_expressions_are_only_allowed_at_the_top_level_of_a_file_when_that_file_is_a_module_but_this_file_has_no_imports_or_exports_Consider_adding_an_empty_export_to_make_this_file_a_module : + Diagnostics.await_using_statements_are_only_allowed_at_the_top_level_of_a_file_when_that_file_is_a_module_but_this_file_has_no_imports_or_exports_Consider_adding_an_empty_export_to_make_this_file_a_module; + const diagnostic = createFileDiagnostic(sourceFile, span.start, span.length, message); diagnostics.add(diagnostic); + hasError = true; } switch (moduleKind) { case ModuleKind.Node16: @@ -36210,6 +36230,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker { diagnostics.add( createFileDiagnostic(sourceFile, span.start, span.length, Diagnostics.The_current_file_is_a_CommonJS_module_and_cannot_use_await_at_the_top_level) ); + hasError = true; break; } // fallthrough @@ -36222,11 +36243,10 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker { // fallthrough default: span ??= getSpanOfTokenAtPosition(sourceFile, node.pos); - diagnostics.add( - createFileDiagnostic(sourceFile, span.start, span.length, - Diagnostics.Top_level_await_expressions_are_only_allowed_when_the_module_option_is_set_to_es2022_esnext_system_node16_or_nodenext_and_the_target_option_is_set_to_es2017_or_higher - ) - ); + const message = isAwaitExpression(node) ? Diagnostics.Top_level_await_expressions_are_only_allowed_when_the_module_option_is_set_to_es2022_esnext_system_node16_or_nodenext_and_the_target_option_is_set_to_es2017_or_higher : + Diagnostics.Top_level_await_using_statements_are_only_allowed_when_the_module_option_is_set_to_es2022_esnext_system_node16_or_nodenext_and_the_target_option_is_set_to_es2017_or_higher; + diagnostics.add(createFileDiagnostic(sourceFile, span.start, span.length, message)); + hasError = true; break; } } @@ -36236,23 +36256,30 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker { const sourceFile = getSourceFileOfNode(node); if (!hasParseDiagnostics(sourceFile)) { const span = getSpanOfTokenAtPosition(sourceFile, node.pos); - const diagnostic = createFileDiagnostic(sourceFile, span.start, span.length, Diagnostics.await_expressions_are_only_allowed_within_async_functions_and_at_the_top_levels_of_modules); + const message = isAwaitExpression(node) ? Diagnostics.await_expressions_are_only_allowed_within_async_functions_and_at_the_top_levels_of_modules : + Diagnostics.await_using_statements_are_only_allowed_within_async_functions_and_at_the_top_levels_of_modules; + const diagnostic = createFileDiagnostic(sourceFile, span.start, span.length, message); if (container && container.kind !== SyntaxKind.Constructor && (getFunctionFlags(container) & FunctionFlags.Async) === 0) { const relatedInfo = createDiagnosticForNode(container, Diagnostics.Did_you_mean_to_mark_this_function_as_async); addRelatedInfo(diagnostic, relatedInfo); } diagnostics.add(diagnostic); + hasError = true; } } } - if (isInParameterInitializerBeforeContainingFunction(node)) { + if (isAwaitExpression(node) && isInParameterInitializerBeforeContainingFunction(node)) { + // NOTE: We report this regardless as to whether there are parse diagnostics. error(node, Diagnostics.await_expressions_cannot_be_used_in_a_parameter_initializer); + hasError = true; } + + return hasError; } function checkAwaitExpression(node: AwaitExpression): Type { - addLazyDiagnostic(() => checkAwaitExpressionGrammar(node)); + addLazyDiagnostic(() => checkAwaitGrammar(node)); const operandType = checkExpression(node.expression); const awaitedType = checkAwaitedType(operandType, /*withAlias*/ true, node, Diagnostics.Type_of_await_operand_must_either_be_a_valid_promise_or_must_not_contain_a_callable_then_member); @@ -37536,7 +37563,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker { } function widenTypeInferredFromInitializer(declaration: HasExpressionInitializer, type: Type) { - const widened = getCombinedNodeFlags(declaration) & NodeFlags.Const || isDeclarationReadonly(declaration) ? type : getWidenedLiteralType(type); + const widened = getCombinedNodeFlagsCached(declaration) & NodeFlags.Constant || isDeclarationReadonly(declaration) ? type : getWidenedLiteralType(type); if (isInJSFile(declaration)) { if (isEmptyLiteralType(widened)) { reportImplicitAny(declaration, anyType); @@ -39031,7 +39058,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker { } function getEffectiveDeclarationFlags(n: Declaration, flagsToCheck: ModifierFlags): ModifierFlags { - let flags = getCombinedModifierFlags(n); + let flags = getCombinedModifierFlagsCached(n); // children of classes (even ambient classes) should not be marked as ambient or export // because those flags have no useful semantics there. @@ -40590,7 +40617,11 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker { } } else if (isVariableDeclaration(declaration)) { - addToGroup(unusedVariables, declaration.parent, declaration, getNodeId); + const blockScopeKind = getCombinedNodeFlagsCached(declaration) & NodeFlags.BlockScoped; + const name = getNameOfDeclaration(declaration); + if (blockScopeKind !== NodeFlags.Using && blockScopeKind !== NodeFlags.AwaitUsing || !name || !isIdentifierThatStartsWithUnderscore(name)) { + addToGroup(unusedVariables, declaration.parent, declaration, getNodeId); + } } else { const parameter = local.valueDeclaration && tryGetRootParameterDeclaration(local.valueDeclaration); @@ -40943,7 +40974,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker { // } // skip block-scoped variables and parameters - if ((getCombinedNodeFlags(node) & NodeFlags.BlockScoped) !== 0 || isParameterDeclaration(node)) { + if ((getCombinedNodeFlagsCached(node) & NodeFlags.BlockScoped) !== 0 || isParameterDeclaration(node)) { return; } @@ -41119,7 +41150,24 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker { (initializer.properties.length === 0 || isPrototypeAccess(node.name)) && !!symbol.exports?.size; if (!isJSObjectLiteralInitializer && node.parent.parent.kind !== SyntaxKind.ForInStatement) { - checkTypeAssignableToAndOptionallyElaborate(checkExpressionCached(initializer), type, node, initializer, /*headMessage*/ undefined); + const initializerType = checkExpressionCached(initializer); + checkTypeAssignableToAndOptionallyElaborate(initializerType, type, node, initializer, /*headMessage*/ undefined); + const blockScopeKind = getCombinedNodeFlagsCached(node) & NodeFlags.BlockScoped; + if (blockScopeKind === NodeFlags.AwaitUsing) { + const globalAsyncDisposableType = getGlobalAsyncDisposableType(/*reportErrors*/ true); + const globalDisposableType = getGlobalDisposableType(/*reportErrors*/ true); + if (globalAsyncDisposableType !== emptyObjectType && globalDisposableType !== emptyObjectType) { + const optionalDisposableType = getUnionType([globalAsyncDisposableType, globalDisposableType, nullType, undefinedType]); + checkTypeAssignableTo(initializerType, optionalDisposableType, initializer, Diagnostics.The_initializer_of_an_await_using_declaration_must_be_either_an_object_with_a_Symbol_asyncDispose_or_Symbol_dispose_method_or_be_null_or_undefined); + } + } + else if (blockScopeKind === NodeFlags.Using) { + const globalDisposableType = getGlobalDisposableType(/*reportErrors*/ true); + if (globalDisposableType !== emptyObjectType) { + const optionalDisposableType = getUnionType([globalDisposableType, nullType, undefinedType]); + checkTypeAssignableTo(initializerType, optionalDisposableType, initializer, Diagnostics.The_initializer_of_a_using_declaration_must_be_either_an_object_with_a_Symbol_dispose_method_or_be_null_or_undefined); + } + } } } if (symbol.declarations && symbol.declarations.length > 1) { @@ -41208,10 +41256,19 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker { return checkVariableLikeDeclaration(node); } + function checkVariableDeclarationList(node: VariableDeclarationList) { + const blockScopeKind = getCombinedNodeFlags(node) & NodeFlags.BlockScoped; + if (blockScopeKind === NodeFlags.Using || blockScopeKind === NodeFlags.AwaitUsing) { + checkExternalEmitHelpers(node, ExternalEmitHelpers.AddDisposableResourceAndDisposeResources); + } + + forEach(node.declarations, checkSourceElement); + } + function checkVariableStatement(node: VariableStatement) { // Grammar checking - if (!checkGrammarModifiers(node) && !checkGrammarVariableDeclarationList(node.declarationList)) checkGrammarForDisallowedLetOrConstStatement(node); - forEach(node.declarationList.declarations, checkSourceElement); + if (!checkGrammarModifiers(node) && !checkGrammarVariableDeclarationList(node.declarationList)) checkGrammarForDisallowedBlockScopedVariableStatement(node); + checkVariableDeclarationList(node.declarationList); } function checkExpressionStatement(node: ExpressionStatement) { @@ -41393,7 +41450,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker { if (node.initializer) { if (node.initializer.kind === SyntaxKind.VariableDeclarationList) { - forEach((node.initializer as VariableDeclarationList).declarations, checkVariableDeclaration); + checkVariableDeclarationList(node.initializer as VariableDeclarationList); } else { checkExpression(node.initializer); @@ -41414,7 +41471,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker { const container = getContainingFunctionOrClassStaticBlock(node); if (node.awaitModifier) { if (container && isClassStaticBlockDeclaration(container)) { - grammarErrorOnNode(node.awaitModifier, Diagnostics.For_await_loops_cannot_be_used_inside_a_class_static_block); + grammarErrorOnNode(node.awaitModifier, Diagnostics.for_await_loops_cannot_be_used_inside_a_class_static_block); } else { const functionFlags = getFunctionFlags(container); @@ -41435,7 +41492,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker { // If the LHS is an expression, check the LHS, as a destructuring assignment or as a reference. // Then check that the RHS is assignable to it. if (node.initializer.kind === SyntaxKind.VariableDeclarationList) { - checkForInOrForOfVariableDeclaration(node); + checkVariableDeclarationList(node.initializer as VariableDeclarationList); } else { const varExpr = node.initializer; @@ -41486,7 +41543,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker { if (variable && isBindingPattern(variable.name)) { error(variable.name, Diagnostics.The_left_hand_side_of_a_for_in_statement_cannot_be_a_destructuring_pattern); } - checkForInOrForOfVariableDeclaration(node); + checkVariableDeclarationList(node.initializer as VariableDeclarationList); } else { // In a 'for-in' statement of the form @@ -41522,15 +41579,6 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker { } } - function checkForInOrForOfVariableDeclaration(iterationStatement: ForInOrOfStatement): void { - const variableDeclarationList = iterationStatement.initializer as VariableDeclarationList; - // checkGrammarForInOrForOfStatement will check that there is exactly one declaration. - if (variableDeclarationList.declarations.length >= 1) { - const decl = variableDeclarationList.declarations[0]; - checkVariableDeclaration(decl); - } - } - function checkRightHandSideOfForOf(statement: ForOfStatement): Type { const use = statement.awaitModifier ? IterationUse.ForAwaitOf : IterationUse.ForOf; return checkIteratedTypeOrElementType(use, checkNonNullExpression(statement.expression), undefinedType, statement.expression); @@ -43776,7 +43824,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker { if (symbol.flags & SymbolFlags.EnumMember) { return location ? evaluateEnumMember(expr, symbol, location) : getEnumMemberValue(symbol.valueDeclaration as EnumMember); } - if (isConstVariable(symbol)) { + if (isConstantVariable(symbol)) { const declaration = symbol.valueDeclaration as VariableDeclaration | undefined; if (declaration && !declaration.type && declaration.initializer && (!location || declaration !== location && isBlockScopedNameDeclaredBeforeUse(declaration, location))) { return evaluate(declaration.initializer, declaration); @@ -46648,7 +46696,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker { } function isLiteralConstDeclaration(node: VariableDeclaration | PropertyDeclaration | PropertySignature | ParameterDeclaration): boolean { - if (isDeclarationReadonly(node) || isVariableDeclaration(node) && isVarConst(node)) { + if (isDeclarationReadonly(node) || isVariableDeclaration(node) && isVarConstLike(node)) { return isFreshLiteralType(getTypeOfSymbol(getSymbolOfDeclaration(node))); } return false; @@ -47138,6 +47186,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker { case ExternalEmitHelpers.CreateBinding: return ["__createBinding"]; case ExternalEmitHelpers.SetFunctionName: return ["__setFunctionName"]; case ExternalEmitHelpers.PropKey: return ["__propKey"]; + case ExternalEmitHelpers.AddDisposableResourceAndDisposeResources: return ["__addDisposableResource", "__disposeResources"]; default: return Debug.fail("Unrecognized helper"); } } @@ -47161,6 +47210,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker { return grammarErrorOnFirstToken(node, Diagnostics.Neither_decorators_nor_modifiers_may_be_applied_to_this_parameters); } + const blockScopeKind = isVariableStatement(node) ? node.declarationList.flags & NodeFlags.BlockScoped : NodeFlags.None; let lastStatic: Node | undefined, lastDeclare: Node | undefined, lastAsync: Node | undefined, lastOverride: Node | undefined, firstDecorator: Decorator | undefined; let flags = ModifierFlags.None; let sawExportBeforeDecorators = false; @@ -47391,6 +47441,12 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker { else if (node.kind === SyntaxKind.Parameter) { return grammarErrorOnNode(modifier, Diagnostics._0_modifier_cannot_appear_on_a_parameter, "export"); } + else if (blockScopeKind === NodeFlags.Using) { + return grammarErrorOnNode(modifier, Diagnostics._0_modifier_cannot_appear_on_a_using_declaration, "export"); + } + else if (blockScopeKind === NodeFlags.AwaitUsing) { + return grammarErrorOnNode(modifier, Diagnostics._0_modifier_cannot_appear_on_an_await_using_declaration, "export"); + } flags |= ModifierFlags.Export; break; case SyntaxKind.DefaultKeyword: @@ -47398,6 +47454,12 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker { if (container.kind === SyntaxKind.ModuleDeclaration && !isAmbientModule(container)) { return grammarErrorOnNode(modifier, Diagnostics.A_default_export_can_only_be_used_in_an_ECMAScript_style_module); } + else if (blockScopeKind === NodeFlags.Using) { + return grammarErrorOnNode(modifier, Diagnostics._0_modifier_cannot_appear_on_a_using_declaration, "default"); + } + else if (blockScopeKind === NodeFlags.AwaitUsing) { + return grammarErrorOnNode(modifier, Diagnostics._0_modifier_cannot_appear_on_an_await_using_declaration, "default"); + } else if (!(flags & ModifierFlags.Export)) { return grammarErrorOnNode(modifier, Diagnostics._0_modifier_must_precede_1_modifier, "export", "default"); } @@ -47423,6 +47485,12 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker { else if (node.kind === SyntaxKind.Parameter) { return grammarErrorOnNode(modifier, Diagnostics._0_modifier_cannot_appear_on_a_parameter, "declare"); } + else if (blockScopeKind === NodeFlags.Using) { + return grammarErrorOnNode(modifier, Diagnostics._0_modifier_cannot_appear_on_a_using_declaration, "declare"); + } + else if (blockScopeKind === NodeFlags.AwaitUsing) { + return grammarErrorOnNode(modifier, Diagnostics._0_modifier_cannot_appear_on_an_await_using_declaration, "declare"); + } else if ((node.parent.flags & NodeFlags.Ambient) && node.parent.kind === SyntaxKind.ModuleBlock) { return grammarErrorOnNode(modifier, Diagnostics.A_declare_modifier_cannot_be_used_in_an_already_ambient_context); } @@ -47594,9 +47662,12 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker { return findFirstModifierExcept(node, SyntaxKind.AbstractKeyword); case SyntaxKind.ClassExpression: case SyntaxKind.InterfaceDeclaration: - case SyntaxKind.VariableStatement: case SyntaxKind.TypeAliasDeclaration: return find(node.modifiers, isModifier); + case SyntaxKind.VariableStatement: + return node.declarationList.flags & NodeFlags.Using ? + findFirstModifierExcept(node, SyntaxKind.AwaitKeyword) : + find(node.modifiers, isModifier); case SyntaxKind.EnumDeclaration: return findFirstModifierExcept(node, SyntaxKind.ConstKeyword); default: @@ -48445,7 +48516,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker { initializer.kind === SyntaxKind.TrueKeyword || initializer.kind === SyntaxKind.FalseKeyword || isBigIntLiteralExpression(initializer) ); - const isConstOrReadonly = isDeclarationReadonly(node) || isVariableDeclaration(node) && isVarConst(node); + const isConstOrReadonly = isDeclarationReadonly(node) || isVariableDeclaration(node) && (isVarConstLike(node)); if (isConstOrReadonly && !node.type) { if (isInvalidInitializer) { return grammarErrorOnNode(initializer, Diagnostics.A_const_initializer_in_an_ambient_context_must_be_a_string_or_numeric_literal_or_literal_enum_reference); @@ -48458,21 +48529,37 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker { } function checkGrammarVariableDeclaration(node: VariableDeclaration) { + const nodeFlags = getCombinedNodeFlagsCached(node); + const blockScopeKind = nodeFlags & NodeFlags.BlockScoped; + if (isBindingPattern(node.name)) { + switch (blockScopeKind) { + case NodeFlags.AwaitUsing: + return grammarErrorOnNode(node, Diagnostics._0_declarations_may_not_have_binding_patterns, "await using"); + case NodeFlags.Using: + return grammarErrorOnNode(node, Diagnostics._0_declarations_may_not_have_binding_patterns, "using"); + } + } + if (node.parent.parent.kind !== SyntaxKind.ForInStatement && node.parent.parent.kind !== SyntaxKind.ForOfStatement) { - if (node.flags & NodeFlags.Ambient) { + if (nodeFlags & NodeFlags.Ambient) { checkAmbientInitializer(node); } else if (!node.initializer) { if (isBindingPattern(node.name) && !isBindingPattern(node.parent)) { return grammarErrorOnNode(node, Diagnostics.A_destructuring_declaration_must_have_an_initializer); } - if (isVarConst(node)) { - return grammarErrorOnNode(node, Diagnostics.const_declarations_must_be_initialized); + switch (blockScopeKind) { + case NodeFlags.AwaitUsing: + return grammarErrorOnNode(node, Diagnostics._0_declarations_must_be_initialized, "await using"); + case NodeFlags.Using: + return grammarErrorOnNode(node, Diagnostics._0_declarations_must_be_initialized, "using"); + case NodeFlags.Const: + return grammarErrorOnNode(node, Diagnostics._0_declarations_must_be_initialized, "const"); } } } - if (node.exclamationToken && (node.parent.parent.kind !== SyntaxKind.VariableStatement || !node.type || node.initializer || node.flags & NodeFlags.Ambient)) { + if (node.exclamationToken && (node.parent.parent.kind !== SyntaxKind.VariableStatement || !node.type || node.initializer || nodeFlags & NodeFlags.Ambient)) { const message = node.initializer ? Diagnostics.Declarations_with_initializers_cannot_also_have_definite_assignment_assertions : !node.type @@ -48486,8 +48573,6 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker { checkESModuleMarker(node.name); } - const checkLetConstNames = (isLet(node) || isVarConst(node)); - // 1. LexicalDeclaration : LetOrConst BindingList ; // It is a Syntax Error if the BoundNames of BindingList contains "let". // 2. ForDeclaration: ForDeclaration : LetOrConst ForBinding @@ -48495,7 +48580,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker { // It is a SyntaxError if a VariableDeclaration or VariableDeclarationNoIn occurs within strict code // and its Identifier is eval or arguments - return checkLetConstNames && checkGrammarNameInLetOrConstDeclarations(node.name); + return !!blockScopeKind && checkGrammarNameInLetOrConstDeclarations(node.name); } function checkESModuleMarker(name: Identifier | BindingPattern): boolean { @@ -48541,6 +48626,19 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker { if (!declarationList.declarations.length) { return grammarErrorAtPos(declarationList, declarations.pos, declarations.end - declarations.pos, Diagnostics.Variable_declaration_list_cannot_be_empty); } + + const blockScopeFlags = declarationList.flags & NodeFlags.BlockScoped; + if ((blockScopeFlags === NodeFlags.Using || blockScopeFlags === NodeFlags.AwaitUsing) && isForInStatement(declarationList.parent)) { + return grammarErrorOnNode(declarationList, + blockScopeFlags === NodeFlags.Using ? + Diagnostics.The_left_hand_side_of_a_for_in_statement_cannot_be_a_using_declaration : + Diagnostics.The_left_hand_side_of_a_for_in_statement_cannot_be_an_await_using_declaration); + } + + if (blockScopeFlags === NodeFlags.AwaitUsing) { + return checkAwaitGrammar(declarationList); + } + return false; } @@ -48561,13 +48659,16 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker { return true; } - function checkGrammarForDisallowedLetOrConstStatement(node: VariableStatement) { + function checkGrammarForDisallowedBlockScopedVariableStatement(node: VariableStatement) { if (!allowLetAndConstDeclarations(node.parent)) { - if (isLet(node.declarationList)) { - return grammarErrorOnNode(node, Diagnostics.let_declarations_can_only_be_declared_inside_a_block); - } - else if (isVarConst(node.declarationList)) { - return grammarErrorOnNode(node, Diagnostics.const_declarations_can_only_be_declared_inside_a_block); + const blockScopeKind = getCombinedNodeFlagsCached(node.declarationList) & NodeFlags.BlockScoped; + if (blockScopeKind) { + const keyword = blockScopeKind === NodeFlags.Let ? "let" : + blockScopeKind === NodeFlags.Const ? "const" : + blockScopeKind === NodeFlags.Using ? "using" : + blockScopeKind === NodeFlags.AwaitUsing ? "await using" : + Debug.fail("Unknown BlockScope flag"); + return grammarErrorOnNode(node, Diagnostics._0_declarations_can_only_be_declared_inside_a_block, keyword); } } } @@ -48991,6 +49092,34 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker { return name ? name : isComputedPropertyName(node) && isEntityNameExpression(node.expression) ? tryGetNameFromEntityNameExpression(node.expression) : undefined; } + + function getCombinedModifierFlagsCached(node: Declaration) { + // we hold onto the last node and result to speed up repeated lookups against the same node. + if (lastGetCombinedModifierFlagsNode === node) { + return lastGetCombinedModifierFlagsResult; + } + + lastGetCombinedModifierFlagsNode = node; + lastGetCombinedModifierFlagsResult = getCombinedModifierFlags(node); + return lastGetCombinedModifierFlagsResult; + } + + function getCombinedNodeFlagsCached(node: Node) { + // we hold onto the last node and result to speed up repeated lookups against the same node. + if (lastGetCombinedNodeFlagsNode === node) { + return lastGetCombinedNodeFlagsResult; + } + lastGetCombinedNodeFlagsNode = node; + lastGetCombinedNodeFlagsResult = getCombinedNodeFlags(node); + return lastGetCombinedNodeFlagsResult; + } + + function isVarConstLike(node: VariableDeclaration | VariableDeclarationList) { + const blockScopeKind = getCombinedNodeFlagsCached(node) & NodeFlags.BlockScoped; + return blockScopeKind === NodeFlags.Const || + blockScopeKind === NodeFlags.Using || + blockScopeKind === NodeFlags.AwaitUsing; + } } function isNotAccessor(declaration: Declaration): boolean { diff --git a/src/compiler/commandLineParser.ts b/src/compiler/commandLineParser.ts index 408fa99683a0a..53c8e61ff0c2c 100644 --- a/src/compiler/commandLineParser.ts +++ b/src/compiler/commandLineParser.ts @@ -218,6 +218,7 @@ const libEntries: [string, string][] = [ ["esnext.symbol", "lib.es2019.symbol.d.ts"], ["esnext.asynciterable", "lib.es2018.asynciterable.d.ts"], ["esnext.intl", "lib.esnext.intl.d.ts"], + ["esnext.disposable", "lib.esnext.disposable.d.ts"], ["esnext.bigint", "lib.es2020.bigint.d.ts"], ["esnext.string", "lib.es2022.string.d.ts"], ["esnext.promise", "lib.es2021.promise.d.ts"], diff --git a/src/compiler/diagnosticMessages.json b/src/compiler/diagnosticMessages.json index 8ba018241d875..bda674e9666b4 100644 --- a/src/compiler/diagnosticMessages.json +++ b/src/compiler/diagnosticMessages.json @@ -451,18 +451,14 @@ "category": "Error", "code": 1149 }, - "'const' declarations must be initialized.": { + "'{0}' declarations must be initialized.": { "category": "Error", "code": 1155 }, - "'const' declarations can only be declared inside a block.": { + "'{0}' declarations can only be declared inside a block.": { "category": "Error", "code": 1156 }, - "'let' declarations can only be declared inside a block.": { - "category": "Error", - "code": 1157 - }, "Unterminated template literal.": { "category": "Error", "code": 1160 @@ -1601,6 +1597,26 @@ "category": "Error", "code": 1490 }, + "'{0}' modifier cannot appear on a 'using' declaration.": { + "category": "Error", + "code": 1491 + }, + "'{0}' declarations may not have binding patterns.": { + "category": "Error", + "code": 1492 + }, + "The left-hand side of a 'for...in' statement cannot be a 'using' declaration.": { + "category": "Error", + "code": 1493 + }, + "The left-hand side of a 'for...in' statement cannot be an 'await using' declaration.": { + "category": "Error", + "code": 1494 + }, + "'{0}' modifier cannot appear on an 'await using' declaration.": { + "category": "Error", + "code": 1495 + }, "The types of '{0}' are incompatible between these types.": { "category": "Error", @@ -3623,6 +3639,26 @@ "category": "Error", "code": 2849 }, + "The initializer of a 'using' declaration must be either an object with a '[Symbol.dispose]()' method, or be 'null' or 'undefined'.": { + "category": "Error", + "code": 2850 + }, + "The initializer of an 'await using' declaration must be either an object with a '[Symbol.asyncDispose]()' or '[Symbol.dispose]()' method, or be 'null' or 'undefined'.": { + "category": "Error", + "code": 2851 + }, + "'await using' statements are only allowed within async functions and at the top levels of modules.": { + "category": "Error", + "code": 2852 + }, + "'await using' statements are only allowed at the top level of a file when that file is a module, but this file has no imports or exports. Consider adding an empty 'export {}' to make this file a module.": { + "category": "Error", + "code": 2853 + }, + "Top-level 'await using' statements are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', 'node16', or 'nodenext', and the 'target' option is set to 'es2017' or higher.": { + "category": "Error", + "code": 2854 + }, "Import declaration '{0}' is using private name '{1}'.": { "category": "Error", @@ -7757,11 +7793,11 @@ "category": "Error", "code": 18036 }, - "Await expression cannot be used inside a class static block.": { + "'await' expression cannot be used inside a class static block.": { "category": "Error", "code": 18037 }, - "'For await' loops cannot be used inside a class static block.": { + "'for await' loops cannot be used inside a class static block.": { "category": "Error", "code": 18038 }, @@ -7820,5 +7856,9 @@ "Its type '{0}' is not a valid JSX element type.": { "category": "Error", "code": 18053 + }, + "'await using' statements cannot be used inside a class static block.": { + "category": "Error", + "code": 18054 } } diff --git a/src/compiler/emitter.ts b/src/compiler/emitter.ts index 6f34ec688fc63..a58223868f8b0 100644 --- a/src/compiler/emitter.ts +++ b/src/compiler/emitter.ts @@ -254,8 +254,10 @@ import { isUnparsedNode, isUnparsedPrepend, isUnparsedSource, + isVarAwaitUsing, isVarConst, isVariableStatement, + isVarUsing, JSDoc, JSDocAugmentsTag, JSDocCallbackTag, @@ -3685,7 +3687,18 @@ export function createPrinter(printerOptions: PrinterOptions = {}, handlers: Pri } function emitVariableDeclarationList(node: VariableDeclarationList) { - writeKeyword(isLet(node) ? "let" : isVarConst(node) ? "const" : "var"); + if (isVarAwaitUsing(node)) { + writeKeyword("await"); + writeSpace(); + writeKeyword("using"); + } + else { + const head = isLet(node) ? "let" : + isVarConst(node) ? "const" : + isVarUsing(node) ? "using" : + "var"; + writeKeyword(head); + } writeSpace(); emitList(node, node.declarations, ListFormat.VariableDeclarationList); } diff --git a/src/compiler/factory/emitHelpers.ts b/src/compiler/factory/emitHelpers.ts index e14652a3ab4b8..d73ca97674119 100644 --- a/src/compiler/factory/emitHelpers.ts +++ b/src/compiler/factory/emitHelpers.ts @@ -136,6 +136,9 @@ export interface EmitHelperFactory { createClassPrivateFieldGetHelper(receiver: Expression, state: Identifier, kind: PrivateIdentifierKind, f: Identifier | undefined): Expression; createClassPrivateFieldSetHelper(receiver: Expression, state: Identifier, value: Expression, kind: PrivateIdentifierKind, f: Identifier | undefined): Expression; createClassPrivateFieldInHelper(state: Identifier, receiver: Expression): Expression; + // 'using' helpers + createAddDisposableResourceHelper(envBinding: Expression, value: Expression, async: boolean): Expression; + createDisposeResourcesHelper(envBinding: Expression): Expression; } /** @internal */ @@ -183,7 +186,10 @@ export function createEmitHelperFactory(context: TransformationContext): EmitHel // Class Fields Helpers createClassPrivateFieldGetHelper, createClassPrivateFieldSetHelper, - createClassPrivateFieldInHelper + createClassPrivateFieldInHelper, + // 'using' helpers + createAddDisposableResourceHelper, + createDisposeResourcesHelper, }; /** @@ -666,6 +672,20 @@ export function createEmitHelperFactory(context: TransformationContext): EmitHel context.requestEmitHelper(classPrivateFieldInHelper); return factory.createCallExpression(getUnscopedHelperName("__classPrivateFieldIn"), /*typeArguments*/ undefined, [state, receiver]); } + + function createAddDisposableResourceHelper(envBinding: Expression, value: Expression, async: boolean): Expression { + context.requestEmitHelper(addDisposableResourceHelper); + return factory.createCallExpression( + getUnscopedHelperName("__addDisposableResource"), + /*typeArguments*/ undefined, + [envBinding, value, async ? factory.createTrue() : factory.createFalse()] + ); + } + + function createDisposeResourcesHelper(envBinding: Expression) { + context.requestEmitHelper(disposeResourcesHelper); + return factory.createCallExpression(getUnscopedHelperName("__disposeResources"), /*typeArguments*/ undefined, [envBinding]); + } } /** @internal */ @@ -1367,6 +1387,71 @@ export const classPrivateFieldInHelper: UnscopedEmitHelper = { };` }; +/** + * @internal + */ +export const addDisposableResourceHelper: UnscopedEmitHelper = { + name: "typescript:addDisposableResource", + importName: "__addDisposableResource", + scoped: false, + text: ` + var __addDisposableResource = (this && this.__addDisposableResource) || function (env, value, async) { + if (value !== null && value !== void 0) { + if (typeof value !== "object") throw new TypeError("Object expected."); + var dispose; + if (async) { + if (!Symbol.asyncDispose) throw new TypeError("Symbol.asyncDispose is not defined."); + dispose = value[Symbol.asyncDispose]; + } + if (dispose === void 0) { + if (!Symbol.dispose) throw new TypeError("Symbol.dispose is not defined."); + dispose = value[Symbol.dispose]; + } + if (typeof dispose !== "function") throw new TypeError("Object not disposable."); + env.stack.push({ value: value, dispose: dispose, async: async }); + } + else if (async) { + env.stack.push({ async: true }); + } + return value; + };` +}; + +/** + * @internal + */ +export const disposeResourcesHelper: UnscopedEmitHelper = { + name: "typescript:disposeResources", + importName: "__disposeResources", + scoped: false, + text: ` + var __disposeResources = (this && this.__disposeResources) || (function (SuppressedError) { + return function (env) { + function fail(e) { + env.error = env.hasError ? new SuppressedError(e, env.error, "An error was suppressed during disposal.") : e; + env.hasError = true; + } + function next() { + while (env.stack.length) { + var rec = env.stack.pop(); + try { + var result = rec.dispose && rec.dispose.call(rec.value); + if (rec.async) return Promise.resolve(result).then(next, function(e) { fail(e); return next(); }); + } + catch (e) { + fail(e); + } + } + if (env.hasError) throw env.error; + } + return next(); + }; + })(typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) { + var e = new Error(message); + return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e; + });` +}; + let allUnscopedEmitHelpers: ReadonlyMap | undefined; /** @internal */ @@ -1399,7 +1484,9 @@ export function getAllUnscopedEmitHelpers() { classPrivateFieldSetHelper, classPrivateFieldInHelper, createBindingHelper, - setModuleDefaultHelper + setModuleDefaultHelper, + addDisposableResourceHelper, + disposeResourcesHelper, ], helper => helper.name)); } diff --git a/src/compiler/factory/nodeConverters.ts b/src/compiler/factory/nodeConverters.ts index 1541d56bf0232..bc12cb58cc73a 100644 --- a/src/compiler/factory/nodeConverters.ts +++ b/src/compiler/factory/nodeConverters.ts @@ -6,6 +6,7 @@ import { BindingOrAssignmentPattern, Block, cast, + ClassDeclaration, ConciseBody, Debug, Expression, @@ -17,6 +18,8 @@ import { isBindingElement, isBindingPattern, isBlock, + isDefaultModifier, + isExportModifier, isExpression, isIdentifier, isObjectBindingPattern, @@ -39,6 +42,7 @@ export function createNodeConverters(factory: NodeFactory): NodeConverters { return { convertToFunctionBlock, convertToFunctionExpression, + convertToClassExpression, convertToArrayAssignmentElement, convertToObjectAssignmentElement, convertToAssignmentPattern, @@ -59,7 +63,7 @@ export function createNodeConverters(factory: NodeFactory): NodeConverters { function convertToFunctionExpression(node: FunctionDeclaration) { if (!node.body) return Debug.fail(`Cannot convert a FunctionDeclaration without a body`); const updated = factory.createFunctionExpression( - getModifiers(node), + getModifiers(node)?.filter(modifier => !isExportModifier(modifier) && !isDefaultModifier(modifier)), node.asteriskToken, node.name, node.typeParameters, @@ -75,6 +79,22 @@ export function createNodeConverters(factory: NodeFactory): NodeConverters { return updated; } + function convertToClassExpression(node: ClassDeclaration) { + const updated = factory.createClassExpression( + node.modifiers?.filter(modifier => !isExportModifier(modifier) && !isDefaultModifier(modifier)), + node.name, + node.typeParameters, + node.heritageClauses, + node.members + ); + setOriginalNode(updated, node); + setTextRange(updated, node); + if (getStartsOnNewLine(node)) { + setStartsOnNewLine(updated, /*newLine*/ true); + } + return updated; + } + function convertToArrayAssignmentElement(element: ArrayBindingOrAssignmentElement) { if (isBindingElement(element)) { if (element.dotDotDotToken) { @@ -163,6 +183,7 @@ export function createNodeConverters(factory: NodeFactory): NodeConverters { export const nullNodeConverters: NodeConverters = { convertToFunctionBlock: notImplemented, convertToFunctionExpression: notImplemented, + convertToClassExpression: notImplemented, convertToArrayAssignmentElement: notImplemented, convertToObjectAssignmentElement: notImplemented, convertToAssignmentPattern: notImplemented, diff --git a/src/compiler/factory/nodeFactory.ts b/src/compiler/factory/nodeFactory.ts index 638ff154747fa..9dd48e0437efe 100644 --- a/src/compiler/factory/nodeFactory.ts +++ b/src/compiler/factory/nodeFactory.ts @@ -134,6 +134,8 @@ import { Identifier, idText, IfStatement, + ImmediatelyInvokedArrowFunction, + ImmediatelyInvokedFunctionExpression, ImportClause, ImportDeclaration, ImportEqualsDeclaration, @@ -991,6 +993,7 @@ export function createNodeFactory(flags: NodeFactoryFlags, baseFactory: BaseNode createExportDefault, createExternalModuleExport, createTypeCheck, + createIsNotTypeCheck, createMethodCall, createGlobalMethodCall, createFunctionBindCall, @@ -1322,6 +1325,10 @@ export function createNodeFactory(flags: NodeFactoryFlags, baseFactory: BaseNode TransformFlags.ContainsES2018; break; + case SyntaxKind.UsingKeyword: + transformFlags = TransformFlags.ContainsESNext; + break; + case SyntaxKind.PublicKeyword: case SyntaxKind.PrivateKeyword: case SyntaxKind.ProtectedKeyword: @@ -4178,6 +4185,9 @@ export function createNodeFactory(flags: NodeFactoryFlags, baseFactory: BaseNode TransformFlags.ContainsES2015 | TransformFlags.ContainsBlockScopedBinding; } + if (flags & NodeFlags.Using) { + node.transformFlags |= TransformFlags.ContainsESNext; + } return node; } @@ -6314,8 +6324,8 @@ export function createNodeFactory(flags: NodeFactoryFlags, baseFactory: BaseNode } // compound nodes - function createImmediatelyInvokedFunctionExpression(statements: readonly Statement[]): CallExpression; - function createImmediatelyInvokedFunctionExpression(statements: readonly Statement[], param: ParameterDeclaration, paramValue: Expression): CallExpression; + function createImmediatelyInvokedFunctionExpression(statements: readonly Statement[]): ImmediatelyInvokedFunctionExpression; + function createImmediatelyInvokedFunctionExpression(statements: readonly Statement[], param: ParameterDeclaration, paramValue: Expression): ImmediatelyInvokedFunctionExpression; function createImmediatelyInvokedFunctionExpression(statements: readonly Statement[], param?: ParameterDeclaration, paramValue?: Expression) { return createCallExpression( createFunctionExpression( @@ -6332,8 +6342,8 @@ export function createNodeFactory(flags: NodeFactoryFlags, baseFactory: BaseNode ); } - function createImmediatelyInvokedArrowFunction(statements: readonly Statement[]): CallExpression; - function createImmediatelyInvokedArrowFunction(statements: readonly Statement[], param: ParameterDeclaration, paramValue: Expression): CallExpression; + function createImmediatelyInvokedArrowFunction(statements: readonly Statement[]): ImmediatelyInvokedArrowFunction; + function createImmediatelyInvokedArrowFunction(statements: readonly Statement[], param: ParameterDeclaration, paramValue: Expression): ImmediatelyInvokedArrowFunction; function createImmediatelyInvokedArrowFunction(statements: readonly Statement[], param?: ParameterDeclaration, paramValue?: Expression) { return createCallExpression( createArrowFunction( @@ -6375,9 +6385,15 @@ export function createNodeFactory(flags: NodeFactoryFlags, baseFactory: BaseNode // function createTypeCheck(value: Expression, tag: TypeOfTag) { - return tag === "undefined" - ? factory.createStrictEquality(value, createVoidZero()) - : factory.createStrictEquality(createTypeOfExpression(value), createStringLiteral(tag)); + return tag === "null" ? factory.createStrictEquality(value, createNull()) : + tag === "undefined" ? factory.createStrictEquality(value, createVoidZero()) : + factory.createStrictEquality(createTypeOfExpression(value), createStringLiteral(tag)); + } + + function createIsNotTypeCheck(value: Expression, tag: TypeOfTag) { + return tag === "null" ? factory.createStrictInequality(value, createNull()) : + tag === "undefined" ? factory.createStrictInequality(value, createVoidZero()) : + factory.createStrictInequality(createTypeOfExpression(value), createStringLiteral(tag)); } function createMethodCall(object: Expression, methodName: string | Identifier, argumentsList: readonly Expression[]) { @@ -7585,10 +7601,12 @@ export function createSourceMapSource(fileName: string, text: string, skipTrivia // Utilities export function setOriginalNode(node: T, original: Node | undefined): T { - node.original = original; - if (original) { - const emitNode = original.emitNode; - if (emitNode) node.emitNode = mergeEmitNode(emitNode, node.emitNode); + if (node.original !== original) { + node.original = original; + if (original) { + const emitNode = original.emitNode; + if (emitNode) node.emitNode = mergeEmitNode(emitNode, node.emitNode); + } } return node; } @@ -7596,7 +7614,7 @@ export function setOriginalNode(node: T, original: Node | undefi function mergeEmitNode(sourceEmitNode: EmitNode, destEmitNode: EmitNode | undefined) { const { flags, - internalFlags, + internalFlags, leadingComments, trailingComments, commentRange, @@ -7606,24 +7624,95 @@ function mergeEmitNode(sourceEmitNode: EmitNode, destEmitNode: EmitNode | undefi helpers, startsOnNewLine, snippetElement, + classThis, + assignedName, } = sourceEmitNode; if (!destEmitNode) destEmitNode = {} as EmitNode; - // We are using `.slice()` here in case `destEmitNode.leadingComments` is pushed to later. - if (leadingComments) destEmitNode.leadingComments = addRange(leadingComments.slice(), destEmitNode.leadingComments); - if (trailingComments) destEmitNode.trailingComments = addRange(trailingComments.slice(), destEmitNode.trailingComments); - if (flags) destEmitNode.flags = flags; - if (internalFlags) destEmitNode.internalFlags = internalFlags & ~InternalEmitFlags.Immutable; - if (commentRange) destEmitNode.commentRange = commentRange; - if (sourceMapRange) destEmitNode.sourceMapRange = sourceMapRange; - if (tokenSourceMapRanges) destEmitNode.tokenSourceMapRanges = mergeTokenSourceMapRanges(tokenSourceMapRanges, destEmitNode.tokenSourceMapRanges!); - if (constantValue !== undefined) destEmitNode.constantValue = constantValue; + + // NOTE: We should have one or more lines here for each property in EmitNode, even if the line + // consists only of a comment indicating the property does not merge + + // `flags` overwrites the destination + if (flags) { + destEmitNode.flags = flags; + } + + // `internalFlags` overwrites the destination. We do not copy over the immutability of the source. + if (internalFlags) { + destEmitNode.internalFlags = internalFlags & ~InternalEmitFlags.Immutable; + } + + // `annotatedNodes` are not merged as they should only present on the parse tree node of a `SourceFile`. + + // `leadingComments` are concatenated with any existing leading comments on the destination + if (leadingComments) { + // We use `.slice()` in case `destEmitNode.leadingComments` is pushed to later + destEmitNode.leadingComments = addRange(leadingComments.slice(), destEmitNode.leadingComments); + } + + // `trailingComments` are concatenated with any existing trailing comments on the destination + if (trailingComments) { + // We use `.slice()` in case `destEmitNode.trailingComments` is pushed to later + destEmitNode.trailingComments = addRange(trailingComments.slice(), destEmitNode.trailingComments); + } + + // `commentRange` overwrites the destination + if (commentRange) { + destEmitNode.commentRange = commentRange; + } + + // `sourceMapRange` overwrites the destination + if (sourceMapRange) { + destEmitNode.sourceMapRange = sourceMapRange; + } + + // `tokenSourceMapRanges` are merged with the destination + if (tokenSourceMapRanges) { + destEmitNode.tokenSourceMapRanges = mergeTokenSourceMapRanges(tokenSourceMapRanges, destEmitNode.tokenSourceMapRanges!); + } + + // `constantValue` overwrites the destination + if (constantValue !== undefined) { + destEmitNode.constantValue = constantValue; + } + + // `externalHelpersModuleName` is not merged + // `externalHelpers` is not merged + + // `helpers` are merged into the destination if (helpers) { for (const helper of helpers) { destEmitNode.helpers = appendIfUnique(destEmitNode.helpers, helper); } } - if (startsOnNewLine !== undefined) destEmitNode.startsOnNewLine = startsOnNewLine; - if (snippetElement !== undefined) destEmitNode.snippetElement = snippetElement; + + // `startsOnNewLine` overwrites the destination + if (startsOnNewLine !== undefined) { + destEmitNode.startsOnNewLine = startsOnNewLine; + } + + // `snippetElement` overwrites the destination + if (snippetElement !== undefined) { + destEmitNode.snippetElement = snippetElement; + } + + // `typeNode` is not merged as it only applies to comment emit for a variable declaration. + // TODO: `typeNode` should overwrite the destination + + // `classThis` overwrites the destination + if (classThis) { + destEmitNode.classThis = classThis; + } + + // `assignedName` overwrites the destination + if (assignedName) { + destEmitNode.assignedName = assignedName; + } + + // `identifierTypeArguments` are not merged as they only apply to an Identifier in quick info + // `autoGenerate` is not merged as it only applies to a specific generated Identifier/PrivateIdentifier + // `generatedImportReference` is not merged as it only applies to an Identifier + return destEmitNode; } diff --git a/src/compiler/factory/utilities.ts b/src/compiler/factory/utilities.ts index 2e2721eadcaaf..bac8f690e1940 100644 --- a/src/compiler/factory/utilities.ts +++ b/src/compiler/factory/utilities.ts @@ -178,6 +178,7 @@ import { Token, TransformFlags, TypeNode, + WrappedExpression } from "../_namespaces/ts"; // Compound nodes @@ -655,6 +656,8 @@ export function isOuterExpression(node: Node, kinds = OuterExpressionKinds.All): return false; } +/** @internal */ +export function skipOuterExpressions(node: WrappedExpression): T; /** @internal */ export function skipOuterExpressions(node: Expression, kinds?: OuterExpressionKinds): Expression; /** @internal */ diff --git a/src/compiler/parser.ts b/src/compiler/parser.ts index f49b48bb44295..436fb04ef2bcf 100644 --- a/src/compiler/parser.ts +++ b/src/compiler/parser.ts @@ -6816,7 +6816,9 @@ namespace Parser { let initializer!: VariableDeclarationList | Expression; if (token() !== SyntaxKind.SemicolonToken) { - if (token() === SyntaxKind.VarKeyword || token() === SyntaxKind.LetKeyword || token() === SyntaxKind.ConstKeyword) { + if (token() === SyntaxKind.VarKeyword || token() === SyntaxKind.LetKeyword || token() === SyntaxKind.ConstKeyword || + token() === SyntaxKind.UsingKeyword && lookAhead(nextTokenIsBindingIdentifierOrStartOfDestructuringOnSameLineDisallowOf) || + token() === SyntaxKind.AwaitKeyword && lookAhead(nextTokenIsUsingKeywordThenBindingIdentifierOrStartOfObjectDestructuringOnSameLineDisallowOf)) { initializer = parseVariableDeclarationList(/*inForStatementInitializer*/ true); } else { @@ -7052,6 +7054,10 @@ namespace Parser { case SyntaxKind.ClassKeyword: case SyntaxKind.EnumKeyword: return true; + case SyntaxKind.UsingKeyword: + return isUsingDeclaration(); + case SyntaxKind.AwaitKeyword: + return isAwaitUsingDeclaration(); // 'declare', 'module', 'namespace', 'interface'* and 'type' are all legal JavaScript identifiers; // however, an identifier cannot be followed by another identifier on the same line. This is what we @@ -7118,6 +7124,7 @@ namespace Parser { case SyntaxKind.StaticKeyword: nextToken(); continue; + default: return false; } @@ -7135,6 +7142,7 @@ namespace Parser { case SyntaxKind.OpenBraceToken: case SyntaxKind.VarKeyword: case SyntaxKind.LetKeyword: + case SyntaxKind.UsingKeyword: case SyntaxKind.FunctionKeyword: case SyntaxKind.ClassKeyword: case SyntaxKind.EnumKeyword: @@ -7200,6 +7208,41 @@ namespace Parser { return lookAhead(nextTokenIsBindingIdentifierOrStartOfDestructuring); } + function nextTokenIsBindingIdentifierOrStartOfDestructuringOnSameLineDisallowOf() { + return nextTokenIsBindingIdentifierOrStartOfDestructuringOnSameLine(/*disallowOf*/ true); + } + + function nextTokenIsBindingIdentifierOrStartOfDestructuringOnSameLine(disallowOf?: boolean) { + nextToken(); + if (disallowOf && token() === SyntaxKind.OfKeyword) return false; + return (isBindingIdentifier() || token() === SyntaxKind.OpenBraceToken) && !scanner.hasPrecedingLineBreak(); + } + + function isUsingDeclaration() { + // 'using' always starts a lexical declaration if followed by an identifier. We also eagerly parse + // |ObjectBindingPattern| so that we can report a grammar error during check. We don't parse out + // |ArrayBindingPattern| since it potentially conflicts with element access (i.e., `using[x]`). + return lookAhead(nextTokenIsBindingIdentifierOrStartOfDestructuringOnSameLine); + } + + function nextTokenIsUsingKeywordThenBindingIdentifierOrStartOfObjectDestructuringOnSameLineDisallowOf() { + return nextTokenIsUsingKeywordThenBindingIdentifierOrStartOfObjectDestructuringOnSameLine(/*disallowOf*/ true); + } + + function nextTokenIsUsingKeywordThenBindingIdentifierOrStartOfObjectDestructuringOnSameLine(disallowOf?: boolean) { + if (nextToken() === SyntaxKind.UsingKeyword) { + return nextTokenIsBindingIdentifierOrStartOfDestructuringOnSameLine(disallowOf); + } + return false; + } + + function isAwaitUsingDeclaration() { + // 'await using' always starts a lexical declaration if followed by an identifier. We also eagerly parse + // |ObjectBindingPattern| so that we can report a grammar error during check. We don't parse out + // |ArrayBindingPattern| since it potentially conflicts with element access (i.e., `await using[x]`). + return lookAhead(nextTokenIsUsingKeywordThenBindingIdentifierOrStartOfObjectDestructuringOnSameLine); + } + function parseStatement(): Statement { switch (token()) { case SyntaxKind.SemicolonToken: @@ -7213,6 +7256,16 @@ namespace Parser { return parseVariableStatement(getNodePos(), hasPrecedingJSDocComment(), /*modifiers*/ undefined); } break; + case SyntaxKind.AwaitKeyword: + if (isAwaitUsingDeclaration()) { + return parseVariableStatement(getNodePos(), hasPrecedingJSDocComment(), /*modifiers*/ undefined); + } + break; + case SyntaxKind.UsingKeyword: + if (isUsingDeclaration()) { + return parseVariableStatement(getNodePos(), hasPrecedingJSDocComment(), /*modifiers*/ undefined); + } + break; case SyntaxKind.FunctionKeyword: return parseFunctionDeclaration(getNodePos(), hasPrecedingJSDocComment(), /*modifiers*/ undefined); case SyntaxKind.ClassKeyword: @@ -7317,6 +7370,8 @@ namespace Parser { case SyntaxKind.VarKeyword: case SyntaxKind.LetKeyword: case SyntaxKind.ConstKeyword: + case SyntaxKind.UsingKeyword: + case SyntaxKind.AwaitKeyword: return parseVariableStatement(pos, hasJSDoc, modifiersIn); case SyntaxKind.FunctionKeyword: return parseFunctionDeclaration(pos, hasJSDoc, modifiersIn); @@ -7473,6 +7528,14 @@ namespace Parser { case SyntaxKind.ConstKeyword: flags |= NodeFlags.Const; break; + case SyntaxKind.UsingKeyword: + flags |= NodeFlags.Using; + break; + case SyntaxKind.AwaitKeyword: + Debug.assert(isAwaitUsingDeclaration()); + flags |= NodeFlags.AwaitUsing; + nextToken(); + break; default: Debug.fail(); } diff --git a/src/compiler/program.ts b/src/compiler/program.ts index c095ebb6ea0fe..36571405cbef5 100644 --- a/src/compiler/program.ts +++ b/src/compiler/program.ts @@ -1392,7 +1392,7 @@ export const plainJSErrors: Set = new Set([ Diagnostics.Did_you_mean_to_use_a_Colon_An_can_only_follow_a_property_name_when_the_containing_object_literal_is_part_of_a_destructuring_pattern.code, Diagnostics.Duplicate_label_0.code, Diagnostics.Dynamic_imports_can_only_accept_a_module_specifier_and_an_optional_assertion_as_arguments.code, - Diagnostics.For_await_loops_cannot_be_used_inside_a_class_static_block.code, + Diagnostics.for_await_loops_cannot_be_used_inside_a_class_static_block.code, Diagnostics.JSX_attributes_must_only_be_assigned_a_non_empty_expression.code, Diagnostics.JSX_elements_cannot_have_multiple_attributes_with_the_same_name.code, Diagnostics.JSX_expressions_may_not_use_the_comma_operator_Did_you_mean_to_write_an_array.code, @@ -1422,14 +1422,14 @@ export const plainJSErrors: Set = new Set([ Diagnostics._0_modifier_cannot_appear_on_class_elements_of_this_kind.code, Diagnostics._0_modifier_cannot_be_used_here.code, Diagnostics._0_modifier_must_precede_1_modifier.code, - Diagnostics.const_declarations_can_only_be_declared_inside_a_block.code, - Diagnostics.const_declarations_must_be_initialized.code, + Diagnostics._0_declarations_can_only_be_declared_inside_a_block.code, + Diagnostics._0_declarations_must_be_initialized.code, Diagnostics.extends_clause_already_seen.code, - Diagnostics.let_declarations_can_only_be_declared_inside_a_block.code, Diagnostics.let_is_not_allowed_to_be_used_as_a_name_in_let_or_const_declarations.code, Diagnostics.Class_constructor_may_not_be_a_generator.code, Diagnostics.Class_constructor_may_not_be_an_accessor.code, Diagnostics.await_expressions_are_only_allowed_within_async_functions_and_at_the_top_levels_of_modules.code, + Diagnostics.await_using_statements_are_only_allowed_within_async_functions_and_at_the_top_levels_of_modules.code, // Type errors Diagnostics.This_condition_will_always_return_0_since_JavaScript_compares_objects_by_reference_not_value.code, ]); diff --git a/src/compiler/scanner.ts b/src/compiler/scanner.ts index 9f539aec49d80..c2d945a020911 100644 --- a/src/compiler/scanner.ts +++ b/src/compiler/scanner.ts @@ -194,6 +194,7 @@ export const textToKeywordObj: MapLike = { undefined: SyntaxKind.UndefinedKeyword, unique: SyntaxKind.UniqueKeyword, unknown: SyntaxKind.UnknownKeyword, + using: SyntaxKind.UsingKeyword, var: SyntaxKind.VarKeyword, void: SyntaxKind.VoidKeyword, while: SyntaxKind.WhileKeyword, diff --git a/src/compiler/transformer.ts b/src/compiler/transformer.ts index a6bf29119479c..f8c1ee5d5eeca 100644 --- a/src/compiler/transformer.ts +++ b/src/compiler/transformer.ts @@ -72,7 +72,7 @@ import { transformNodeModule, transformSystemModule, transformTypeScript, - VariableDeclaration, + VariableDeclaration } from "./_namespaces/ts"; import * as performance from "./_namespaces/ts.performance"; @@ -131,11 +131,6 @@ function getScriptTransformers(compilerOptions: CompilerOptions, customTransform if (compilerOptions.experimentalDecorators) { transformers.push(transformLegacyDecorators); } - else if (languageVersion < ScriptTarget.ESNext || !useDefineForClassFields) { - transformers.push(transformESDecorators); - } - - transformers.push(transformClassFields); if (getJSXTransformEnabled(compilerOptions)) { transformers.push(transformJsx); @@ -145,6 +140,12 @@ function getScriptTransformers(compilerOptions: CompilerOptions, customTransform transformers.push(transformESNext); } + if (!compilerOptions.experimentalDecorators && (languageVersion < ScriptTarget.ESNext || !useDefineForClassFields)) { + transformers.push(transformESDecorators); + } + + transformers.push(transformClassFields); + if (languageVersion < ScriptTarget.ES2021) { transformers.push(transformES2021); } diff --git a/src/compiler/transformers/classFields.ts b/src/compiler/transformers/classFields.ts index f038aa3d37a27..07adbf4b1cbf6 100644 --- a/src/compiler/transformers/classFields.ts +++ b/src/compiler/transformers/classFields.ts @@ -20,6 +20,8 @@ import { ClassDeclaration, ClassElement, ClassExpression, + classHasClassThisAssignment, + classHasExplicitlyAssignedName, ClassLikeDeclaration, classOrConstructorParameterIsDecorated, ClassStaticBlockDeclaration, @@ -44,7 +46,7 @@ import { filter, find, findComputedPropertyNameCacheAssignment, - findSuperStatementIndex, + findSuperStatementIndexPath, flattenCommaList, ForStatement, GeneratedIdentifier, @@ -80,14 +82,16 @@ import { isArrowFunction, isAssignmentExpression, isAutoAccessorPropertyDeclaration, - isBindingName, + isBlock, isCallChain, isCallToHelper, + isCatchClause, isClassDeclaration, isClassElement, isClassExpression, - isClassLike, + isClassNamedEvaluationHelperBlock, isClassStaticBlockDeclaration, + isClassThisAssignmentBlock, isCommaExpression, isCompoundAssignment, isComputedPropertyName, @@ -96,7 +100,6 @@ import { isElementAccessExpression, isExportOrDefaultModifier, isExpression, - isExpressionStatement, isForInitializer, isGeneratedIdentifier, isGeneratedPrivateIdentifier, @@ -104,6 +107,7 @@ import { isGetAccessorDeclaration, isHeritageClause, isIdentifier, + isIdentifierText, isInitializedProperty, isLeftHandSideExpression, isMethodDeclaration, @@ -127,7 +131,6 @@ import { isPropertyAssignment, isPropertyDeclaration, isPropertyName, - isPropertyNameLiteral, isSetAccessor, isSetAccessorDeclaration, isShorthandPropertyAssignment, @@ -138,9 +141,11 @@ import { isStatement, isStatic, isStaticModifier, + isStringLiteral, isSuperProperty, isTemplateLiteral, isThisProperty, + isTryStatement, isVoidExpression, LeftHandSideExpression, LexicalEnvironment, @@ -153,6 +158,7 @@ import { moveRangePos, newPrivateEnvironment, Node, + NodeArray, NodeCheckFlags, NodeFactory, nodeIsSynthesized, @@ -161,7 +167,6 @@ import { OuterExpressionKinds, ParameterDeclaration, ParenthesizedExpression, - PartiallyEmittedExpression, PostfixUnaryExpression, PrefixUnaryExpression, PrivateEnvironment, @@ -203,6 +208,7 @@ import { ThisExpression, TransformationContext, TransformFlags, + transformNamedEvaluation, tryCast, tryGetTextOfPropertyName, unescapeLeadingUnderscores, @@ -217,7 +223,7 @@ import { visitNodes, Visitor, visitParameterList, - VisitResult, + VisitResult } from "../_namespaces/ts"; const enum ClassPropertySubstitutionFlags { @@ -462,7 +468,7 @@ export function transformClassFields(context: TransformationContext): (x: Source case SyntaxKind.ClassDeclaration: return visitClassDeclaration(node as ClassDeclaration); case SyntaxKind.ClassExpression: - return visitClassExpression(node as ClassExpression, /*referencedName*/ undefined); + return visitClassExpression(node as ClassExpression); case SyntaxKind.ClassStaticBlockDeclaration: case SyntaxKind.PropertyDeclaration: return Debug.fail("Use `classElementVisitor` instead."); @@ -490,7 +496,7 @@ export function transformClassFields(context: TransformationContext): (x: Source case SyntaxKind.BinaryExpression: return visitBinaryExpression(node as BinaryExpression, /*discarded*/ false); case SyntaxKind.ParenthesizedExpression: - return visitParenthesizedExpression(node as ParenthesizedExpression, /*discarded*/ false, /*referencedName*/ undefined); + return visitParenthesizedExpression(node as ParenthesizedExpression, /*discarded*/ false); case SyntaxKind.CallExpression: return visitCallExpression(node as CallExpression); case SyntaxKind.ExpressionStatement: @@ -499,6 +505,8 @@ export function transformClassFields(context: TransformationContext): (x: Source return visitTaggedTemplateExpression(node as TaggedTemplateExpression); case SyntaxKind.ForStatement: return visitForStatement(node as ForStatement); + case SyntaxKind.ThisKeyword: + return visitThisExpression(node as ThisExpression); case SyntaxKind.FunctionDeclaration: case SyntaxKind.FunctionExpression: // If we are descending into a new scope, clear the current class element @@ -527,19 +535,6 @@ export function transformClassFields(context: TransformationContext): (x: Source return visitEachChild(node, visitor, context); } - function namedEvaluationVisitor(node: Node, referencedName: Expression): VisitResult { - switch (node.kind) { - case SyntaxKind.PartiallyEmittedExpression: - return visitPartiallyEmittedExpression(node as PartiallyEmittedExpression, /*discarded*/ false, referencedName); - case SyntaxKind.ParenthesizedExpression: - return visitParenthesizedExpression(node as ParenthesizedExpression, /*discarded*/ false, referencedName); - case SyntaxKind.ClassExpression: - return visitClassExpression(node as ClassExpression, referencedName); - default: - return visitor(node); - } - } - /** * Visits a node in an expression whose result is discarded. */ @@ -553,7 +548,7 @@ export function transformClassFields(context: TransformationContext): (x: Source case SyntaxKind.CommaListExpression: return visitCommaListExpression(node as CommaListExpression, /*discarded*/ true); case SyntaxKind.ParenthesizedExpression: - return visitParenthesizedExpression(node as ParenthesizedExpression, /*discarded*/ true, /*referencedName*/ undefined); + return visitParenthesizedExpression(node as ParenthesizedExpression, /*discarded*/ true); default: return visitor(node); } @@ -692,9 +687,7 @@ export function transformClassFields(context: TransformationContext): (x: Source // ... if (isNamedEvaluation(node, isAnonymousClassNeedingAssignedName)) { - const { referencedName, name } = visitReferencedPropertyName(node.name); - const initializer = visitNode(node.initializer, node => namedEvaluationVisitor(node, referencedName), isExpression); - return factory.updatePropertyAssignment(node, name, initializer); + node = transformNamedEvaluation(context, node); } return visitEachChild(node, visitor, context); @@ -713,13 +706,6 @@ export function transformClassFields(context: TransformationContext): (x: Source return statement; } - function getAssignedNameOfIdentifier(name: Identifier, initializer: Expression) { - const originalClass = getOriginalNode(initializer, isClassLike); - return originalClass && !originalClass.name && hasSyntacticModifier(originalClass, ModifierFlags.Default) ? - factory.createStringLiteral("default") : - factory.createStringLiteralFromNode(name); - } - function visitVariableDeclaration(node: VariableDeclaration) { // 14.3.1.2 RS: Evaluation // LexicalBinding : BindingIdentifier Initializer @@ -736,10 +722,7 @@ export function transformClassFields(context: TransformationContext): (x: Source // ... if (isNamedEvaluation(node, isAnonymousClassNeedingAssignedName)) { - const assignedName = getAssignedNameOfIdentifier(node.name, node.initializer); - const name = visitNode(node.name, visitor, isBindingName); - const initializer = visitNode(node.initializer, node => namedEvaluationVisitor(node, assignedName), isExpression); - return factory.updateVariableDeclaration(node, name, /*exclamationToken*/ undefined, /*type*/ undefined, initializer); + node = transformNamedEvaluation(context, node); } return visitEachChild(node, visitor, context); @@ -763,18 +746,7 @@ export function transformClassFields(context: TransformationContext): (x: Source // ... if (isNamedEvaluation(node, isAnonymousClassNeedingAssignedName)) { - const assignedName = getAssignedNameOfIdentifier(node.name, node.initializer); - const name = visitNode(node.name, visitor, isBindingName); - const initializer = visitNode(node.initializer, node => namedEvaluationVisitor(node, assignedName), isExpression); - return factory.updateParameterDeclaration( - node, - /*modifiers*/ undefined, - /*dotDotDotToken*/ undefined, - name, - /*questionToken*/ undefined, - /*type*/ undefined, - initializer - ); + node = transformNamedEvaluation(context, node); } return visitEachChild(node, visitor, context); @@ -798,11 +770,7 @@ export function transformClassFields(context: TransformationContext): (x: Source // ... if (isNamedEvaluation(node, isAnonymousClassNeedingAssignedName)) { - const assignedName = getAssignedNameOfIdentifier(node.name, node.initializer); - const propertyName = visitNode(node.propertyName, visitor, isPropertyName); - const name = visitNode(node.name, visitor, isBindingName); - const initializer = visitNode(node.initializer, node => namedEvaluationVisitor(node, assignedName), isExpression); - return factory.updateBindingElement(node, /*dotDotDotToken*/ undefined, propertyName, name, initializer); + node = transformNamedEvaluation(context, node); } return visitEachChild(node, visitor, context); @@ -819,10 +787,7 @@ export function transformClassFields(context: TransformationContext): (x: Source // is `""`. if (isNamedEvaluation(node, isAnonymousClassNeedingAssignedName)) { - const assignedName = factory.createStringLiteral(node.isExportEquals ? "" : "default"); - const modifiers = visitNodes(node.modifiers, modifierVisitor, isModifier); - const expression = visitNode(node.expression, node => namedEvaluationVisitor(node, assignedName), isExpression); - return factory.updateExportAssignment(node, modifiers, expression); + node = transformNamedEvaluation(context, node, /*ignoreEmptyStringLiteral*/ true, node.isExportEquals ? "" : "default"); } return visitEachChild(node, visitor, context); @@ -1023,15 +988,7 @@ export function transformClassFields(context: TransformationContext): (x: Source } if (isNamedEvaluation(node, isAnonymousClassNeedingAssignedName)) { - const { referencedName, name } = visitReferencedPropertyName(node.name); - return factory.updatePropertyDeclaration( - node, - visitNodes(node.modifiers, modifierVisitor, isModifier), - name, - /*questionOrExclamationToken*/ undefined, - /*type*/ undefined, - visitNode(node.initializer, child => namedEvaluationVisitor(child, referencedName), isExpression) - ); + node = transformNamedEvaluation(context, node); } return factory.updatePropertyDeclaration( @@ -1052,8 +1009,7 @@ export function transformClassFields(context: TransformationContext): (x: Source const expr = getPropertyNameExpressionIfNeeded( node.name, - /*shouldHoist*/ !!node.initializer || useDefineForClassFields, - /*captureReferencedName*/ isNamedEvaluation(node, isAnonymousClassNeedingAssignedName)); + /*shouldHoist*/ !!node.initializer || useDefineForClassFields); if (expr) { getPendingExpressions().push(...flattenCommaList(expr)); } @@ -1448,6 +1404,21 @@ export function transformClassFields(context: TransformationContext): (x: Source } if (shouldTransformPrivateElementsOrClassStaticBlocks) { + if (isClassThisAssignmentBlock(node)) { + const result = visitNode(node.body.statements[0].expression, visitor, isExpression); + // If the generated `_classThis` assignment is a noop (i.e., `_classThis = _classThis`), we can + // eliminate the expression + if (isAssignmentExpression(result, /*excludeCompoundAssignment*/ true) && + result.left === result.right) { + return undefined; + } + return result; + } + + if (isClassNamedEvaluationHelperBlock(node)) { + return visitNode(node.body.statements[0].expression, visitor, isExpression); + } + startLexicalEnvironment(); let statements = setCurrentClassElementAnd( node, @@ -1457,9 +1428,10 @@ export function transformClassFields(context: TransformationContext): (x: Source statements = factory.mergeLexicalEnvironment(statements, endLexicalEnvironment()); const iife = factory.createImmediatelyInvokedArrowFunction(statements); + setOriginalNode(skipParentheses(iife.expression), node); + addEmitFlags(skipParentheses(iife.expression), EmitFlags.AdviseOnEmitNode); setOriginalNode(iife, node); setTextRange(iife, node); - addEmitFlags(iife, EmitFlags.AdviseOnEmitNode); return iife; } } @@ -1467,14 +1439,8 @@ export function transformClassFields(context: TransformationContext): (x: Source function isAnonymousClassNeedingAssignedName(node: AnonymousFunctionDefinition) { if (isClassExpression(node) && !node.name) { const staticPropertiesOrClassStaticBlocks = getStaticPropertiesAndClassStaticBlock(node); - const classStaticBlock = find(staticPropertiesOrClassStaticBlocks, isClassStaticBlockDeclaration); - if (classStaticBlock) { - for (const statement of classStaticBlock.body.statements) { - if (isExpressionStatement(statement) && - isCallToHelper(statement.expression, "___setFunctionName" as __String)) { - return false; - } - } + if (some(staticPropertiesOrClassStaticBlocks, isClassNamedEvaluationHelperBlock)) { + return false; } const hasTransformableStatics = @@ -1536,10 +1502,8 @@ export function transformClassFields(context: TransformationContext): (x: Source // ... if (isNamedEvaluation(node, isAnonymousClassNeedingAssignedName)) { - const assignedName = getAssignedNameOfIdentifier(node.left, node.right); - const left = visitNode(node.left, visitor, isExpression); - const right = visitNode(node.right, node => namedEvaluationVisitor(node, assignedName), isExpression); - return factory.updateBinaryExpression(node, left, node.operatorToken, right); + node = transformNamedEvaluation(context, node); + Debug.assertNode(node, isAssignmentExpression); } const left = skipOuterExpressions(node.left, OuterExpressionKinds.PartiallyEmittedExpressions | OuterExpressionKinds.Parentheses); @@ -1645,7 +1609,7 @@ export function transformClassFields(context: TransformationContext): (x: Source return factory.updateCommaListExpression(node, elements); } - function visitParenthesizedExpression(node: ParenthesizedExpression, discarded: boolean, referencedName: Expression | undefined) { + function visitParenthesizedExpression(node: ParenthesizedExpression, discarded: boolean) { // 8.4.5 RS: NamedEvaluation // ParenthesizedExpression : `(` Expression `)` // ... @@ -1653,42 +1617,11 @@ export function transformClassFields(context: TransformationContext): (x: Source const visitorFunc: Visitor = discarded ? discardedValueVisitor : - referencedName ? node => namedEvaluationVisitor(node, referencedName) : visitor; const expression = visitNode(node.expression, visitorFunc, isExpression); return factory.updateParenthesizedExpression(node, expression); } - function visitPartiallyEmittedExpression(node: PartiallyEmittedExpression, discarded: boolean, referencedName: Expression | undefined) { - // Emulates 8.4.5 RS: NamedEvaluation - - const visitorFunc: Visitor = - discarded ? discardedValueVisitor : - referencedName ? node => namedEvaluationVisitor(node, referencedName) : - visitor; - const expression = visitNode(node.expression, visitorFunc, isExpression); - return factory.updatePartiallyEmittedExpression(node, expression); - } - - function visitReferencedPropertyName(node: PropertyName) { - if (isPropertyNameLiteral(node) || isPrivateIdentifier(node)) { - const referencedName = factory.createStringLiteralFromNode(node); - const name = visitNode(node, visitor, isPropertyName); - return { referencedName, name }; - } - - if (isPropertyNameLiteral(node.expression) && !isIdentifier(node.expression)) { - const referencedName = factory.createStringLiteralFromNode(node.expression); - const name = visitNode(node, visitor, isPropertyName); - return { referencedName, name }; - } - - const referencedName = factory.createTempVariable(hoistVariableDeclaration); - const key = emitHelpers().createPropKeyHelper(visitNode(node.expression, visitor, isExpression)); - const assignment = factory.createAssignment(referencedName, key); - const name = factory.updateComputedPropertyName(node, injectPendingExpressions(assignment)); - return { referencedName, name }; - } function createPrivateIdentifierAssignment(info: PrivateIdentifierInfo, receiver: Expression, right: Expression, operator: AssignmentOperator): Expression { receiver = visitNode(receiver, visitor, isExpression); @@ -1750,6 +1683,9 @@ export function transformClassFields(context: TransformationContext): (x: Source if (isClassDeclaration(original) && classOrConstructorParameterIsDecorated(legacyDecorators, original)) { facts |= ClassFacts.ClassWasDecorated; } + if (shouldTransformPrivateElementsOrClassStaticBlocks && (classHasClassThisAssignment(node) || classHasExplicitlyAssignedName(node))) { + facts |= ClassFacts.NeedsClassConstructorReference; + } let containsPublicInstanceFields = false; let containsInitializedPublicInstanceFields = false; let containsInstancePrivateElements = false; @@ -1820,7 +1756,7 @@ export function transformClassFields(context: TransformationContext): (x: Source return visitEachChild(node, visitor, context); } - function visitInNewClassLexicalEnvironment(node: T, referencedName: Expression | undefined, visitor: (node: T, facts: ClassFacts, referencedName: Expression | undefined) => U) { + function visitInNewClassLexicalEnvironment(node: T, visitor: (node: T, facts: ClassFacts) => U) { const savedCurrentClassContainer = currentClassContainer; const savedPendingExpressions = pendingExpressions; const savedLexicalEnvironment = lexicalEnvironment; @@ -1834,6 +1770,22 @@ export function transformClassFields(context: TransformationContext): (x: Source if (name && isIdentifier(name)) { getPrivateIdentifierEnvironment().data.className = name; } + else if (node.emitNode?.assignedName) { + if (isStringLiteral(node.emitNode.assignedName)) { + // If the class name was assigned from a string literal based on an Identifier, use the Identifier + // as the prefix. + if (node.emitNode.assignedName.textSourceNode && + isIdentifier(node.emitNode.assignedName.textSourceNode)) { + getPrivateIdentifierEnvironment().data.className = node.emitNode.assignedName.textSourceNode; + } + // If the class name was assigned from a string literal that is a valid identifier, create an + // identifier from it. + else if (isIdentifierText(node.emitNode.assignedName.text, languageVersion)) { + const prefixName = factory.createIdentifier(node.emitNode.assignedName.text); + getPrivateIdentifierEnvironment().data.className = prefixName; + } + } + } } if (shouldTransformPrivateElementsOrClassStaticBlocks) { @@ -1855,7 +1807,7 @@ export function transformClassFields(context: TransformationContext): (x: Source enableSubstitutionForClassStaticThisOrSuperReference(); } - const result = visitor(node, facts, referencedName); + const result = visitor(node, facts); endClassLexicalEnvironment(); Debug.assert(lexicalEnvironment === savedLexicalEnvironment); currentClassContainer = savedCurrentClassContainer; @@ -1865,7 +1817,7 @@ export function transformClassFields(context: TransformationContext): (x: Source } function visitClassDeclaration(node: ClassDeclaration) { - return visitInNewClassLexicalEnvironment(node, /*referencedName*/ undefined, visitClassDeclarationInNewClassLexicalEnvironment); + return visitInNewClassLexicalEnvironment(node, visitClassDeclarationInNewClassLexicalEnvironment); } function visitClassDeclarationInNewClassLexicalEnvironment(node: ClassDeclaration, facts: ClassFacts) { @@ -1952,11 +1904,11 @@ export function transformClassFields(context: TransformationContext): (x: Source return statements; } - function visitClassExpression(node: ClassExpression, referencedName: Expression | undefined): Expression { - return visitInNewClassLexicalEnvironment(node, referencedName, visitClassExpressionInNewClassLexicalEnvironment); + function visitClassExpression(node: ClassExpression): Expression { + return visitInNewClassLexicalEnvironment(node, visitClassExpressionInNewClassLexicalEnvironment); } - function visitClassExpressionInNewClassLexicalEnvironment(node: ClassExpression, facts: ClassFacts, referencedName: Expression | undefined): Expression { + function visitClassExpressionInNewClassLexicalEnvironment(node: ClassExpression, facts: ClassFacts): Expression { // If this class expression is a transformation of a decorated class declaration, // then we want to output the pendingExpressions as statements, not as inlined // expressions with the class statement. @@ -2002,7 +1954,7 @@ export function transformClassFields(context: TransformationContext): (x: Source const modifiers = visitNodes(node.modifiers, modifierVisitor, isModifier); const heritageClauses = visitNodes(node.heritageClauses, heritageClauseVisitor, isHeritageClause); const { members, prologue } = transformClassMembers(node); - let classExpression = factory.updateClassExpression( + const classExpression = factory.updateClassExpression( node, modifiers, node.name, @@ -2025,7 +1977,7 @@ export function transformClassFields(context: TransformationContext): (x: Source isPrivateIdentifierClassElementDeclaration(node) || shouldTransformInitializers && isInitializedProperty(node)); - if (hasTransformableStatics || some(pendingExpressions) || referencedName) { + if (hasTransformableStatics || some(pendingExpressions)) { if (isDecoratedClassDeclaration) { Debug.assertIsDefined(pendingStatements, "Decorated classes transformed by TypeScript are expected to be within a variable declaration."); @@ -2034,30 +1986,6 @@ export function transformClassFields(context: TransformationContext): (x: Source addRange(pendingStatements, map(pendingExpressions, factory.createExpressionStatement)); } - if (referencedName) { - if (shouldTransformPrivateElementsOrClassStaticBlocks) { - const setNameExpression = emitHelpers().createSetFunctionNameHelper(temp ?? node.emitNode?.classThis ?? factory.getInternalName(node), referencedName); - pendingStatements.push(factory.createExpressionStatement(setNameExpression)); - } - else { - const setNameExpression = emitHelpers().createSetFunctionNameHelper(factory.createThis(), referencedName); - classExpression = factory.updateClassExpression( - classExpression, - classExpression.modifiers, - classExpression.name, - classExpression.typeParameters, - classExpression.heritageClauses, [ - factory.createClassStaticBlockDeclaration( - factory.createBlock([ - factory.createExpressionStatement(setNameExpression) - ]) - ), - ...classExpression.members - ] - ); - } - } - if (some(staticPropertiesOrClassStaticBlocks)) { addPropertyOrClassStaticBlockStatements(pendingStatements, staticPropertiesOrClassStaticBlocks, node.emitNode?.classThis ?? factory.getInternalName(node)); } @@ -2086,9 +2014,6 @@ export function transformClassFields(context: TransformationContext): (x: Source // Add any pending expressions leftover from elided or relocated computed property names addRange(expressions, pendingExpressions); - if (referencedName) { - expressions.push(emitHelpers().createSetFunctionNameHelper(temp, referencedName)); - } addRange(expressions, generateInitializedPropertyExpressionsOrClassStaticBlock(staticPropertiesOrClassStaticBlocks, temp)); expressions.push(factory.cloneNode(temp)); } @@ -2115,6 +2040,17 @@ export function transformClassFields(context: TransformationContext): (x: Source return undefined; } + function visitThisExpression(node: ThisExpression) { + if (shouldTransformThisInStaticInitializers && currentClassElement && + isClassStaticBlockDeclaration(currentClassElement) && + lexicalEnvironment?.data) { + const { classThis, classConstructor } = lexicalEnvironment.data; + return classThis ?? classConstructor ?? node; + } + + return node; + } + function transformClassMembers(node: ClassDeclaration | ClassExpression) { const shouldTransformPrivateStaticElementsInClass = !!(getInternalEmitFlags(node) & InternalEmitFlags.TransformPrivateStaticElements); @@ -2197,9 +2133,16 @@ export function transformClassFields(context: TransformationContext): (x: Source // and return a new array. if (syntheticConstructor || syntheticStaticBlock) { let membersArray: ClassElement[] | undefined; + const classThisAssignmentBlock = find(members, isClassThisAssignmentBlock); + const classNamedEvaluationHelperBlock = find(members, isClassNamedEvaluationHelperBlock); + membersArray = append(membersArray, classThisAssignmentBlock); + membersArray = append(membersArray, classNamedEvaluationHelperBlock); membersArray = append(membersArray, syntheticConstructor); membersArray = append(membersArray, syntheticStaticBlock); - membersArray = addRange(membersArray, members); + const remainingMembers = classThisAssignmentBlock || classNamedEvaluationHelperBlock ? + filter(members, member => member !== classThisAssignmentBlock && member !== classNamedEvaluationHelperBlock) : + members; + membersArray = addRange(membersArray, remainingMembers); members = setTextRange(factory.createNodeArray(membersArray), /*location*/ node.members); } @@ -2256,6 +2199,66 @@ export function transformClassFields(context: TransformationContext): (x: Source ); } + function transformConstructorBodyWorker(statementsOut: Statement[], statementsIn: NodeArray, statementOffset: number, superPath: readonly number[], superPathDepth: number, initializerStatements: readonly Statement[], constructor: ConstructorDeclaration) { + const superStatementIndex = superPath[superPathDepth]; + const superStatement = statementsIn[superStatementIndex]; + addRange(statementsOut, visitNodes(statementsIn, visitor, isStatement, statementOffset, superStatementIndex - statementOffset)); + statementOffset = superStatementIndex + 1; + if (isTryStatement(superStatement)) { + const tryBlockStatements: Statement[] = []; + + transformConstructorBodyWorker( + tryBlockStatements, + superStatement.tryBlock.statements, + /*statementOffset*/ 0, + superPath, + superPathDepth + 1, + initializerStatements, + constructor); + + const tryBlockStatementsArray = factory.createNodeArray(tryBlockStatements); + setTextRange(tryBlockStatementsArray, superStatement.tryBlock.statements); + + statementsOut.push(factory.updateTryStatement( + superStatement, + factory.updateBlock(superStatement.tryBlock, tryBlockStatements), + visitNode(superStatement.catchClause, visitor, isCatchClause), + visitNode(superStatement.finallyBlock, visitor, isBlock))); + } + else { + addRange(statementsOut, visitNodes(statementsIn, visitor, isStatement, superStatementIndex, 1)); + + // Add the property initializers. Transforms this: + // + // public x = 1; + // + // Into this: + // + // constructor() { + // this.x = 1; + // } + // + // If we do useDefineForClassFields, they'll be converted elsewhere. + // We instead *remove* them from the transformed output at this stage. + + // parameter-property assignments should occur immediately after the prologue and `super()`, + // so only count the statements that immediately follow. + while (statementOffset < statementsIn.length) { + const statement = statementsIn[statementOffset]; + if (isParameterPropertyDeclaration(getOriginalNode(statement), constructor)) { + statementOffset++; + } + else { + break; + } + } + + addRange(statementsOut, initializerStatements); + } + + addRange(statementsOut, visitNodes(statementsIn, visitor, isStatement, statementOffset)); + } + function transformConstructorBody(node: ClassDeclaration | ClassExpression, constructor: ConstructorDeclaration | undefined, isDerivedClass: boolean) { const instanceProperties = getProperties(node, /*requireInitializer*/ false, /*isStatic*/ false); let properties = instanceProperties; @@ -2274,45 +2277,9 @@ export function transformClassFields(context: TransformationContext): (x: Source resumeLexicalEnvironment(); const needsSyntheticConstructor = !constructor && isDerivedClass; - let indexOfFirstStatementAfterSuperAndPrologue = 0; - let prologueStatementCount = 0; - let superStatementIndex = -1; + let statementOffset = 0; let statements: Statement[] = []; - if (constructor?.body?.statements) { - prologueStatementCount = factory.copyPrologue(constructor.body.statements, statements, /*ensureUseStrict*/ false, visitor); - superStatementIndex = findSuperStatementIndex(constructor.body.statements, prologueStatementCount); - - // If there was a super call, visit existing statements up to and including it - if (superStatementIndex >= 0) { - indexOfFirstStatementAfterSuperAndPrologue = superStatementIndex + 1; - statements = [ - ...statements.slice(0, prologueStatementCount), - ...visitNodes(constructor.body.statements, visitor, isStatement, prologueStatementCount, indexOfFirstStatementAfterSuperAndPrologue - prologueStatementCount), - ...statements.slice(prologueStatementCount), - ]; - } - else if (prologueStatementCount >= 0) { - indexOfFirstStatementAfterSuperAndPrologue = prologueStatementCount; - } - } - - if (needsSyntheticConstructor) { - // Add a synthetic `super` call: - // - // super(...arguments); - // - statements.push( - factory.createExpressionStatement( - factory.createCallExpression( - factory.createSuper(), - /*typeArguments*/ undefined, - [factory.createSpreadElement(factory.createIdentifier("arguments"))] - ) - ) - ); - } - // Add the property initializers. Transforms this: // // public x = 1; @@ -2323,42 +2290,68 @@ export function transformClassFields(context: TransformationContext): (x: Source // this.x = 1; // } // - // If we do useDefineForClassFields, they'll be converted elsewhere. - // We instead *remove* them from the transformed output at this stage. - let parameterPropertyDeclarationCount = 0; - if (constructor?.body) { - // parameter-property assignments should occur immediately after the prologue and `super()`, - // so only count the statements that immediately follow. - for (let i = indexOfFirstStatementAfterSuperAndPrologue; i < constructor.body.statements.length; i++) { - const statement = constructor.body.statements[i]; - if (isParameterPropertyDeclaration(getOriginalNode(statement), constructor)) { - parameterPropertyDeclarationCount++; - } - else { - break; - } - } - if (parameterPropertyDeclarationCount > 0) { - indexOfFirstStatementAfterSuperAndPrologue += parameterPropertyDeclarationCount; - } - } - + const initializerStatements: Statement[] = []; const receiver = factory.createThis(); + // private methods can be called in property initializers, they should execute first. - addInstanceMethodStatements(statements, privateMethodsAndAccessors, receiver); + addInstanceMethodStatements(initializerStatements, privateMethodsAndAccessors, receiver); if (constructor) { const parameterProperties = filter(instanceProperties, prop => isParameterPropertyDeclaration(getOriginalNode(prop), constructor)); const nonParameterProperties = filter(properties, prop => !isParameterPropertyDeclaration(getOriginalNode(prop), constructor)); - addPropertyOrClassStaticBlockStatements(statements, parameterProperties, receiver); - addPropertyOrClassStaticBlockStatements(statements, nonParameterProperties, receiver); + addPropertyOrClassStaticBlockStatements(initializerStatements, parameterProperties, receiver); + addPropertyOrClassStaticBlockStatements(initializerStatements, nonParameterProperties, receiver); } else { - addPropertyOrClassStaticBlockStatements(statements, properties, receiver); + addPropertyOrClassStaticBlockStatements(initializerStatements, properties, receiver); } - // Add existing statements after the initial prologues and super call - if (constructor) { - addRange(statements, visitNodes(constructor.body!.statements, visitor, isStatement, indexOfFirstStatementAfterSuperAndPrologue)); + if (constructor?.body) { + statementOffset = factory.copyPrologue(constructor.body.statements, statements, /*ensureUseStrict*/ false, visitor); + const superStatementIndices = findSuperStatementIndexPath(constructor.body.statements, statementOffset); + if (superStatementIndices.length) { + transformConstructorBodyWorker( + statements, + constructor.body.statements, + statementOffset, + superStatementIndices, + /*superPathDepth*/ 0, + initializerStatements, + constructor + ); + } + else { + // parameter-property assignments should occur immediately after the prologue and `super()`, + // so only count the statements that immediately follow. + while (statementOffset < constructor.body.statements.length) { + const statement = constructor.body.statements[statementOffset]; + if (isParameterPropertyDeclaration(getOriginalNode(statement), constructor)) { + statementOffset++; + } + else { + break; + } + } + addRange(statements, initializerStatements); + addRange(statements, visitNodes(constructor.body.statements, visitor, isStatement, statementOffset)); + } + } + else { + if (needsSyntheticConstructor) { + // Add a synthetic `super` call: + // + // super(...arguments); + // + statements.push( + factory.createExpressionStatement( + factory.createCallExpression( + factory.createSuper(), + /*typeArguments*/ undefined, + [factory.createSpreadElement(factory.createIdentifier("arguments"))] + ) + ) + ); + } + addRange(statements, initializerStatements); } statements = factory.mergeLexicalEnvironment(statements, endLexicalEnvironment()); @@ -2406,7 +2399,7 @@ export function transformClassFields(context: TransformationContext): (x: Source function transformPropertyOrClassStaticBlock(property: PropertyDeclaration | ClassStaticBlockDeclaration, receiver: LeftHandSideExpression) { const expression = isClassStaticBlockDeclaration(property) ? - transformClassStaticBlockDeclaration(property) : + setCurrentClassElementAnd(property, transformClassStaticBlockDeclaration, property) : transformProperty(property, receiver); if (!expression) { return undefined; @@ -2451,7 +2444,9 @@ export function transformClassFields(context: TransformationContext): (x: Source function generateInitializedPropertyExpressionsOrClassStaticBlock(propertiesOrClassStaticBlocks: readonly (PropertyDeclaration | ClassStaticBlockDeclaration)[], receiver: LeftHandSideExpression) { const expressions: Expression[] = []; for (const property of propertiesOrClassStaticBlocks) { - const expression = isClassStaticBlockDeclaration(property) ? transformClassStaticBlockDeclaration(property) : transformProperty(property, receiver); + const expression = isClassStaticBlockDeclaration(property) ? + setCurrentClassElementAnd(property, transformClassStaticBlockDeclaration, property) : + setCurrentClassElementAnd(property, () => transformProperty(property, receiver), /*arg*/ undefined); if (!expression) { continue; } @@ -2490,17 +2485,8 @@ export function transformClassFields(context: TransformationContext): (x: Source // We generate a name here in order to reuse the value cached by the relocated computed name expression (which uses the same generated name) const emitAssignment = !useDefineForClassFields; - let referencedName: Expression | undefined; if (isNamedEvaluation(property, isAnonymousClassNeedingAssignedName)) { - if (isPropertyNameLiteral(property.name) || isPrivateIdentifier(property.name)) { - referencedName = factory.createStringLiteralFromNode(property.name); - } - else if (isPropertyNameLiteral(property.name.expression) && !isIdentifier(property.name.expression)) { - referencedName = factory.createStringLiteralFromNode(property.name.expression); - } - else { - referencedName = factory.getGeneratedNameForNode(property.name); - } + property = transformNamedEvaluation(context, property); } const propertyName = @@ -2514,10 +2500,6 @@ export function transformClassFields(context: TransformationContext): (x: Source currentClassElement = property; } - const initializerVisitor: Visitor = - referencedName ? child => namedEvaluationVisitor(child, referencedName!) : - visitor; - if (isPrivateIdentifier(propertyName) && shouldTransformClassElementToWeakMap(property as PrivateIdentifierPropertyDeclaration)) { const privateIdentifierInfo = accessPrivateIdentifier(propertyName); if (privateIdentifierInfo) { @@ -2526,7 +2508,7 @@ export function transformClassFields(context: TransformationContext): (x: Source return createPrivateInstanceFieldInitializer( factory, receiver, - visitNode(property.initializer, initializerVisitor, isExpression), + visitNode(property.initializer, visitor, isExpression), privateIdentifierInfo.brandCheckIdentifier ); } @@ -2534,7 +2516,7 @@ export function transformClassFields(context: TransformationContext): (x: Source return createPrivateStaticFieldInitializer( factory, privateIdentifierInfo.variableName, - visitNode(property.initializer, initializerVisitor, isExpression) + visitNode(property.initializer, visitor, isExpression) ); } } @@ -2555,7 +2537,7 @@ export function transformClassFields(context: TransformationContext): (x: Source return undefined; } - let initializer = visitNode(property.initializer, initializerVisitor, isExpression); + let initializer = visitNode(property.initializer, visitor, isExpression); if (isParameterPropertyDeclaration(propertyOriginalNode, propertyOriginalNode.parent) && isIdentifier(propertyName)) { // A parameter-property declaration always overrides the initializer. The only time a parameter-property // declaration *should* have an initializer is when decorators have added initializers that need to run before @@ -2666,10 +2648,10 @@ export function transformClassFields(context: TransformationContext): (x: Source * value of the result or the expression itself if the value is either unused or safe to inline into multiple locations * @param shouldHoist Does the expression need to be reused? (ie, for an initializer or a decorator) */ - function getPropertyNameExpressionIfNeeded(name: PropertyName, shouldHoist: boolean, captureReferencedName: boolean): Expression | undefined { + function getPropertyNameExpressionIfNeeded(name: PropertyName, shouldHoist: boolean): Expression | undefined { if (isComputedPropertyName(name)) { const cacheAssignment = findComputedPropertyNameCacheAssignment(name); - let expression = visitNode(name.expression, visitor, isExpression); + const expression = visitNode(name.expression, visitor, isExpression); const innerExpression = skipPartiallyEmittedExpressions(expression); const inlinable = isSimpleInlineableExpression(innerExpression); const alreadyTransformed = !!cacheAssignment || isAssignmentExpression(innerExpression) && isGeneratedIdentifier(innerExpression.left); @@ -2681,9 +2663,6 @@ export function transformClassFields(context: TransformationContext): (x: Source else { hoistVariableDeclaration(generatedName); } - if (captureReferencedName) { - expression = emitHelpers().createPropKeyHelper(expression); - } return factory.createAssignment(generatedName, expression); } return (inlinable || isIdentifier(innerExpression)) ? undefined : expression; @@ -3024,10 +3003,7 @@ export function transformClassFields(context: TransformationContext): (x: Source // ... if (isNamedEvaluation(node, isAnonymousClassNeedingAssignedName)) { - const left = visitDestructuringAssignmentTarget(node.left); - const assignedName = getAssignedNameOfIdentifier(node.left, node.right); - const right = visitNode(node.right, node => namedEvaluationVisitor(node, assignedName), isExpression); - return factory.updateBinaryExpression(node, left, node.operatorToken, right) as AssignmentExpression; + node = transformNamedEvaluation(context, node); } if (isAssignmentExpression(node, /*excludeCompoundAssignment*/ true)) { const left = visitDestructuringAssignmentTarget(node.left); @@ -3092,9 +3068,7 @@ export function transformClassFields(context: TransformationContext): (x: Source // ... if (isNamedEvaluation(node, isAnonymousClassNeedingAssignedName)) { - const assignedName = getAssignedNameOfIdentifier(node.name, node.objectAssignmentInitializer); - const objectAssignmentInitializer = visitNode(node.objectAssignmentInitializer, node => namedEvaluationVisitor(node, assignedName), isExpression); - return factory.updateShorthandPropertyAssignment(node, node.name, objectAssignmentInitializer); + node = transformNamedEvaluation(context, node); } return visitEachChild(node, visitor, context); @@ -3240,9 +3214,6 @@ export function transformClassFields(context: TransformationContext): (x: Source lexicalEnvironment?.data && !noSubstitution.has(node)) { const { facts, classConstructor, classThis } = lexicalEnvironment.data; - if (facts & ClassFacts.ClassWasDecorated && legacyDecorators) { - return factory.createParenthesizedExpression(factory.createVoidZero()); - } const substituteThis = shouldSubstituteThisWithClassThis ? classThis ?? classConstructor : classConstructor; if (substituteThis) { return setTextRange( @@ -3253,6 +3224,9 @@ export function transformClassFields(context: TransformationContext): (x: Source node ); } + if (facts & ClassFacts.ClassWasDecorated && legacyDecorators) { + return factory.createParenthesizedExpression(factory.createVoidZero()); + } } return node; } diff --git a/src/compiler/transformers/classThis.ts b/src/compiler/transformers/classThis.ts new file mode 100644 index 0000000000000..b03cd68144b09 --- /dev/null +++ b/src/compiler/transformers/classThis.ts @@ -0,0 +1,148 @@ +import { + AssignmentExpression, + Block, + ClassLikeDeclaration, + ClassStaticBlockDeclaration, + EqualsToken, + ExpressionStatement, + getOrCreateEmitNode, + Identifier, + isAssignmentExpression, + isClassDeclaration, + isClassStaticBlockDeclaration, + isExpressionStatement, + isIdentifier, + Node, + NodeArray, + NodeFactory, + setSourceMapRange, + setTextRange, + some, + Statement, + SyntaxKind, + ThisExpression +} from "../_namespaces/ts"; + +/** + * Creates a class `static {}` block used to assign the static `this` to a `_classThis` (or similar) variable. + * + * @param classThis The identifier to use for the captured static `this` reference, usually with the name `_classThis`. + * @param thisExpression Overrides the expression to use for the actual `this` reference. This can be used to provide an + * expression that has already had its `EmitFlags` set or may have been tracked to prevent substitution. + * @internal + */ +export function createClassThisAssignmentBlock(factory: NodeFactory, classThis: Identifier, thisExpression = factory.createThis()): ClassThisAssignmentBlock { + // produces: + // + // static { _classThis = this; } + // + + const expression = factory.createAssignment(classThis, thisExpression); + const statement = factory.createExpressionStatement(expression); + const body = factory.createBlock([statement], /*multiLine*/ false); + const block = factory.createClassStaticBlockDeclaration(body); + + // We use `emitNode.classThis` to indicate this is a `_classThis` assignment helper block + // and to stash the variable used for `_classThis`. + getOrCreateEmitNode(block).classThis = classThis; + + return block as ClassThisAssignmentBlock; +} + +/** @internal */ +export type ClassThisAssignmentBlock = ClassStaticBlockDeclaration & { + readonly body: Block & { + readonly statements: NodeArray & readonly [ + ExpressionStatement & { + readonly expression: AssignmentExpression & { + readonly left: Identifier; + readonly right: ThisExpression; + }; + } + ]; + }; +}; + +/** + * Gets whether a node is a `static {}` block containing only a single assignment of the static `this` to the `_classThis` + * (or similar) variable stored in the `classthis` property of the block's `EmitNode`. + * @internal + */ +export function isClassThisAssignmentBlock(node: Node): node is ClassThisAssignmentBlock { + if (!isClassStaticBlockDeclaration(node) || node.body.statements.length !== 1) { + return false; + } + + const statement = node.body.statements[0]; + return isExpressionStatement(statement) && + isAssignmentExpression(statement.expression, /*excludeCompoundAssignment*/ true) && + isIdentifier(statement.expression.left) && + node.emitNode?.classThis === statement.expression.left && + statement.expression.right.kind === SyntaxKind.ThisKeyword; +} + +/** + * Gets whether a `ClassLikeDeclaration` has a `static {}` block containing only a single assignment to a + * `_classThis` (or similar) variable. + * @internal + */ +export function classHasClassThisAssignment(node: ClassLikeDeclaration) { + return !!node.emitNode?.classThis && some(node.members, isClassThisAssignmentBlock); +} + +/** + * Injects a class `static {}` block containing only an assignment of the static `this` to a `_classThis` (or similar) + * variable. + * + * @param classThis The identifier to use for the captured static `this` reference, usually with the name `_classThis`. + * @param thisExpression Overrides the expression to use for the actual `this` reference. This can be used to provide an + * expression that has already had its `EmitFlags` set or may have been tracked to prevent substitution. + * @internal + */ +export function injectClassThisAssignmentIfMissing(factory: NodeFactory, node: T, + classThis: Identifier, thisExpression?: ThisExpression): Extract>; +export function injectClassThisAssignmentIfMissing(factory: NodeFactory, node: T, + classThis: Identifier, thisExpression?: ThisExpression) { + + // given: + // + // class C { + // } + // + // produces: + // + // class C { + // static { _classThis = this; } + // } + + if (classHasClassThisAssignment(node)) { + return node; + } + + const staticBlock = createClassThisAssignmentBlock(factory, classThis, thisExpression); + if (node.name) { + setSourceMapRange(staticBlock.body.statements[0], node.name); + } + + const members = factory.createNodeArray([staticBlock, ...node.members]); + setTextRange(members, node.members); + + const updatedNode = isClassDeclaration(node) ? + factory.updateClassDeclaration( + node, + node.modifiers, + node.name, + node.typeParameters, + node.heritageClauses, + members) : + factory.updateClassExpression( + node, + node.modifiers, + node.name, + node.typeParameters, + node.heritageClauses, + members); + + getOrCreateEmitNode(updatedNode).classThis = classThis; + return updatedNode; +} diff --git a/src/compiler/transformers/declarations.ts b/src/compiler/transformers/declarations.ts index 4be05fd79eb06..e94128e8e30a4 100644 --- a/src/compiler/transformers/declarations.ts +++ b/src/compiler/transformers/declarations.ts @@ -150,7 +150,9 @@ import { isTypeParameterDeclaration, isTypeQueryNode, isUnparsedSource, + isVarAwaitUsing, isVariableDeclaration, + isVarUsing, last, LateBoundDeclaration, LateVisibilityPaintedStatement, @@ -217,6 +219,7 @@ import { unescapeLeadingUnderscores, UnparsedSource, VariableDeclaration, + VariableDeclarationList, VariableStatement, visitArray, visitEachChild, @@ -1763,7 +1766,19 @@ export function transformDeclarations(context: TransformationContext) { if (!forEach(input.declarationList.declarations, getBindingNameVisible)) return; const nodes = visitNodes(input.declarationList.declarations, visitDeclarationSubtree, isVariableDeclaration); if (!length(nodes)) return; - return factory.updateVariableStatement(input, factory.createNodeArray(ensureModifiers(input)), factory.updateVariableDeclarationList(input.declarationList, nodes)); + + const modifiers = factory.createNodeArray(ensureModifiers(input)); + let declList: VariableDeclarationList; + if (isVarUsing(input.declarationList) || isVarAwaitUsing(input.declarationList)) { + declList = factory.createVariableDeclarationList(nodes, NodeFlags.Const); + setOriginalNode(declList, input.declarationList); + setTextRange(declList, input.declarationList); + setCommentRange(declList, input.declarationList); + } + else { + declList = factory.updateVariableDeclarationList(input.declarationList, nodes); + } + return factory.updateVariableStatement(input, modifiers, declList); } function recreateBindingPattern(d: BindingPattern): VariableDeclaration[] { diff --git a/src/compiler/transformers/es2015.ts b/src/compiler/transformers/es2015.ts index a6e9222b4e8da..5e2b895a23498 100644 --- a/src/compiler/transformers/es2015.ts +++ b/src/compiler/transformers/es2015.ts @@ -39,11 +39,12 @@ import { elementAt, EmitFlags, EmitHint, - emptyArray, + every, Expression, ExpressionStatement, ExpressionWithTypeArguments, filter, + findSuperStatementIndexPath, first, firstOrUndefined, flatten, @@ -112,11 +113,13 @@ import { isIterationStatement, isLabeledStatement, isModifier, + isNumericLiteral, isObjectLiteralElementLike, + isObjectLiteralExpression, isOmittedExpression, isPackedArrayLiteral, isPrivateIdentifier, - isPrologueDirective, + isPropertyAssignment, isPropertyDeclaration, isPropertyName, isReturnStatement, @@ -129,6 +132,7 @@ import { isVariableDeclaration, isVariableDeclarationList, isVariableStatement, + isVoidExpression, isWithStatement, IterationStatement, LabeledStatement, @@ -186,7 +190,6 @@ import { SwitchStatement, SyntaxKind, TaggedTemplateExpression, - takeWhile, TemplateExpression, TextRange, TokenFlags, @@ -205,7 +208,7 @@ import { VisitResult, VoidExpression, WhileStatement, - YieldExpression, + YieldExpression } from "../_namespaces/ts"; const enum ES2015SubstitutionFlags { @@ -1188,6 +1191,190 @@ export function transformES2015(context: TransformationContext): (x: SourceFile return block; } + function transformConstructorBodyWorker( + prologueOut: Statement[], + statementsOut: Statement[], + statementsIn: NodeArray, + statementOffset: number, + superPath: readonly number[], + superPathDepth: number, + constructor: ConstructorDeclaration & { body: FunctionBody }, + isDerivedClass: boolean, + hasSynthesizedSuper: boolean, + isFirstStatement: boolean, + ): boolean { + let mayReplaceThis = false; + + const superStatementIndex = superPathDepth < superPath.length ? superPath[superPathDepth] : -1; + const leadingStatementsEnd = superStatementIndex >= 0 ? superStatementIndex : statementsIn.length; + + // find the index of the first statement material to evaluation + if (isFirstStatement && superStatementIndex >= 0) { + let firstMaterialIndex = statementOffset; + while (isFirstStatement && firstMaterialIndex < superStatementIndex) { + const statement = constructor.body.statements[firstMaterialIndex]; + if (!isUninitializedVariableStatement(statement) && !isUsingDeclarationStateVariableStatement(statement)) break; + firstMaterialIndex++; + } + + isFirstStatement = superStatementIndex === firstMaterialIndex; + } + + // visit everything prior to the statement containing `super()`. + addRange(statementsOut, visitNodes(statementsIn, visitor, isStatement, statementOffset, leadingStatementsEnd - statementOffset)); + + const superStatement = superStatementIndex >= 0 ? statementsIn[superStatementIndex] : undefined; + if (superStatement && isTryStatement(superStatement)) { + const tryBlockStatements: Statement[] = []; + + mayReplaceThis = transformConstructorBodyWorker( + prologueOut, + tryBlockStatements, + superStatement.tryBlock.statements, + /*statementOffset*/ 0, + superPath, + superPathDepth + 1, + constructor, + isDerivedClass, + hasSynthesizedSuper, + isFirstStatement); + + const tryBlockStatementsArray = factory.createNodeArray(tryBlockStatements); + setTextRange(tryBlockStatementsArray, superStatement.tryBlock.statements); + + statementsOut.push(factory.updateTryStatement( + superStatement, + factory.updateBlock(superStatement.tryBlock, tryBlockStatements), + visitNode(superStatement.catchClause, visitor, isCatchClause), + visitNode(superStatement.finallyBlock, visitor, isBlock))); + } + else { + const superCall = superStatement && getSuperCallFromStatement(superStatement); + let superCallExpression: Expression | undefined; + if (hasSynthesizedSuper) { + superCallExpression = createDefaultSuperCallOrThis(); + hierarchyFacts |= HierarchyFacts.ConstructorWithCapturedSuper; + } + else if (superCall) { + superCallExpression = visitSuperCallInBody(superCall); + hierarchyFacts |= HierarchyFacts.ConstructorWithCapturedSuper; + } + + if (isDerivedClass || superCallExpression) { + if (superCallExpression && + superStatementIndex === statementsIn.length - 1 && + !(constructor.body.transformFlags & TransformFlags.ContainsLexicalThis)) { + // If the subclass constructor does *not* contain `this` and *ends* with a `super()` call, we will use the + // following representation: + // + // ``` + // // es2015 (source) + // class C extends Base { + // constructor() { + // super("foo"); + // } + // } + // + // // es5 (transformed) + // var C = (function (_super) { + // function C() { + // return _super.call(this, "foo") || this; + // } + // return C; + // })(Base); + // ``` + + const superCall = cast(cast(superCallExpression, isBinaryExpression).left, isCallExpression); + const returnStatement = factory.createReturnStatement(superCallExpression); + setCommentRange(returnStatement, getCommentRange(superCall)); + setEmitFlags(superCall, EmitFlags.NoComments); + statementsOut.push(returnStatement); + return false; + } + else { + // Otherwise, we will use the following transformed representation for calls to `super()` in a constructor: + // + // ``` + // // es2015 (source) + // class C extends Base { + // constructor() { + // super("foo"); + // this.x = 1; + // } + // } + // + // // es5 (transformed) + // var C = (function (_super) { + // function C() { + // var _this = _super.call(this, "foo") || this; + // _this.x = 1; + // return _this; + // } + // return C; + // })(Base); + // ``` + + // If the super() call is the first statement, we can directly create and assign its result to `_this` + if (isFirstStatement) { + insertCaptureThisForNode(statementsOut, constructor, superCallExpression || createActualThis()); + } + // Since the `super()` call isn't the first statement, it's split across 1-2 statements: + // * A prologue `var _this = this;`, in case the constructor accesses this before super() + // * If it exists, a reassignment to that `_this` of the super() call + else { + insertCaptureThisForNode(prologueOut, constructor, createActualThis()); + if (superCallExpression) { + addSuperThisCaptureThisForNode(statementsOut, superCallExpression); + } + } + + mayReplaceThis = true; + } + } + else { + // If a class is not derived from a base class or does not have a call to `super()`, `this` is only + // captured when necessitated by an arrow function capturing the lexical `this`: + // + // ``` + // // es2015 + // class C {} + // + // // es5 + // var C = (function () { + // function C() { + // } + // return C; + // })(); + // ``` + insertCaptureThisForNodeIfNeeded(prologueOut, constructor); + } + } + + // visit everything following the statement containing `super()`. + if (superStatementIndex >= 0) { + addRange(statementsOut, visitNodes(statementsIn, visitor, isStatement, superStatementIndex + 1)); + } + + return mayReplaceThis; + } + + function isUninitializedVariableStatement(node: Statement) { + return isVariableStatement(node) && every(node.declarationList.declarations, decl => isIdentifier(decl.name) && !decl.initializer); + } + + function isUsingDeclarationStateVariableStatement(node: Statement) { + if (!isVariableStatement(node) || node.declarationList.declarations.length !== 1) return false; + const varDecl = node.declarationList.declarations[0]; + if (!isIdentifier(varDecl.name) || !varDecl.initializer) return false; + const initializer = varDecl.initializer; + if (!isObjectLiteralExpression(initializer) || initializer.properties.length !== 3) return false; + const [stackProp, errorProp, hasErrorProp] = initializer.properties; + if (!isPropertyAssignment(stackProp) || !isIdentifier(stackProp.name) || idText(stackProp.name) !== "stack" || !isArrayLiteralExpression(stackProp.initializer)) return false; + if (!isPropertyAssignment(errorProp) || !isIdentifier(errorProp.name) || idText(errorProp.name) !== "error" || !isVoidExpression(errorProp.initializer) || !isNumericLiteral(errorProp.initializer.expression)) return false; + if (!isPropertyAssignment(hasErrorProp) || !isIdentifier(hasErrorProp.name) || idText(hasErrorProp.name) !== "hasError" || hasErrorProp.initializer.kind !== SyntaxKind.FalseKeyword) return false; + return true; + } + /** * Transforms the body of a constructor declaration of a class. * @@ -1226,134 +1413,40 @@ export function transformES2015(context: TransformationContext): (x: SourceFile // In derived classes, there may be code before the necessary super() call // We'll remove pre-super statements to be tacked on after the rest of the body - const existingPrologue = takeWhile(constructor.body.statements, isPrologueDirective); - const { superCall, superStatementIndex } = findSuperCallAndStatementIndex(constructor.body.statements, existingPrologue); - const postSuperStatementsStart = superStatementIndex === -1 ? existingPrologue.length : superStatementIndex + 1; - - // If a super call has already been synthesized, - // we're going to assume that we should just transform everything after that. - // The assumption is that no prior step in the pipeline has added any prologue directives. - let statementOffset = postSuperStatementsStart; - if (!hasSynthesizedSuper) statementOffset = factory.copyStandardPrologue(constructor.body.statements, prologue, statementOffset, /*ensureUseStrict*/ false); - if (!hasSynthesizedSuper) statementOffset = factory.copyCustomPrologue(constructor.body.statements, statements, statementOffset, visitor, /*filter*/ undefined); - - // If there already exists a call to `super()`, visit the statement directly - let superCallExpression: Expression | undefined; - if (hasSynthesizedSuper) { - superCallExpression = createDefaultSuperCallOrThis(); - } - else if (superCall) { - superCallExpression = visitSuperCallInBody(superCall); - } - - if (superCallExpression) { + const standardPrologueEnd = factory.copyStandardPrologue(constructor.body.statements, prologue, /*statementOffset*/ 0); + const superStatementIndices = findSuperStatementIndexPath(constructor.body.statements, standardPrologueEnd); + if (hasSynthesizedSuper || superStatementIndices.length > 0) { hierarchyFacts |= HierarchyFacts.ConstructorWithCapturedSuper; } + const mayReplaceThis = transformConstructorBodyWorker( + prologue, + statements, + constructor.body.statements, + standardPrologueEnd, + superStatementIndices, + /*superPathDepth*/ 0, + constructor, + isDerivedClass, + hasSynthesizedSuper, + /*isFirstStatement*/ true // NOTE: this will be recalculated inside of transformConstructorBodyWorker + ); + // Add parameter defaults at the beginning of the output, with prologue statements addDefaultValueAssignmentsIfNeeded(prologue, constructor); addRestParameterIfNeeded(prologue, constructor, hasSynthesizedSuper); - - // visit the remaining statements - addRange(statements, visitNodes(constructor.body.statements, visitor, isStatement, /*start*/ statementOffset)); - + insertCaptureNewTargetIfNeeded(prologue, constructor); factory.mergeLexicalEnvironment(prologue, endLexicalEnvironment()); - insertCaptureNewTargetIfNeeded(prologue, constructor, /*copyOnWrite*/ false); - if (isDerivedClass || superCallExpression) { - if (superCallExpression && postSuperStatementsStart === constructor.body.statements.length && !(constructor.body.transformFlags & TransformFlags.ContainsLexicalThis)) { - // If the subclass constructor does *not* contain `this` and *ends* with a `super()` call, we will use the - // following representation: - // - // ``` - // // es2015 (source) - // class C extends Base { - // constructor() { - // super("foo"); - // } - // } - // - // // es5 (transformed) - // var C = (function (_super) { - // function C() { - // return _super.call(this, "foo") || this; - // } - // return C; - // })(Base); - // ``` - const superCall = cast(cast(superCallExpression, isBinaryExpression).left, isCallExpression); - const returnStatement = factory.createReturnStatement(superCallExpression); - setCommentRange(returnStatement, getCommentRange(superCall)); - setEmitFlags(superCall, EmitFlags.NoComments); - statements.push(returnStatement); - } - else { - // Otherwise, we will use the following transformed representation for calls to `super()` in a constructor: - // - // ``` - // // es2015 (source) - // class C extends Base { - // constructor() { - // super("foo"); - // this.x = 1; - // } - // } - // - // // es5 (transformed) - // var C = (function (_super) { - // function C() { - // var _this = _super.call(this, "foo") || this; - // _this.x = 1; - // return _this; - // } - // return C; - // })(Base); - // ``` - - // If the super() call is the first statement, we can directly create and assign its result to `_this` - if (superStatementIndex <= existingPrologue.length) { - insertCaptureThisForNode(statements, constructor, superCallExpression || createActualThis()); - } - // Since the `super()` call isn't the first statement, it's split across 1-2 statements: - // * A prologue `var _this = this;`, in case the constructor accesses this before super() - // * If it exists, a reassignment to that `_this` of the super() call - else { - insertCaptureThisForNode(prologue, constructor, createActualThis()); - if (superCallExpression) { - insertSuperThisCaptureThisForNode(statements, superCallExpression); - } - } - - if (!isSufficientlyCoveredByReturnStatements(constructor.body)) { - statements.push(factory.createReturnStatement(factory.createUniqueName("_this", GeneratedIdentifierFlags.Optimistic | GeneratedIdentifierFlags.FileLevel))); - } - } - } - else { - // If a class is not derived from a base class or does not have a call to `super()`, `this` is only - // captured when necessitated by an arrow function capturing the lexical `this`: - // - // ``` - // // es2015 - // class C {} - // - // // es5 - // var C = (function () { - // function C() { - // } - // return C; - // })(); - // ``` - insertCaptureThisForNodeIfNeeded(prologue, constructor); + if (mayReplaceThis && !isSufficientlyCoveredByReturnStatements(constructor.body)) { + statements.push(factory.createReturnStatement(factory.createUniqueName("_this", GeneratedIdentifierFlags.Optimistic | GeneratedIdentifierFlags.FileLevel))); } const body = factory.createBlock( setTextRange( factory.createNodeArray( [ - ...existingPrologue, ...prologue, - ...(superStatementIndex <= existingPrologue.length ? emptyArray : visitNodes(constructor.body.statements, visitor, isStatement, existingPrologue.length, superStatementIndex - existingPrologue.length)), ...statements ] ), @@ -1366,24 +1459,6 @@ export function transformES2015(context: TransformationContext): (x: SourceFile return body; } - function findSuperCallAndStatementIndex(originalBodyStatements: NodeArray, existingPrologue: Statement[]) { - for (let i = existingPrologue.length; i < originalBodyStatements.length; i += 1) { - const superCall = getSuperCallFromStatement(originalBodyStatements[i]); - if (superCall) { - // With a super() call, split the statements into pre-super() and 'body' (post-super()) - return { - superCall, - superStatementIndex: i, - }; - } - } - - // Since there was no super() call found, consider all statements to be in the main 'body' (post-super()) - return { - superStatementIndex: -1, - }; - } - /** * We want to try to avoid emitting a return statement in certain cases if a user already returned something. * It would generate obviously dead code, so we'll try to make things a little bit prettier @@ -1758,7 +1833,7 @@ export function transformES2015(context: TransformationContext): (x: SourceFile * @param statements Statements in the constructor body. * @param superExpression Existing `super()` call for the constructor. */ - function insertSuperThisCaptureThisForNode(statements: Statement[], superExpression: Expression): void { + function addSuperThisCaptureThisForNode(statements: Statement[], superExpression: Expression): void { enableSubstitutionsForCapturedThis(); const assignSuperExpression = factory.createExpressionStatement( factory.createBinaryExpression( @@ -1767,7 +1842,7 @@ export function transformES2015(context: TransformationContext): (x: SourceFile superExpression ) ); - insertStatementAfterCustomPrologue(statements, assignSuperExpression); + statements.push(assignSuperExpression); setCommentRange(assignSuperExpression, getOriginalNode(superExpression).parent); } @@ -1789,7 +1864,7 @@ export function transformES2015(context: TransformationContext): (x: SourceFile insertStatementAfterCustomPrologue(statements, captureThisStatement); } - function insertCaptureNewTargetIfNeeded(statements: Statement[], node: FunctionLikeDeclaration, copyOnWrite: boolean): Statement[] { + function insertCaptureNewTargetIfNeeded(statements: Statement[], node: FunctionLikeDeclaration): Statement[] { if (hierarchyFacts & HierarchyFacts.NewTarget) { let newTarget: Expression; switch (node.kind) { @@ -1853,11 +1928,6 @@ export function transformES2015(context: TransformationContext): (x: SourceFile ); setEmitFlags(captureNewTargetStatement, EmitFlags.NoComments | EmitFlags.CustomPrologue); - - if (copyOnWrite) { - statements = statements.slice(); - } - insertStatementAfterCustomPrologue(statements, captureNewTargetStatement); } @@ -2232,7 +2302,7 @@ export function transformES2015(context: TransformationContext): (x: SourceFile } factory.mergeLexicalEnvironment(prologue, endLexicalEnvironment()); - insertCaptureNewTargetIfNeeded(prologue, node, /*copyOnWrite*/ false); + insertCaptureNewTargetIfNeeded(prologue, node); insertCaptureThisForNodeIfNeeded(prologue, node); // If we added any final generated statements, this must be a multi-line block diff --git a/src/compiler/transformers/esDecorators.ts b/src/compiler/transformers/esDecorators.ts index cdb69e6298752..d68dda028fa5a 100644 --- a/src/compiler/transformers/esDecorators.ts +++ b/src/compiler/transformers/esDecorators.ts @@ -18,6 +18,7 @@ import { ClassDeclaration, ClassElement, ClassExpression, + classHasDeclaredOrExplicitlyAssignedName, ClassLikeDeclaration, classOrConstructorParameterIsDecorated, ClassStaticBlockDeclaration, @@ -36,7 +37,7 @@ import { Expression, ExpressionStatement, findComputedPropertyNameCacheAssignment, - findSuperStatementIndex, + findSuperStatementIndexPath, firstOrUndefined, forEachEntry, ForStatement, @@ -46,11 +47,9 @@ import { getAllDecoratorsOfClassElement, getCommentRange, getEffectiveBaseTypeNode, - getEmitScriptTarget, getFirstConstructorWithBody, getHeritageClause, getNonAssignmentOperatorForCompoundAssignment, - getOrCreateEmitNode, getOriginalNode, getSourceMapRange, hasAccessorModifier, @@ -60,6 +59,8 @@ import { HeritageClause, Identifier, idText, + injectClassNamedEvaluationHelperBlockIfMissing, + injectClassThisAssignmentIfMissing, InternalEmitFlags, isAmbientPropertyDeclaration, isArrayBindingOrAssignmentElement, @@ -70,15 +71,18 @@ import { isAutoAccessorPropertyDeclaration, isBindingName, isBlock, + isCatchClause, isClassElement, isClassExpression, isClassLike, + isClassNamedEvaluationHelperBlock, isClassStaticBlockDeclaration, + isClassThisAssignmentBlock, isCompoundAssignment, isComputedPropertyName, isDestructuringAssignment, isElementAccessExpression, - isEmptyStringLiteral, + isExportModifier, isExpression, isForInitializer, isFunctionExpression, @@ -118,6 +122,7 @@ import { isStringLiteral, isSuperProperty, isTemplateLiteral, + isTryStatement, LeftHandSideExpression, map, MethodDeclaration, @@ -156,6 +161,7 @@ import { setSourceMapRange, setTextRange, ShorthandPropertyAssignment, + singleOrMany, skipOuterExpressions, skipParentheses, some, @@ -168,6 +174,7 @@ import { ThisExpression, TransformationContext, TransformFlags, + transformNamedEvaluation, tryCast, VariableDeclaration, visitCommaListElements, @@ -177,6 +184,7 @@ import { visitNodes, Visitor, VisitResult, + WrappedExpression } from "../_namespaces/ts"; // Class/Decorator evaluation order, as it pertains to this transformer: @@ -280,9 +288,6 @@ export function transformESDecorators(context: TransformationContext): (x: Sourc hoistVariableDeclaration, } = context; - const compilerOptions = context.getCompilerOptions(); - const languageVersion = getEmitScriptTarget(compilerOptions); - let top: LexicalEnvironmentStackEntry | undefined; let classInfo: ClassInfo | undefined; let classThis: Identifier | undefined; @@ -412,7 +417,7 @@ export function transformESDecorators(context: TransformationContext): (x: Sourc case SyntaxKind.ClassDeclaration: return visitClassDeclaration(node as ClassDeclaration); case SyntaxKind.ClassExpression: - return visitClassExpression(node as ClassExpression, /*referencedName*/ undefined); + return visitClassExpression(node as ClassExpression); case SyntaxKind.Constructor: case SyntaxKind.PropertyDeclaration: case SyntaxKind.ClassStaticBlockDeclaration: @@ -440,9 +445,9 @@ export function transformESDecorators(context: TransformationContext): (x: Sourc case SyntaxKind.CommaListExpression: return visitCommaListExpression(node as CommaListExpression, /*discarded*/ false); case SyntaxKind.ParenthesizedExpression: - return visitParenthesizedExpression(node as ParenthesizedExpression, /*discarded*/ false, /*referencedName*/ undefined); + return visitParenthesizedExpression(node as ParenthesizedExpression, /*discarded*/ false); case SyntaxKind.PartiallyEmittedExpression: - return visitPartiallyEmittedExpression(node as PartiallyEmittedExpression, /*discarded*/ false, /*referencedName*/ undefined); + return visitPartiallyEmittedExpression(node as PartiallyEmittedExpression, /*discarded*/ false); case SyntaxKind.CallExpression: return visitCallExpression(node as CallExpression); case SyntaxKind.TaggedTemplateExpression: @@ -510,19 +515,6 @@ export function transformESDecorators(context: TransformationContext): (x: Sourc } } - function namedEvaluationVisitor(node: Node, referencedName: Expression): VisitResult { - switch (node.kind) { - case SyntaxKind.PartiallyEmittedExpression: - return visitPartiallyEmittedExpression(node as PartiallyEmittedExpression, /*discarded*/ false, referencedName); - case SyntaxKind.ParenthesizedExpression: - return visitParenthesizedExpression(node as ParenthesizedExpression, /*discarded*/ false, referencedName); - case SyntaxKind.ClassExpression: - return visitClassExpression(node as ClassExpression, referencedName); - default: - return visitor(node); - } - } - function discardedValueVisitor(node: Node): VisitResult { switch (node.kind) { case SyntaxKind.PrefixUnaryExpression: @@ -533,7 +525,7 @@ export function transformESDecorators(context: TransformationContext): (x: Sourc case SyntaxKind.CommaListExpression: return visitCommaListExpression(node as CommaListExpression, /*discarded*/ true); case SyntaxKind.ParenthesizedExpression: - return visitParenthesizedExpression(node as ParenthesizedExpression, /*discarded*/ true, /*referencedName*/ undefined); + return visitParenthesizedExpression(node as ParenthesizedExpression, /*discarded*/ true); default: return visitor(node); } @@ -583,14 +575,16 @@ export function transformESDecorators(context: TransformationContext): (x: Sourc for (const member of node.members) { if (isNamedClassElement(member) && nodeOrChildIsDecorated(/*useLegacyDecorators*/ false, member, node)) { if (hasStaticModifier(member)) { - staticExtraInitializersName ??= factory.createUniqueName("_staticExtraInitializers", GeneratedIdentifierFlags.Optimistic); + staticExtraInitializersName ??= factory.createUniqueName("_staticExtraInitializers", GeneratedIdentifierFlags.Optimistic | GeneratedIdentifierFlags.FileLevel); } else { - instanceExtraInitializersName ??= factory.createUniqueName("_instanceExtraInitializers", GeneratedIdentifierFlags.Optimistic); + instanceExtraInitializersName ??= factory.createUniqueName("_instanceExtraInitializers", GeneratedIdentifierFlags.Optimistic | GeneratedIdentifierFlags.FileLevel); } } if (isClassStaticBlockDeclaration(member)) { - hasStaticInitializers = true; + if (!isClassNamedEvaluationHelperBlock(member)) { + hasStaticInitializers = true; + } } else if (isPropertyDeclaration(member)) { if (hasStaticModifier(member)) { @@ -637,9 +631,15 @@ export function transformESDecorators(context: TransformationContext): (x: Sourc return false; } - function transformClassLike(node: ClassLikeDeclaration, className: Expression) { + function transformClassLike(node: ClassLikeDeclaration) { startLexicalEnvironment(); + // When a class has class decorators we end up transforming it into a statement that would otherwise give it an + // assigned name. If the class doesn't have an assigned name, we'll give it an assigned name of `""`) + if (!classHasDeclaredOrExplicitlyAssignedName(node) && classOrConstructorParameterIsDecorated(/*useLegacyDecorators*/ false, node)) { + node = injectClassNamedEvaluationHelperBlockIfMissing(context, node, factory.createStringLiteral("")); + } + const classReference = factory.getLocalName(node, /*allowComments*/ false, /*allowSourceMaps*/ false, /*ignoreAssignedName*/ true); const classInfo = createClassInfo(node); const classDefinitionStatements: Statement[] = []; @@ -658,10 +658,15 @@ export function transformESDecorators(context: TransformationContext): (x: Sourc // of the mutated class. // - Since a class decorator can add extra initializers, we must define a variable to keep track of // extra initializers. - classInfo.classDecoratorsName = factory.createUniqueName("_classDecorators", GeneratedIdentifierFlags.Optimistic); - classInfo.classDescriptorName = factory.createUniqueName("_classDescriptor", GeneratedIdentifierFlags.Optimistic); - classInfo.classExtraInitializersName = factory.createUniqueName("_classExtraInitializers", GeneratedIdentifierFlags.Optimistic); - classInfo.classThis = factory.createUniqueName("_classThis", GeneratedIdentifierFlags.Optimistic); + classInfo.classDecoratorsName = factory.createUniqueName("_classDecorators", GeneratedIdentifierFlags.Optimistic | GeneratedIdentifierFlags.FileLevel); + classInfo.classDescriptorName = factory.createUniqueName("_classDescriptor", GeneratedIdentifierFlags.Optimistic | GeneratedIdentifierFlags.FileLevel); + classInfo.classExtraInitializersName = factory.createUniqueName("_classExtraInitializers", GeneratedIdentifierFlags.Optimistic | GeneratedIdentifierFlags.FileLevel); + // We do not mark _classThis as FileLevel if it may be reused by class private fields, which requires the + // ability access the captured `_classThis` of outer scopes. + const needsUniqueClassThis = some(node.members, member => (isPrivateIdentifierClassElementDeclaration(member) || isAutoAccessorPropertyDeclaration(member)) && hasStaticModifier(member)); + classInfo.classThis = factory.createUniqueName("_classThis", needsUniqueClassThis ? + GeneratedIdentifierFlags.Optimistic | GeneratedIdentifierFlags.ReservedInNestedScopes : + GeneratedIdentifierFlags.Optimistic | GeneratedIdentifierFlags.FileLevel); classDefinitionStatements.push( createLet(classInfo.classDecoratorsName, factory.createArrayLiteralExpression(classDecorators)), createLet(classInfo.classDescriptorName), @@ -681,7 +686,7 @@ export function transformESDecorators(context: TransformationContext): (x: Sourc const extendsElement = extendsClause && firstOrUndefined(extendsClause.types); const extendsExpression = extendsElement && visitNode(extendsElement.expression, visitor, isExpression); if (extendsExpression) { - classInfo.classSuper = factory.createUniqueName("_classSuper", GeneratedIdentifierFlags.Optimistic); + classInfo.classSuper = factory.createUniqueName("_classSuper", GeneratedIdentifierFlags.Optimistic | GeneratedIdentifierFlags.FileLevel); // Ensure we do not give the class or function an assigned name due to the variable by prefixing it // with `0, `. @@ -707,15 +712,8 @@ export function transformESDecorators(context: TransformationContext): (x: Sourc // 3. The name of the class is assigned. // - // If the class did not have a name, set the assigned name as if from NamedEvaluation. - // We don't need to use the assigned name if it consists of the empty string and the transformed class - // expression won't get its name from any other source (such as the variable we create to handle - // class decorators) - const needsSetNameHelper = !getOriginalNode(node, isClassLike)?.name && (classDecorators || !isStringLiteral(className) || !isEmptyStringLiteral(className)); - if (needsSetNameHelper) { - const setNameExpr = emitHelpers().createSetFunctionNameHelper(factory.createThis(), className); - leadingBlockStatements = append(leadingBlockStatements, factory.createExpressionStatement(setNameExpr)); - } + // If the class did not have a name, the caller should have performed injectClassNamedEvaluationHelperBlockIfMissing + // prior to calling this function if a name was needed. // 4. For each member: // a. Member Decorators are evaluated @@ -841,11 +839,12 @@ export function transformESDecorators(context: TransformationContext): (x: Sourc if (classInfo.classDescriptorName && classInfo.classDecoratorsName && classInfo.classExtraInitializersName && classInfo.classThis) { leadingBlockStatements ??= []; + // produces: // __esDecorate(null, _classDescriptor = { value: this }, _classDecorators, { kind: "class", name: this.name }, _classExtraInitializers); - const valueProperty = factory.createPropertyAssignment("value", factory.createThis()); + const valueProperty = factory.createPropertyAssignment("value", renamedClassThis); const classDescriptor = factory.createObjectLiteralExpression([valueProperty]); const classDescriptorAssignment = factory.createAssignment(classInfo.classDescriptorName, classDescriptor); - const classNameReference = factory.createPropertyAccessExpression(factory.createThis(), "name"); + const classNameReference = factory.createPropertyAccessExpression(renamedClassThis, "name"); const esDecorateHelper = emitHelpers().createESDecorateHelper( factory.createNull(), classDescriptorAssignment, @@ -858,6 +857,7 @@ export function transformESDecorators(context: TransformationContext): (x: Sourc setSourceMapRange(esDecorateStatement, moveRangePastDecorators(node)); leadingBlockStatements.push(esDecorateStatement); + // produces: // C = _classThis = _classDescriptor.value; const classDescriptorValueReference = factory.createPropertyAccessExpression(classInfo.classDescriptorName, "value"); const classThisAssignment = factory.createAssignment(classInfo.classThis, classDescriptorValueReference); @@ -889,43 +889,60 @@ export function transformESDecorators(context: TransformationContext): (x: Sourc trailingBlockStatements = undefined; } - let newMembers: readonly ClassElement[] = members; + // prepare a leading `static {}` block, if necessary + // + // produces: + // class C { + // static { ... } + // ... + // } + const leadingStaticBlock = leadingBlockStatements && + factory.createClassStaticBlockDeclaration(factory.createBlock(leadingBlockStatements, /*multiLine*/ true)); - // insert a leading `static {}` block, if necessary - if (leadingBlockStatements) { - // class C { - // static { ... } - // ... - // } - const leadingStaticBlockBody = factory.createBlock(leadingBlockStatements, /*multiLine*/ true); - const leadingStaticBlock = factory.createClassStaticBlockDeclaration(leadingStaticBlockBody); - if (shouldTransformPrivateStaticElementsInClass) { - // We use `InternalEmitFlags.TransformPrivateStaticElements` as a marker on a class static block - // to inform the classFields transform that it shouldn't rename `this` to `_classThis` in the - // transformed class static block. - setInternalEmitFlags(leadingStaticBlock, InternalEmitFlags.TransformPrivateStaticElements); - } - newMembers = [leadingStaticBlock, ...newMembers]; + if (leadingStaticBlock && shouldTransformPrivateStaticElementsInClass) { + // We use `InternalEmitFlags.TransformPrivateStaticElements` as a marker on a class static block + // to inform the classFields transform that it shouldn't rename `this` to `_classThis` in the + // transformed class static block. + setInternalEmitFlags(leadingStaticBlock, InternalEmitFlags.TransformPrivateStaticElements); } - // append the synthetic constructor, if necessary - if (syntheticConstructor) { - newMembers = [...newMembers, syntheticConstructor]; - } + // prepare a trailing `static {}` block, if necessary + // + // produces: + // class C { + // ... + // static { ... } + // } + const trailingStaticBlock = trailingBlockStatements && + factory.createClassStaticBlockDeclaration(factory.createBlock(trailingBlockStatements, /*multiLine*/ true)); - // append a trailing `static {}` block, if necessary - if (trailingBlockStatements) { - // class C { - // ... - // static { ... } - // } - const trailingStaticBlockBody = factory.createBlock(trailingBlockStatements, /*multiLine*/ true); - const trailingStaticBlock = factory.createClassStaticBlockDeclaration(trailingStaticBlockBody); - newMembers = [...newMembers, trailingStaticBlock]; - } + if (leadingStaticBlock || syntheticConstructor || trailingStaticBlock) { + const newMembers: ClassElement[] = []; + + // add the NamedEvaluation helper block, if needed + const existingNamedEvaluationHelperBlockIndex = members.findIndex(isClassNamedEvaluationHelperBlock); + + // add the leading `static {}` block + if (leadingStaticBlock) { + // add the `static {}` block after any existing NamedEvaluation helper block, if one exists. + addRange(newMembers, members, 0, existingNamedEvaluationHelperBlockIndex + 1); + newMembers.push(leadingStaticBlock); + addRange(newMembers, members, existingNamedEvaluationHelperBlockIndex + 1); + } + else { + addRange(newMembers, members); + } + + // append the synthetic constructor, if necessary + if (syntheticConstructor) { + newMembers.push(syntheticConstructor); + } + + // append a trailing `static {}` block, if necessary + if (trailingStaticBlock) { + newMembers.push(trailingStaticBlock); + } - // Update members with newly added members. - if (newMembers !== members) { members = setTextRange(factory.createNodeArray(newMembers), members); } @@ -935,6 +952,7 @@ export function transformESDecorators(context: TransformationContext): (x: Sourc // We use `var` instead of `let` so we can leverage NamedEvaluation to define the class name // and still be able to ensure it is initialized prior to any use in `static {}`. + // produces: // (() => { // let _classDecorators = [...]; // let _classDescriptor; @@ -955,6 +973,10 @@ export function transformESDecorators(context: TransformationContext): (x: Sourc // })(); classExpression = factory.createClassExpression(/*modifiers*/ undefined, /*name*/ undefined, /*typeParameters*/ undefined, heritageClauses, members); + if (classInfo.classThis) { + classExpression = injectClassThisAssignmentIfMissing(factory, classExpression, classInfo.classThis); + } + const classReferenceDeclaration = factory.createVariableDeclaration(classReference, /*exclamationToken*/ undefined, /*type*/ undefined, classExpression); const classReferenceVarDeclList = factory.createVariableDeclarationList([classReferenceDeclaration]); const returnExpr = classInfo.classThis ? factory.createAssignment(classReference, classInfo.classThis) : classReference; @@ -964,6 +986,7 @@ export function transformESDecorators(context: TransformationContext): (x: Sourc ); } else { + // produces: // return ; classExpression = factory.createClassExpression(/*modifiers*/ undefined, node.name, /*typeParameters*/ undefined, heritageClauses, members); classDefinitionStatements.push(factory.createReturnStatement(classExpression)); @@ -979,7 +1002,6 @@ export function transformESDecorators(context: TransformationContext): (x: Sourc } setOriginalNode(classExpression, node); - getOrCreateEmitNode(classExpression).classThis = classInfo.classThis; return factory.createImmediatelyInvokedArrowFunction(factory.mergeLexicalEnvironment(classDefinitionStatements, lexicalEnvironment)); } @@ -990,37 +1012,64 @@ export function transformESDecorators(context: TransformationContext): (x: Sourc function visitClassDeclaration(node: ClassDeclaration): VisitResult { if (isDecoratedClassLike(node)) { - if (hasSyntacticModifier(node, ModifierFlags.Export) && - hasSyntacticModifier(node, ModifierFlags.Default)) { - // export default (() => { ... })(); - const originalClass = getOriginalNode(node, isClassLike) ?? node; - const className = originalClass.name ? factory.createStringLiteralFromNode(originalClass.name) : factory.createStringLiteral("default"); - const iife = transformClassLike(node, className); - const statement = factory.createExportDefault(iife); - setOriginalNode(statement, node); - setCommentRange(statement, getCommentRange(node)); - setSourceMapRange(statement, moveRangePastDecorators(node)); - return statement; + const statements: Statement[] = []; + const originalClass = getOriginalNode(node, isClassLike) ?? node; + const className = originalClass.name ? factory.createStringLiteralFromNode(originalClass.name) : factory.createStringLiteral("default"); + const isExport = hasSyntacticModifier(node, ModifierFlags.Export); + const isDefault = hasSyntacticModifier(node, ModifierFlags.Default); + if (!node.name) { + node = injectClassNamedEvaluationHelperBlockIfMissing(context, node, className); + } + if (isExport && isDefault) { + const iife = transformClassLike(node); + if (node.name) { + // let C = (() => { ... })(); + // export default C; + const varDecl = factory.createVariableDeclaration(factory.getLocalName(node), /*exclamationToken*/ undefined, /*type*/ undefined, iife); + setOriginalNode(varDecl, node); + + const varDecls = factory.createVariableDeclarationList([varDecl], NodeFlags.Let); + const varStatement = factory.createVariableStatement(/*modifiers*/ undefined, varDecls); + statements.push(varStatement); + + const exportStatement = factory.createExportDefault(factory.getDeclarationName(node)); + setOriginalNode(exportStatement, node); + setCommentRange(exportStatement, getCommentRange(node)); + setSourceMapRange(exportStatement, moveRangePastDecorators(node)); + statements.push(exportStatement); + } + else { + // export default (() => { ... })(); + const exportStatement = factory.createExportDefault(iife); + setOriginalNode(exportStatement, node); + setCommentRange(exportStatement, getCommentRange(node)); + setSourceMapRange(exportStatement, moveRangePastDecorators(node)); + statements.push(exportStatement); + } } else { // let C = (() => { ... })(); Debug.assertIsDefined(node.name, "A class declaration that is not a default export must have a name."); - const iife = transformClassLike(node, factory.createStringLiteralFromNode(node.name)); - const modifiers = visitNodes(node.modifiers, modifierVisitor, isModifier); - // When we transform to ES5/3 this will be moved inside an IIFE and should reference the name - // without any block-scoped variable collision handling - const declName = languageVersion <= ScriptTarget.ES2015 ? - factory.getInternalName(node, /*allowComments*/ false, /*allowSourceMaps*/ true) : - factory.getLocalName(node, /*allowComments*/ false, /*allowSourceMaps*/ true); + const iife = transformClassLike(node); + const modifierVisitorNoExport = isExport ? ((node: ModifierLike) => isExportModifier(node) ? undefined : modifierVisitor(node)) : modifierVisitor; + const modifiers = visitNodes(node.modifiers, modifierVisitorNoExport, isModifier); + const declName = factory.getLocalName(node, /*allowComments*/ false, /*allowSourceMaps*/ true); const varDecl = factory.createVariableDeclaration(declName, /*exclamationToken*/ undefined, /*type*/ undefined, iife); setOriginalNode(varDecl, node); const varDecls = factory.createVariableDeclarationList([varDecl], NodeFlags.Let); - const statement = factory.createVariableStatement(modifiers, varDecls); - setOriginalNode(statement, node); - setCommentRange(statement, getCommentRange(node)); - return statement; + const varStatement = factory.createVariableStatement(modifiers, varDecls); + setOriginalNode(varStatement, node); + setCommentRange(varStatement, getCommentRange(node)); + statements.push(varStatement); + if (isExport) { + // export { C }; + const exportStatement = factory.createExternalModuleExport(declName); + setOriginalNode(exportStatement, node); + statements.push(exportStatement); + } } + return singleOrMany(statements); } else { const modifiers = visitNodes(node.modifiers, modifierVisitor, isModifier); @@ -1032,10 +1081,9 @@ export function transformESDecorators(context: TransformationContext): (x: Sourc } } - function visitClassExpression(node: ClassExpression, referencedName: Expression | undefined) { + function visitClassExpression(node: ClassExpression) { if (isDecoratedClassLike(node)) { - const className = node.name ? factory.createStringLiteralFromNode(node.name) : referencedName ?? factory.createStringLiteral(""); - const iife = transformClassLike(node, className); + const iife = transformClassLike(node); setOriginalNode(iife, node); return iife; } @@ -1072,6 +1120,37 @@ export function transformESDecorators(context: TransformationContext): (x: Sourc } } + function transformConstructorBodyWorker(statementsOut: Statement[], statementsIn: NodeArray, statementOffset: number, superPath: readonly number[], superPathDepth: number, initializerStatements: readonly Statement[]) { + const superStatementIndex = superPath[superPathDepth]; + const superStatement = statementsIn[superStatementIndex]; + addRange(statementsOut, visitNodes(statementsIn, visitor, isStatement, statementOffset, superStatementIndex - statementOffset)); + if (isTryStatement(superStatement)) { + const tryBlockStatements: Statement[] = []; + + transformConstructorBodyWorker( + tryBlockStatements, + superStatement.tryBlock.statements, + /*statementOffset*/ 0, + superPath, + superPathDepth + 1, + initializerStatements); + + const tryBlockStatementsArray = factory.createNodeArray(tryBlockStatements); + setTextRange(tryBlockStatementsArray, superStatement.tryBlock.statements); + + statementsOut.push(factory.updateTryStatement( + superStatement, + factory.updateBlock(superStatement.tryBlock, tryBlockStatements), + visitNode(superStatement.catchClause, visitor, isCatchClause), + visitNode(superStatement.finallyBlock, visitor, isBlock))); + } + else { + addRange(statementsOut, visitNodes(statementsIn, visitor, isStatement, superStatementIndex, 1)); + addRange(statementsOut, initializerStatements); + } + addRange(statementsOut, visitNodes(statementsIn, visitor, isStatement, superStatementIndex + 1)); + } + function visitConstructorDeclaration(node: ConstructorDeclaration) { enterClassElement(node); const modifiers = visitNodes(node.modifiers, modifierVisitor, isModifier); @@ -1084,11 +1163,9 @@ export function transformESDecorators(context: TransformationContext): (x: Sourc if (initializerStatements) { const statements: Statement[] = []; const nonPrologueStart = factory.copyPrologue(node.body.statements, statements, /*ensureUseStrict*/ false, visitor); - const superStatementIndex = findSuperStatementIndex(node.body.statements, nonPrologueStart); - if (superStatementIndex >= 0) { - addRange(statements, visitNodes(node.body.statements, visitor, isStatement, nonPrologueStart, superStatementIndex + 1 - nonPrologueStart)); - addRange(statements, initializerStatements); - addRange(statements, visitNodes(node.body.statements, visitor, isStatement, superStatementIndex + 1)); + const superStatementIndices = findSuperStatementIndexPath(node.body.statements, nonPrologueStart); + if (superStatementIndices.length > 0) { + transformConstructorBodyWorker(statements, node.body.statements, nonPrologueStart, superStatementIndices, 0, initializerStatements); } else { addRange(statements, initializerStatements); @@ -1119,7 +1196,6 @@ export function transformESDecorators(context: TransformationContext): (x: Sourc TNode extends MethodDeclaration | PropertyDeclaration | GetAccessorDeclaration | SetAccessorDeclaration, >( member: TNode, - useNamedEvaluation: boolean, classInfo: ClassInfo | undefined, createDescriptor?: (node: TNode & { readonly name: PrivateIdentifier }, modifiers: ModifiersArray | undefined) => Expression ) { @@ -1131,12 +1207,7 @@ export function transformESDecorators(context: TransformationContext): (x: Sourc if (!classInfo) { const modifiers = visitNodes(member.modifiers, modifierVisitor, isModifier); enterName(); - if (useNamedEvaluation) { - ({ referencedName, name } = visitReferencedPropertyName(member.name)); - } - else { - name = visitPropertyName(member.name); - } + name = visitPropertyName(member.name); exitName(); return { modifiers, referencedName, name, initializersName, descriptorName, thisArg }; } @@ -1215,8 +1286,8 @@ export function transformESDecorators(context: TransformationContext): (x: Sourc }; const extraInitializers = isStatic(member) ? - classInfo.staticExtraInitializersName ??= factory.createUniqueName("_staticExtraInitializers", GeneratedIdentifierFlags.Optimistic) : - classInfo.instanceExtraInitializersName ??= factory.createUniqueName("_instanceExtraInitializers", GeneratedIdentifierFlags.Optimistic); + classInfo.staticExtraInitializersName ??= factory.createUniqueName("_staticExtraInitializers", GeneratedIdentifierFlags.Optimistic | GeneratedIdentifierFlags.FileLevel) : + classInfo.instanceExtraInitializersName ??= factory.createUniqueName("_instanceExtraInitializers", GeneratedIdentifierFlags.Optimistic | GeneratedIdentifierFlags.FileLevel); if (isMethodOrAccessor(member)) { // __esDecorate(this, null, _static_member_decorators, { kind: "method", name: "...", static: true, private: false, access: { ... } }, _staticExtraInitializers); @@ -1278,12 +1349,7 @@ export function transformESDecorators(context: TransformationContext): (x: Sourc if (name === undefined) { enterName(); - if (useNamedEvaluation) { - ({ referencedName, name } = visitReferencedPropertyName(member.name)); - } - else { - name = visitPropertyName(member.name); - } + name = visitPropertyName(member.name); exitName(); } @@ -1298,7 +1364,7 @@ export function transformESDecorators(context: TransformationContext): (x: Sourc function visitMethodDeclaration(node: MethodDeclaration) { enterClassElement(node); - const { modifiers, name, descriptorName } = partialTransformClassElement(node, /*useNamedEvaluation*/ false, classInfo, createMethodDescriptorObject); + const { modifiers, name, descriptorName } = partialTransformClassElement(node, classInfo, createMethodDescriptorObject); if (descriptorName) { exitClassElement(); return finishClassElement(createMethodDescriptorForwarder(modifiers, name, descriptorName), node); @@ -1313,7 +1379,7 @@ export function transformESDecorators(context: TransformationContext): (x: Sourc function visitGetAccessorDeclaration(node: GetAccessorDeclaration) { enterClassElement(node); - const { modifiers, name, descriptorName } = partialTransformClassElement(node, /*useNamedEvaluation*/ false, classInfo, createGetAccessorDescriptorObject); + const { modifiers, name, descriptorName } = partialTransformClassElement(node, classInfo, createGetAccessorDescriptorObject); if (descriptorName) { exitClassElement(); return finishClassElement(createGetAccessorDescriptorForwarder(modifiers, name, descriptorName), node); @@ -1328,7 +1394,7 @@ export function transformESDecorators(context: TransformationContext): (x: Sourc function visitSetAccessorDeclaration(node: SetAccessorDeclaration) { enterClassElement(node); - const { modifiers, name, descriptorName } = partialTransformClassElement(node, /*useNamedEvaluation*/ false, classInfo, createSetAccessorDescriptorObject); + const { modifiers, name, descriptorName } = partialTransformClassElement(node, classInfo, createSetAccessorDescriptorObject); if (descriptorName) { exitClassElement(); return finishClassElement(createSetAccessorDescriptorForwarder(modifiers, name, descriptorName), node); @@ -1344,14 +1410,30 @@ export function transformESDecorators(context: TransformationContext): (x: Sourc function visitClassStaticBlockDeclaration(node: ClassStaticBlockDeclaration) { enterClassElement(node); - if (classInfo) classInfo.hasStaticInitializers = true; - const result = visitEachChild(node, visitor, context); + let result: ClassStaticBlockDeclaration; + if (isClassNamedEvaluationHelperBlock(node)) { + result = visitEachChild(node, visitor, context); + } + else if (isClassThisAssignmentBlock(node)) { + const savedClassThis = classThis; + classThis = undefined; + result = visitEachChild(node, visitor, context); + classThis = savedClassThis; + } + else { + if (classInfo) classInfo.hasStaticInitializers = true; + result = visitEachChild(node, visitor, context); + } exitClassElement(); return result; } function visitPropertyDeclaration(node: PropertyDeclaration) { + if (isNamedEvaluation(node, isAnonymousClassNeedingAssignedName)) { + node = transformNamedEvaluation(context, node, canIgnoreEmptyStringLiteralInAssignedName(node.initializer)); + } + enterClassElement(node); // TODO(rbuckton): We support decorating `declare x` fields with legacyDecorators, but we currently don't @@ -1366,15 +1448,11 @@ export function transformESDecorators(context: TransformationContext): (x: Sourc // a. Let _value_ be ? NamedEvaluation of |Initializer| with argument _functionObject_.[[ClassFieldInitializerName]]. // ... - const useNamedEvaluation = isNamedEvaluation(node, isAnonymousClassNeedingAssignedName); - const { modifiers, name, referencedName, initializersName, descriptorName, thisArg } = partialTransformClassElement(node, useNamedEvaluation, classInfo, hasAccessorModifier(node) ? createAccessorPropertyDescriptorObject : undefined); + const { modifiers, name, initializersName, descriptorName, thisArg } = partialTransformClassElement(node, classInfo, hasAccessorModifier(node) ? createAccessorPropertyDescriptorObject : undefined); startLexicalEnvironment(); - let initializer = referencedName ? - visitNode(node.initializer, node => namedEvaluationVisitor(node, referencedName), isExpression): - visitNode(node.initializer, visitor, isExpression); - + let initializer = visitNode(node.initializer, visitor, isExpression); if (initializersName) { initializer = emitHelpers().createRunInitializersHelper( thisArg ?? factory.createThis(), @@ -1542,32 +1620,20 @@ export function transformESDecorators(context: TransformationContext): (x: Sourc // i. Set _v_ to ? NamedEvaluation of |Initializer| with argument _bindingId_. // ... - let updated: ParameterDeclaration; if (isNamedEvaluation(node, isAnonymousClassNeedingAssignedName)) { - const assignedName = getAssignedNameOfIdentifier(node.name, node.initializer); - const name = visitNode(node.name, visitor, isBindingName); - const initializer = visitNode(node.initializer, node => namedEvaluationVisitor(node, assignedName), isExpression); - updated = factory.updateParameterDeclaration( - node, - /*modifiers*/ undefined, - /*dotDotDotToken*/ undefined, - name, - /*questionToken*/ undefined, - /*type*/ undefined, - initializer); - } - else { - updated = factory.updateParameterDeclaration( - node, - /*modifiers*/ undefined, - node.dotDotDotToken, - visitNode(node.name, visitor, isBindingName), - /*questionToken*/ undefined, - /*type*/ undefined, - visitNode(node.initializer, visitor, isExpression) - ); + node = transformNamedEvaluation(context, node, canIgnoreEmptyStringLiteralInAssignedName(node.initializer)); } + const updated = factory.updateParameterDeclaration( + node, + /*modifiers*/ undefined, + node.dotDotDotToken, + visitNode(node.name, visitor, isBindingName), + /*questionToken*/ undefined, + /*type*/ undefined, + visitNode(node.initializer, visitor, isExpression) + ); + if (updated !== node) { // While we emit the source map for the node after skipping decorators and modifiers, // we need to emit the comments for the original range. @@ -1583,6 +1649,16 @@ export function transformESDecorators(context: TransformationContext): (x: Sourc return isClassExpression(node) && !node.name && isDecoratedClassLike(node); } + function canIgnoreEmptyStringLiteralInAssignedName(node: WrappedExpression) { + // The IIFE produced for `(@dec class {})` will result in an assigned name of the form + // `var class_1 = class { };`, and thus the empty string cannot be ignored. However, The IIFE + // produced for `(class { @dec x; })` will not result in an assigned name since it + // transforms to `return class { };`, and thus the empty string *can* be ignored. + + const innerExpression = skipOuterExpressions(node); + return isClassExpression(innerExpression) && !innerExpression.name && !classOrConstructorParameterIsDecorated(/*useLegacyDecorators*/ false, innerExpression); + } + function visitForStatement(node: ForStatement) { return factory.updateForStatement( node, @@ -1632,10 +1708,8 @@ export function transformESDecorators(context: TransformationContext): (x: Sourc // ... if (isNamedEvaluation(node, isAnonymousClassNeedingAssignedName)) { - const assignedName = getAssignedNameOfIdentifier(node.left, node.right); - const left = visitNode(node.left, visitor, isExpression); - const right = visitNode(node.right, node => namedEvaluationVisitor(node, assignedName), isExpression); - return factory.updateBinaryExpression(node, left, node.operatorToken, right); + node = transformNamedEvaluation(context, node, canIgnoreEmptyStringLiteralInAssignedName(node.right)); + return visitEachChild(node, visitor, context); } if (isSuperProperty(node.left) && classThis && classSuper) { @@ -1818,9 +1892,7 @@ export function transformESDecorators(context: TransformationContext): (x: Sourc // ... if (isNamedEvaluation(node, isAnonymousClassNeedingAssignedName)) { - const { referencedName, name } = visitReferencedPropertyName(node.name); - const initializer = visitNode(node.initializer, node => namedEvaluationVisitor(node, referencedName), isExpression); - return factory.updatePropertyAssignment(node, name, initializer); + node = transformNamedEvaluation(context, node, canIgnoreEmptyStringLiteralInAssignedName(node.initializer)); } return visitEachChild(node, visitor, context); @@ -1842,10 +1914,7 @@ export function transformESDecorators(context: TransformationContext): (x: Sourc // ... if (isNamedEvaluation(node, isAnonymousClassNeedingAssignedName)) { - const assignedName = getAssignedNameOfIdentifier(node.name, node.initializer); - const name = visitNode(node.name, visitor, isBindingName); - const initializer = visitNode(node.initializer, node => namedEvaluationVisitor(node, assignedName), isExpression); - return factory.updateVariableDeclaration(node, name, /*exclamationToken*/ undefined, /*type*/ undefined, initializer); + node = transformNamedEvaluation(context, node, canIgnoreEmptyStringLiteralInAssignedName(node.initializer)); } return visitEachChild(node, visitor, context); @@ -1869,11 +1938,7 @@ export function transformESDecorators(context: TransformationContext): (x: Sourc // ... if (isNamedEvaluation(node, isAnonymousClassNeedingAssignedName)) { - const assignedName = getAssignedNameOfIdentifier(node.name, node.initializer); - const propertyName = visitNode(node.propertyName, visitor, isPropertyName); - const name = visitNode(node.name, visitor, isBindingName); - const initializer = visitNode(node.initializer, node => namedEvaluationVisitor(node, assignedName), isExpression); - return factory.updateBindingElement(node, /*dotDotDotToken*/ undefined, propertyName, name, initializer); + node = transformNamedEvaluation(context, node, canIgnoreEmptyStringLiteralInAssignedName(node.initializer)); } return visitEachChild(node, visitor, context); @@ -1919,15 +1984,12 @@ export function transformESDecorators(context: TransformationContext): (x: Sourc // ... if (isAssignmentExpression(node, /*excludeCompoundAssignment*/ true)) { - const assignmentTarget = visitDestructuringAssignmentTarget(node.left); - let initializer: Expression; if (isNamedEvaluation(node, isAnonymousClassNeedingAssignedName)) { - const assignedName = getAssignedNameOfIdentifier(node.left, node.right); - initializer = visitNode(node.right, node => namedEvaluationVisitor(node, assignedName), isExpression); - } - else { - initializer = visitNode(node.right, visitor, isExpression); + node = transformNamedEvaluation(context, node, canIgnoreEmptyStringLiteralInAssignedName(node.right)); } + + const assignmentTarget = visitDestructuringAssignmentTarget(node.left); + const initializer = visitNode(node.right, visitor, isExpression); return factory.updateBinaryExpression(node, assignmentTarget, node.operatorToken, initializer) as ArrayAssignmentElement; } else { @@ -1989,10 +2051,7 @@ export function transformESDecorators(context: TransformationContext): (x: Sourc // ... if (isNamedEvaluation(node, isAnonymousClassNeedingAssignedName)) { - const assignedName = getAssignedNameOfIdentifier(node.name, node.objectAssignmentInitializer); - const name = visitNode(node.name, visitor, isIdentifier); - const objectAssignmentInitializer = visitNode(node.objectAssignmentInitializer, node => namedEvaluationVisitor(node, assignedName), isExpression); - return factory.updateShorthandPropertyAssignment(node, name, objectAssignmentInitializer); + node = transformNamedEvaluation(context, node, canIgnoreEmptyStringLiteralInAssignedName(node.objectAssignmentInitializer)); } return visitEachChild(node, visitor, context); @@ -2033,40 +2092,28 @@ export function transformESDecorators(context: TransformationContext): (x: Sourc // a. Let _value_ be ? NamedEvaluation of |AssignmentExpression| with argument `"default"`. // ... - // NOTE: Since emit for `export =` translates to `module.exports = ...`, the assigned nameof the class - // is `""`. - if (isNamedEvaluation(node, isAnonymousClassNeedingAssignedName)) { - const referencedName = factory.createStringLiteral(node.isExportEquals ? "" : "default"); - const modifiers = visitNodes(node.modifiers, modifierVisitor, isModifier); - const expression = visitNode(node.expression, node => namedEvaluationVisitor(node, referencedName), isExpression); - return factory.updateExportAssignment(node, modifiers, expression); + node = transformNamedEvaluation(context, node, canIgnoreEmptyStringLiteralInAssignedName(node.expression)); } return visitEachChild(node, visitor, context); } - function visitParenthesizedExpression(node: ParenthesizedExpression, discarded: boolean, referencedName: Expression | undefined) { + function visitParenthesizedExpression(node: ParenthesizedExpression, discarded: boolean) { // 8.4.5 RS: NamedEvaluation // ParenthesizedExpression : `(` Expression `)` // ... // 2. Return ? NamedEvaluation of |Expression| with argument _name_. - const visitorFunc: Visitor = - discarded ? discardedValueVisitor : - referencedName ? node => namedEvaluationVisitor(node, referencedName) : - visitor; + const visitorFunc: Visitor = discarded ? discardedValueVisitor : visitor; const expression = visitNode(node.expression, visitorFunc, isExpression); return factory.updateParenthesizedExpression(node, expression); } - function visitPartiallyEmittedExpression(node: PartiallyEmittedExpression, discarded: boolean, referencedName: Expression | undefined) { + function visitPartiallyEmittedExpression(node: PartiallyEmittedExpression, discarded: boolean) { // Emulates 8.4.5 RS: NamedEvaluation - const visitorFunc: Visitor = - discarded ? discardedValueVisitor : - referencedName ? node => namedEvaluationVisitor(node, referencedName) : - visitor; + const visitorFunc: Visitor = discarded ? discardedValueVisitor : visitor; const expression = visitNode(node.expression, visitorFunc, isExpression); return factory.updatePartiallyEmittedExpression(node, expression); } @@ -2132,7 +2179,6 @@ export function transformESDecorators(context: TransformationContext): (x: Sourc const prefix = kind === "get" || kind === "set" ? kind : undefined; const functionName = factory.createStringLiteralFromNode(name, /*isSingleQuote*/ undefined); const namedFunction = emitHelpers().createSetFunctionNameHelper(func, functionName, prefix); - const method = factory.createPropertyAssignment(factory.createIdentifier(kind), namedFunction); setOriginalNode(method, original); setSourceMapRange(method, moveRangePastDecorators(original)); @@ -2325,11 +2371,4 @@ export function transformESDecorators(context: TransformationContext): (x: Sourc ]) ); } - - function getAssignedNameOfIdentifier(name: Identifier, initializer: Expression) { - const originalClass = getOriginalNode(initializer, isClassLike); - return originalClass && !originalClass.name && hasSyntacticModifier(originalClass, ModifierFlags.Default) ? - factory.createStringLiteral("default") : - factory.createStringLiteralFromNode(name); - } } diff --git a/src/compiler/transformers/esnext.ts b/src/compiler/transformers/esnext.ts index 730958dae1e00..d20cdd511d9ba 100644 --- a/src/compiler/transformers/esnext.ts +++ b/src/compiler/transformers/esnext.ts @@ -1,33 +1,875 @@ import { + addEmitHelpers, + addRange, + append, + arrayFrom, + BindingElement, + Block, Bundle, + CaseOrDefaultClause, chainBundle, + ClassDeclaration, + Debug, + EmitFlags, + ExportAssignment, + ExportSpecifier, + Expression, + ForOfStatement, + ForStatement, + GeneratedIdentifierFlags, + getEmitFlags, + hasSyntacticModifier, + Identifier, + IdentifierNameMap, + isArray, + isBindingPattern, + isBlock, + isCaseClause, + isCustomPrologue, + isExpression, + isGeneratedIdentifier, + isIdentifier, + isLocalName, + isNamedEvaluation, + isOmittedExpression, + isPrologueDirective, + isSourceFile, + isStatement, + isVariableDeclarationList, + isVariableStatement, + ModifierFlags, Node, + NodeFlags, + setCommentRange, + setEmitFlags, + setOriginalNode, + setSourceMapRange, + setTextRange, + skipOuterExpressions, SourceFile, + Statement, + SwitchStatement, + SyntaxKind, TransformationContext, TransformFlags, + transformNamedEvaluation, + VariableDeclaration, + VariableDeclarationList, + VariableStatement, + visitArray, visitEachChild, - VisitResult, + visitNode, + visitNodes, + VisitResult } from "../_namespaces/ts"; +const enum UsingKind { + None, + Sync, + Async, +} + /** @internal */ export function transformESNext(context: TransformationContext): (x: SourceFile | Bundle) => SourceFile | Bundle { - return chainBundle(context, transformSourceFile); - - function transformSourceFile(node: SourceFile) { - if (node.isDeclarationFile) { - return node; - } - - return visitEachChild(node, visitor, context); - } - - function visitor(node: Node): VisitResult { - if ((node.transformFlags & TransformFlags.ContainsESNext) === 0) { - return node; - } - switch (node.kind) { - default: - return visitEachChild(node, visitor, context); - } - } + const { + factory, + getEmitHelperFactory: emitHelpers, + hoistVariableDeclaration, + startLexicalEnvironment, + endLexicalEnvironment, + } = context; + + let exportBindings: IdentifierNameMap; + let exportVars: VariableDeclaration[]; + let defaultExportBinding: Identifier | undefined; + let exportEqualsBinding: Identifier | undefined; + + return chainBundle(context, transformSourceFile); + + function transformSourceFile(node: SourceFile) { + if (node.isDeclarationFile) { + return node; + } + + const visited = visitNode(node, visitor, isSourceFile); + addEmitHelpers(visited, context.readEmitHelpers()); + exportVars = undefined!; + exportBindings = undefined!; + defaultExportBinding = undefined; + return visited; + } + + function visitor(node: Node): VisitResult { + if ((node.transformFlags & TransformFlags.ContainsESNext) === 0) { + return node; + } + + switch (node.kind) { + case SyntaxKind.SourceFile: + return visitSourceFile(node as SourceFile); + + case SyntaxKind.Block: + return visitBlock(node as Block); + + case SyntaxKind.ForStatement: + return visitForStatement(node as ForStatement); + + case SyntaxKind.ForOfStatement: + return visitForOfStatement(node as ForOfStatement); + + case SyntaxKind.SwitchStatement: + return visitSwitchStatement(node as SwitchStatement); + + default: + return visitEachChild(node, visitor, context); + } + } + + function visitSourceFile(node: SourceFile): SourceFile { + const usingKind = getUsingKindOfStatements(node.statements); + if (usingKind) { + // Imports and exports must stay at the top level. This means we must hoist all imports, exports, and + // top-level function declarations and bindings out of the `try` statements we generate. For example: + // + // given: + // + // import { w } from "mod"; + // const x = expr1; + // using y = expr2; + // const z = expr3; + // export function f() { + // console.log(z); + // } + // + // produces: + // + // import { x } from "mod"; // <-- preserved + // const x = expr1; // <-- preserved + // var y, z; // <-- hoisted + // export function f() { // <-- hoisted + // console.log(z); + // } + // const env_1 = { stack: [], error: void 0, hasError: false }; + // try { + // y = __addDisposableResource(env_1, expr2, false); + // z = expr3; + // } + // catch (e_1) { + // env_1.error = e_1; + // env_1.hasError = true; + // } + // finally { + // __disposeResource(env_1); + // } + // + // In this transformation, we hoist `y`, `z`, and `f` to a new outer statement list while moving all other + // statements in the source file into the `try` block, which is the same approach we use for System module + // emit. Unlike System module emit, we attempt to preserve all statements prior to the first top-level + // `using` to isolate the complexity of the transformed output to only where it is necessary. + startLexicalEnvironment(); + + exportBindings = new IdentifierNameMap(); + exportVars = []; + + const prologueCount = countPrologueStatements(node.statements); + const topLevelStatements: Statement[] = []; + addRange(topLevelStatements, visitArray(node.statements, visitor, isStatement, 0, prologueCount)); + + // Collect and transform any leading statements up to the first `using` or `await using`. This preserves + // the original statement order much as is possible. + let pos = prologueCount; + while (pos < node.statements.length) { + const statement = node.statements[pos]; + if (getUsingKind(statement) !== UsingKind.None) { + if (pos > prologueCount) { + addRange(topLevelStatements, visitNodes(node.statements, visitor, isStatement, prologueCount, pos - prologueCount)); + } + break; + } + pos++; + } + + Debug.assert(pos < node.statements.length, "Should have encountered at least one 'using' statement."); + + // transform the rest of the body + const envBinding = createEnvBinding(); + const bodyStatements = transformUsingDeclarations(node.statements, pos, node.statements.length, envBinding, topLevelStatements); + + // add `export {}` declarations for any hoisted bindings. + if (exportBindings.size) { + append(topLevelStatements, factory.createExportDeclaration( + /*modifiers*/ undefined, + /*isTypeOnly*/ false, + factory.createNamedExports(arrayFrom(exportBindings.values())) + )); + } + + addRange(topLevelStatements, endLexicalEnvironment()); + if (exportVars.length) { + topLevelStatements.push(factory.createVariableStatement( + factory.createModifiersFromModifierFlags(ModifierFlags.Export), + factory.createVariableDeclarationList( + exportVars, + NodeFlags.Let + ) + )); + } + addRange(topLevelStatements, createDownlevelUsingStatements(bodyStatements, envBinding, usingKind === UsingKind.Async)); + + if (exportEqualsBinding) { + topLevelStatements.push(factory.createExportAssignment( + /*modifiers*/ undefined, + /*isExportEquals*/ true, + exportEqualsBinding + )); + } + + return factory.updateSourceFile(node, topLevelStatements); + } + + return visitEachChild(node, visitor, context); + } + + function visitBlock(node: Block): VisitResult { + const usingKind = getUsingKindOfStatements(node.statements); + if (usingKind) { + const prologueCount = countPrologueStatements(node.statements); + const envBinding = createEnvBinding(); + return factory.updateBlock( + node, + [ + ...visitArray(node.statements, visitor, isStatement, 0, prologueCount), + ...createDownlevelUsingStatements( + transformUsingDeclarations(node.statements, prologueCount, node.statements.length, envBinding, /*topLevelStatements*/ undefined), + envBinding, + usingKind === UsingKind.Async, + ) + ] + ); + } + return visitEachChild(node, visitor, context); + } + + function visitForStatement(node: ForStatement): VisitResult { + if (node.initializer && isUsingVariableDeclarationList(node.initializer)) { + // given: + // + // for (using x = expr; cond; incr) { ... } + // + // produces a shallow transformation to: + // + // { + // using x = expr; + // for (; cond; incr) { ... } + // } + // + // before handing the shallow transformation back to the visitor for an in-depth transformation. + return visitNode( + factory.createBlock([ + factory.createVariableStatement(/*modifiers*/ undefined, node.initializer), + factory.updateForStatement( + node, + /*initializer*/ undefined, + node.condition, + node.incrementor, + node.statement + ) + ]), + visitor, + isStatement + ); + } + + return visitEachChild(node, visitor, context); + } + + function visitForOfStatement(node: ForOfStatement) { + if (isUsingVariableDeclarationList(node.initializer)) { + // given: + // + // for (using x of y) { ... } + // + // produces a shallow transformation to: + // + // for (const x_1 of y) { + // using x = x; + // ... + // } + // + // before handing the shallow transformation back to the visitor for an in-depth transformation. + const forInitializer = node.initializer; + Debug.assertNode(forInitializer, isUsingVariableDeclarationList); + Debug.assert(forInitializer.declarations.length === 1, "ForInitializer may only have one declaration"); + + const forDecl = forInitializer.declarations[0]; + Debug.assert(!forDecl.initializer, "ForInitializer may not have an initializer"); + + const isAwaitUsing = getUsingKindOfVariableDeclarationList(forInitializer) === UsingKind.Async; + const temp = factory.getGeneratedNameForNode(forDecl.name); + const usingVar = factory.updateVariableDeclaration(forDecl, forDecl.name, /*exclamationToken*/ undefined, /*type*/ undefined, temp); + const usingVarList = factory.createVariableDeclarationList([usingVar], isAwaitUsing ? NodeFlags.AwaitUsing : NodeFlags.Using); + const usingVarStatement = factory.createVariableStatement(/*modifiers*/ undefined, usingVarList); + return visitNode( + factory.updateForOfStatement( + node, + node.awaitModifier, + factory.createVariableDeclarationList([ + factory.createVariableDeclaration(temp) + ], NodeFlags.Const), + node.expression, + isBlock(node.statement) ? + factory.updateBlock(node.statement, [ + usingVarStatement, + ...node.statement.statements + ]) : + factory.createBlock([ + usingVarStatement, + node.statement + ], /*multiLine*/ true) + ), + visitor, + isStatement + ); + } + return visitEachChild(node, visitor, context); + } + + function visitCaseOrDefaultClause(node: CaseOrDefaultClause, envBinding: Identifier) { + if (getUsingKindOfStatements(node.statements) !== UsingKind.None) { + if (isCaseClause(node)) { + return factory.updateCaseClause( + node, + visitNode(node.expression, visitor, isExpression), + transformUsingDeclarations(node.statements, /*start*/ 0, node.statements.length, envBinding, /*topLevelStatements*/ undefined) + ); + } + else { + return factory.updateDefaultClause( + node, + transformUsingDeclarations(node.statements, /*start*/ 0, node.statements.length, envBinding, /*topLevelStatements*/ undefined) + ); + } + } + return visitEachChild(node, visitor, context); + } + + function visitSwitchStatement(node: SwitchStatement) { + // given: + // + // switch (expr) { + // case expr: + // using res = expr; + // } + // + // produces: + // + // const env_1 = { stack: [], error: void 0, hasError: false }; + // try { + // switch(expr) { + // case expr: + // const res = __addDisposableResource(env_1, expr, false); + // } + // } + // catch (e_1) { + // env_1.error = e_1; + // env_1.hasError = true; + // } + // finally { + // __disposeResources(env_1); + // } + // + const usingKind = getUsingKindOfCaseOrDefaultClauses(node.caseBlock.clauses); + if (usingKind) { + const envBinding = createEnvBinding(); + return createDownlevelUsingStatements( + [ + factory.updateSwitchStatement( + node, + visitNode(node.expression, visitor, isExpression), + factory.updateCaseBlock( + node.caseBlock, + node.caseBlock.clauses.map(clause => visitCaseOrDefaultClause(clause, envBinding)) + ) + ) + ], + envBinding, + usingKind === UsingKind.Async, + ); + } + + return visitEachChild(node, visitor, context); + } + + /** + * Transform `using` declarations in a statement list. + */ + function transformUsingDeclarations(statementsIn: readonly Statement[], start: number, end: number, envBinding: Identifier, topLevelStatements: Statement[] | undefined) { + const statements: Statement[] = []; + + for (let i = start; i < end; i++) { + const statement = statementsIn[i]; + const usingKind = getUsingKind(statement); + if (usingKind) { + Debug.assertNode(statement, isVariableStatement); + const declarations: VariableDeclaration[] = []; + for (let declaration of statement.declarationList.declarations) { + if (!isIdentifier(declaration.name)) { + // Since binding patterns are a grammar error, we reset `declarations` so we don't process this as a `using`. + declarations.length = 0; + break; + } + + // perform a shallow transform for any named evaluation + if (isNamedEvaluation(declaration)) { + declaration = transformNamedEvaluation(context, declaration); + } + + const initializer = visitNode(declaration.initializer, visitor, isExpression) ?? factory.createVoidZero(); + declarations.push(factory.updateVariableDeclaration( + declaration, + declaration.name, + /*exclamationToken*/ undefined, + /*type*/ undefined, + emitHelpers().createAddDisposableResourceHelper( + envBinding, + initializer, + usingKind === UsingKind.Async + ) + )); + } + + // Only replace the statement if it was valid. + if (declarations.length) { + const varList = factory.createVariableDeclarationList(declarations, NodeFlags.Const); + setOriginalNode(varList, statement.declarationList); + setTextRange(varList, statement.declarationList); + hoistOrAppendNode(factory.updateVariableStatement(statement, /*modifiers*/ undefined, varList)); + continue; + } + } + + const result = visitor(statement); + if (isArray(result)) { + result.forEach(hoistOrAppendNode); + } + else if (result) { + hoistOrAppendNode(result); + } + } + + return statements; + + function hoistOrAppendNode(node: Node) { + Debug.assertNode(node, isStatement); + append(statements, hoist(node)); + } + + function hoist(node: Statement) { + if (!topLevelStatements) return node; + + switch (node.kind) { + case SyntaxKind.ImportDeclaration: + case SyntaxKind.ImportEqualsDeclaration: + case SyntaxKind.ExportDeclaration: + case SyntaxKind.FunctionDeclaration: + return hoistImportOrExportOrHoistedDeclaration(node, topLevelStatements); + case SyntaxKind.ExportAssignment: + return hoistExportAssignment(node as ExportAssignment); + case SyntaxKind.ClassDeclaration: + return hoistClassDeclaration(node as ClassDeclaration); + case SyntaxKind.VariableStatement: + return hoistVariableStatement(node as VariableStatement); + } + + return node; + } + } + + function hoistImportOrExportOrHoistedDeclaration(node: Statement, topLevelStatements: Statement[]) { + // NOTE: `node` has already been visited + topLevelStatements.push(node); + return undefined; + } + + function hoistExportAssignment(node: ExportAssignment) { + return node.isExportEquals ? hoistExportEquals(node) : hoistExportDefault(node); + } + + function hoistExportDefault(node: ExportAssignment) { + // NOTE: `node` has already been visited + if (defaultExportBinding) { + // invalid case of multiple `export default` declarations. Don't assert here, just pass it through + return node; + } + + // given: + // + // export default expr; + // + // produces: + // + // // top level + // var default_1; + // export { default_1 as default }; + // + // // body + // default_1 = expr; + + defaultExportBinding = factory.createUniqueName("_default", GeneratedIdentifierFlags.ReservedInNestedScopes | GeneratedIdentifierFlags.FileLevel | GeneratedIdentifierFlags.Optimistic); + hoistBindingIdentifier(defaultExportBinding, /*isExport*/ true, "default", node); + + // give a class or function expression an assigned name, if needed. + let expression = node.expression; + let innerExpression = skipOuterExpressions(expression); + if (isNamedEvaluation(innerExpression)) { + innerExpression = transformNamedEvaluation(context, innerExpression, /*ignoreEmptyStringLiteral*/ false, "default"); + expression = factory.restoreOuterExpressions(expression, innerExpression); + } + + const assignment = factory.createAssignment(defaultExportBinding, expression); + return factory.createExpressionStatement(assignment); + } + + function hoistExportEquals(node: ExportAssignment) { + // NOTE: `node` has already been visited + if (exportEqualsBinding) { + // invalid case of multiple `export default` declarations. Don't assert here, just pass it through + return node; + } + + // given: + // + // export = expr; + // + // produces: + // + // // top level + // var default_1; + // + // try { + // // body + // default_1 = expr; + // } ... + // + // // top level suffix + // export = default_1; + + exportEqualsBinding = factory.createUniqueName("_default", GeneratedIdentifierFlags.ReservedInNestedScopes | GeneratedIdentifierFlags.FileLevel | GeneratedIdentifierFlags.Optimistic); + hoistVariableDeclaration(exportEqualsBinding); + + // give a class or function expression an assigned name, if needed. + const assignment = factory.createAssignment(exportEqualsBinding, node.expression); + return factory.createExpressionStatement(assignment); + } + + function hoistClassDeclaration(node: ClassDeclaration) { + // NOTE: `node` has already been visited + if (!node.name && defaultExportBinding) { + // invalid case of multiple `export default` declarations. Don't assert here, just pass it through + return node; + } + + const isExported = hasSyntacticModifier(node, ModifierFlags.Export); + const isDefault = hasSyntacticModifier(node, ModifierFlags.Default); + + // When hoisting a class declaration at the top level of a file containing a top-level `using` statement, we + // must first convert it to a class expression so that we can hoist the binding outside of the `try`. + let expression: Expression = factory.converters.convertToClassExpression(node); + if (node.name) { + // given: + // + // using x = expr; + // class C {} + // + // produces: + // + // var x, C; + // const env_1 = { ... }; + // try { + // x = __addDisposableResource(env_1, expr, false); + // C = class {}; + // } + // catch (e_1) { + // env_1.error = e_1; + // env_1.hasError = true; + // } + // finally { + // __disposeResources(env_1); + // } + // + // If the class is exported, we also produce an `export { C };` + hoistBindingIdentifier(factory.getLocalName(node), isExported && !isDefault, /*exportAlias*/ undefined, node); + expression = factory.createAssignment(factory.getDeclarationName(node), expression); + if (isNamedEvaluation(expression)) { + expression = transformNamedEvaluation(context, expression, /*ignoreEmptyStringLiteral*/ false); + } + setOriginalNode(expression, node); + setSourceMapRange(expression, node); + setCommentRange(expression, node); + } + + if (isDefault && !defaultExportBinding) { + // In the case of a default export, we create a temporary variable that we export as the default and then + // assign to that variable. + // + // given: + // + // using x = expr; + // export default class C {} + // + // produces: + // + // export { default_1 as default }; + // var x, C, default_1; + // const env_1 = { ... }; + // try { + // x = __addDisposableResource(env_1, expr, false); + // default_1 = C = class {}; + // } + // catch (e_1) { + // env_1.error = e_1; + // env_1.hasError = true; + // } + // finally { + // __disposeResources(env_1); + // } + // + // Though we will never reassign `default_1`, this most closely matches the specified runtime semantics. + defaultExportBinding = factory.createUniqueName("_default", GeneratedIdentifierFlags.ReservedInNestedScopes | GeneratedIdentifierFlags.FileLevel | GeneratedIdentifierFlags.Optimistic); + hoistBindingIdentifier(defaultExportBinding, /*isExport*/ true, "default", node); + expression = factory.createAssignment(defaultExportBinding, expression); + if (isNamedEvaluation(expression)) { + expression = transformNamedEvaluation(context, expression, /*ignoreEmptyStringLiteral*/ false, "default"); + } + setOriginalNode(expression, node); + } + + return factory.createExpressionStatement(expression); + } + + function hoistVariableStatement(node: VariableStatement) { + // NOTE: `node` has already been visited + let expressions: Expression[] | undefined; + const isExported = hasSyntacticModifier(node, ModifierFlags.Export); + for (const variable of node.declarationList.declarations) { + hoistBindingElement(variable, isExported, variable); + if (variable.initializer) { + expressions = append(expressions, hoistInitializedVariable(variable)); + } + } + if (expressions) { + const statement = factory.createExpressionStatement(factory.inlineExpressions(expressions)); + setOriginalNode(statement, node); + setCommentRange(statement, node); + setSourceMapRange(statement, node); + return statement; + } + return undefined; + } + + function hoistInitializedVariable(node: VariableDeclaration) { + // NOTE: `node` has already been visited + Debug.assertIsDefined(node.initializer); + let target: Expression; + if (isIdentifier(node.name)) { + target = factory.cloneNode(node.name); + setEmitFlags(target, getEmitFlags(target) & ~(EmitFlags.LocalName | EmitFlags.ExportName | EmitFlags.InternalName)); + } + else { + target = factory.converters.convertToAssignmentPattern(node.name); + } + + const assignment = factory.createAssignment(target, node.initializer); + setOriginalNode(assignment, node); + setCommentRange(assignment, node); + setSourceMapRange(assignment, node); + return assignment; + } + + function hoistBindingElement(node: VariableDeclaration | BindingElement, isExportedDeclaration: boolean, original: Node | undefined) { + // NOTE: `node` has already been visited + if (isBindingPattern(node.name)) { + for (const element of node.name.elements) { + if (!isOmittedExpression(element)) { + hoistBindingElement(element, isExportedDeclaration, original); + } + } + } + else { + hoistBindingIdentifier(node.name, isExportedDeclaration, /*exportAlias*/ undefined, original); + } + } + + function hoistBindingIdentifier(node: Identifier, isExport: boolean, exportAlias: string | Identifier | undefined, original: Node | undefined) { + // NOTE: `node` has already been visited + const name = isGeneratedIdentifier(node) ? node : factory.cloneNode(node); + if (isExport) { + if (exportAlias === undefined && !isLocalName(name)) { + const varDecl = factory.createVariableDeclaration(name); + if (original) { + setOriginalNode(varDecl, original); + } + exportVars.push(varDecl); + return; + } + + const localName = exportAlias !== undefined ? name : undefined; + const exportName = exportAlias !== undefined ? exportAlias : name; + const specifier = factory.createExportSpecifier(/*isTypeOnly*/ false, localName, exportName); + if (original) { + setOriginalNode(specifier, original); + } + exportBindings.set(name, specifier); + } + hoistVariableDeclaration(name); + } + + function createEnvBinding() { + return factory.createUniqueName("env"); + } + + function createDownlevelUsingStatements(bodyStatements: readonly Statement[], envBinding: Identifier, async: boolean) { + const statements: Statement[] = []; + + // produces: + // + // const env_1 = { stack: [], error: void 0, hasError: false }; + // + const envObject = factory.createObjectLiteralExpression([ + factory.createPropertyAssignment("stack", factory.createArrayLiteralExpression()), + factory.createPropertyAssignment("error", factory.createVoidZero()), + factory.createPropertyAssignment("hasError", factory.createFalse()) + ]); + const envVar = factory.createVariableDeclaration(envBinding, /*exclamationToken*/ undefined, /*type*/ undefined, envObject); + const envVarList = factory.createVariableDeclarationList([envVar], NodeFlags.Const); + const envVarStatement = factory.createVariableStatement(/*modifiers*/ undefined, envVarList); + statements.push(envVarStatement); + + // when `async` is `false`, produces: + // + // try { + // + // } + // catch (e_1) { + // env_1.error = e_1; + // env_1.hasError = true; + // } + // finally { + // __disposeResources(env_1); + // } + + // when `async` is `true`, produces: + // + // try { + // + // } + // catch (e_1) { + // env_1.error = e_1; + // env_1.hasError = true; + // } + // finally { + // const result_1 = __disposeResources(env_1); + // if (result_1) { + // await result_1; + // } + // } + + // Unfortunately, it is necessary to use two properties to indicate an error because `throw undefined` is legal + // JavaScript. + const tryBlock = factory.createBlock(bodyStatements, /*multiLine*/ true); + const bodyCatchBinding = factory.createUniqueName("e"); + const catchClause = factory.createCatchClause( + bodyCatchBinding, + factory.createBlock([ + factory.createExpressionStatement( + factory.createAssignment( + factory.createPropertyAccessExpression(envBinding, "error"), + bodyCatchBinding) + ), + factory.createExpressionStatement( + factory.createAssignment( + factory.createPropertyAccessExpression(envBinding, "hasError"), + factory.createTrue()) + ), + ], /*multiLine*/ true) + ); + + let finallyBlock: Block; + if (async) { + const result = factory.createUniqueName("result"); + finallyBlock = factory.createBlock([ + factory.createVariableStatement( + /*modifiers*/ undefined, + factory.createVariableDeclarationList([ + factory.createVariableDeclaration( + result, + /*exclamationToken*/ undefined, + /*type*/ undefined, + emitHelpers().createDisposeResourcesHelper(envBinding) + ) + ], NodeFlags.Const) + ), + factory.createIfStatement(result, factory.createExpressionStatement(factory.createAwaitExpression(result))) + ], /*multiLine*/ true); + } + else { + finallyBlock = factory.createBlock([ + factory.createExpressionStatement( + emitHelpers().createDisposeResourcesHelper(envBinding) + ) + ], /*multiLine*/ true); + } + + const tryStatement = factory.createTryStatement(tryBlock, catchClause, finallyBlock); + statements.push(tryStatement); + + return statements; + } +} + +function countPrologueStatements(statements: readonly Statement[]) { + for (let i = 0; i < statements.length; i++) { + if (!isPrologueDirective(statements[i]) && !isCustomPrologue(statements[i])) { + return i; + } + } + return 0; +} + +function isUsingVariableDeclarationList(node: Node): node is VariableDeclarationList & { _usingBrand: any } { + return isVariableDeclarationList(node) && getUsingKindOfVariableDeclarationList(node) !== UsingKind.None; +} + +function getUsingKindOfVariableDeclarationList(node: VariableDeclarationList) { + return (node.flags & NodeFlags.BlockScoped) === NodeFlags.AwaitUsing ? UsingKind.Async : + (node.flags & NodeFlags.BlockScoped) === NodeFlags.Using ? UsingKind.Sync : + UsingKind.None; +} + +function getUsingKindOfVariableStatement(node: VariableStatement) { + return getUsingKindOfVariableDeclarationList(node.declarationList); +} + +function getUsingKind(statement: Statement): UsingKind { + return isVariableStatement(statement) ? getUsingKindOfVariableStatement(statement) : UsingKind.None; +} + +function getUsingKindOfStatements(statements: readonly Statement[]): UsingKind { + let result = UsingKind.None; + for (const statement of statements) { + const usingKind = getUsingKind(statement); + if (usingKind === UsingKind.Async) return UsingKind.Async; + if (usingKind > result) result = usingKind; + } + return result; +} + +function getUsingKindOfCaseOrDefaultClauses(clauses: readonly CaseOrDefaultClause[]): UsingKind { + let result = UsingKind.None; + for (const clause of clauses) { + const usingKind = getUsingKindOfStatements(clause.statements); + if (usingKind === UsingKind.Async) return UsingKind.Async; + if (usingKind > result) result = usingKind; + } + return result; } diff --git a/src/compiler/transformers/legacyDecorators.ts b/src/compiler/transformers/legacyDecorators.ts index f175fe71a1951..87b3b162ca490 100644 --- a/src/compiler/transformers/legacyDecorators.ts +++ b/src/compiler/transformers/legacyDecorators.ts @@ -55,7 +55,6 @@ import { isStatic, map, MethodDeclaration, - Modifier, ModifierFlags, moveRangePastModifiers, Node, @@ -373,39 +372,29 @@ export function transformLegacyDecorators(context: TransformationContext): (x: S // let ${name} = ${classExpression} where name is either declaredName if the class doesn't contain self-reference // or decoratedClassAlias if the class contain self-reference. - const varDecl = factory.createVariableDeclaration( - declName, - /*exclamationToken*/ undefined, - /*type*/ undefined, - classAlias && !assignClassAliasInStaticBlock ? factory.createAssignment(classAlias, classExpression) : classExpression - ); + const varInitializer = classAlias && !assignClassAliasInStaticBlock ? factory.createAssignment(classAlias, classExpression) : classExpression; + const varDecl = factory.createVariableDeclaration(declName, /*exclamationToken*/ undefined, /*type*/ undefined, varInitializer); setOriginalNode(varDecl, node); - let varModifiers: Modifier[] | undefined; - if (isExport && !isDefault) { - varModifiers = factory.createModifiersFromModifierFlags(ModifierFlags.Export); - } + const varDeclList = factory.createVariableDeclarationList([varDecl], NodeFlags.Let); + const varStatement = factory.createVariableStatement(/*modifiers*/ undefined, varDeclList); + setOriginalNode(varStatement, node); + setTextRange(varStatement, location); + setCommentRange(varStatement, node); - const statement = factory.createVariableStatement( - varModifiers, - factory.createVariableDeclarationList([ - varDecl - ], NodeFlags.Let) - ); - setOriginalNode(statement, node); - setTextRange(statement, location); - setCommentRange(statement, node); - - const statements: Statement[] = [statement]; + const statements: Statement[] = [varStatement]; addRange(statements, decorationStatements); addConstructorDecorationStatement(statements, node); - if (isExport && isDefault) { - statements.push(factory.createExportAssignment( - /*modifiers*/ undefined, - /*isExportEquals*/ false, - declName - )); + if (isExport) { + if (isDefault) { + const exportStatement = factory.createExportDefault(declName); + statements.push(exportStatement); + } + else { + const exportStatement = factory.createExternalModuleExport(factory.getDeclarationName(node)); + statements.push(exportStatement); + } } return statements; diff --git a/src/compiler/transformers/module/module.ts b/src/compiler/transformers/module/module.ts index fc95446ce54c2..b6339fcc15a90 100644 --- a/src/compiler/transformers/module/module.ts +++ b/src/compiler/transformers/module/module.ts @@ -59,6 +59,7 @@ import { hasJsonModuleEmitEnabled, hasSyntacticModifier, Identifier, + IdentifierNameMap, idText, IfStatement, ImportCall, @@ -86,6 +87,7 @@ import { isExpression, isExternalModule, isExternalModuleImportEqualsDeclaration, + isFileLevelReservedGeneratedIdentifier, isForInitializer, isFunctionExpression, isGeneratedIdentifier, @@ -224,7 +226,7 @@ export function transformModule(context: TransformationContext): (x: SourceFile } currentSourceFile = node; - currentModuleInfo = collectExternalModuleInfo(context, node, resolver, compilerOptions); + currentModuleInfo = collectExternalModuleInfo(context, node); moduleInfoMap[getOriginalNodeId(node)] = currentModuleInfo; // Perform the transformation. @@ -668,22 +670,16 @@ export function transformModule(context: TransformationContext): (x: SourceFile function topLevelVisitor(node: Node): VisitResult { switch (node.kind) { case SyntaxKind.ImportDeclaration: - return visitImportDeclaration(node as ImportDeclaration); + return visitTopLevelImportDeclaration(node as ImportDeclaration); case SyntaxKind.ImportEqualsDeclaration: - return visitImportEqualsDeclaration(node as ImportEqualsDeclaration); + return visitTopLevelImportEqualsDeclaration(node as ImportEqualsDeclaration); case SyntaxKind.ExportDeclaration: - return visitExportDeclaration(node as ExportDeclaration); + return visitTopLevelExportDeclaration(node as ExportDeclaration); case SyntaxKind.ExportAssignment: - return visitExportAssignment(node as ExportAssignment); - - case SyntaxKind.FunctionDeclaration: - return visitFunctionDeclaration(node as FunctionDeclaration); - - case SyntaxKind.ClassDeclaration: - return visitClassDeclaration(node as ClassDeclaration); + return visitTopLevelExportAssignment(node as ExportAssignment); default: return topLevelNestedVisitor(node); @@ -1358,7 +1354,7 @@ export function transformModule(context: TransformationContext): (x: SourceFile * * @param node The node to visit. */ - function visitImportDeclaration(node: ImportDeclaration): VisitResult { + function visitTopLevelImportDeclaration(node: ImportDeclaration): VisitResult { let statements: Statement[] | undefined; const namespaceDeclaration = getNamespaceDeclarationNode(node); if (moduleKind !== ModuleKind.AMD) { @@ -1470,7 +1466,7 @@ export function transformModule(context: TransformationContext): (x: SourceFile * * @param node The node to visit. */ - function visitImportEqualsDeclaration(node: ImportEqualsDeclaration): VisitResult { + function visitTopLevelImportEqualsDeclaration(node: ImportEqualsDeclaration): VisitResult { Debug.assert(isExternalModuleImportEqualsDeclaration(node), "import= for internal module references should be handled in an earlier transformer."); let statements: Statement[] | undefined; @@ -1538,7 +1534,7 @@ export function transformModule(context: TransformationContext): (x: SourceFile * * @param The node to visit. */ - function visitExportDeclaration(node: ExportDeclaration): VisitResult { + function visitTopLevelExportDeclaration(node: ExportDeclaration): VisitResult { if (!node.moduleSpecifier) { // Elide export declarations with no module specifier as they are handled // elsewhere. @@ -1648,7 +1644,7 @@ export function transformModule(context: TransformationContext): (x: SourceFile * * @param node The node to visit. */ - function visitExportAssignment(node: ExportAssignment): VisitResult { + function visitTopLevelExportAssignment(node: ExportAssignment): VisitResult { if (node.isExportEquals) { return undefined; } @@ -1878,20 +1874,21 @@ export function transformModule(context: TransformationContext): (x: SourceFile return statements; } + const seen = new IdentifierNameMap(); if (importClause.name) { - statements = appendExportsOfDeclaration(statements, importClause); + statements = appendExportsOfDeclaration(statements, seen, importClause); } const namedBindings = importClause.namedBindings; if (namedBindings) { switch (namedBindings.kind) { case SyntaxKind.NamespaceImport: - statements = appendExportsOfDeclaration(statements, namedBindings); + statements = appendExportsOfDeclaration(statements, seen, namedBindings); break; case SyntaxKind.NamedImports: for (const importBinding of namedBindings.elements) { - statements = appendExportsOfDeclaration(statements, importBinding, /*liveBinding*/ true); + statements = appendExportsOfDeclaration(statements, seen, importBinding, /*liveBinding*/ true); } break; @@ -1915,7 +1912,7 @@ export function transformModule(context: TransformationContext): (x: SourceFile return statements; } - return appendExportsOfDeclaration(statements, decl); + return appendExportsOfDeclaration(statements, new IdentifierNameMap(), decl); } /** @@ -1974,7 +1971,7 @@ export function transformModule(context: TransformationContext): (x: SourceFile } } else if (!isGeneratedIdentifier(decl.name) && (!isVariableDeclaration(decl) || decl.initializer || isForInOrOfInitializer)) { - statements = appendExportsOfDeclaration(statements, decl); + statements = appendExportsOfDeclaration(statements, new IdentifierNameMap(), decl); } return statements; @@ -1994,13 +1991,14 @@ export function transformModule(context: TransformationContext): (x: SourceFile return statements; } + const seen = new IdentifierNameMap(); if (hasSyntacticModifier(decl, ModifierFlags.Export)) { const exportName = hasSyntacticModifier(decl, ModifierFlags.Default) ? factory.createIdentifier("default") : factory.getDeclarationName(decl); - statements = appendExportStatement(statements, exportName, factory.getLocalName(decl), /*location*/ decl); + statements = appendExportStatement(statements, seen, exportName, factory.getLocalName(decl), /*location*/ decl); } if (decl.name) { - statements = appendExportsOfDeclaration(statements, decl); + statements = appendExportsOfDeclaration(statements, seen, decl); } return statements; @@ -2014,12 +2012,12 @@ export function transformModule(context: TransformationContext): (x: SourceFile * appended. * @param decl The declaration to export. */ - function appendExportsOfDeclaration(statements: Statement[] | undefined, decl: Declaration, liveBinding?: boolean): Statement[] | undefined { + function appendExportsOfDeclaration(statements: Statement[] | undefined, seen: IdentifierNameMap, decl: Declaration, liveBinding?: boolean): Statement[] | undefined { const name = factory.getDeclarationName(decl); - const exportSpecifiers = currentModuleInfo.exportSpecifiers.get(idText(name)); + const exportSpecifiers = currentModuleInfo.exportSpecifiers.get(name); if (exportSpecifiers) { for (const exportSpecifier of exportSpecifiers) { - statements = appendExportStatement(statements, exportSpecifier.name, name, /*location*/ exportSpecifier.name, /*allowComments*/ undefined, liveBinding); + statements = appendExportStatement(statements, seen, exportSpecifier.name, name, /*location*/ exportSpecifier.name, /*allowComments*/ undefined, liveBinding); } } return statements; @@ -2037,8 +2035,11 @@ export function transformModule(context: TransformationContext): (x: SourceFile * @param location The location to use for source maps and comments for the export. * @param allowComments Whether to allow comments on the export. */ - function appendExportStatement(statements: Statement[] | undefined, exportName: Identifier, expression: Expression, location?: TextRange, allowComments?: boolean, liveBinding?: boolean): Statement[] | undefined { - statements = append(statements, createExportStatement(exportName, expression, location, allowComments, liveBinding)); + function appendExportStatement(statements: Statement[] | undefined, seen: IdentifierNameMap, exportName: Identifier, expression: Expression, location?: TextRange, allowComments?: boolean, liveBinding?: boolean): Statement[] | undefined { + if (!seen.has(exportName)) { + seen.set(exportName, true); + statements = append(statements, createExportStatement(exportName, expression, location, allowComments, liveBinding)); + } return statements; } @@ -2341,12 +2342,12 @@ export function transformModule(context: TransformationContext): (x: SourceFile // When we see an assignment expression whose left-hand side is an exported symbol, // we should ensure all exports of that symbol are updated with the correct value. // - // - We do not substitute generated identifiers for any reason. + // - We do not substitute generated identifiers unless they are file-level reserved names. // - We do not substitute identifiers tagged with the LocalName flag. // - We only substitute identifiers that are exported at the top level. if (isAssignmentOperator(node.operatorToken.kind) && isIdentifier(node.left) - && !isGeneratedIdentifier(node.left) + && (!isGeneratedIdentifier(node.left) || isFileLevelReservedGeneratedIdentifier(node.left)) && !isLocalName(node.left)) { const exportedNames = getExports(node.left); if (exportedNames) { @@ -2395,6 +2396,16 @@ export function transformModule(context: TransformationContext): (x: SourceFile } } } + else if (isFileLevelReservedGeneratedIdentifier(name)) { + const exportSpecifiers = currentModuleInfo?.exportSpecifiers.get(name); + if (exportSpecifiers) { + const exportedNames: Identifier[] = []; + for (const exportSpecifier of exportSpecifiers) { + exportedNames.push(exportSpecifier.name); + } + return exportedNames; + } + } } } diff --git a/src/compiler/transformers/module/system.ts b/src/compiler/transformers/module/system.ts index 4e2d9b954e626..b83bf5244a7f3 100644 --- a/src/compiler/transformers/module/system.ts +++ b/src/compiler/transformers/module/system.ts @@ -64,6 +64,7 @@ import { isExpression, isExternalModule, isExternalModuleImportEqualsDeclaration, + isFileLevelReservedGeneratedIdentifier, isForInitializer, isGeneratedIdentifier, isHeritageClause, @@ -84,7 +85,9 @@ import { isSpreadElement, isStatement, isStringLiteral, + isVarAwaitUsing, isVariableDeclarationList, + isVarUsing, LabeledStatement, map, MetaProperty, @@ -198,7 +201,7 @@ export function transformSystemModule(context: TransformationContext): (x: Sourc // see comment to 'substitutePostfixUnaryExpression' for more details // Collect information about the external module and dependency groups. - moduleInfo = moduleInfoMap[id] = collectExternalModuleInfo(context, node, resolver, compilerOptions); + moduleInfo = moduleInfoMap[id] = collectExternalModuleInfo(context, node); // Make sure that the name of the 'exports' function does not conflict with // existing identifiers. @@ -845,20 +848,44 @@ export function transformSystemModule(context: TransformationContext): (x: Sourc return visitNode(node, visitor, isStatement); } - let expressions: Expression[] | undefined; - const isExportedDeclaration = hasSyntacticModifier(node, ModifierFlags.Export); - for (const variable of node.declarationList.declarations) { - if (variable.initializer) { - expressions = append(expressions, transformInitializedVariable(variable, isExportedDeclaration)); - } - else { - hoistBindingElement(variable); + let statements: Statement[] | undefined; + // `using` and `await using` declarations cannot be hoisted directly, so we will hoist the variable name + // as a normal variable, and declare it as a temp variable that remains as a `using` to ensure the correct + // lifetime. + if (isVarUsing(node.declarationList) || isVarAwaitUsing(node.declarationList)) { + const modifiers = visitNodes(node.modifiers, modifierVisitor, isModifierLike); + const declarations: VariableDeclaration[] = []; + for (const variable of node.declarationList.declarations) { + declarations.push(factory.updateVariableDeclaration( + variable, + factory.getGeneratedNameForNode(variable.name), + /*exclamationToken*/ undefined, + /*type*/ undefined, + transformInitializedVariable(variable, /*isExportedDeclaration*/ false) + )); } + + const declarationList = factory.updateVariableDeclarationList( + node.declarationList, + declarations + ); + statements = append(statements, factory.updateVariableStatement(node, modifiers, declarationList)); } + else { + let expressions: Expression[] | undefined; + const isExportedDeclaration = hasSyntacticModifier(node, ModifierFlags.Export); + for (const variable of node.declarationList.declarations) { + if (variable.initializer) { + expressions = append(expressions, transformInitializedVariable(variable, isExportedDeclaration)); + } + else { + hoistBindingElement(variable); + } + } - let statements: Statement[] | undefined; - if (expressions) { - statements = append(statements, setTextRange(factory.createExpressionStatement(factory.inlineExpressions(expressions)), node)); + if (expressions) { + statements = append(statements, setTextRange(factory.createExpressionStatement(factory.inlineExpressions(expressions)), node)); + } } statements = appendExportsOfVariableStatement(statements, node, /*exportSelf*/ false); @@ -1114,7 +1141,7 @@ export function transformSystemModule(context: TransformationContext): (x: Sourc } const name = factory.getDeclarationName(decl); - const exportSpecifiers = moduleInfo.exportSpecifiers.get(idText(name)); + const exportSpecifiers = moduleInfo.exportSpecifiers.get(name); if (exportSpecifiers) { for (const exportSpecifier of exportSpecifiers) { if (exportSpecifier.name.escapedText !== excludeName) { @@ -1894,12 +1921,12 @@ export function transformSystemModule(context: TransformationContext): (x: Sourc // When we see an assignment expression whose left-hand side is an exported symbol, // we should ensure all exports of that symbol are updated with the correct value. // - // - We do not substitute generated identifiers for any reason. + // - We do not substitute generated identifiers unless they are file-level reserved names. // - We do not substitute identifiers tagged with the LocalName flag. // - We only substitute identifiers that are exported at the top level. if (isAssignmentOperator(node.operatorToken.kind) && isIdentifier(node.left) - && !isGeneratedIdentifier(node.left) + && (!isGeneratedIdentifier(node.left) || isFileLevelReservedGeneratedIdentifier(node.left)) && !isLocalName(node.left)) { const exportedNames = getExports(node.left); if (exportedNames) { @@ -1939,6 +1966,16 @@ export function transformSystemModule(context: TransformationContext): (x: Sourc exportedNames = addRange(exportedNames, moduleInfo?.exportedBindings[getOriginalNodeId(valueDeclaration)]); } + else if (isGeneratedIdentifier(name) && isFileLevelReservedGeneratedIdentifier(name)) { + const exportSpecifiers = moduleInfo?.exportSpecifiers.get(name); + if (exportSpecifiers) { + const exportedNames: Identifier[] = []; + for (const exportSpecifier of exportSpecifiers) { + exportedNames.push(exportSpecifier.name); + } + return exportedNames; + } + } return exportedNames; } diff --git a/src/compiler/transformers/namedEvaluation.ts b/src/compiler/transformers/namedEvaluation.ts new file mode 100644 index 0000000000000..5af5d90781e63 --- /dev/null +++ b/src/compiler/transformers/namedEvaluation.ts @@ -0,0 +1,478 @@ +import { + __String, + AnonymousFunctionDefinition, + BinaryExpression, + BindingElement, + Block, + CallExpression, + cast, + ClassLikeDeclaration, + ClassStaticBlockDeclaration, + ExportAssignment, + Expression, + ExpressionStatement, + findIndex, + getOrCreateEmitNode, + getOriginalNode, + hasSyntacticModifier, + Identifier, + isCallToHelper, + isClassDeclaration, + isClassExpression, + isClassStaticBlockDeclaration, + isClassThisAssignmentBlock, + isEmptyStringLiteral, + isExpressionStatement, + isFunctionDeclaration, + isIdentifier, + isPrivateIdentifier, + isPropertyNameLiteral, + isStringLiteral, + ModifierFlags, + NamedEvaluation, + Node, + NodeArray, + NodeFactory, + ParameterDeclaration, + PropertyAssignment, + PropertyDeclaration, + PropertyName, + setSourceMapRange, + setTextRange, + ShorthandPropertyAssignment, + skipOuterExpressions, + some, + Statement, + StringLiteral, + SyntaxKind, + TransformationContext, + VariableDeclaration, + WrappedExpression +} from "../_namespaces/ts"; + +/** + * Gets a string literal to use as the assigned name of an anonymous class or function declaration. + * @internal + */ +export function getAssignedNameOfIdentifier(factory: NodeFactory, name: Identifier, expression: WrappedExpression): StringLiteral { + const original = getOriginalNode(skipOuterExpressions(expression)); + if ((isClassDeclaration(original) || isFunctionDeclaration(original)) && + !original.name && hasSyntacticModifier(original, ModifierFlags.Default)) { + return factory.createStringLiteral("default"); + } + return factory.createStringLiteralFromNode(name); +} + +function getAssignedNameOfPropertyName(context: TransformationContext, name: PropertyName, assignedNameText: string | undefined) { + const { factory } = context; + if (assignedNameText !== undefined) { + const assignedName = factory.createStringLiteral(assignedNameText); + return { assignedName, name }; + } + + if (isPropertyNameLiteral(name) || isPrivateIdentifier(name)) { + const assignedName = factory.createStringLiteralFromNode(name); + return { assignedName, name }; + } + + if (isPropertyNameLiteral(name.expression) && !isIdentifier(name.expression)) { + const assignedName = factory.createStringLiteralFromNode(name.expression); + return { assignedName, name }; + } + + const assignedName = factory.getGeneratedNameForNode(name); + context.hoistVariableDeclaration(assignedName); + + const key = context.getEmitHelperFactory().createPropKeyHelper(name.expression); + const assignment = factory.createAssignment(assignedName, key); + const updatedName = factory.updateComputedPropertyName(name, assignment); + return { assignedName, name: updatedName }; +} + +/** + * Creates a class `static {}` block used to dynamically set the name of a class. + * + * @param assignedName The expression used to resolve the assigned name at runtime. This expression should not produce + * side effects. + * @param thisExpression Overrides the expression to use for the actual `this` reference. This can be used to provide an + * expression that has already had its `EmitFlags` set or may have been tracked to prevent substitution. + * @internal + */ +export function createClassNamedEvaluationHelperBlock(context: TransformationContext, assignedName: Expression, thisExpression: Expression = context.factory.createThis()): ClassNamedEvaluationHelperBlock { + // produces: + // + // static { __setFunctionName(this, "C"); } + // + + const { factory } = context; + const expression = context.getEmitHelperFactory().createSetFunctionNameHelper(thisExpression, assignedName); + const statement = factory.createExpressionStatement(expression); + const body = factory.createBlock([statement], /*multiLine*/ false); + const block = factory.createClassStaticBlockDeclaration(body); + + // We use `emitNode.assignedName` to indicate this is a NamedEvaluation helper block + // and to stash the expression used to resolve the assigned name. + getOrCreateEmitNode(block).assignedName = assignedName; + return block as ClassNamedEvaluationHelperBlock; +} + +/** @internal */ +export type ClassNamedEvaluationHelperBlock = ClassStaticBlockDeclaration & { + readonly body: Block & { + readonly statements: NodeArray & readonly [ + ExpressionStatement & { + readonly expression: CallExpression & { + readonly expression: Identifier; + }; + } + ]; + }; +}; + + +/** + * Gets whether a node is a `static {}` block containing only a single call to the `__setFunctionName` helper where that + * call's second argument is the value stored in the `assignedName` property of the block's `EmitNode`. + * @internal + */ +export function isClassNamedEvaluationHelperBlock(node: Node): node is ClassNamedEvaluationHelperBlock { + if (!isClassStaticBlockDeclaration(node) || node.body.statements.length !== 1) { + return false; + } + + const statement = node.body.statements[0]; + return isExpressionStatement(statement) && + isCallToHelper(statement.expression, "___setFunctionName" as __String) && + (statement.expression as CallExpression).arguments.length >= 2 && + (statement.expression as CallExpression).arguments[1] === node.emitNode?.assignedName; +} + +/** + * Gets whether a `ClassLikeDeclaration` has a `static {}` block containing only a single call to the + * `__setFunctionName` helper. + * @internal + */ +export function classHasExplicitlyAssignedName(node: ClassLikeDeclaration): boolean { + return !!node.emitNode?.assignedName && some(node.members, isClassNamedEvaluationHelperBlock); +} + +/** + * Gets whether a `ClassLikeDeclaration` has a declared name or contains a `static {}` block containing only a single + * call to the `__setFunctionName` helper. + * @internal + */ +export function classHasDeclaredOrExplicitlyAssignedName(node: ClassLikeDeclaration): boolean { + return !!node.name || classHasExplicitlyAssignedName(node); +} + +/** + * Injects a class `static {}` block used to dynamically set the name of a class, if one does not already exist. + * @internal + */ +export function injectClassNamedEvaluationHelperBlockIfMissing( + context: TransformationContext, + node: T, + assignedName: Expression, + thisExpression?: Expression +): Extract>; +export function injectClassNamedEvaluationHelperBlockIfMissing( + context: TransformationContext, + node: ClassLikeDeclaration, + assignedName: Expression, + thisExpression?: Expression +) { + // given: + // + // let C = class { + // }; + // + // produces: + // + // let C = class { + // static { __setFunctionName(this, "C"); } + // }; + + // NOTE: If the class has a `_classThis` assignment block, this helper will be injected after that block. + + if (classHasExplicitlyAssignedName(node)) { + return node; + } + + const { factory } = context; + const namedEvaluationBlock = createClassNamedEvaluationHelperBlock(context, assignedName, thisExpression); + if (node.name) { + setSourceMapRange(namedEvaluationBlock.body.statements[0], node.name); + } + + const insertionIndex = findIndex(node.members, isClassThisAssignmentBlock) + 1; + const leading = node.members.slice(0, insertionIndex); + const trailing = node.members.slice(insertionIndex); + const members = factory.createNodeArray([...leading, namedEvaluationBlock, ...trailing]); + setTextRange(members, node.members); + + node = isClassDeclaration(node) ? + factory.updateClassDeclaration( + node, + node.modifiers, + node.name, + node.typeParameters, + node.heritageClauses, + members) : + factory.updateClassExpression( + node, + node.modifiers, + node.name, + node.typeParameters, + node.heritageClauses, + members); + + getOrCreateEmitNode(node).assignedName = assignedName; + return node; +} + +function finishTransformNamedEvaluation( + context: TransformationContext, + expression: WrappedExpression, + assignedName: Expression, + ignoreEmptyStringLiteral?: boolean, +): Expression { + if (ignoreEmptyStringLiteral && isStringLiteral(assignedName) && isEmptyStringLiteral(assignedName)) { + return expression; + } + + const { factory } = context; + const innerExpression = skipOuterExpressions(expression); + + const updatedExpression = isClassExpression(innerExpression) ? + cast(injectClassNamedEvaluationHelperBlockIfMissing(context, innerExpression, assignedName), isClassExpression) : + context.getEmitHelperFactory().createSetFunctionNameHelper(innerExpression, assignedName); + + return factory.restoreOuterExpressions(expression, updatedExpression); +} + +function transformNamedEvaluationOfPropertyAssignment(context: TransformationContext, node: NamedEvaluation & PropertyAssignment, ignoreEmptyStringLiteral?: boolean, assignedNameText?: string) { + // 13.2.5.5 RS: PropertyDefinitionEvaluation + // PropertyAssignment : PropertyName `:` AssignmentExpression + // ... + // 5. If IsAnonymousFunctionDefinition(|AssignmentExpression|) is *true* and _isProtoSetter_ is *false*, then + // a. Let _popValue_ be ? NamedEvaluation of |AssignmentExpression| with argument _propKey_. + // ... + + const { factory } = context; + const { assignedName, name } = getAssignedNameOfPropertyName(context, node.name, assignedNameText); + const initializer = finishTransformNamedEvaluation(context, node.initializer, assignedName, ignoreEmptyStringLiteral); + return factory.updatePropertyAssignment( + node, + name, + initializer); +} + +function transformNamedEvaluationOfShorthandAssignmentProperty(context: TransformationContext, node: NamedEvaluation & ShorthandPropertyAssignment, ignoreEmptyStringLiteral?: boolean, assignedNameText?: string) { + // 13.15.5.3 RS: PropertyDestructuringAssignmentEvaluation + // AssignmentProperty : IdentifierReference Initializer? + // ... + // 4. If |Initializer?| is present and _v_ is *undefined*, then + // a. If IsAnonymousFunctionDefinition(|Initializer|) is *true*, then + // i. Set _v_ to ? NamedEvaluation of |Initializer| with argument _P_. + // ... + + const { factory } = context; + const assignedName = assignedNameText !== undefined ? factory.createStringLiteral(assignedNameText) : + getAssignedNameOfIdentifier(factory, node.name, node.objectAssignmentInitializer); + const objectAssignmentInitializer = finishTransformNamedEvaluation(context, node.objectAssignmentInitializer, assignedName, ignoreEmptyStringLiteral); + return factory.updateShorthandPropertyAssignment( + node, + node.name, + objectAssignmentInitializer); +} + +function transformNamedEvaluationOfVariableDeclaration(context: TransformationContext, node: NamedEvaluation & VariableDeclaration, ignoreEmptyStringLiteral?: boolean, assignedNameText?: string) { + // 14.3.1.2 RS: Evaluation + // LexicalBinding : BindingIdentifier Initializer + // ... + // 3. If IsAnonymousFunctionDefinition(|Initializer|) is *true*, then + // a. Let _value_ be ? NamedEvaluation of |Initializer| with argument _bindingId_. + // ... + // + // 14.3.2.1 RS: Evaluation + // VariableDeclaration : BindingIdentifier Initializer + // ... + // 3. If IsAnonymousFunctionDefinition(|Initializer|) is *true*, then + // a. Let _value_ be ? NamedEvaluation of |Initializer| with argument _bindingId_. + // ... + + const { factory } = context; + const assignedName = assignedNameText !== undefined ? factory.createStringLiteral(assignedNameText) : + getAssignedNameOfIdentifier(factory, node.name, node.initializer); + const initializer = finishTransformNamedEvaluation(context, node.initializer, assignedName, ignoreEmptyStringLiteral); + return factory.updateVariableDeclaration( + node, + node.name, + node.exclamationToken, + node.type, + initializer); +} + +function transformNamedEvaluationOfParameterDeclaration(context: TransformationContext, node: NamedEvaluation & ParameterDeclaration, ignoreEmptyStringLiteral?: boolean, assignedNameText?: string) { + // 8.6.3 RS: IteratorBindingInitialization + // SingleNameBinding : BindingIdentifier Initializer? + // ... + // 5. If |Initializer| is present and _v_ is *undefined*, then + // a. If IsAnonymousFunctionDefinition(|Initializer|) is *true*, then + // i. Set _v_ to ? NamedEvaluation of |Initializer| with argument _bindingId_. + // ... + // + // 14.3.3.3 RS: KeyedBindingInitialization + // SingleNameBinding : BindingIdentifier Initializer? + // ... + // 4. If |Initializer| is present and _v_ is *undefined*, then + // a. If IsAnonymousFunctionDefinition(|Initializer|) is *true*, then + // i. Set _v_ to ? NamedEvaluation of |Initializer| with argument _bindingId_. + // ... + + const { factory } = context; + const assignedName = assignedNameText !== undefined ? factory.createStringLiteral(assignedNameText) : + getAssignedNameOfIdentifier(factory, node.name, node.initializer); + const initializer = finishTransformNamedEvaluation(context, node.initializer, assignedName, ignoreEmptyStringLiteral); + return factory.updateParameterDeclaration( + node, + node.modifiers, + node.dotDotDotToken, + node.name, + node.questionToken, + node.type, + initializer); +} + +function transformNamedEvaluationOfBindingElement(context: TransformationContext, node: NamedEvaluation & BindingElement, ignoreEmptyStringLiteral?: boolean, assignedNameText?: string) { + // 8.6.3 RS: IteratorBindingInitialization + // SingleNameBinding : BindingIdentifier Initializer? + // ... + // 5. If |Initializer| is present and _v_ is *undefined*, then + // a. If IsAnonymousFunctionDefinition(|Initializer|) is *true*, then + // i. Set _v_ to ? NamedEvaluation of |Initializer| with argument _bindingId_. + // ... + // + // 14.3.3.3 RS: KeyedBindingInitialization + // SingleNameBinding : BindingIdentifier Initializer? + // ... + // 4. If |Initializer| is present and _v_ is *undefined*, then + // a. If IsAnonymousFunctionDefinition(|Initializer|) is *true*, then + // i. Set _v_ to ? NamedEvaluation of |Initializer| with argument _bindingId_. + // ... + + const { factory } = context; + const assignedName = assignedNameText !== undefined ? factory.createStringLiteral(assignedNameText) : + getAssignedNameOfIdentifier(factory, node.name, node.initializer); + const initializer = finishTransformNamedEvaluation(context, node.initializer, assignedName, ignoreEmptyStringLiteral); + return factory.updateBindingElement( + node, + node.dotDotDotToken, + node.propertyName, + node.name, + initializer); +} + +function transformNamedEvaluationOfPropertyDeclaration(context: TransformationContext, node: NamedEvaluation & PropertyDeclaration, ignoreEmptyStringLiteral?: boolean, assignedNameText?: string) { + // 10.2.1.3 RS: EvaluateBody + // Initializer : `=` AssignmentExpression + // ... + // 3. If IsAnonymousFunctionDefinition(|AssignmentExpression|) is *true*, then + // a. Let _value_ be ? NamedEvaluation of |Initializer| with argument _functionObject_.[[ClassFieldInitializerName]]. + // ... + + const { factory } = context; + const { assignedName, name } = getAssignedNameOfPropertyName(context, node.name, assignedNameText); + const initializer = finishTransformNamedEvaluation(context, node.initializer, assignedName, ignoreEmptyStringLiteral); + return factory.updatePropertyDeclaration( + node, + node.modifiers, + name, + node.questionToken ?? node.exclamationToken, + node.type, + initializer); +} + +function transformNamedEvaluationOfAssignmentExpression(context: TransformationContext, node: NamedEvaluation & BinaryExpression, ignoreEmptyStringLiteral?: boolean, assignedNameText?: string) { + // 13.15.2 RS: Evaluation + // AssignmentExpression : LeftHandSideExpression `=` AssignmentExpression + // 1. If |LeftHandSideExpression| is neither an |ObjectLiteral| nor an |ArrayLiteral|, then + // a. Let _lref_ be ? Evaluation of |LeftHandSideExpression|. + // b. If IsAnonymousFunctionDefinition(|AssignmentExpression|) and IsIdentifierRef of |LeftHandSideExpression| are both *true*, then + // i. Let _rval_ be ? NamedEvaluation of |AssignmentExpression| with argument _lref_.[[ReferencedName]]. + // ... + // + // AssignmentExpression : LeftHandSideExpression `&&=` AssignmentExpression + // ... + // 5. If IsAnonymousFunctionDefinition(|AssignmentExpression|) is *true* and IsIdentifierRef of |LeftHandSideExpression| is *true*, then + // a. Let _rval_ be ? NamedEvaluation of |AssignmentExpression| with argument _lref_.[[ReferencedName]]. + // ... + // + // AssignmentExpression : LeftHandSideExpression `||=` AssignmentExpression + // ... + // 5. If IsAnonymousFunctionDefinition(|AssignmentExpression|) is *true* and IsIdentifierRef of |LeftHandSideExpression| is *true*, then + // a. Let _rval_ be ? NamedEvaluation of |AssignmentExpression| with argument _lref_.[[ReferencedName]]. + // ... + // + // AssignmentExpression : LeftHandSideExpression `??=` AssignmentExpression + // ... + // 4. If IsAnonymousFunctionDefinition(|AssignmentExpression|) is *true* and IsIdentifierRef of |LeftHandSideExpression| is *true*, then + // a. Let _rval_ be ? NamedEvaluation of |AssignmentExpression| with argument _lref_.[[ReferencedName]]. + // ... + + const { factory } = context; + const assignedName = assignedNameText !== undefined ? factory.createStringLiteral(assignedNameText) : + getAssignedNameOfIdentifier(factory, node.left, node.right); + const right = finishTransformNamedEvaluation(context, node.right, assignedName, ignoreEmptyStringLiteral); + return factory.updateBinaryExpression( + node, + node.left, + node.operatorToken, + right); +} + +function transformNamedEvaluationOfExportAssignment(context: TransformationContext, node: NamedEvaluation & ExportAssignment, ignoreEmptyStringLiteral?: boolean, assignedNameText?: string) { + // 16.2.3.7 RS: Evaluation + // ExportDeclaration : `export` `default` AssignmentExpression `;` + // 1. If IsAnonymousFunctionDefinition(|AssignmentExpression|) is *true*, then + // a. Let _value_ be ? NamedEvaluation of |AssignmentExpression| with argument `"default"`. + // ... + + // NOTE: Since emit for `export =` translates to `module.exports = ...`, the assigned name of the class or function + // is `""`. + + const { factory } = context; + const assignedName = assignedNameText !== undefined ? factory.createStringLiteral(assignedNameText) : + factory.createStringLiteral(node.isExportEquals ? "" : "default"); + const expression = finishTransformNamedEvaluation(context, node.expression, assignedName, ignoreEmptyStringLiteral); + return factory.updateExportAssignment( + node, + node.modifiers, + expression); +} + +/** + * Performs a shallow transformation of a `NamedEvaluation` node, such that a valid name will be assigned. + * @internal + */ +export function transformNamedEvaluation(context: TransformationContext, node: T, ignoreEmptyStringLiteral?: boolean, assignedName?: string): Extract>; +export function transformNamedEvaluation(context: TransformationContext, node: NamedEvaluation, ignoreEmptyStringLiteral?: boolean, assignedName?: string) { + switch (node.kind) { + case SyntaxKind.PropertyAssignment: + return transformNamedEvaluationOfPropertyAssignment(context, node, ignoreEmptyStringLiteral, assignedName); + case SyntaxKind.ShorthandPropertyAssignment: + return transformNamedEvaluationOfShorthandAssignmentProperty(context, node, ignoreEmptyStringLiteral, assignedName); + case SyntaxKind.VariableDeclaration: + return transformNamedEvaluationOfVariableDeclaration(context, node, ignoreEmptyStringLiteral, assignedName); + case SyntaxKind.Parameter: + return transformNamedEvaluationOfParameterDeclaration(context, node, ignoreEmptyStringLiteral, assignedName); + case SyntaxKind.BindingElement: + return transformNamedEvaluationOfBindingElement(context, node, ignoreEmptyStringLiteral, assignedName); + case SyntaxKind.PropertyDeclaration: + return transformNamedEvaluationOfPropertyDeclaration(context, node, ignoreEmptyStringLiteral, assignedName); + case SyntaxKind.BinaryExpression: + return transformNamedEvaluationOfAssignmentExpression(context, node, ignoreEmptyStringLiteral, assignedName); + case SyntaxKind.ExportAssignment: + return transformNamedEvaluationOfExportAssignment(context, node, ignoreEmptyStringLiteral, assignedName); + } +} diff --git a/src/compiler/transformers/ts.ts b/src/compiler/transformers/ts.ts index 6fec0b61bd294..8b97637c07722 100644 --- a/src/compiler/transformers/ts.ts +++ b/src/compiler/transformers/ts.ts @@ -41,7 +41,7 @@ import { Expression, ExpressionWithTypeArguments, filter, - findSuperStatementIndex, + findSuperStatementIndexPath, flattenDestructuringAssignment, FlattenLevel, FunctionDeclaration, @@ -79,6 +79,8 @@ import { isAssertionExpression, isBindingName, isBindingPattern, + isBlock, + isCatchClause, isClassElement, isClassLike, isComputedPropertyName, @@ -118,6 +120,7 @@ import { isSourceFile, isStatement, isTemplateLiteral, + isTryStatement, JsxOpeningElement, JsxSelfClosingElement, LeftHandSideExpression, @@ -194,7 +197,7 @@ import { visitNode, visitNodes, visitParameterList, - VisitResult, + VisitResult } from "../_namespaces/ts"; /** @@ -922,24 +925,19 @@ export function transformTypeScript(context: TransformationContext) { const iife = factory.createImmediatelyInvokedArrowFunction(statements); setInternalEmitFlags(iife, InternalEmitFlags.TypeScriptClassWrapper); - // export let C = (() => { ... })(); - const modifiers = facts & ClassFacts.IsNamedExternalExport ? - factory.createModifiersFromModifierFlags(ModifierFlags.Export) : - undefined; - // let C = (() => { ... })(); - const varStatement = factory.createVariableStatement( - modifiers, - factory.createVariableDeclarationList([ - factory.createVariableDeclaration( - factory.getLocalName(node, /*allowComments*/ false, /*allowSourceMaps*/ false), - /*exclamationToken*/ undefined, - /*type*/ undefined, - iife - ) - ], NodeFlags.Let) + const varDecl = factory.createVariableDeclaration( + factory.getLocalName(node, /*allowComments*/ false, /*allowSourceMaps*/ false), + /*exclamationToken*/ undefined, + /*type*/ undefined, + iife ); + setOriginalNode(varDecl, node); + const varStatement = factory.createVariableStatement( + /*modifiers*/ undefined, + factory.createVariableDeclarationList([varDecl], NodeFlags.Let) + ); setOriginalNode(varStatement, node); setCommentRange(varStatement, node); setSourceMapRange(varStatement, moveRangePastDecorators(node)); @@ -963,10 +961,10 @@ export function transformTypeScript(context: TransformationContext) { factory.createExportDefault(factory.getLocalName(node, /*allowComments*/ false, /*allowSourceMaps*/ true)) ]; } - if (facts & ClassFacts.IsNamedExternalExport && !promoteToIIFE) { + if (facts & ClassFacts.IsNamedExternalExport) { return [ statement, - factory.createExternalModuleExport(factory.getLocalName(node, /*allowComments*/ false, /*allowSourceMaps*/ true)) + factory.createExternalModuleExport(factory.getDeclarationName(node, /*allowComments*/ false, /*allowSourceMaps*/ true)) ]; } } @@ -1293,6 +1291,37 @@ export function transformTypeScript(context: TransformationContext) { ); } + function transformConstructorBodyWorker(statementsOut: Statement[], statementsIn: NodeArray, statementOffset: number, superPath: readonly number[], superPathDepth: number, initializerStatements: readonly Statement[]) { + const superStatementIndex = superPath[superPathDepth]; + const superStatement = statementsIn[superStatementIndex]; + addRange(statementsOut, visitNodes(statementsIn, visitor, isStatement, statementOffset, superStatementIndex - statementOffset)); + if (isTryStatement(superStatement)) { + const tryBlockStatements: Statement[] = []; + + transformConstructorBodyWorker( + tryBlockStatements, + superStatement.tryBlock.statements, + /*statementOffset*/ 0, + superPath, + superPathDepth + 1, + initializerStatements); + + const tryBlockStatementsArray = factory.createNodeArray(tryBlockStatements); + setTextRange(tryBlockStatementsArray, superStatement.tryBlock.statements); + + statementsOut.push(factory.updateTryStatement( + superStatement, + factory.updateBlock(superStatement.tryBlock, tryBlockStatements), + visitNode(superStatement.catchClause, visitor, isCatchClause), + visitNode(superStatement.finallyBlock, visitor, isBlock))); + } + else { + addRange(statementsOut, visitNodes(statementsIn, visitor, isStatement, superStatementIndex, 1)); + addRange(statementsOut, initializerStatements); + } + addRange(statementsOut, visitNodes(statementsIn, visitor, isStatement, superStatementIndex + 1)); + } + function transformConstructorBody(body: Block, constructor: ConstructorDeclaration) { const parametersWithPropertyAssignments = constructor && filter(constructor.parameters, p => isParameterPropertyDeclaration(p, constructor)) as readonly ParameterPropertyDeclaration[] | undefined; @@ -1305,15 +1334,7 @@ export function transformTypeScript(context: TransformationContext) { resumeLexicalEnvironment(); const prologueStatementCount = factory.copyPrologue(body.statements, statements, /*ensureUseStrict*/ false, visitor); - const superStatementIndex = findSuperStatementIndex(body.statements, prologueStatementCount); - - // If there was a super call, visit existing statements up to and including it - if (superStatementIndex >= 0) { - addRange( - statements, - visitNodes(body.statements, visitor, isStatement, prologueStatementCount, superStatementIndex + 1 - prologueStatementCount), - ); - } + const superPath = findSuperStatementIndexPath(body.statements, prologueStatementCount); // Transform parameters into property assignments. Transforms this: // @@ -1328,24 +1349,14 @@ export function transformTypeScript(context: TransformationContext) { // } // const parameterPropertyAssignments = mapDefined(parametersWithPropertyAssignments, transformParameterWithPropertyAssignment); - - // If there is a super() call, the parameter properties go immediately after it - if (superStatementIndex >= 0) { - addRange(statements, parameterPropertyAssignments); + if (superPath.length) { + transformConstructorBodyWorker(statements, body.statements, prologueStatementCount, superPath, /*superPathDepth*/ 0, parameterPropertyAssignments); } - // Since there was no super() call, parameter properties are the first statements in the constructor after any prologue statements else { - statements = [ - ...statements.slice(0, prologueStatementCount), - ...parameterPropertyAssignments, - ...statements.slice(prologueStatementCount), - ]; + addRange(statements, parameterPropertyAssignments); + addRange(statements, visitNodes(body.statements, visitor, isStatement, prologueStatementCount)); } - // Add remaining statements from the body, skipping the super() call if it was found and any (already added) prologue statements - const start = superStatementIndex >= 0 ? superStatementIndex + 1 : prologueStatementCount; - addRange(statements, visitNodes(body.statements, visitor, isStatement, start)); - // End the lexical environment. statements = factory.mergeLexicalEnvironment(statements, endLexicalEnvironment()); const block = factory.createBlock(setTextRange(factory.createNodeArray(statements), body.statements), /*multiLine*/ true); diff --git a/src/compiler/transformers/utilities.ts b/src/compiler/transformers/utilities.ts index c094a8dc0e76c..d01206af9057f 100644 --- a/src/compiler/transformers/utilities.ts +++ b/src/compiler/transformers/utilities.ts @@ -12,20 +12,19 @@ import { ClassExpression, ClassLikeDeclaration, ClassStaticBlockDeclaration, - CompilerOptions, CompoundAssignmentOperator, CoreTransformationContext, createExternalHelpersImportDeclarationIfNeeded, - createMultiMap, Decorator, - EmitResolver, ExportAssignment, ExportDeclaration, ExportSpecifier, Expression, filter, + formatGeneratedName, FunctionDeclaration, FunctionLikeDeclaration, + GeneratedIdentifierFlags, getAllAccessorDeclarations, getDecorators, getFirstConstructorWithBody, @@ -53,6 +52,7 @@ import { isIdentifier, isKeyword, isLocalName, + isMemberName, isMethodOrAccessor, isNamedExports, isNamedImports, @@ -62,6 +62,7 @@ import { isStatic, isStringLiteralLike, isSuperCall, + isTryStatement, LogicalOperatorOrHigher, map, MethodDeclaration, @@ -83,8 +84,9 @@ import { SuperCall, SyntaxKind, TransformationContext, + unorderedRemoveItem, VariableDeclaration, - VariableStatement, + VariableStatement } from "../_namespaces/ts"; /** @internal */ @@ -97,7 +99,7 @@ export function getOriginalNodeId(node: Node) { export interface ExternalModuleInfo { externalImports: (ImportDeclaration | ImportEqualsDeclaration | ExportDeclaration)[]; // imports of other external modules externalHelpersImportDeclaration: ImportDeclaration | undefined; // import of external helpers - exportSpecifiers: Map; // file-local export specifiers by name (no reexports) + exportSpecifiers: IdentifierNameMap; // file-local export specifiers by name (no reexports) exportedBindings: Identifier[][]; // exported names of local declarations exportedNames: Identifier[] | undefined; // all exported names in the module, both local and reexported exportEquals: ExportAssignment | undefined; // an export= declaration if one was present @@ -159,9 +161,11 @@ export function getImportNeedsImportDefaultHelper(node: ImportDeclaration): bool } /** @internal */ -export function collectExternalModuleInfo(context: TransformationContext, sourceFile: SourceFile, resolver: EmitResolver, compilerOptions: CompilerOptions): ExternalModuleInfo { +export function collectExternalModuleInfo(context: TransformationContext, sourceFile: SourceFile): ExternalModuleInfo { + const resolver = context.getEmitResolver(); + const compilerOptions = context.getCompilerOptions(); const externalImports: (ImportDeclaration | ImportEqualsDeclaration | ExportDeclaration)[] = []; - const exportSpecifiers = createMultiMap(); + const exportSpecifiers = new IdentifierNameMultiMap(); const exportedBindings: Identifier[][] = []; const uniqueExports = new Map(); let exportedNames: Identifier[] | undefined; @@ -298,7 +302,7 @@ export function collectExternalModuleInfo(context: TransformationContext, source if (!uniqueExports.get(idText(specifier.name))) { const name = specifier.propertyName || specifier.name; if (!node.moduleSpecifier) { - exportSpecifiers.add(idText(name), specifier); + exportSpecifiers.add(name, specifier); } const decl = resolver.getReferencedImportDeclaration(name) @@ -348,6 +352,83 @@ function multiMapSparseArrayAdd(map: V[][], key: number, value: V): V[] { return values; } +/** @internal */ +export class IdentifierNameMap { + private readonly _map = new Map(); + + get size() { + return this._map.size; + } + + has(key: Identifier) { + return this._map.has(IdentifierNameMap.toKey(key)); + } + + get(key: Identifier) { + return this._map.get(IdentifierNameMap.toKey(key)); + } + + set(key: Identifier, value: V) { + this._map.set(IdentifierNameMap.toKey(key), value); + return this; + } + + delete(key: Identifier): boolean { + return this._map?.delete(IdentifierNameMap.toKey(key)) ?? false; + } + + clear(): void { + this._map.clear(); + } + + values() { + return this._map.values(); + } + + private static toKey(name: Identifier | PrivateIdentifier): string { + if (isGeneratedPrivateIdentifier(name) || isGeneratedIdentifier(name)) { + const autoGenerate = name.emitNode.autoGenerate; + if ((autoGenerate.flags & GeneratedIdentifierFlags.KindMask) === GeneratedIdentifierFlags.Node) { + const node = getNodeForGeneratedName(name); + const baseName = isMemberName(node) && node !== name ? IdentifierNameMap.toKey(node) : `(generated@${getNodeId(node)})`; + return formatGeneratedName(/*privateName*/ false, autoGenerate.prefix, baseName, autoGenerate.suffix, IdentifierNameMap.toKey); + } + else { + const baseName = `(auto@${autoGenerate.id})`; + return formatGeneratedName(/*privateName*/ false, autoGenerate.prefix, baseName, autoGenerate.suffix, IdentifierNameMap.toKey); + } + } + if (isPrivateIdentifier(name)) { + return idText(name).slice(1); + } + return idText(name); + } +} + +/** @internal */ +export class IdentifierNameMultiMap extends IdentifierNameMap { + add(key: Identifier, value: V): V[] { + let values = this.get(key); + if (values) { + values.push(value); + } + else { + this.set(key, values = [value]); + } + return values; + } + + remove(key: Identifier, value: V) { + const values = this.get(key); + if (values) { + unorderedRemoveItem(values, value); + if (!values.length) { + this.delete(key); + } + } + } +} + /** * Used in the module transformer to check if an expression is reasonably without sideeffect, * and thus better to copy into multiple places rather than to cache in a temporary variable @@ -417,21 +498,34 @@ export function getSuperCallFromStatement(statement: Statement): SuperCall | und : undefined; } -/** - * @returns The index (after prologue statements) of a super call, or -1 if not found. - * - * @internal - */ -export function findSuperStatementIndex(statements: NodeArray, indexAfterLastPrologueStatement: number) { - for (let i = indexAfterLastPrologueStatement; i < statements.length; i += 1) { +function findSuperStatementIndexPathWorker(statements: NodeArray, start: number, indices: number[]) { + for (let i = start; i < statements.length; i += 1) { const statement = statements[i]; - if (getSuperCallFromStatement(statement)) { - return i; + indices.unshift(i); + return true; + } + else if (isTryStatement(statement) && findSuperStatementIndexPathWorker(statement.tryBlock.statements, 0, indices)) { + indices.unshift(i); + return true; } } - return -1; + return false; +} + +/** + * Finds a path of indices to navigate to a `super()` call, descending only through `try` statements. + * + * @returns An array of indicies to walk down through `try` statements, with the last element being the index of + * the statement containing `super()`. Otherwise, an empty array if `super()` was not found. + * + * @internal + */ +export function findSuperStatementIndexPath(statements: NodeArray, start: number) { + const indices: number[] = []; + findSuperStatementIndexPathWorker(statements, start, indices); + return indices; } /** diff --git a/src/compiler/types.ts b/src/compiler/types.ts index a5edcc4a7030d..06d4d1799194f 100644 --- a/src/compiler/types.ts +++ b/src/compiler/types.ts @@ -218,6 +218,7 @@ export const enum SyntaxKind { UndefinedKeyword, UniqueKeyword, UnknownKeyword, + UsingKeyword, FromKeyword, GlobalKeyword, BigIntKeyword, @@ -663,6 +664,7 @@ export type KeywordSyntaxKind = | SyntaxKind.UndefinedKeyword | SyntaxKind.UniqueKeyword | SyntaxKind.UnknownKeyword + | SyntaxKind.UsingKeyword | SyntaxKind.VarKeyword | SyntaxKind.VoidKeyword | SyntaxKind.WhileKeyword @@ -791,25 +793,27 @@ export const enum NodeFlags { None = 0, Let = 1 << 0, // Variable declaration Const = 1 << 1, // Variable declaration - NestedNamespace = 1 << 2, // Namespace declaration - Synthesized = 1 << 3, // Node was synthesized during transformation - Namespace = 1 << 4, // Namespace declaration - OptionalChain = 1 << 5, // Chained MemberExpression rooted to a pseudo-OptionalExpression - ExportContext = 1 << 6, // Export context (initialized by binding) - ContainsThis = 1 << 7, // Interface contains references to "this" - HasImplicitReturn = 1 << 8, // If function implicitly returns on one of codepaths (initialized by binding) - HasExplicitReturn = 1 << 9, // If function has explicit reachable return on one of codepaths (initialized by binding) - GlobalAugmentation = 1 << 10, // Set if module declaration is an augmentation for the global scope - HasAsyncFunctions = 1 << 11, // If the file has async functions (initialized by binding) - DisallowInContext = 1 << 12, // If node was parsed in a context where 'in-expressions' are not allowed - YieldContext = 1 << 13, // If node was parsed in the 'yield' context created when parsing a generator - DecoratorContext = 1 << 14, // If node was parsed as part of a decorator - AwaitContext = 1 << 15, // If node was parsed in the 'await' context created when parsing an async function - DisallowConditionalTypesContext = 1 << 16, // If node was parsed in a context where conditional types are not allowed - ThisNodeHasError = 1 << 17, // If the parser encountered an error when parsing the code that created this node - JavaScriptFile = 1 << 18, // If node was parsed in a JavaScript - ThisNodeOrAnySubNodesHasError = 1 << 19, // If this node or any of its children had an error - HasAggregatedChildData = 1 << 20, // If we've computed data from children and cached it in this node + Using = 1 << 2, // Variable declaration + AwaitUsing = Const | Using, // Variable declaration (NOTE: on a single node these flags would otherwise be mutually exclusive) + NestedNamespace = 1 << 3, // Namespace declaration + Synthesized = 1 << 4, // Node was synthesized during transformation + Namespace = 1 << 5, // Namespace declaration + OptionalChain = 1 << 6, // Chained MemberExpression rooted to a pseudo-OptionalExpression + ExportContext = 1 << 7, // Export context (initialized by binding) + ContainsThis = 1 << 8, // Interface contains references to "this" + HasImplicitReturn = 1 << 9, // If function implicitly returns on one of codepaths (initialized by binding) + HasExplicitReturn = 1 << 10, // If function has explicit reachable return on one of codepaths (initialized by binding) + GlobalAugmentation = 1 << 11, // Set if module declaration is an augmentation for the global scope + HasAsyncFunctions = 1 << 12, // If the file has async functions (initialized by binding) + DisallowInContext = 1 << 13, // If node was parsed in a context where 'in-expressions' are not allowed + YieldContext = 1 << 14, // If node was parsed in the 'yield' context created when parsing a generator + DecoratorContext = 1 << 15, // If node was parsed as part of a decorator + AwaitContext = 1 << 16, // If node was parsed in the 'await' context created when parsing an async function + DisallowConditionalTypesContext = 1 << 17, // If node was parsed in a context where conditional types are not allowed + ThisNodeHasError = 1 << 18, // If the parser encountered an error when parsing the code that created this node + JavaScriptFile = 1 << 19, // If node was parsed in a JavaScript + ThisNodeOrAnySubNodesHasError = 1 << 20, // If this node or any of its children had an error + HasAggregatedChildData = 1 << 21, // If we've computed data from children and cached it in this node // These flags will be set when the parser encounters a dynamic import expression or 'import.meta' to avoid // walking the tree if the flags are not set. However, these flags are just a approximation @@ -820,17 +824,18 @@ export const enum NodeFlags { // removal, it is likely that users will add the import anyway. // The advantage of this approach is its simplicity. For the case of batch compilation, // we guarantee that users won't have to pay the price of walking the tree if a dynamic import isn't used. - /** @internal */ PossiblyContainsDynamicImport = 1 << 21, - /** @internal */ PossiblyContainsImportMeta = 1 << 22, + /** @internal */ PossiblyContainsDynamicImport = 1 << 22, + /** @internal */ PossiblyContainsImportMeta = 1 << 23, - JSDoc = 1 << 23, // If node was parsed inside jsdoc - /** @internal */ Ambient = 1 << 24, // If node was inside an ambient context -- a declaration file, or inside something with the `declare` modifier. - /** @internal */ InWithStatement = 1 << 25, // If any ancestor of node was the `statement` of a WithStatement (not the `expression`) - JsonFile = 1 << 26, // If node was parsed in a Json - /** @internal */ TypeCached = 1 << 27, // If a type was cached for node at any point - /** @internal */ Deprecated = 1 << 28, // If has '@deprecated' JSDoc tag + JSDoc = 1 << 24, // If node was parsed inside jsdoc + /** @internal */ Ambient = 1 << 25, // If node was inside an ambient context -- a declaration file, or inside something with the `declare` modifier. + /** @internal */ InWithStatement = 1 << 26, // If any ancestor of node was the `statement` of a WithStatement (not the `expression`) + JsonFile = 1 << 27, // If node was parsed in a Json + /** @internal */ TypeCached = 1 << 28, // If a type was cached for node at any point + /** @internal */ Deprecated = 1 << 29, // If has '@deprecated' JSDoc tag - BlockScoped = Let | Const, + BlockScoped = Let | Const | Using, + Constant = Const | Using, ReachabilityCheckFlags = HasImplicitReturn | HasExplicitReturn, ReachabilityAndEmitFlags = ReachabilityCheckFlags | HasAsyncFunctions, @@ -7945,10 +7950,11 @@ export interface SourceMapSource { } /** @internal */ +// NOTE: Any new properties should be accounted for in `mergeEmitNode` in factory/nodeFactory.ts export interface EmitNode { - annotatedNodes?: Node[]; // Tracks Parse-tree nodes with EmitNodes for eventual cleanup. flags: EmitFlags; // Flags that customize emit internalFlags: InternalEmitFlags; // Internal flags that customize emit + annotatedNodes?: Node[]; // Tracks Parse-tree nodes with EmitNodes for eventual cleanup. leadingComments?: SynthesizedComment[]; // Synthesized leading comments trailingComments?: SynthesizedComment[]; // Synthesized trailing comments commentRange?: TextRange; // The text range to use when emitting leading or trailing comments @@ -7961,7 +7967,8 @@ export interface EmitNode { startsOnNewLine?: boolean; // If the node should begin on a new line snippetElement?: SnippetElement; // Snippet element of the node typeNode?: TypeNode; // VariableDeclaration type - classThis?: Identifier; // Identifier that points to the final class constructor after decorators are applied + classThis?: Identifier; // Identifier that points to a captured static `this` for a class which may be updated after decorators are applied + assignedName?: Expression; // Expression used as the assigned name of a class or function identifierTypeArguments?: NodeArray; // Only defined on synthesized identifiers. Though not syntactically valid, used in emitting diagnostics, quickinfo, and signature help. autoGenerate: AutoGenerateInfo | undefined; // Used for auto-generated identifiers and private identifiers. generatedImportReference?: ImportSpecifier; // Reference to the generated import specifier this identifier refers to @@ -8093,9 +8100,10 @@ export const enum ExternalEmitHelpers { CreateBinding = 1 << 22, // __createBinding (use by the module transform for (re)exports and namespace imports) SetFunctionName = 1 << 23, // __setFunctionName (used by class fields and ECMAScript decorators) PropKey = 1 << 24, // __propKey (used by class fields and ECMAScript decorators) + AddDisposableResourceAndDisposeResources = 1 << 25, // __addDisposableResource and __disposeResources (used by ESNext transformations) FirstEmitHelper = Extends, - LastEmitHelper = PropKey, + LastEmitHelper = AddDisposableResourceAndDisposeResources, // Helpers included by ES2015 for..of ForOfIncludes = Values, @@ -8190,7 +8198,8 @@ export type WrappedExpression = | T ; -export type TypeOfTag = "undefined" | "number" | "bigint" | "boolean" | "string" | "symbol" | "object" | "function"; +/** @internal */ +export type TypeOfTag = "null" | "undefined" | "number" | "bigint" | "boolean" | "string" | "symbol" | "object" | "function"; /** @internal */ export interface CallBinding { @@ -8237,6 +8246,7 @@ export interface ParenthesizerRules { export interface NodeConverters { convertToFunctionBlock(node: ConciseBody, multiLine?: boolean): Block; convertToFunctionExpression(node: FunctionDeclaration): FunctionExpression; + convertToClassExpression(node: ClassDeclaration): ClassExpression; convertToArrayAssignmentElement(element: ArrayBindingOrAssignmentElement): Expression; convertToObjectAssignmentElement(element: ObjectBindingOrAssignmentElement): ObjectLiteralElementLike; convertToAssignmentPattern(node: BindingOrAssignmentPattern): AssignmentPattern; @@ -8254,11 +8264,15 @@ export interface GeneratedNamePart { suffix?: string; } +export type ImmediatelyInvokedFunctionExpression = CallExpression & { readonly expression: FunctionExpression; }; +export type ImmediatelyInvokedArrowFunction = CallExpression & { readonly expression: ParenthesizedExpression & { readonly expression: ArrowFunction; }; }; + export interface NodeFactory { /** @internal */ readonly parenthesizer: ParenthesizerRules; /** @internal */ readonly converters: NodeConverters; /** @internal */ readonly baseFactory: BaseNodeFactory; /** @internal */ readonly flags: NodeFactoryFlags; + createNodeArray(elements?: readonly T[], hasTrailingComma?: boolean): NodeArray; // @@ -8877,8 +8891,8 @@ export interface NodeFactory { createImmediatelyInvokedFunctionExpression(statements: readonly Statement[]): CallExpression; createImmediatelyInvokedFunctionExpression(statements: readonly Statement[], param: ParameterDeclaration, paramValue: Expression): CallExpression; - createImmediatelyInvokedArrowFunction(statements: readonly Statement[]): CallExpression; - createImmediatelyInvokedArrowFunction(statements: readonly Statement[], param: ParameterDeclaration, paramValue: Expression): CallExpression; + createImmediatelyInvokedArrowFunction(statements: readonly Statement[]): ImmediatelyInvokedArrowFunction; + createImmediatelyInvokedArrowFunction(statements: readonly Statement[], param: ParameterDeclaration, paramValue: Expression): ImmediatelyInvokedArrowFunction; createVoidZero(): VoidExpression; @@ -8886,6 +8900,7 @@ export interface NodeFactory { createExternalModuleExport(exportName: Identifier): ExportDeclaration; /** @internal */ createTypeCheck(value: Expression, tag: TypeOfTag): Expression; + /** @internal */ createIsNotTypeCheck(value: Expression, tag: TypeOfTag): Expression; /** @internal */ createMethodCall(object: Expression, methodName: string | Identifier, argumentsList: readonly Expression[]): CallExpression; /** @internal */ createGlobalMethodCall(globalObjectName: string, globalMethodName: string, argumentsList: readonly Expression[]): CallExpression; /** @internal */ createFunctionBindCall(target: Expression, thisArg: Expression, argumentsList: readonly Expression[]): CallExpression; diff --git a/src/compiler/utilities.ts b/src/compiler/utilities.ts index c681495eda0cb..44a62be7e3a52 100644 --- a/src/compiler/utilities.ts +++ b/src/compiler/utilities.ts @@ -52,6 +52,7 @@ import { ClassDeclaration, ClassElement, ClassExpression, + classHasDeclaredOrExplicitlyAssignedName, ClassLikeDeclaration, ClassStaticBlockDeclaration, combinePaths, @@ -2335,14 +2336,36 @@ export function isDeclarationReadonly(declaration: Declaration): boolean { return !!(getCombinedModifierFlags(declaration) & ModifierFlags.Readonly && !isParameterPropertyDeclaration(declaration, declaration.parent)); } -/** @internal */ +/** + * Gets whether a bound `VariableDeclaration` or `VariableDeclarationList` is part of an `await using` declaration. + * @internal + */ +export function isVarAwaitUsing(node: VariableDeclaration | VariableDeclarationList): boolean { + return (getCombinedNodeFlags(node) & NodeFlags.BlockScoped) === NodeFlags.AwaitUsing; +} + +/** + * Gets whether a bound `VariableDeclaration` or `VariableDeclarationList` is part of a `using` declaration. + * @internal + */ +export function isVarUsing(node: VariableDeclaration | VariableDeclarationList): boolean { + return (getCombinedNodeFlags(node) & NodeFlags.BlockScoped) === NodeFlags.Using; +} + +/** + * Gets whether a bound `VariableDeclaration` or `VariableDeclarationList` is part of a `const` declaration. + * @internal + */ export function isVarConst(node: VariableDeclaration | VariableDeclarationList): boolean { - return !!(getCombinedNodeFlags(node) & NodeFlags.Const); + return (getCombinedNodeFlags(node) & NodeFlags.BlockScoped) === NodeFlags.Const; } -/** @internal */ +/** + * Gets whether a bound `VariableDeclaration` or `VariableDeclarationList` is part of a `let` declaration. + * @internal + */ export function isLet(node: Node): boolean { - return !!(getCombinedNodeFlags(node) & NodeFlags.Let); + return (getCombinedNodeFlags(node) & NodeFlags.BlockScoped) === NodeFlags.Let; } /** @internal */ @@ -5104,8 +5127,12 @@ export function isAnonymousFunctionDefinition(node: Expression, cb?: (node: Anon node = skipOuterExpressions(node); switch (node.kind) { case SyntaxKind.ClassExpression: + if (classHasDeclaredOrExplicitlyAssignedName(node as ClassExpression)) { + return false; + } + break; case SyntaxKind.FunctionExpression: - if ((node as ClassExpression | FunctionExpression).name) { + if ((node as FunctionExpression).name) { return false; } break; @@ -5171,7 +5198,8 @@ export type NamedEvaluation = | ParameterDeclaration & { readonly name: Identifier, readonly dotDotDotToken: undefined, readonly initializer: WrappedExpression } | BindingElement & { readonly name: Identifier, readonly dotDotDotToken: undefined, readonly initializer: WrappedExpression } | PropertyDeclaration & { readonly initializer: WrappedExpression } - | AssignmentExpression & { readonly left: Identifier, readonly right: WrappedExpression } + | AssignmentExpression & { readonly left: Identifier, readonly right: WrappedExpression } + | AssignmentExpression & { readonly left: Identifier, readonly right: WrappedExpression } | ExportAssignment & { readonly expression: WrappedExpression } ; diff --git a/src/compiler/utilitiesPublic.ts b/src/compiler/utilitiesPublic.ts index 4d0220bdf4308..62be656474719 100644 --- a/src/compiler/utilitiesPublic.ts +++ b/src/compiler/utilitiesPublic.ts @@ -68,6 +68,7 @@ import { FunctionLikeDeclaration, FunctionTypeNode, GeneratedIdentifier, + GeneratedIdentifierFlags, GeneratedPrivateIdentifier, GetAccessorDeclaration, getAssignmentDeclarationKind, @@ -604,7 +605,11 @@ export function getCombinedNodeFlagsAlwaysIncludeJSDoc(node: Declaration): Modif // list. By calling this function, all those flags are combined so that the client can treat // the node as if it actually had those flags. export function getCombinedNodeFlags(node: Node): NodeFlags { - return getCombinedFlags(node, n => n.flags); + return getCombinedFlags(node, getNodeFlags); +} + +function getNodeFlags(node: Node) { + return node.flags; } /** @internal */ @@ -1533,6 +1538,14 @@ export function isGeneratedPrivateIdentifier(node: Node): node is GeneratedPriva return isPrivateIdentifier(node) && node.emitNode?.autoGenerate !== undefined; } +/** @internal */ +export function isFileLevelReservedGeneratedIdentifier(node: GeneratedIdentifier) { + const flags = node.emitNode.autoGenerate.flags; + return !!(flags & GeneratedIdentifierFlags.FileLevel) + && !!(flags & GeneratedIdentifierFlags.Optimistic) + && !!(flags & GeneratedIdentifierFlags.ReservedInNestedScopes); +} + // Private Identifiers /** @internal */ export function isPrivateIdentifierClassElementDeclaration(node: Node): node is PrivateClassElementDeclaration { diff --git a/src/harness/evaluatorImpl.ts b/src/harness/evaluatorImpl.ts index f72526fb4a129..95668b3dfa1c7 100644 --- a/src/harness/evaluatorImpl.ts +++ b/src/harness/evaluatorImpl.ts @@ -16,8 +16,21 @@ for (const key of Object.getOwnPropertyNames(Symbol)) { Object.defineProperty(FakeSymbol, key, Object.getOwnPropertyDescriptor(Symbol, key)!); } -// Add "asyncIterator" if missing -if (!ts.hasProperty(FakeSymbol, "asyncIterator")) Object.defineProperty(FakeSymbol, "asyncIterator", { value: Symbol.for("Symbol.asyncIterator"), configurable: true }); +// Add symbols if missing +const symbolNames = [ + "asyncIterator", + "dispose", + "asyncDispose" +]; + +for (const symbolName of symbolNames) { + if (!ts.hasProperty(FakeSymbol, symbolName)) { + Object.defineProperty(FakeSymbol, symbolName, { + value: Symbol.for(`Symbol.${symbolName}`), + configurable: true + }); + } +} export function evaluateTypeScript(source: string | { files: vfs.FileSet, rootFiles: string[], main: string }, options?: ts.CompilerOptions, globals?: Record) { if (typeof source === "string") source = { files: { [sourceFile]: source }, rootFiles: [sourceFile], main: sourceFile }; @@ -60,6 +73,7 @@ function getLoader(compilerOptions: ts.CompilerOptions, fs: vfs.FileSystem, glob case ts.ModuleKind.System: return new SystemLoader(fs, globals); case ts.ModuleKind.AMD: + return new AmdLoader(fs, globals); case ts.ModuleKind.None: default: throw new Error(`ModuleKind '${ts.ModuleKind[moduleKind]}' not supported by evaluator.`); @@ -171,7 +185,7 @@ class CommonJsLoader extends Loader { } const base = vpath.dirname(file); const localRequire = (id: string) => this.import(id, base); - const evaluateText = `(function (module, exports, require, __dirname, __filename, ${globalNames.join(", ")}) { ${text} })`; + const evaluateText = `(function (module, exports, require, __dirname, __filename, ${globalNames.join(", ")}) { ${text}\n})`; // eslint-disable-next-line no-eval const evaluateThunk = (void 0, eval)(evaluateText) as (module: any, exports: any, require: (id: string) => any, dirname: string, filename: string, ...globalArgs: any[]) => void; evaluateThunk.call(this.globals, module, module.exports, localRequire, vpath.dirname(file), file, ...globalArgs); @@ -281,7 +295,7 @@ class SystemLoader extends Loader { const localSystem: SystemGlobal = { register: (dependencies, declare) => this.instantiateModule(module, dependencies, declare) }; - const evaluateText = `(function (System, ${globalNames.join(", ")}) { ${text} })`; + const evaluateText = `(function (System, ${globalNames.join(", ")}) { ${text}\n})`; try { // eslint-disable-next-line no-eval const evaluateThunk = (void 0, eval)(evaluateText) as (System: any, ...globalArgs: any[]) => void; @@ -460,3 +474,278 @@ class SystemLoader extends Loader { } } } + +interface AmdModule { + file: string; + state: AmdModuleState; + dependencies: (AmdModule | "require" | "module" | "exports")[]; + dependers: AmdModule[]; + require: (id: string) => any; + requestedDependencies?: string[]; + declaration?: AmdModuleDefineCallback; + hasError?: boolean; + module: { exports: any; }; + error?: any; +} + +type AmdModuleDefineCallback = (...args: any[]) => any; +type AmdModuleDeclaration = AmdModuleDefineCallback | Record; + +const enum AmdModuleState { + // Instantiation phases: + Uninstantiated, + Instantiated, + + // Linker phases: + AddingDependencies, + AllDependenciesAdded, + AllDependenciesInstantiated, + Linked, + + // Evaluation phases: + Evaluating, + Ready, +} + +type AmdDefineArgsUnnamedModuleNoDependencies = [declare: AmdModuleDeclaration]; +type AmdDefineArgsUnnamedModule = [dependencies: string[], declare: AmdModuleDeclaration]; +type AmdDefineArgsNamedModuleNoDependencies = [id: string, declare: AmdModuleDeclaration]; +type AmdDefineArgsNamedModule = [id: string, dependencies: string[], declare: AmdModuleDeclaration]; +type AmdDefineArgs = AmdDefineArgsUnnamedModuleNoDependencies | AmdDefineArgsUnnamedModule | AmdDefineArgsNamedModuleNoDependencies | AmdDefineArgsNamedModule; + +function isAmdDefineArgsUnnamedModuleNoDependencies(args: AmdDefineArgs): args is AmdDefineArgsUnnamedModuleNoDependencies { + return args.length === 1; +} + +function isAmdDefineArgsUnnamedModule(args: AmdDefineArgs): args is AmdDefineArgsUnnamedModule { + return args.length === 2 && Array.isArray(args[0]); +} + +function isAmdDefineArgsNamedModuleNoDependencies(args: AmdDefineArgs): args is AmdDefineArgsNamedModuleNoDependencies { + return args.length === 2 && typeof args[0] === "string"; +} + +function isAmdDefineArgsNamedModule(args: AmdDefineArgs): args is AmdDefineArgsNamedModule { + return args.length === 3 && typeof args[0] === "string"; +} + +class AmdLoader extends Loader { + protected createModule(file: string): AmdModule { + const base = vpath.dirname(file); + return { + file, + state: AmdModuleState.Uninstantiated, + dependencies: [], + dependers: [], + module: { exports: {} }, + require: (id: string) => this.import(id, base), + }; + } + + protected getExports(module: AmdModule) { + if (module.state < AmdModuleState.Ready) { + this.resetDependers(module, []); + this.evaluateModule(module, []); + if (module.state < AmdModuleState.Ready) { + const error = new Error("Module graph could not be loaded"); + this.handleError(module, error); + throw error; + } + } + if (module.hasError) { + throw module.error; + } + return module.module.exports; + } + + private handleError(module: AmdModule, error: any) { + if (!module.hasError) { + module.hasError = true; + module.error = error; + module.state = AmdModuleState.Ready; + } + } + + protected evaluate(text: string, _file: string, module: AmdModule): void { + const globalNames: string[] = []; + const globalArgs: any[] = []; + for (const name in this.globals) { + if (ts.hasProperty(this.globals, name)) { + globalNames.push(name); + globalArgs.push(this.globals[name]); + } + } + const localDefine = (...args: AmdDefineArgs) => { + if (isAmdDefineArgsUnnamedModuleNoDependencies(args)) { + const [declare] = args; + this.instantiateModule(module, [], declare); + } + else if (isAmdDefineArgsUnnamedModule(args)) { + const [dependencies, declare] = args; + this.instantiateModule(module, dependencies, declare); + } + else if (isAmdDefineArgsNamedModuleNoDependencies(args) || isAmdDefineArgsNamedModule(args)) { + throw new Error("Named modules not supported"); + } + else { + throw new Error("Unsupported arguments"); + } + }; + localDefine.amd = true; + const evaluateText = `(function (define, ${globalNames.join(", ")}) { ${text}\n})`; + try { + // eslint-disable-next-line no-eval + const evaluateThunk = (void 0, eval)(evaluateText) as (define: any, ...globalArgs: any[]) => void; + evaluateThunk.call(this.globals, localDefine, ...globalArgs); + } + catch (e) { + this.handleError(module, e); + throw e; + } + } + + private instantiateModule(module: AmdModule, dependencies: string[], callback?: AmdModuleDeclaration) { + try { + module.requestedDependencies = dependencies; + module.declaration = typeof callback === "function" ? callback as AmdModuleDefineCallback : () => callback; + module.state = AmdModuleState.Instantiated; + + for (const depender of module.dependers) { + this.linkModule(depender); + } + + this.linkModule(module); + } + catch (e) { + this.handleError(module, e); + throw e; + } + } + + private linkModule(module: AmdModule) { + try { + for (;;) { + switch (module.state) { + case AmdModuleState.Uninstantiated: { + throw new Error("Module not yet instantiated"); + } + case AmdModuleState.Instantiated: { + // Module has been instantiated, start requesting dependencies. + // Set state so that re-entry while adding dependencies does nothing. + module.state = AmdModuleState.AddingDependencies; + const base = vpath.dirname(module.file); + const dependencies = module.requestedDependencies || []; + + for (const dependencyId of dependencies) { + if (dependencyId === "require" || dependencyId === "exports" || dependencyId === "module") { + module.dependencies.push(dependencyId); + } + else { + const dependency = this.load(this.resolve(dependencyId, base)); + module.dependencies.push(dependency); + dependency.dependers.push(module); + } + } + + // All dependencies have been added, switch state + // to check whether all dependencies are instantiated + module.state = AmdModuleState.AllDependenciesAdded; + continue; + } + case AmdModuleState.AddingDependencies: { + // in the middle of adding dependencies for this module, do nothing + return; + } + case AmdModuleState.AllDependenciesAdded: { + // all dependencies have been added, advance state if all dependencies are instantiated. + for (const dependency of module.dependencies) { + if (typeof dependency === "object" && dependency.state === AmdModuleState.Uninstantiated) { + return; + } + } + + // indicate all dependencies are instantiated for this module. + module.state = AmdModuleState.AllDependenciesInstantiated; + + // trigger links for dependers of this module. + for (const depender of module.dependers) { + this.linkModule(depender); + } + continue; + } + case AmdModuleState.AllDependenciesInstantiated: { + module.state = AmdModuleState.Linked; + + // ensure graph is fully linked + for (const depender of module.dependers) { + this.linkModule(depender); + } + continue; + } + + case AmdModuleState.Linked: // module has already been linked, nothing to do + case AmdModuleState.Evaluating: // module is currently evaluating, nothing to do + case AmdModuleState.Ready: // module is done evaluating, nothing to do + return; + } + } + } + catch (e) { + this.handleError(module, e); + throw e; + } + } + + private resetDependers(module: AmdModule, stack: AmdModule[]) { + if (stack.lastIndexOf(module) !== -1) { + return; + } + + stack.push(module); + module.dependers.length = 0; + for (const dependency of module.dependencies) { + if (typeof dependency === "object") { + this.resetDependers(dependency, stack); + } + } + stack.pop(); + } + + private evaluateModule(module: AmdModule, stack: AmdModule[]) { + if (module.state < AmdModuleState.Linked) throw new Error("Invalid state for evaluation."); + if (module.state !== AmdModuleState.Linked) return; + + if (stack.lastIndexOf(module) !== -1) { + // we are already evaluating this module + return; + } + + stack.push(module); + module.state = AmdModuleState.Evaluating; + try { + const args: any[] = []; + for (const dependency of module.dependencies) { + if (dependency === "require") { + args.push(module.require); + } + else if (dependency === "exports") { + args.push(module.module.exports); + } + else if (dependency === "module") { + args.push(module.module); + } + else { + this.evaluateModule(dependency, stack); + args.push(dependency.module.exports); + } + } + + module.module.exports = module.declaration?.(...args) ?? module.module.exports; + module.state = AmdModuleState.Ready; + } + catch (e) { + this.handleError(module, e); + throw e; + } + } +} diff --git a/src/lib/esnext.d.ts b/src/lib/esnext.d.ts index 30eaf070bfb96..efec1799923df 100644 --- a/src/lib/esnext.d.ts +++ b/src/lib/esnext.d.ts @@ -1,2 +1,3 @@ /// /// +/// diff --git a/src/lib/esnext.disposable.d.ts b/src/lib/esnext.disposable.d.ts new file mode 100644 index 0000000000000..318b7395ac28a --- /dev/null +++ b/src/lib/esnext.disposable.d.ts @@ -0,0 +1,167 @@ +/// + +interface SymbolConstructor { + /** + * A method that is used to release resources held by an object. Called by the semantics of the `using` statement. + */ + readonly dispose: unique symbol; + + /** + * A method that is used to asynchronously release resources held by an object. Called by the semantics of the `await using` statement. + */ + readonly asyncDispose: unique symbol; +} + +interface Disposable { + [Symbol.dispose](): void; +} + +interface AsyncDisposable { + [Symbol.asyncDispose](): PromiseLike; +} + +interface SuppressedError extends Error { + error: any; + suppressed: any; +} + +interface SuppressedErrorConstructor extends ErrorConstructor { + new (error: any, suppressed: any, message?: string): SuppressedError; + (error: any, suppressed: any, message?: string): SuppressedError; + readonly prototype: SuppressedError; +} +declare var SuppressedError: SuppressedErrorConstructor; + +interface DisposableStack { + /** + * Returns a value indicating whether this stack has been disposed. + */ + readonly disposed: boolean; + /** + * Disposes each resource in the stack in the reverse order that they were added. + */ + dispose(): void; + /** + * Adds a disposable resource to the stack, returning the resource. + * @param value The resource to add. `null` and `undefined` will not be added, but will be returned. + * @returns The provided {@link value}. + */ + use(value: T): T; + /** + * Adds a value and associated disposal callback as a resource to the stack. + * @param value The value to add. + * @param onDispose The callback to use in place of a `[Symbol.dispose]()` method. Will be invoked with `value` + * as the first parameter. + * @returns The provided {@link value}. + */ + adopt(value: T, onDispose: (value: T) => void): T; + /** + * Adds a callback to be invoked when the stack is disposed. + */ + defer(onDispose: () => void): void; + /** + * Move all resources out of this stack and into a new `DisposableStack`, and marks this stack as disposed. + * @example + * ```ts + * class C { + * #res1: Disposable; + * #res2: Disposable; + * #disposables: DisposableStack; + * constructor() { + * // stack will be disposed when exiting constructor for any reason + * using stack = new DisposableStack(); + * + * // get first resource + * this.#res1 = stack.use(getResource1()); + * + * // get second resource. If this fails, both `stack` and `#res1` will be disposed. + * this.#res2 = stack.use(getResource2()); + * + * // all operations succeeded, move resources out of `stack` so that they aren't disposed + * // when constructor exits + * this.#disposables = stack.move(); + * } + * + * [Symbol.dispose]() { + * this.#disposables.dispose(); + * } + * } + * ``` + */ + move(): DisposableStack; + [Symbol.dispose](): void; + readonly [Symbol.toStringTag]: string; +} + +interface DisposableStackConstructor { + new(): DisposableStack; + readonly prototype: DisposableStack; +} +declare var DisposableStack: DisposableStackConstructor; + +interface AsyncDisposableStack { + /** + * Returns a value indicating whether this stack has been disposed. + */ + readonly disposed: boolean; + /** + * Disposes each resource in the stack in the reverse order that they were added. + */ + disposeAsync(): Promise; + /** + * Adds a disposable resource to the stack, returning the resource. + * @param value The resource to add. `null` and `undefined` will not be added, but will be returned. + * @returns The provided {@link value}. + */ + use(value: T): T; + /** + * Adds a value and associated disposal callback as a resource to the stack. + * @param value The value to add. + * @param onDisposeAsync The callback to use in place of a `[Symbol.asyncDispose]()` method. Will be invoked with `value` + * as the first parameter. + * @returns The provided {@link value}. + */ + adopt(value: T, onDisposeAsync: (value: T) => PromiseLike | void): T; + /** + * Adds a callback to be invoked when the stack is disposed. + */ + defer(onDisposeAsync: () => PromiseLike | void): void; + /** + * Move all resources out of this stack and into a new `DisposableStack`, and marks this stack as disposed. + * @example + * ```ts + * class C { + * #res1: Disposable; + * #res2: Disposable; + * #disposables: DisposableStack; + * constructor() { + * // stack will be disposed when exiting constructor for any reason + * using stack = new DisposableStack(); + * + * // get first resource + * this.#res1 = stack.use(getResource1()); + * + * // get second resource. If this fails, both `stack` and `#res1` will be disposed. + * this.#res2 = stack.use(getResource2()); + * + * // all operations succeeded, move resources out of `stack` so that they aren't disposed + * // when constructor exits + * this.#disposables = stack.move(); + * } + * + * [Symbol.dispose]() { + * this.#disposables.dispose(); + * } + * } + * ``` + */ + move(): AsyncDisposableStack; + [Symbol.asyncDispose](): Promise; + readonly [Symbol.toStringTag]: string; +} + +interface AsyncDisposableStackConstructor { + new(): AsyncDisposableStack; + readonly prototype: AsyncDisposableStack; +} +declare var AsyncDisposableStack: AsyncDisposableStackConstructor; diff --git a/src/lib/libs.json b/src/lib/libs.json index a7a07d9d2191b..2603798799ac6 100644 --- a/src/lib/libs.json +++ b/src/lib/libs.json @@ -68,6 +68,7 @@ "es2023.array", "es2023.collection", "esnext.intl", + "esnext.disposable", "decorators", "decorators.legacy", // Default libraries diff --git a/src/services/codefixes/addEmptyExportDeclaration.ts b/src/services/codefixes/addEmptyExportDeclaration.ts index d4020fea83f7f..b490c66af5ecd 100644 --- a/src/services/codefixes/addEmptyExportDeclaration.ts +++ b/src/services/codefixes/addEmptyExportDeclaration.ts @@ -11,6 +11,7 @@ import { registerCodeFix({ errorCodes: [ Diagnostics.await_expressions_are_only_allowed_at_the_top_level_of_a_file_when_that_file_is_a_module_but_this_file_has_no_imports_or_exports_Consider_adding_an_empty_export_to_make_this_file_a_module.code, + Diagnostics.await_using_statements_are_only_allowed_at_the_top_level_of_a_file_when_that_file_is_a_module_but_this_file_has_no_imports_or_exports_Consider_adding_an_empty_export_to_make_this_file_a_module.code, Diagnostics.for_await_loops_are_only_allowed_at_the_top_level_of_a_file_when_that_file_is_a_module_but_this_file_has_no_imports_or_exports_Consider_adding_an_empty_export_to_make_this_file_a_module.code, ], getCodeActions: function getCodeActionsToAddEmptyExportDeclaration(context) { diff --git a/src/services/codefixes/fixAwaitInSyncFunction.ts b/src/services/codefixes/fixAwaitInSyncFunction.ts index f12ba12e3f0fc..ee1f5f73a4c31 100644 --- a/src/services/codefixes/fixAwaitInSyncFunction.ts +++ b/src/services/codefixes/fixAwaitInSyncFunction.ts @@ -29,6 +29,7 @@ import { const fixId = "fixAwaitInSyncFunction"; const errorCodes = [ Diagnostics.await_expressions_are_only_allowed_within_async_functions_and_at_the_top_levels_of_modules.code, + Diagnostics.await_using_statements_are_only_allowed_within_async_functions_and_at_the_top_levels_of_modules.code, Diagnostics.for_await_loops_are_only_allowed_within_async_functions_and_at_the_top_levels_of_modules.code, Diagnostics.Cannot_find_name_0_Did_you_mean_to_write_this_in_an_async_function.code ]; diff --git a/src/services/codefixes/fixModuleAndTargetOptions.ts b/src/services/codefixes/fixModuleAndTargetOptions.ts index 9a223fa10d829..0cc3e489ab25d 100644 --- a/src/services/codefixes/fixModuleAndTargetOptions.ts +++ b/src/services/codefixes/fixModuleAndTargetOptions.ts @@ -20,6 +20,7 @@ import { registerCodeFix({ errorCodes: [ Diagnostics.Top_level_await_expressions_are_only_allowed_when_the_module_option_is_set_to_es2022_esnext_system_node16_or_nodenext_and_the_target_option_is_set_to_es2017_or_higher.code, + Diagnostics.Top_level_await_using_statements_are_only_allowed_when_the_module_option_is_set_to_es2022_esnext_system_node16_or_nodenext_and_the_target_option_is_set_to_es2017_or_higher.code, Diagnostics.Top_level_for_await_loops_are_only_allowed_when_the_module_option_is_set_to_es2022_esnext_system_node16_or_nodenext_and_the_target_option_is_set_to_es2017_or_higher.code, ], getCodeActions: function getCodeActionsToFixModuleAndTarget(context) { diff --git a/src/testRunner/tests.ts b/src/testRunner/tests.ts index fb002cc3491a8..0e81a8d2a07e4 100644 --- a/src/testRunner/tests.ts +++ b/src/testRunner/tests.ts @@ -45,6 +45,8 @@ import "./unittests/evaluation/objectRest"; import "./unittests/evaluation/superInStaticInitializer"; import "./unittests/evaluation/templateLiteral"; import "./unittests/evaluation/updateExpressionInModule"; +import "./unittests/evaluation/usingDeclarations"; +import "./unittests/evaluation/awaitUsingDeclarations"; import "./unittests/services/cancellableLanguageServiceOperations"; import "./unittests/services/colorization"; import "./unittests/services/convertToAsyncFunction"; diff --git a/src/testRunner/unittests/evaluation/awaitUsingDeclarations.ts b/src/testRunner/unittests/evaluation/awaitUsingDeclarations.ts new file mode 100644 index 0000000000000..c3e5c7e999637 --- /dev/null +++ b/src/testRunner/unittests/evaluation/awaitUsingDeclarations.ts @@ -0,0 +1,1672 @@ +import * as evaluator from "../../_namespaces/evaluator"; +import * as ts from "../../_namespaces/ts"; + +function FakeSuppressedError(error: any, suppressed: any) { + return { error, suppressed }; +} + +describe("unittests:: evaluation:: awaitUsingDeclarations", () => { + it("'await using' in Block, normal completion (es2018)", async () => { + const { main, output } = evaluator.evaluateTypeScript(` + export const output: any[] = []; + + const disposable = { + async [Symbol.asyncDispose]() { + output.push("disposed"); + } + }; + + function body() { + output.push("body"); + } + + export async function main() { + output.push("before block"); + { + output.push("enter block"); + await using _ = disposable; + body(); + output.push("exit block"); + } + output.push("after block"); + } + `, { target: ts.ScriptTarget.ES2018 }); + + await main(); + + assert.deepEqual(output, [ + "before block", + "enter block", + "body", + "exit block", + "disposed", + "after block" + ]); + }); + + it("'await using' in Block, 'throw' in body (es2018)", async () => { + const { main, output } = evaluator.evaluateTypeScript(` + export const output: any[] = []; + + const disposable = { + async [Symbol.asyncDispose]() { + output.push("disposed"); + } + }; + + function body() { + output.push("body"); + throw "error"; + } + + export async function main() { + output.push("before try"); + try { + output.push("enter try"); + await using _ = disposable; + body(); + output.push("exit try"); + } + catch (e) { + output.push(e); + } + output.push("after try"); + } + `, { target: ts.ScriptTarget.ES2018 }); + + await main(); + + assert.deepEqual(output, [ + "before try", + "enter try", + "body", + "disposed", + "error", + "after try" + ]); + }); + + it("'await using' in Block, 'throw' in dispose (es2018)", async () => { + const { main, output } = evaluator.evaluateTypeScript(` + export const output: any[] = []; + + const disposable = { + async [Symbol.asyncDispose]() { + output.push("disposed"); + throw "error"; + } + }; + + function body() { + output.push("body"); + } + + export async function main() { + output.push("before try"); + try { + output.push("enter try"); + await using _ = disposable; + body(); + output.push("exit try"); + } + catch (e) { + output.push(e); + } + output.push("after try"); + } + `, { target: ts.ScriptTarget.ES2018 }); + + await main(); + + assert.deepEqual(output, [ + "before try", + "enter try", + "body", + "exit try", + "disposed", + "error", + "after try" + ]); + }); + + it("'await using' in Block, 'throw' in body and dispose (es2018)", async () => { + const { main, output } = evaluator.evaluateTypeScript(` + export const output: any[] = []; + + const disposable = { + async [Symbol.asyncDispose]() { + output.push("disposed"); + throw "dispose error"; + } + }; + + function body() { + output.push("body"); + throw "body error"; + } + + export async function main() { + output.push("before try"); + try { + output.push("enter try"); + await using _ = disposable; + body(); + output.push("exit try"); + } + catch (e) { + output.push(e); + } + output.push("after try"); + } + `, { target: ts.ScriptTarget.ES2018 }, { SuppressedError: FakeSuppressedError }); + + await main(); + + assert.deepEqual(output, [ + "before try", + "enter try", + "body", + "disposed", + { + error: "dispose error", + suppressed: "body error" + }, + "after try" + ]); + }); + + it("'await using' in Block, 'throw' in body and dispose, no global SuppressedError (es2018)", async () => { + const { main, output } = evaluator.evaluateTypeScript(` + export const output: any[] = []; + + const disposable = { + async [Symbol.asyncDispose]() { + output.push("disposed"); + throw "dispose error"; + } + }; + + function body() { + output.push("body"); + throw "body error"; + } + + export async function main() { + output.push("before try"); + try { + output.push("enter try"); + await using _ = disposable; + body(); + output.push("exit try"); + } + catch (e) { + output.push(e); + } + output.push("after try"); + } + `, { target: ts.ScriptTarget.ES2018 }); + + await main(); + + assert.deepEqual(output.slice(0, 4), [ + "before try", + "enter try", + "body", + "disposed"]); + assert.instanceOf(output[4], Error); + assert.strictEqual(output[4].name, "SuppressedError"); + assert.strictEqual(output[4].error, "dispose error"); + assert.strictEqual(output[4].suppressed, "body error"); + assert.deepEqual(output.slice(5), [ + "after try" + ]); + }); + + it("'await using' in Block, 'return' in body (es2018)", async () => { + const { main, output } = evaluator.evaluateTypeScript(` + export const output: any[] = []; + + const disposable = { + async [Symbol.asyncDispose]() { + output.push("disposed"); + } + }; + + function body() { + output.push("body"); + } + + export async function main() { + output.push("before block"); + { + output.push("enter block"); + await using _ = disposable; + body(); + return; + } + output.push("after block"); + } + `, { target: ts.ScriptTarget.ES2018 }); + + await main(); + + assert.deepEqual(output, [ + "before block", + "enter block", + "body", + "disposed" + ]); + }); + + it("'await using' in Block, 'break' in body (es2018)", async () => { + const { main, output } = evaluator.evaluateTypeScript(` + export const output: any[] = []; + + const disposable = { + async [Symbol.asyncDispose]() { + output.push("disposed"); + } + }; + + function body() { + output.push("body"); + } + + export async function main() { + output.push("before block"); + for (let i = 0; i < 2; i++) { + output.push("enter block"); + await using _ = disposable; + body(); + break; + } + output.push("after block"); + } + `, { target: ts.ScriptTarget.ES2018 }); + + await main(); + + assert.deepEqual(output, [ + "before block", + "enter block", + "body", + "disposed", + "after block" + ]); + }); + + it("'await using' in Block, 'continue' in body (es2018)", async () => { + const { main, output } = evaluator.evaluateTypeScript(` + export const output: any[] = []; + + const disposable = { + async [Symbol.asyncDispose]() { + output.push("disposed"); + } + }; + + function body() { + output.push("body"); + } + + export async function main() { + output.push("before block"); + for (let i = 0; i < 2; i++) { + output.push("enter block"); + await using _ = disposable; + body(); + continue; + } + output.push("after block"); + } + `, { target: ts.ScriptTarget.ES2018 }); + + await main(); + + assert.deepEqual(output, [ + "before block", + "enter block", + "body", + "disposed", + "enter block", + "body", + "disposed", + "after block" + ]); + }); + + it("'await using' in head of 'for', normal completion (es2018)", async () => { + const { main, output } = evaluator.evaluateTypeScript(` + export const output: any[] = []; + + const disposable = { + async [Symbol.asyncDispose]() { + output.push("disposed"); + } + }; + + function body() { + output.push("body"); + } + + export async function main() { + output.push("before loop"); + let i = 0; + for (await using _ = disposable; i < 2; i++) { + output.push("enter loop"); + body(); + output.push("exit loop"); + } + output.push("after loop"); + } + `, { target: ts.ScriptTarget.ES2018 }); + + await main(); + + assert.deepEqual(output, [ + "before loop", + "enter loop", + "body", + "exit loop", + "enter loop", + "body", + "exit loop", + "disposed", + "after loop" + ]); + }); + + it("'await using' in head of 'for', 'throw' in body (es2018)", async () => { + const { main, output } = evaluator.evaluateTypeScript(` + export const output: any[] = []; + + const disposable = { + async [Symbol.asyncDispose]() { + output.push("disposed"); + } + }; + + function body() { + output.push("body"); + throw "error"; + } + + export async function main() { + output.push("before loop"); + let i = 0; + try { + for (await using _ = disposable; i < 2; i++) { + output.push("enter loop"); + body(); + output.push("exit loop"); + } + } catch (e) { + output.push(e); + } + output.push("after loop"); + } + `, { target: ts.ScriptTarget.ES2018 }); + + await main(); + + assert.deepEqual(output, [ + "before loop", + "enter loop", + "body", + "disposed", + "error", + "after loop" + ]); + }); + + it("'await using' in head of 'for', 'throw' in dispose (es2018)", async () => { + const { main, output } = evaluator.evaluateTypeScript(` + export const output: any[] = []; + + const disposable = { + async [Symbol.asyncDispose]() { + output.push("disposed"); + throw "error"; + } + }; + + function body() { + output.push("body"); + } + + export async function main() { + output.push("before loop"); + let i = 0; + try { + for (await using _ = disposable; i < 2; i++) { + output.push("enter loop"); + body(); + output.push("exit loop"); + } + } catch (e) { + output.push(e); + } + output.push("after loop"); + } + `, { target: ts.ScriptTarget.ES2018 }); + + await main(); + + assert.deepEqual(output, [ + "before loop", + "enter loop", + "body", + "exit loop", + "enter loop", + "body", + "exit loop", + "disposed", + "error", + "after loop" + ]); + }); + + it("'await using' in head of 'for', 'throw' in body and dispose (es2018)", async () => { + const { main, output } = evaluator.evaluateTypeScript(` + export const output: any[] = []; + + const disposable = { + async [Symbol.asyncDispose]() { + output.push("disposed"); + throw "dispose error"; + } + }; + + function body() { + output.push("body"); + throw "body error"; + } + + export async function main() { + output.push("before loop"); + let i = 0; + try { + for (await using _ = disposable; i < 2; i++) { + output.push("enter loop"); + body(); + output.push("exit loop"); + } + } catch (e) { + output.push(e); + } + output.push("after loop"); + } + `, { target: ts.ScriptTarget.ES2018 }, { SuppressedError: FakeSuppressedError }); + + await main(); + + assert.deepEqual(output, [ + "before loop", + "enter loop", + "body", + "disposed", + { + error: "dispose error", + suppressed: "body error" + }, + "after loop" + ]); + }); + + it("'await using' in head of 'for', 'return' in body (es2018)", async () => { + const { main, output } = evaluator.evaluateTypeScript(` + export const output: any[] = []; + + const disposable = { + async [Symbol.asyncDispose]() { + output.push("disposed"); + } + }; + + function body() { + output.push("body"); + } + + export async function main() { + output.push("before loop"); + let i = 0; + for (await using _ = disposable; i < 2; i++) { + output.push("enter loop"); + body(); + return; + } + output.push("after loop"); + } + `, { target: ts.ScriptTarget.ES2018 }); + + await main(); + + assert.deepEqual(output, [ + "before loop", + "enter loop", + "body", + "disposed" + ]); + }); + + it("'await using' in head of 'for', 'break' in body (es2018)", async () => { + const { main, output } = evaluator.evaluateTypeScript(` + export const output: any[] = []; + + const disposable = { + async [Symbol.asyncDispose]() { + output.push("disposed"); + } + }; + + function body() { + output.push("body"); + } + + export async function main() { + output.push("before loop"); + let i = 0; + for (await using _ = disposable; i < 2; i++) { + output.push("enter loop"); + body(); + break; + } + output.push("after loop"); + } + `, { target: ts.ScriptTarget.ES2018 }); + + await main(); + + assert.deepEqual(output, [ + "before loop", + "enter loop", + "body", + "disposed", + "after loop" + ]); + }); + + it("'await using' in head of 'for', 'continue' in body (es2018)", async () => { + const { main, output } = evaluator.evaluateTypeScript(` + export const output: any[] = []; + + const disposable = { + async [Symbol.asyncDispose]() { + output.push("disposed"); + } + }; + + function body() { + output.push("body"); + } + + export async function main() { + output.push("before loop"); + let i = 0; + for (await using _ = disposable; i < 2; i++) { + output.push("enter loop"); + body(); + continue; + } + output.push("after loop"); + } + `, { target: ts.ScriptTarget.ES2018 }); + + await main(); + + assert.deepEqual(output, [ + "before loop", + "enter loop", + "body", + "enter loop", + "body", + "disposed", + "after loop" + ]); + }); + + it("'await using' in head of 'for', multiple iterations (es2018)", async () => { + const { main, output } = evaluator.evaluateTypeScript(` + export const output: any[] = []; + + const disposable = { + async [Symbol.asyncDispose]() { + output.push("disposed"); + } + }; + + function body() { + output.push("body"); + } + + export async function main() { + output.push("before loop"); + let i = 0; + for (await using _ = disposable; i < 2; i++) { + output.push("enter loop"); + body(); + output.push("exit loop"); + } + output.push("after loop"); + } + `, { target: ts.ScriptTarget.ES2018 }); + + await main(); + + assert.deepEqual(output, [ + "before loop", + "enter loop", + "body", + "exit loop", + "enter loop", + "body", + "exit loop", + "disposed", + "after loop" + ]); + }); + + it("'await using' in head of 'for-of', normal completion (es2018)", async () => { + const { main, output } = evaluator.evaluateTypeScript(` + export const output: any[] = []; + + function* g() { + yield { + async [Symbol.asyncDispose]() { + output.push("a disposed"); + } + }; + yield { + async [Symbol.asyncDispose]() { + output.push("b disposed"); + } + }; + } + + function body() { + output.push("body"); + } + + export async function main() { + output.push("before loop"); + for (await using _ of g()) { + output.push("enter loop"); + body(); + output.push("exit loop"); + } + output.push("after loop"); + } + `, { target: ts.ScriptTarget.ES2018 }); + + await main(); + + assert.deepEqual(output, [ + "before loop", + "enter loop", + "body", + "exit loop", + "a disposed", + "enter loop", + "body", + "exit loop", + "b disposed", + "after loop" + ]); + }); + + it("'await using' in head of 'for-of', 'throw' in body (es2018)", async () => { + const { main, output } = evaluator.evaluateTypeScript(` + export const output: any[] = []; + + function* g() { + yield { + async [Symbol.asyncDispose]() { + output.push("a disposed"); + } + }; + yield { + async [Symbol.asyncDispose]() { + output.push("b disposed"); + } + }; + } + + function body() { + output.push("body"); + throw "error"; + } + + export async function main() { + output.push("before loop"); + try { + for (await using _ of g()) { + output.push("enter loop"); + body(); + output.push("exit loop"); + } + } + catch (e) { + output.push(e); + } + output.push("after loop"); + } + `, { target: ts.ScriptTarget.ES2018 }); + + await main(); + + assert.deepEqual(output, [ + "before loop", + "enter loop", + "body", + "a disposed", + "error", + "after loop", + ]); + }); + + it("'await using' in head of 'for-of', 'throw' in dispose (es2018)", async () => { + const { main, output } = evaluator.evaluateTypeScript(` + export const output: any[] = []; + + function* g() { + yield { + async [Symbol.asyncDispose]() { + output.push("a disposed"); + throw "error"; + } + }; + yield { + async [Symbol.asyncDispose]() { + output.push("b disposed"); + } + }; + } + + function body() { + output.push("body"); + } + + export async function main() { + output.push("before loop"); + try { + for (await using _ of g()) { + output.push("enter loop"); + body(); + output.push("exit loop"); + } + } + catch (e) { + output.push(e); + } + output.push("after loop"); + } + `, { target: ts.ScriptTarget.ES2018 }); + + await main(); + + assert.deepEqual(output, [ + "before loop", + "enter loop", + "body", + "exit loop", + "a disposed", + "error", + "after loop", + ]); + }); + + it("'await using' in head of 'for-of', 'throw' in body and dispose (es2018)", async () => { + const { main, output } = evaluator.evaluateTypeScript(` + export const output: any[] = []; + + function* g() { + yield { + async [Symbol.asyncDispose]() { + output.push("a disposed"); + throw "dispose error"; + } + }; + yield { + async [Symbol.asyncDispose]() { + output.push("b disposed"); + } + }; + } + + function body() { + output.push("body"); + throw "body error"; + } + + export async function main() { + output.push("before loop"); + try { + for (await using _ of g()) { + output.push("enter loop"); + body(); + output.push("exit loop"); + } + } + catch (e) { + output.push(e); + } + output.push("after loop"); + } + `, { target: ts.ScriptTarget.ES2018 }, { SuppressedError: FakeSuppressedError }); + + await main(); + + assert.deepEqual(output, [ + "before loop", + "enter loop", + "body", + "a disposed", + { + error: "dispose error", + suppressed: "body error" + }, + "after loop", + ]); + }); + + it("'await using' in head of 'for-of', 'return' in body (es2018)", async () => { + const { main, output } = evaluator.evaluateTypeScript(` + export const output: any[] = []; + + function* g() { + yield { + async [Symbol.asyncDispose]() { + output.push("a disposed"); + } + }; + yield { + async [Symbol.asyncDispose]() { + output.push("b disposed"); + } + }; + } + + function body() { + output.push("body"); + } + + export async function main() { + output.push("before loop"); + for (await using _ of g()) { + output.push("enter loop"); + body(); + return; + } + output.push("after loop"); + } + `, { target: ts.ScriptTarget.ES2018 }); + + await main(); + + assert.deepEqual(output, [ + "before loop", + "enter loop", + "body", + "a disposed", + ]); + }); + + it("'await using' in head of 'for-of', 'break' in body (es2018)", async () => { + const { main, output } = evaluator.evaluateTypeScript(` + export const output: any[] = []; + + function* g() { + yield { + async [Symbol.asyncDispose]() { + output.push("a disposed"); + } + }; + yield { + async [Symbol.asyncDispose]() { + output.push("b disposed"); + } + }; + } + + function body() { + output.push("body"); + } + + export async function main() { + output.push("before loop"); + for (await using _ of g()) { + output.push("enter loop"); + body(); + break; + } + output.push("after loop"); + } + `, { target: ts.ScriptTarget.ES2018 }); + + await main(); + + assert.deepEqual(output, [ + "before loop", + "enter loop", + "body", + "a disposed", + "after loop" + ]); + }); + + it("'await using' in head of 'for-of', 'continue' in body (es2018)", async () => { + const { main, output } = evaluator.evaluateTypeScript(` + export const output: any[] = []; + + function* g() { + yield { + async [Symbol.asyncDispose]() { + output.push("a disposed"); + } + }; + yield { + async [Symbol.asyncDispose]() { + output.push("b disposed"); + } + }; + } + + function body() { + output.push("body"); + } + + export async function main() { + output.push("before loop"); + for (await using _ of g()) { + output.push("enter loop"); + body(); + continue; + } + output.push("after loop"); + } + `, { target: ts.ScriptTarget.ES2018 }); + + await main(); + + assert.deepEqual(output, [ + "before loop", + "enter loop", + "body", + "a disposed", + "enter loop", + "body", + "b disposed", + "after loop" + ]); + }); + + it("'await using' in head of 'for-await-of', normal completion (es2018)", async () => { + const { main, output } = evaluator.evaluateTypeScript(` + export const output: any[] = []; + + function* g() { + yield { + async [Symbol.asyncDispose]() { + output.push("a disposed"); + } + }; + yield { + async [Symbol.asyncDispose]() { + output.push("b disposed"); + } + }; + } + + function body() { + output.push("body"); + } + + export async function main() { + output.push("before loop"); + for await (await using _ of g()) { + output.push("enter loop"); + body(); + output.push("exit loop"); + } + output.push("after loop"); + } + `, { target: ts.ScriptTarget.ES2018 }); + + await main(); + + assert.deepEqual(output, [ + "before loop", + "enter loop", + "body", + "exit loop", + "a disposed", + "enter loop", + "body", + "exit loop", + "b disposed", + "after loop" + ]); + }); + + it("'await using' in head of 'for-await-of', 'throw' in body (es2018)", async () => { + const { main, output } = evaluator.evaluateTypeScript(` + export const output: any[] = []; + + function* g() { + yield { + async [Symbol.asyncDispose]() { + output.push("a disposed"); + } + }; + yield { + async [Symbol.asyncDispose]() { + output.push("b disposed"); + } + }; + } + + function body() { + output.push("body"); + throw "error"; + } + + export async function main() { + output.push("before loop"); + try { + for await (await using _ of g()) { + output.push("enter loop"); + body(); + output.push("exit loop"); + } + } + catch (e) { + output.push(e); + } + output.push("after loop"); + } + `, { target: ts.ScriptTarget.ES2018 }); + + await main(); + + assert.deepEqual(output, [ + "before loop", + "enter loop", + "body", + "a disposed", + "error", + "after loop", + ]); + }); + + it("'await using' in head of 'for-await-of', 'throw' in dispose (es2018)", async () => { + const { main, output } = evaluator.evaluateTypeScript(` + export const output: any[] = []; + + function* g() { + yield { + async [Symbol.asyncDispose]() { + output.push("a disposed"); + throw "error"; + } + }; + yield { + async [Symbol.asyncDispose]() { + output.push("b disposed"); + } + }; + } + + function body() { + output.push("body"); + } + + export async function main() { + output.push("before loop"); + try { + for await (await using _ of g()) { + output.push("enter loop"); + body(); + output.push("exit loop"); + } + } + catch (e) { + output.push(e); + } + output.push("after loop"); + } + `, { target: ts.ScriptTarget.ES2018 }); + + await main(); + + assert.deepEqual(output, [ + "before loop", + "enter loop", + "body", + "exit loop", + "a disposed", + "error", + "after loop", + ]); + }); + + it("'await using' in head of 'for-await-of', 'throw' in body and dispose (es2018)", async () => { + const { main, output } = evaluator.evaluateTypeScript(` + export const output: any[] = []; + + function* g() { + yield { + async [Symbol.asyncDispose]() { + output.push("a disposed"); + throw "dispose error"; + } + }; + yield { + async [Symbol.asyncDispose]() { + output.push("b disposed"); + } + }; + } + + function body() { + output.push("body"); + throw "body error"; + } + + export async function main() { + output.push("before loop"); + try { + for await (await using _ of g()) { + output.push("enter loop"); + body(); + output.push("exit loop"); + } + } + catch (e) { + output.push(e); + } + output.push("after loop"); + } + `, { target: ts.ScriptTarget.ES2018 }, { SuppressedError: FakeSuppressedError }); + + await main(); + + assert.deepEqual(output, [ + "before loop", + "enter loop", + "body", + "a disposed", + { + error: "dispose error", + suppressed: "body error" + }, + "after loop", + ]); + }); + + it("'await using' in head of 'for-await-of', 'return' in body (es2018)", async () => { + const { main, output } = evaluator.evaluateTypeScript(` + export const output: any[] = []; + + function* g() { + yield { + async [Symbol.asyncDispose]() { + output.push("a disposed"); + } + }; + yield { + async [Symbol.asyncDispose]() { + output.push("b disposed"); + } + }; + } + + function body() { + output.push("body"); + } + + export async function main() { + output.push("before loop"); + for await (await using _ of g()) { + output.push("enter loop"); + body(); + return; + } + output.push("after loop"); + } + `, { target: ts.ScriptTarget.ES2018 }); + + await main(); + + assert.deepEqual(output, [ + "before loop", + "enter loop", + "body", + "a disposed", + ]); + }); + + it("'await using' in head of 'for-await-of', 'break' in body (es2018)", async () => { + const { main, output } = evaluator.evaluateTypeScript(` + export const output: any[] = []; + + function* g() { + yield { + async [Symbol.asyncDispose]() { + output.push("a disposed"); + } + }; + yield { + async [Symbol.asyncDispose]() { + output.push("b disposed"); + } + }; + } + + function body() { + output.push("body"); + } + + export async function main() { + output.push("before loop"); + for await (await using _ of g()) { + output.push("enter loop"); + body(); + break; + } + output.push("after loop"); + } + `, { target: ts.ScriptTarget.ES2018 }); + + await main(); + + assert.deepEqual(output, [ + "before loop", + "enter loop", + "body", + "a disposed", + "after loop" + ]); + }); + + it("'await using' in head of 'for-await-of', 'continue' in body (es2018)", async () => { + const { main, output } = evaluator.evaluateTypeScript(` + export const output: any[] = []; + + function* g() { + yield { + async [Symbol.asyncDispose]() { + output.push("a disposed"); + } + }; + yield { + async [Symbol.asyncDispose]() { + output.push("b disposed"); + } + }; + } + + function body() { + output.push("body"); + } + + export async function main() { + output.push("before loop"); + for await (await using _ of g()) { + output.push("enter loop"); + body(); + continue; + } + output.push("after loop"); + } + `, { target: ts.ScriptTarget.ES2018 }); + + await main(); + + assert.deepEqual(output, [ + "before loop", + "enter loop", + "body", + "a disposed", + "enter loop", + "body", + "b disposed", + "after loop" + ]); + }); + + it("'await using' at top level of module (System)", async () => { + const { output, x, y } = await evaluator.evaluateTypeScript(` + export const output: any[] = []; + output.push("before export x"); + export const x = 1; + output.push("before using"); + await using _ = { + async [Symbol.asyncDispose]() { + output.push("disposed"); + } + }; + output.push("after using"); + export const y = 2; + output.push("after export y"); + `, { target: ts.ScriptTarget.ES2018, module: ts.ModuleKind.System }); + + assert.strictEqual(x, 1); + assert.strictEqual(y, 2); + assert.deepEqual(output, [ + "before export x", + "before using", + "after using", + "after export y", + "disposed" + ]); + }); + + it("'await using' for 'null' value", async () => { + const { main, output } = evaluator.evaluateTypeScript(` + export const output: any[] = []; + + function body() { + output.push("body"); + } + + export async function main() { + output.push("before block"); + { + output.push("enter block"); + await using _ = null; + body(); + output.push("exit block"); + } + output.push("after block"); + } + `, { target: ts.ScriptTarget.ES2018 }); + + await main(); + + assert.deepEqual(output, [ + "before block", + "enter block", + "body", + "exit block", + "after block" + ]); + }); + + it("'await using' for 'undefined' value", async () => { + const { main, output } = evaluator.evaluateTypeScript(` + export const output: any[] = []; + + function body() { + output.push("body"); + } + + export async function main() { + output.push("before block"); + { + output.push("enter block"); + await using _ = undefined; + body(); + output.push("exit block"); + } + output.push("after block"); + } + `, { target: ts.ScriptTarget.ES2018 }); + + await main(); + + assert.deepEqual(output, [ + "before block", + "enter block", + "body", + "exit block", + "after block" + ]); + }); + + it("'await using' for sync disposable value", async () => { + const { main, output } = evaluator.evaluateTypeScript(` + export const output: any[] = []; + + const disposable = { + [Symbol.dispose]() { + output.push("disposed"); + } + }; + + function body() { + output.push("body"); + } + + export async function main() { + output.push("before block"); + { + output.push("enter block"); + await using _ = disposable; + body(); + output.push("exit block"); + } + output.push("after block"); + } + `, { target: ts.ScriptTarget.ES2018 }); + + await main(); + + assert.deepEqual(output, [ + "before block", + "enter block", + "body", + "exit block", + "disposed", + "after block" + ]); + }); + + it("'await using' for non-disposable value", async () => { + const { main, output } = evaluator.evaluateTypeScript(` + export const output: any[] = []; + + function body() { + output.push("body"); + } + + export async function main() { + output.push("before block"); + { + output.push("enter block"); + await using _ = {} as any; + body(); + output.push("exit block"); + } + output.push("after block"); + } + `, { target: ts.ScriptTarget.ES2018 }); + + try { + await main(); + assert.fail("Expected 'main' to throw an error"); + } + catch { + // ignore + } + + assert.deepEqual(output, [ + "before block", + "enter block", + ]); + }); + + it("'await using' disposes in reverse order", async () => { + const { main, output } = evaluator.evaluateTypeScript(` + export const output: any[] = []; + + const disposable_1 = { + async [Symbol.asyncDispose]() { + output.push("disposed_1"); + } + }; + const disposable_2 = { + async [Symbol.asyncDispose]() { + output.push("disposed_2"); + } + }; + + function body() { + output.push("body"); + } + + export async function main() { + output.push("before block"); + { + output.push("enter block"); + await using _1 = disposable_1, _2 = disposable_2; + body(); + output.push("exit block"); + } + output.push("after block"); + } + `, { target: ts.ScriptTarget.ES2018 }); + + await main(); + + assert.deepEqual(output, [ + "before block", + "enter block", + "body", + "exit block", + "disposed_2", + "disposed_1", + "after block" + ]); + }); + + it("'await using' + 'using' disposes in reverse order", async () => { + const { main, output } = evaluator.evaluateTypeScript(` + export const output: any[] = []; + + const disposable_1 = { + async [Symbol.asyncDispose]() { + output.push("disposed_1"); + } + }; + + const disposable_2 = { + [Symbol.dispose]() { + output.push("disposed_2"); + } + }; + + function body() { + output.push("body"); + } + + export async function main() { + output.push("before block"); + { + output.push("enter block"); + await using _1 = disposable_1; + using _2 = disposable_2; + body(); + output.push("exit block"); + } + output.push("after block"); + } + `, { target: ts.ScriptTarget.ES2018 }); + + await main(); + + assert.deepEqual(output, [ + "before block", + "enter block", + "body", + "exit block", + "disposed_2", + "disposed_1", + "after block" + ]); + }); + + it("'await using' forces await if null and evaluated", async () => { + const { main, output } = evaluator.evaluateTypeScript(` + export const output: any[] = []; + + function body() { + output.push("body"); + } + + async function a() { + output.push("before block"); + { + output.push("enter block"); + await using _ = null; + body(); + output.push("exit block"); + } + output.push("after block"); + } + + function b() { + output.push("interleave"); + } + + export async function main() { + const p = a(); + b(); + await p; + } + + `, { target: ts.ScriptTarget.ES2018 }); + + await main(); + + assert.deepEqual(output, [ + "before block", + "enter block", + "body", + "exit block", + "interleave", + "after block" + ]); + }); + + it("'await using' does not force await if null and not evaluated", async () => { + const { main, output } = evaluator.evaluateTypeScript(` + export const output: any[] = []; + + function body() { + output.push("body"); + } + + async function a(exitEarly: boolean) { + output.push("before block"); + block: { + output.push("enter block"); + if (exitEarly) break block; + await using _ = null; + body(); + output.push("exit block"); + } + output.push("after block"); + } + + function b() { + output.push("no interleave"); + } + + export async function main() { + const p = a(true); + b(); + await p; + } + + `, { target: ts.ScriptTarget.ES2018 }); + + await main(); + + assert.deepEqual(output, [ + "before block", + "enter block", + "after block", + "no interleave", + ]); + }); +}); diff --git a/src/testRunner/unittests/evaluation/usingDeclarations.ts b/src/testRunner/unittests/evaluation/usingDeclarations.ts new file mode 100644 index 0000000000000..11100c952804d --- /dev/null +++ b/src/testRunner/unittests/evaluation/usingDeclarations.ts @@ -0,0 +1,1661 @@ +import * as evaluator from "../../_namespaces/evaluator"; +import * as ts from "../../_namespaces/ts"; + +function FakeSuppressedError(error: any, suppressed: any) { + return { error, suppressed }; +} + +describe("unittests:: evaluation:: usingDeclarations", () => { + it("'using' in Block, normal completion (es2018)", () => { + const { main, output } = evaluator.evaluateTypeScript(` + export const output: any[] = []; + + const disposable = { + [Symbol.dispose]() { + output.push("disposed"); + } + }; + + function body() { + output.push("body"); + } + + export function main() { + output.push("before block"); + { + output.push("enter block"); + using _ = disposable; + body(); + output.push("exit block"); + } + output.push("after block"); + } + `, { target: ts.ScriptTarget.ES2018 }); + + main(); + + assert.deepEqual(output, [ + "before block", + "enter block", + "body", + "exit block", + "disposed", + "after block" + ]); + }); + + it("'using' in Block, 'throw' in body (es2018)", () => { + const { main, output } = evaluator.evaluateTypeScript(` + export const output: any[] = []; + + const disposable = { + [Symbol.dispose]() { + output.push("disposed"); + } + }; + + function body() { + output.push("body"); + throw "error"; + } + + export function main() { + output.push("before try"); + try { + output.push("enter try"); + using _ = disposable; + body(); + output.push("exit try"); + } + catch (e) { + output.push(e); + } + output.push("after try"); + } + `, { target: ts.ScriptTarget.ES2018 }); + + main(); + + assert.deepEqual(output, [ + "before try", + "enter try", + "body", + "disposed", + "error", + "after try" + ]); + }); + + it("'using' in Block, 'throw' in dispose (es2018)", () => { + const { main, output } = evaluator.evaluateTypeScript(` + export const output: any[] = []; + + const disposable = { + [Symbol.dispose]() { + output.push("disposed"); + throw "error"; + } + }; + + function body() { + output.push("body"); + } + + export function main() { + output.push("before try"); + try { + output.push("enter try"); + using _ = disposable; + body(); + output.push("exit try"); + } + catch (e) { + output.push(e); + } + output.push("after try"); + } + `, { target: ts.ScriptTarget.ES2018 }); + + main(); + + assert.deepEqual(output, [ + "before try", + "enter try", + "body", + "exit try", + "disposed", + "error", + "after try" + ]); + }); + + it("'using' in Block, 'throw' in multiple dispose (es2018)", () => { + const { main, output } = evaluator.evaluateTypeScript(` + export const output: any[] = []; + + const disposable_1 = { + [Symbol.dispose]() { + output.push("disposed 1"); + throw "error 1"; + } + }; + + const disposable_2 = { + [Symbol.dispose]() { + output.push("disposed 2"); + throw "error 2"; + } + }; + + function body() { + output.push("body"); + } + + export function main() { + output.push("before try"); + try { + output.push("enter try"); + using _1 = disposable_1, _2 = disposable_2; + body(); + output.push("exit try"); + } + catch (e) { + output.push(e); + } + output.push("after try"); + } + `, { target: ts.ScriptTarget.ES2018 }, { SuppressedError: FakeSuppressedError }); + + main(); + + assert.deepEqual(output, [ + "before try", + "enter try", + "body", + "exit try", + "disposed 2", + "disposed 1", + { + error: "error 1", + suppressed: "error 2" + }, + "after try" + ]); + }); + + it("'using' in Block, 'throw' in body and dispose (es2018)", () => { + const { main, output } = evaluator.evaluateTypeScript(` + export const output: any[] = []; + + const disposable = { + [Symbol.dispose]() { + output.push("disposed"); + throw "dispose error"; + } + }; + + function body() { + output.push("body"); + throw "body error"; + } + + export function main() { + output.push("before try"); + try { + output.push("enter try"); + using _ = disposable; + body(); + output.push("exit try"); + } + catch (e) { + output.push(e); + } + output.push("after try"); + } + `, { target: ts.ScriptTarget.ES2018 }, { SuppressedError: FakeSuppressedError }); + + main(); + + assert.deepEqual(output, [ + "before try", + "enter try", + "body", + "disposed", + { + error: "dispose error", + suppressed: "body error" + }, + "after try" + ]); + }); + + it("'using' in Block, 'throw' in body and multiple dispose (es2018)", () => { + const { main, output } = evaluator.evaluateTypeScript(` + export const output: any[] = []; + + const disposable_1 = { + [Symbol.dispose]() { + output.push("disposed 1"); + throw "dispose error 1"; + } + }; + + const disposable_2 = { + [Symbol.dispose]() { + output.push("disposed 2"); + throw "dispose error 2"; + } + }; + + function body() { + output.push("body"); + throw "body error"; + } + + export function main() { + output.push("before try"); + try { + output.push("enter try"); + using _1 = disposable_1, _2 = disposable_2; + body(); + output.push("exit try"); + } + catch (e) { + output.push(e); + } + output.push("after try"); + } + `, { target: ts.ScriptTarget.ES2018 }, { SuppressedError: FakeSuppressedError }); + + main(); + + assert.deepEqual(output, [ + "before try", + "enter try", + "body", + "disposed 2", + "disposed 1", + { + error: "dispose error 1", + suppressed: { + error: "dispose error 2", + suppressed: "body error" + } + }, + "after try" + ]); + }); + + it("'using' in Block, 'throw' in body and dispose, no global SuppressedError (es2018)", () => { + const { main, output } = evaluator.evaluateTypeScript(` + export const output: any[] = []; + + const disposable = { + [Symbol.dispose]() { + output.push("disposed"); + throw "dispose error"; + } + }; + + function body() { + output.push("body"); + throw "body error"; + } + + export function main() { + output.push("before try"); + try { + output.push("enter try"); + using _ = disposable; + body(); + output.push("exit try"); + } + catch (e) { + output.push(e); + } + output.push("after try"); + } + `, { target: ts.ScriptTarget.ES2018 }); + + main(); + + assert.deepEqual(output.slice(0, 4), [ + "before try", + "enter try", + "body", + "disposed"]); + assert.instanceOf(output[4], Error); + assert.strictEqual(output[4].name, "SuppressedError"); + assert.strictEqual(output[4].error, "dispose error"); + assert.strictEqual(output[4].suppressed, "body error"); + assert.deepEqual(output.slice(5), [ + "after try" + ]); + }); + + it("'using' in Block, 'return' in body (es2018)", () => { + const { main, output } = evaluator.evaluateTypeScript(` + export const output: any[] = []; + + const disposable = { + [Symbol.dispose]() { + output.push("disposed"); + } + }; + + function body() { + output.push("body"); + } + + export function main() { + output.push("before block"); + { + output.push("enter block"); + using _ = disposable; + body(); + return; + } + output.push("after block"); + } + `, { target: ts.ScriptTarget.ES2018 }); + + main(); + + assert.deepEqual(output, [ + "before block", + "enter block", + "body", + "disposed" + ]); + }); + + it("'using' in Block, 'break' in body (es2018)", () => { + const { main, output } = evaluator.evaluateTypeScript(` + export const output: any[] = []; + + const disposable = { + [Symbol.dispose]() { + output.push("disposed"); + } + }; + + function body() { + output.push("body"); + } + + export function main() { + output.push("before block"); + for (let i = 0; i < 2; i++) { + output.push("enter block"); + using _ = disposable; + body(); + break; + } + output.push("after block"); + } + `, { target: ts.ScriptTarget.ES2018 }); + + main(); + + assert.deepEqual(output, [ + "before block", + "enter block", + "body", + "disposed", + "after block" + ]); + }); + + it("'using' in Block, 'continue' in body (es2018)", () => { + const { main, output } = evaluator.evaluateTypeScript(` + export const output: any[] = []; + + const disposable = { + [Symbol.dispose]() { + output.push("disposed"); + } + }; + + function body() { + output.push("body"); + } + + export function main() { + output.push("before block"); + for (let i = 0; i < 2; i++) { + output.push("enter block"); + using _ = disposable; + body(); + continue; + } + output.push("after block"); + } + `, { target: ts.ScriptTarget.ES2018 }); + + main(); + + assert.deepEqual(output, [ + "before block", + "enter block", + "body", + "disposed", + "enter block", + "body", + "disposed", + "after block" + ]); + }); + + it("'using' in head of 'for', normal completion (es2018)", () => { + const { main, output } = evaluator.evaluateTypeScript(` + export const output: any[] = []; + + const disposable = { + [Symbol.dispose]() { + output.push("disposed"); + } + }; + + function body() { + output.push("body"); + } + + export function main() { + output.push("before loop"); + let i = 0; + for (using _ = disposable; i < 2; i++) { + output.push("enter loop"); + body(); + output.push("exit loop"); + } + output.push("after loop"); + } + `, { target: ts.ScriptTarget.ES2018 }); + + main(); + + assert.deepEqual(output, [ + "before loop", + "enter loop", + "body", + "exit loop", + "enter loop", + "body", + "exit loop", + "disposed", + "after loop" + ]); + }); + + it("'using' in head of 'for', 'throw' in body (es2018)", () => { + const { main, output } = evaluator.evaluateTypeScript(` + export const output: any[] = []; + + const disposable = { + [Symbol.dispose]() { + output.push("disposed"); + } + }; + + function body() { + output.push("body"); + throw "error"; + } + + export function main() { + output.push("before loop"); + let i = 0; + try { + for (using _ = disposable; i < 2; i++) { + output.push("enter loop"); + body(); + output.push("exit loop"); + } + } catch (e) { + output.push(e); + } + output.push("after loop"); + } + `, { target: ts.ScriptTarget.ES2018 }); + + main(); + + assert.deepEqual(output, [ + "before loop", + "enter loop", + "body", + "disposed", + "error", + "after loop" + ]); + }); + + it("'using' in head of 'for', 'throw' in dispose (es2018)", () => { + const { main, output } = evaluator.evaluateTypeScript(` + export const output: any[] = []; + + const disposable = { + [Symbol.dispose]() { + output.push("disposed"); + throw "error"; + } + }; + + function body() { + output.push("body"); + } + + export function main() { + output.push("before loop"); + let i = 0; + try { + for (using _ = disposable; i < 2; i++) { + output.push("enter loop"); + body(); + output.push("exit loop"); + } + } catch (e) { + output.push(e); + } + output.push("after loop"); + } + `, { target: ts.ScriptTarget.ES2018 }); + + main(); + + assert.deepEqual(output, [ + "before loop", + "enter loop", + "body", + "exit loop", + "enter loop", + "body", + "exit loop", + "disposed", + "error", + "after loop" + ]); + }); + + it("'using' in head of 'for', 'throw' in body and dispose (es2018)", () => { + const { main, output } = evaluator.evaluateTypeScript(` + export const output: any[] = []; + + const disposable = { + [Symbol.dispose]() { + output.push("disposed"); + throw "dispose error"; + } + }; + + function body() { + output.push("body"); + throw "body error"; + } + + export function main() { + output.push("before loop"); + let i = 0; + try { + for (using _ = disposable; i < 2; i++) { + output.push("enter loop"); + body(); + output.push("exit loop"); + } + } catch (e) { + output.push(e); + } + output.push("after loop"); + } + `, { target: ts.ScriptTarget.ES2018 }, { SuppressedError: FakeSuppressedError }); + + main(); + + assert.deepEqual(output, [ + "before loop", + "enter loop", + "body", + "disposed", + { + error: "dispose error", + suppressed: "body error" + }, + "after loop" + ]); + }); + + it("'using' in head of 'for', 'return' in body (es2018)", () => { + const { main, output } = evaluator.evaluateTypeScript(` + export const output: any[] = []; + + const disposable = { + [Symbol.dispose]() { + output.push("disposed"); + } + }; + + function body() { + output.push("body"); + } + + export function main() { + output.push("before loop"); + let i = 0; + for (using _ = disposable; i < 2; i++) { + output.push("enter loop"); + body(); + return; + } + output.push("after loop"); + } + `, { target: ts.ScriptTarget.ES2018 }); + + main(); + + assert.deepEqual(output, [ + "before loop", + "enter loop", + "body", + "disposed" + ]); + }); + + it("'using' in head of 'for', 'break' in body (es2018)", () => { + const { main, output } = evaluator.evaluateTypeScript(` + export const output: any[] = []; + + const disposable = { + [Symbol.dispose]() { + output.push("disposed"); + } + }; + + function body() { + output.push("body"); + } + + export function main() { + output.push("before loop"); + let i = 0; + for (using _ = disposable; i < 2; i++) { + output.push("enter loop"); + body(); + break; + } + output.push("after loop"); + } + `, { target: ts.ScriptTarget.ES2018 }); + + main(); + + assert.deepEqual(output, [ + "before loop", + "enter loop", + "body", + "disposed", + "after loop" + ]); + }); + + it("'using' in head of 'for', 'continue' in body (es2018)", () => { + const { main, output } = evaluator.evaluateTypeScript(` + export const output: any[] = []; + + const disposable = { + [Symbol.dispose]() { + output.push("disposed"); + } + }; + + function body() { + output.push("body"); + } + + export function main() { + output.push("before loop"); + let i = 0; + for (using _ = disposable; i < 2; i++) { + output.push("enter loop"); + body(); + continue; + } + output.push("after loop"); + } + `, { target: ts.ScriptTarget.ES2018 }); + + main(); + + assert.deepEqual(output, [ + "before loop", + "enter loop", + "body", + "enter loop", + "body", + "disposed", + "after loop" + ]); + }); + + it("'using' in head of 'for', multiple iterations (es2018)", () => { + const { main, output } = evaluator.evaluateTypeScript(` + export const output: any[] = []; + + const disposable = { + [Symbol.dispose]() { + output.push("disposed"); + } + }; + + function body() { + output.push("body"); + } + + export function main() { + output.push("before loop"); + let i = 0; + for (using _ = disposable; i < 2; i++) { + output.push("enter loop"); + body(); + output.push("exit loop"); + } + output.push("after loop"); + } + `, { target: ts.ScriptTarget.ES2018 }); + + main(); + + assert.deepEqual(output, [ + "before loop", + "enter loop", + "body", + "exit loop", + "enter loop", + "body", + "exit loop", + "disposed", + "after loop" + ]); + }); + + it("'using' in head of 'for-of', normal completion (es2018)", () => { + const { main, output } = evaluator.evaluateTypeScript(` + export const output: any[] = []; + + function* g() { + yield { + [Symbol.dispose]() { + output.push("a disposed"); + } + }; + yield { + [Symbol.dispose]() { + output.push("b disposed"); + } + }; + } + + function body() { + output.push("body"); + } + + export function main() { + output.push("before loop"); + for (using _ of g()) { + output.push("enter loop"); + body(); + output.push("exit loop"); + } + output.push("after loop"); + } + `, { target: ts.ScriptTarget.ES2018 }); + + main(); + + assert.deepEqual(output, [ + "before loop", + "enter loop", + "body", + "exit loop", + "a disposed", + "enter loop", + "body", + "exit loop", + "b disposed", + "after loop" + ]); + }); + + it("'using' in head of 'for-of', 'throw' in body (es2018)", () => { + const { main, output } = evaluator.evaluateTypeScript(` + export const output: any[] = []; + + function* g() { + yield { + [Symbol.dispose]() { + output.push("a disposed"); + } + }; + yield { + [Symbol.dispose]() { + output.push("b disposed"); + } + }; + } + + function body() { + output.push("body"); + throw "error"; + } + + export function main() { + output.push("before loop"); + try { + for (using _ of g()) { + output.push("enter loop"); + body(); + output.push("exit loop"); + } + } + catch (e) { + output.push(e); + } + output.push("after loop"); + } + `, { target: ts.ScriptTarget.ES2018 }); + + main(); + + assert.deepEqual(output, [ + "before loop", + "enter loop", + "body", + "a disposed", + "error", + "after loop", + ]); + }); + + it("'using' in head of 'for-of', 'throw' in dispose (es2018)", () => { + const { main, output } = evaluator.evaluateTypeScript(` + export const output: any[] = []; + + function* g() { + yield { + [Symbol.dispose]() { + output.push("a disposed"); + throw "error"; + } + }; + yield { + [Symbol.dispose]() { + output.push("b disposed"); + } + }; + } + + function body() { + output.push("body"); + } + + export function main() { + output.push("before loop"); + try { + for (using _ of g()) { + output.push("enter loop"); + body(); + output.push("exit loop"); + } + } + catch (e) { + output.push(e); + } + output.push("after loop"); + } + `, { target: ts.ScriptTarget.ES2018 }); + + main(); + + assert.deepEqual(output, [ + "before loop", + "enter loop", + "body", + "exit loop", + "a disposed", + "error", + "after loop", + ]); + }); + + it("'using' in head of 'for-of', 'throw' in body and dispose (es2018)", () => { + const { main, output } = evaluator.evaluateTypeScript(` + export const output: any[] = []; + + function* g() { + yield { + [Symbol.dispose]() { + output.push("a disposed"); + throw "dispose error"; + } + }; + yield { + [Symbol.dispose]() { + output.push("b disposed"); + } + }; + } + + function body() { + output.push("body"); + throw "body error"; + } + + export function main() { + output.push("before loop"); + try { + for (using _ of g()) { + output.push("enter loop"); + body(); + output.push("exit loop"); + } + } + catch (e) { + output.push(e); + } + output.push("after loop"); + } + `, { target: ts.ScriptTarget.ES2018 }, { SuppressedError: FakeSuppressedError }); + + main(); + + assert.deepEqual(output, [ + "before loop", + "enter loop", + "body", + "a disposed", + { + error: "dispose error", + suppressed: "body error" + }, + "after loop", + ]); + }); + + it("'using' in head of 'for-of', 'return' in body (es2018)", () => { + const { main, output } = evaluator.evaluateTypeScript(` + export const output: any[] = []; + + function* g() { + yield { + [Symbol.dispose]() { + output.push("a disposed"); + } + }; + yield { + [Symbol.dispose]() { + output.push("b disposed"); + } + }; + } + + function body() { + output.push("body"); + } + + export function main() { + output.push("before loop"); + for (using _ of g()) { + output.push("enter loop"); + body(); + return; + } + output.push("after loop"); + } + `, { target: ts.ScriptTarget.ES2018 }); + + main(); + + assert.deepEqual(output, [ + "before loop", + "enter loop", + "body", + "a disposed", + ]); + }); + + it("'using' in head of 'for-of', 'break' in body (es2018)", () => { + const { main, output } = evaluator.evaluateTypeScript(` + export const output: any[] = []; + + function* g() { + yield { + [Symbol.dispose]() { + output.push("a disposed"); + } + }; + yield { + [Symbol.dispose]() { + output.push("b disposed"); + } + }; + } + + function body() { + output.push("body"); + } + + export function main() { + output.push("before loop"); + for (using _ of g()) { + output.push("enter loop"); + body(); + break; + } + output.push("after loop"); + } + `, { target: ts.ScriptTarget.ES2018 }); + + main(); + + assert.deepEqual(output, [ + "before loop", + "enter loop", + "body", + "a disposed", + "after loop" + ]); + }); + + it("'using' in head of 'for-of', 'continue' in body (es2018)", () => { + const { main, output } = evaluator.evaluateTypeScript(` + export const output: any[] = []; + + function* g() { + yield { + [Symbol.dispose]() { + output.push("a disposed"); + } + }; + yield { + [Symbol.dispose]() { + output.push("b disposed"); + } + }; + } + + function body() { + output.push("body"); + } + + export function main() { + output.push("before loop"); + for (using _ of g()) { + output.push("enter loop"); + body(); + continue; + } + output.push("after loop"); + } + `, { target: ts.ScriptTarget.ES2018 }); + + main(); + + assert.deepEqual(output, [ + "before loop", + "enter loop", + "body", + "a disposed", + "enter loop", + "body", + "b disposed", + "after loop" + ]); + }); + + it("'using' in head of 'for-await-of', normal completion (es2018)", async () => { + const { main, output } = evaluator.evaluateTypeScript(` + export const output: any[] = []; + + function* g() { + yield { + [Symbol.dispose]() { + output.push("a disposed"); + } + }; + yield { + [Symbol.dispose]() { + output.push("b disposed"); + } + }; + } + + function body() { + output.push("body"); + } + + export async function main() { + output.push("before loop"); + for await (using _ of g()) { + output.push("enter loop"); + body(); + output.push("exit loop"); + } + output.push("after loop"); + } + `, { target: ts.ScriptTarget.ES2018 }); + + await main(); + + assert.deepEqual(output, [ + "before loop", + "enter loop", + "body", + "exit loop", + "a disposed", + "enter loop", + "body", + "exit loop", + "b disposed", + "after loop" + ]); + }); + + it("'using' in head of 'for-await-of', 'throw' in body (es2018)", async () => { + const { main, output } = evaluator.evaluateTypeScript(` + export const output: any[] = []; + + function* g() { + yield { + [Symbol.dispose]() { + output.push("a disposed"); + } + }; + yield { + [Symbol.dispose]() { + output.push("b disposed"); + } + }; + } + + function body() { + output.push("body"); + throw "error"; + } + + export async function main() { + output.push("before loop"); + try { + for await (using _ of g()) { + output.push("enter loop"); + body(); + output.push("exit loop"); + } + } + catch (e) { + output.push(e); + } + output.push("after loop"); + } + `, { target: ts.ScriptTarget.ES2018 }); + + await main(); + + assert.deepEqual(output, [ + "before loop", + "enter loop", + "body", + "a disposed", + "error", + "after loop", + ]); + }); + + it("'using' in head of 'for-await-of', 'throw' in dispose (es2018)", async () => { + const { main, output } = evaluator.evaluateTypeScript(` + export const output: any[] = []; + + function* g() { + yield { + [Symbol.dispose]() { + output.push("a disposed"); + throw "error"; + } + }; + yield { + [Symbol.dispose]() { + output.push("b disposed"); + } + }; + } + + function body() { + output.push("body"); + } + + export async function main() { + output.push("before loop"); + try { + for await (using _ of g()) { + output.push("enter loop"); + body(); + output.push("exit loop"); + } + } + catch (e) { + output.push(e); + } + output.push("after loop"); + } + `, { target: ts.ScriptTarget.ES2018 }); + + await main(); + + assert.deepEqual(output, [ + "before loop", + "enter loop", + "body", + "exit loop", + "a disposed", + "error", + "after loop", + ]); + }); + + it("'using' in head of 'for-await-of', 'throw' in body and dispose (es2018)", async () => { + const { main, output } = evaluator.evaluateTypeScript(` + export const output: any[] = []; + + function* g() { + yield { + [Symbol.dispose]() { + output.push("a disposed"); + throw "dispose error"; + } + }; + yield { + [Symbol.dispose]() { + output.push("b disposed"); + } + }; + } + + function body() { + output.push("body"); + throw "body error"; + } + + export async function main() { + output.push("before loop"); + try { + for await (using _ of g()) { + output.push("enter loop"); + body(); + output.push("exit loop"); + } + } + catch (e) { + output.push(e); + } + output.push("after loop"); + } + `, { target: ts.ScriptTarget.ES2018 }, { SuppressedError: FakeSuppressedError }); + + await main(); + + assert.deepEqual(output, [ + "before loop", + "enter loop", + "body", + "a disposed", + { + error: "dispose error", + suppressed: "body error" + }, + "after loop", + ]); + }); + + it("'using' in head of 'for-await-of', 'return' in body (es2018)", async () => { + const { main, output } = evaluator.evaluateTypeScript(` + export const output: any[] = []; + + function* g() { + yield { + [Symbol.dispose]() { + output.push("a disposed"); + } + }; + yield { + [Symbol.dispose]() { + output.push("b disposed"); + } + }; + } + + function body() { + output.push("body"); + } + + export async function main() { + output.push("before loop"); + for await (using _ of g()) { + output.push("enter loop"); + body(); + return; + } + output.push("after loop"); + } + `, { target: ts.ScriptTarget.ES2018 }); + + await main(); + + assert.deepEqual(output, [ + "before loop", + "enter loop", + "body", + "a disposed", + ]); + }); + + it("'using' in head of 'for-await-of', 'break' in body (es2018)", async () => { + const { main, output } = evaluator.evaluateTypeScript(` + export const output: any[] = []; + + function* g() { + yield { + [Symbol.dispose]() { + output.push("a disposed"); + } + }; + yield { + [Symbol.dispose]() { + output.push("b disposed"); + } + }; + } + + function body() { + output.push("body"); + } + + export async function main() { + output.push("before loop"); + for await (using _ of g()) { + output.push("enter loop"); + body(); + break; + } + output.push("after loop"); + } + `, { target: ts.ScriptTarget.ES2018 }); + + await main(); + + assert.deepEqual(output, [ + "before loop", + "enter loop", + "body", + "a disposed", + "after loop" + ]); + }); + + it("'using' in head of 'for-await-of', 'continue' in body (es2018)", async () => { + const { main, output } = evaluator.evaluateTypeScript(` + export const output: any[] = []; + + function* g() { + yield { + [Symbol.dispose]() { + output.push("a disposed"); + } + }; + yield { + [Symbol.dispose]() { + output.push("b disposed"); + } + }; + } + + function body() { + output.push("body"); + } + + export async function main() { + output.push("before loop"); + for await (using _ of g()) { + output.push("enter loop"); + body(); + continue; + } + output.push("after loop"); + } + `, { target: ts.ScriptTarget.ES2018 }); + + await main(); + + assert.deepEqual(output, [ + "before loop", + "enter loop", + "body", + "a disposed", + "enter loop", + "body", + "b disposed", + "after loop" + ]); + }); + + it("'using' at top level of module (CommonJS)", () => { + const { output, x, y } = evaluator.evaluateTypeScript(` + export const output: any[] = []; + output.push("before export x"); + export const x = 1; + output.push("before using"); + using _ = { + [Symbol.dispose]() { + output.push("disposed"); + } + }; + output.push("after using"); + export const y = 2; + output.push("after export y"); + `, { target: ts.ScriptTarget.ES2018, module: ts.ModuleKind.CommonJS }); + + assert.strictEqual(x, 1); + assert.strictEqual(y, 2); + assert.deepEqual(output, [ + "before export x", + "before using", + "after using", + "after export y", + "disposed" + ]); + }); + + it("'using' at top level of module (AMD)", () => { + const { output, x, y } = evaluator.evaluateTypeScript(` + export const output: any[] = []; + output.push("before export x"); + export const x = 1; + output.push("before using"); + using _ = { + [Symbol.dispose]() { + output.push("disposed"); + } + }; + output.push("after using"); + export const y = 2; + output.push("after export y"); + `, { target: ts.ScriptTarget.ES2018, module: ts.ModuleKind.AMD }); + + assert.strictEqual(x, 1); + assert.strictEqual(y, 2); + assert.deepEqual(output, [ + "before export x", + "before using", + "after using", + "after export y", + "disposed" + ]); + }); + + it("'using' at top level of module (System)", () => { + const { output, x, y } = evaluator.evaluateTypeScript(` + export const output: any[] = []; + output.push("before export x"); + export const x = 1; + output.push("before using"); + using _ = { + [Symbol.dispose]() { + output.push("disposed"); + } + }; + output.push("after using"); + export const y = 2; + output.push("after export y"); + `, { target: ts.ScriptTarget.ES2018, module: ts.ModuleKind.System }); + + assert.strictEqual(x, 1); + assert.strictEqual(y, 2); + assert.deepEqual(output, [ + "before export x", + "before using", + "after using", + "after export y", + "disposed" + ]); + }); + + it("'using' for 'null' value", () => { + const { main, output } = evaluator.evaluateTypeScript(` + export const output: any[] = []; + + function body() { + output.push("body"); + } + + export function main() { + output.push("before block"); + { + output.push("enter block"); + using _ = null; + body(); + output.push("exit block"); + } + output.push("after block"); + } + `, { target: ts.ScriptTarget.ES2018 }); + + main(); + + assert.deepEqual(output, [ + "before block", + "enter block", + "body", + "exit block", + "after block" + ]); + }); + + it("'using' for 'undefined' value", () => { + const { main, output } = evaluator.evaluateTypeScript(` + export const output: any[] = []; + + function body() { + output.push("body"); + } + + export function main() { + output.push("before block"); + { + output.push("enter block"); + using _ = undefined; + body(); + output.push("exit block"); + } + output.push("after block"); + } + `, { target: ts.ScriptTarget.ES2018 }); + + main(); + + assert.deepEqual(output, [ + "before block", + "enter block", + "body", + "exit block", + "after block" + ]); + }); + + it("'using' for non-disposable value", () => { + const { main, output } = evaluator.evaluateTypeScript(` + export const output: any[] = []; + + function body() { + output.push("body"); + } + + export function main() { + output.push("before block"); + { + output.push("enter block"); + using _ = {} as any; + body(); + output.push("exit block"); + } + output.push("after block"); + } + `, { target: ts.ScriptTarget.ES2018 }); + + assert.throws(main); + assert.deepEqual(output, [ + "before block", + "enter block", + ]); + }); + + it("'using' disposes in reverse order", () => { + const { main, output } = evaluator.evaluateTypeScript(` + export const output: any[] = []; + + const disposable_1 = { + [Symbol.dispose]() { + output.push("disposed 1"); + } + }; + const disposable_2 = { + [Symbol.dispose]() { + output.push("disposed 2"); + } + }; + + function body() { + output.push("body"); + } + + export function main() { + output.push("before block"); + { + output.push("enter block"); + using _ = disposable_1, __ = disposable_2; + body(); + output.push("exit block"); + } + output.push("after block"); + } + `, { target: ts.ScriptTarget.ES2018 }); + + main(); + + assert.deepEqual(output, [ + "before block", + "enter block", + "body", + "exit block", + "disposed 2", + "disposed 1", + "after block" + ]); + }); +}); diff --git a/tests/baselines/reference/amdImportNotAsPrimaryExpression.js b/tests/baselines/reference/amdImportNotAsPrimaryExpression.js index e2c5aae28ed32..c6f5699f6d1ae 100644 --- a/tests/baselines/reference/amdImportNotAsPrimaryExpression.js +++ b/tests/baselines/reference/amdImportNotAsPrimaryExpression.js @@ -36,13 +36,14 @@ define(["require", "exports"], function (require, exports) { "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.E1 = exports.C1 = void 0; - var C1 = exports.C1 = /** @class */ (function () { + var C1 = /** @class */ (function () { function C1() { this.m1 = 42; } C1.s1 = true; return C1; }()); + exports.C1 = C1; var E1; (function (E1) { E1[E1["A"] = 0] = "A"; diff --git a/tests/baselines/reference/api/tsserverlibrary.d.ts b/tests/baselines/reference/api/tsserverlibrary.d.ts index 2860761a90ee7..eff2717fe15a8 100644 --- a/tests/baselines/reference/api/tsserverlibrary.d.ts +++ b/tests/baselines/reference/api/tsserverlibrary.d.ts @@ -4257,211 +4257,212 @@ declare namespace ts { UndefinedKeyword = 157, UniqueKeyword = 158, UnknownKeyword = 159, - FromKeyword = 160, - GlobalKeyword = 161, - BigIntKeyword = 162, - OverrideKeyword = 163, - OfKeyword = 164, - QualifiedName = 165, - ComputedPropertyName = 166, - TypeParameter = 167, - Parameter = 168, - Decorator = 169, - PropertySignature = 170, - PropertyDeclaration = 171, - MethodSignature = 172, - MethodDeclaration = 173, - ClassStaticBlockDeclaration = 174, - Constructor = 175, - GetAccessor = 176, - SetAccessor = 177, - CallSignature = 178, - ConstructSignature = 179, - IndexSignature = 180, - TypePredicate = 181, - TypeReference = 182, - FunctionType = 183, - ConstructorType = 184, - TypeQuery = 185, - TypeLiteral = 186, - ArrayType = 187, - TupleType = 188, - OptionalType = 189, - RestType = 190, - UnionType = 191, - IntersectionType = 192, - ConditionalType = 193, - InferType = 194, - ParenthesizedType = 195, - ThisType = 196, - TypeOperator = 197, - IndexedAccessType = 198, - MappedType = 199, - LiteralType = 200, - NamedTupleMember = 201, - TemplateLiteralType = 202, - TemplateLiteralTypeSpan = 203, - ImportType = 204, - ObjectBindingPattern = 205, - ArrayBindingPattern = 206, - BindingElement = 207, - ArrayLiteralExpression = 208, - ObjectLiteralExpression = 209, - PropertyAccessExpression = 210, - ElementAccessExpression = 211, - CallExpression = 212, - NewExpression = 213, - TaggedTemplateExpression = 214, - TypeAssertionExpression = 215, - ParenthesizedExpression = 216, - FunctionExpression = 217, - ArrowFunction = 218, - DeleteExpression = 219, - TypeOfExpression = 220, - VoidExpression = 221, - AwaitExpression = 222, - PrefixUnaryExpression = 223, - PostfixUnaryExpression = 224, - BinaryExpression = 225, - ConditionalExpression = 226, - TemplateExpression = 227, - YieldExpression = 228, - SpreadElement = 229, - ClassExpression = 230, - OmittedExpression = 231, - ExpressionWithTypeArguments = 232, - AsExpression = 233, - NonNullExpression = 234, - MetaProperty = 235, - SyntheticExpression = 236, - SatisfiesExpression = 237, - TemplateSpan = 238, - SemicolonClassElement = 239, - Block = 240, - EmptyStatement = 241, - VariableStatement = 242, - ExpressionStatement = 243, - IfStatement = 244, - DoStatement = 245, - WhileStatement = 246, - ForStatement = 247, - ForInStatement = 248, - ForOfStatement = 249, - ContinueStatement = 250, - BreakStatement = 251, - ReturnStatement = 252, - WithStatement = 253, - SwitchStatement = 254, - LabeledStatement = 255, - ThrowStatement = 256, - TryStatement = 257, - DebuggerStatement = 258, - VariableDeclaration = 259, - VariableDeclarationList = 260, - FunctionDeclaration = 261, - ClassDeclaration = 262, - InterfaceDeclaration = 263, - TypeAliasDeclaration = 264, - EnumDeclaration = 265, - ModuleDeclaration = 266, - ModuleBlock = 267, - CaseBlock = 268, - NamespaceExportDeclaration = 269, - ImportEqualsDeclaration = 270, - ImportDeclaration = 271, - ImportClause = 272, - NamespaceImport = 273, - NamedImports = 274, - ImportSpecifier = 275, - ExportAssignment = 276, - ExportDeclaration = 277, - NamedExports = 278, - NamespaceExport = 279, - ExportSpecifier = 280, - MissingDeclaration = 281, - ExternalModuleReference = 282, - JsxElement = 283, - JsxSelfClosingElement = 284, - JsxOpeningElement = 285, - JsxClosingElement = 286, - JsxFragment = 287, - JsxOpeningFragment = 288, - JsxClosingFragment = 289, - JsxAttribute = 290, - JsxAttributes = 291, - JsxSpreadAttribute = 292, - JsxExpression = 293, - JsxNamespacedName = 294, - CaseClause = 295, - DefaultClause = 296, - HeritageClause = 297, - CatchClause = 298, - AssertClause = 299, - AssertEntry = 300, - ImportTypeAssertionContainer = 301, - PropertyAssignment = 302, - ShorthandPropertyAssignment = 303, - SpreadAssignment = 304, - EnumMember = 305, - /** @deprecated */ UnparsedPrologue = 306, - /** @deprecated */ UnparsedPrepend = 307, - /** @deprecated */ UnparsedText = 308, - /** @deprecated */ UnparsedInternalText = 309, - /** @deprecated */ UnparsedSyntheticReference = 310, - SourceFile = 311, - Bundle = 312, - /** @deprecated */ UnparsedSource = 313, - /** @deprecated */ InputFiles = 314, - JSDocTypeExpression = 315, - JSDocNameReference = 316, - JSDocMemberName = 317, - JSDocAllType = 318, - JSDocUnknownType = 319, - JSDocNullableType = 320, - JSDocNonNullableType = 321, - JSDocOptionalType = 322, - JSDocFunctionType = 323, - JSDocVariadicType = 324, - JSDocNamepathType = 325, - JSDoc = 326, + UsingKeyword = 160, + FromKeyword = 161, + GlobalKeyword = 162, + BigIntKeyword = 163, + OverrideKeyword = 164, + OfKeyword = 165, + QualifiedName = 166, + ComputedPropertyName = 167, + TypeParameter = 168, + Parameter = 169, + Decorator = 170, + PropertySignature = 171, + PropertyDeclaration = 172, + MethodSignature = 173, + MethodDeclaration = 174, + ClassStaticBlockDeclaration = 175, + Constructor = 176, + GetAccessor = 177, + SetAccessor = 178, + CallSignature = 179, + ConstructSignature = 180, + IndexSignature = 181, + TypePredicate = 182, + TypeReference = 183, + FunctionType = 184, + ConstructorType = 185, + TypeQuery = 186, + TypeLiteral = 187, + ArrayType = 188, + TupleType = 189, + OptionalType = 190, + RestType = 191, + UnionType = 192, + IntersectionType = 193, + ConditionalType = 194, + InferType = 195, + ParenthesizedType = 196, + ThisType = 197, + TypeOperator = 198, + IndexedAccessType = 199, + MappedType = 200, + LiteralType = 201, + NamedTupleMember = 202, + TemplateLiteralType = 203, + TemplateLiteralTypeSpan = 204, + ImportType = 205, + ObjectBindingPattern = 206, + ArrayBindingPattern = 207, + BindingElement = 208, + ArrayLiteralExpression = 209, + ObjectLiteralExpression = 210, + PropertyAccessExpression = 211, + ElementAccessExpression = 212, + CallExpression = 213, + NewExpression = 214, + TaggedTemplateExpression = 215, + TypeAssertionExpression = 216, + ParenthesizedExpression = 217, + FunctionExpression = 218, + ArrowFunction = 219, + DeleteExpression = 220, + TypeOfExpression = 221, + VoidExpression = 222, + AwaitExpression = 223, + PrefixUnaryExpression = 224, + PostfixUnaryExpression = 225, + BinaryExpression = 226, + ConditionalExpression = 227, + TemplateExpression = 228, + YieldExpression = 229, + SpreadElement = 230, + ClassExpression = 231, + OmittedExpression = 232, + ExpressionWithTypeArguments = 233, + AsExpression = 234, + NonNullExpression = 235, + MetaProperty = 236, + SyntheticExpression = 237, + SatisfiesExpression = 238, + TemplateSpan = 239, + SemicolonClassElement = 240, + Block = 241, + EmptyStatement = 242, + VariableStatement = 243, + ExpressionStatement = 244, + IfStatement = 245, + DoStatement = 246, + WhileStatement = 247, + ForStatement = 248, + ForInStatement = 249, + ForOfStatement = 250, + ContinueStatement = 251, + BreakStatement = 252, + ReturnStatement = 253, + WithStatement = 254, + SwitchStatement = 255, + LabeledStatement = 256, + ThrowStatement = 257, + TryStatement = 258, + DebuggerStatement = 259, + VariableDeclaration = 260, + VariableDeclarationList = 261, + FunctionDeclaration = 262, + ClassDeclaration = 263, + InterfaceDeclaration = 264, + TypeAliasDeclaration = 265, + EnumDeclaration = 266, + ModuleDeclaration = 267, + ModuleBlock = 268, + CaseBlock = 269, + NamespaceExportDeclaration = 270, + ImportEqualsDeclaration = 271, + ImportDeclaration = 272, + ImportClause = 273, + NamespaceImport = 274, + NamedImports = 275, + ImportSpecifier = 276, + ExportAssignment = 277, + ExportDeclaration = 278, + NamedExports = 279, + NamespaceExport = 280, + ExportSpecifier = 281, + MissingDeclaration = 282, + ExternalModuleReference = 283, + JsxElement = 284, + JsxSelfClosingElement = 285, + JsxOpeningElement = 286, + JsxClosingElement = 287, + JsxFragment = 288, + JsxOpeningFragment = 289, + JsxClosingFragment = 290, + JsxAttribute = 291, + JsxAttributes = 292, + JsxSpreadAttribute = 293, + JsxExpression = 294, + JsxNamespacedName = 295, + CaseClause = 296, + DefaultClause = 297, + HeritageClause = 298, + CatchClause = 299, + AssertClause = 300, + AssertEntry = 301, + ImportTypeAssertionContainer = 302, + PropertyAssignment = 303, + ShorthandPropertyAssignment = 304, + SpreadAssignment = 305, + EnumMember = 306, + /** @deprecated */ UnparsedPrologue = 307, + /** @deprecated */ UnparsedPrepend = 308, + /** @deprecated */ UnparsedText = 309, + /** @deprecated */ UnparsedInternalText = 310, + /** @deprecated */ UnparsedSyntheticReference = 311, + SourceFile = 312, + Bundle = 313, + /** @deprecated */ UnparsedSource = 314, + /** @deprecated */ InputFiles = 315, + JSDocTypeExpression = 316, + JSDocNameReference = 317, + JSDocMemberName = 318, + JSDocAllType = 319, + JSDocUnknownType = 320, + JSDocNullableType = 321, + JSDocNonNullableType = 322, + JSDocOptionalType = 323, + JSDocFunctionType = 324, + JSDocVariadicType = 325, + JSDocNamepathType = 326, + JSDoc = 327, /** @deprecated Use SyntaxKind.JSDoc */ - JSDocComment = 326, - JSDocText = 327, - JSDocTypeLiteral = 328, - JSDocSignature = 329, - JSDocLink = 330, - JSDocLinkCode = 331, - JSDocLinkPlain = 332, - JSDocTag = 333, - JSDocAugmentsTag = 334, - JSDocImplementsTag = 335, - JSDocAuthorTag = 336, - JSDocDeprecatedTag = 337, - JSDocClassTag = 338, - JSDocPublicTag = 339, - JSDocPrivateTag = 340, - JSDocProtectedTag = 341, - JSDocReadonlyTag = 342, - JSDocOverrideTag = 343, - JSDocCallbackTag = 344, - JSDocOverloadTag = 345, - JSDocEnumTag = 346, - JSDocParameterTag = 347, - JSDocReturnTag = 348, - JSDocThisTag = 349, - JSDocTypeTag = 350, - JSDocTemplateTag = 351, - JSDocTypedefTag = 352, - JSDocSeeTag = 353, - JSDocPropertyTag = 354, - JSDocThrowsTag = 355, - JSDocSatisfiesTag = 356, - SyntaxList = 357, - NotEmittedStatement = 358, - PartiallyEmittedExpression = 359, - CommaListExpression = 360, - SyntheticReferenceExpression = 361, - Count = 362, + JSDocComment = 327, + JSDocText = 328, + JSDocTypeLiteral = 329, + JSDocSignature = 330, + JSDocLink = 331, + JSDocLinkCode = 332, + JSDocLinkPlain = 333, + JSDocTag = 334, + JSDocAugmentsTag = 335, + JSDocImplementsTag = 336, + JSDocAuthorTag = 337, + JSDocDeprecatedTag = 338, + JSDocClassTag = 339, + JSDocPublicTag = 340, + JSDocPrivateTag = 341, + JSDocProtectedTag = 342, + JSDocReadonlyTag = 343, + JSDocOverrideTag = 344, + JSDocCallbackTag = 345, + JSDocOverloadTag = 346, + JSDocEnumTag = 347, + JSDocParameterTag = 348, + JSDocReturnTag = 349, + JSDocThisTag = 350, + JSDocTypeTag = 351, + JSDocTemplateTag = 352, + JSDocTypedefTag = 353, + JSDocSeeTag = 354, + JSDocPropertyTag = 355, + JSDocThrowsTag = 356, + JSDocSatisfiesTag = 357, + SyntaxList = 358, + NotEmittedStatement = 359, + PartiallyEmittedExpression = 360, + CommaListExpression = 361, + SyntheticReferenceExpression = 362, + Count = 363, FirstAssignment = 64, LastAssignment = 79, FirstCompoundAssignment = 65, @@ -4469,15 +4470,15 @@ declare namespace ts { FirstReservedWord = 83, LastReservedWord = 118, FirstKeyword = 83, - LastKeyword = 164, + LastKeyword = 165, FirstFutureReservedWord = 119, LastFutureReservedWord = 127, - FirstTypeNode = 181, - LastTypeNode = 204, + FirstTypeNode = 182, + LastTypeNode = 205, FirstPunctuation = 19, LastPunctuation = 79, FirstToken = 0, - LastToken = 164, + LastToken = 165, FirstTriviaToken = 2, LastTriviaToken = 7, FirstLiteralToken = 9, @@ -4486,19 +4487,19 @@ declare namespace ts { LastTemplateToken = 18, FirstBinaryOperator = 30, LastBinaryOperator = 79, - FirstStatement = 242, - LastStatement = 258, - FirstNode = 165, - FirstJSDocNode = 315, - LastJSDocNode = 356, - FirstJSDocTagNode = 333, - LastJSDocTagNode = 356 + FirstStatement = 243, + LastStatement = 259, + FirstNode = 166, + FirstJSDocNode = 316, + LastJSDocNode = 357, + FirstJSDocTagNode = 334, + LastJSDocTagNode = 357 } type TriviaSyntaxKind = SyntaxKind.SingleLineCommentTrivia | SyntaxKind.MultiLineCommentTrivia | SyntaxKind.NewLineTrivia | SyntaxKind.WhitespaceTrivia | SyntaxKind.ShebangTrivia | SyntaxKind.ConflictMarkerTrivia; type LiteralSyntaxKind = SyntaxKind.NumericLiteral | SyntaxKind.BigIntLiteral | SyntaxKind.StringLiteral | SyntaxKind.JsxText | SyntaxKind.JsxTextAllWhiteSpaces | SyntaxKind.RegularExpressionLiteral | SyntaxKind.NoSubstitutionTemplateLiteral; type PseudoLiteralSyntaxKind = SyntaxKind.TemplateHead | SyntaxKind.TemplateMiddle | SyntaxKind.TemplateTail; type PunctuationSyntaxKind = SyntaxKind.OpenBraceToken | SyntaxKind.CloseBraceToken | SyntaxKind.OpenParenToken | SyntaxKind.CloseParenToken | SyntaxKind.OpenBracketToken | SyntaxKind.CloseBracketToken | SyntaxKind.DotToken | SyntaxKind.DotDotDotToken | SyntaxKind.SemicolonToken | SyntaxKind.CommaToken | SyntaxKind.QuestionDotToken | SyntaxKind.LessThanToken | SyntaxKind.LessThanSlashToken | SyntaxKind.GreaterThanToken | SyntaxKind.LessThanEqualsToken | SyntaxKind.GreaterThanEqualsToken | SyntaxKind.EqualsEqualsToken | SyntaxKind.ExclamationEqualsToken | SyntaxKind.EqualsEqualsEqualsToken | SyntaxKind.ExclamationEqualsEqualsToken | SyntaxKind.EqualsGreaterThanToken | SyntaxKind.PlusToken | SyntaxKind.MinusToken | SyntaxKind.AsteriskToken | SyntaxKind.AsteriskAsteriskToken | SyntaxKind.SlashToken | SyntaxKind.PercentToken | SyntaxKind.PlusPlusToken | SyntaxKind.MinusMinusToken | SyntaxKind.LessThanLessThanToken | SyntaxKind.GreaterThanGreaterThanToken | SyntaxKind.GreaterThanGreaterThanGreaterThanToken | SyntaxKind.AmpersandToken | SyntaxKind.BarToken | SyntaxKind.CaretToken | SyntaxKind.ExclamationToken | SyntaxKind.TildeToken | SyntaxKind.AmpersandAmpersandToken | SyntaxKind.AmpersandAmpersandEqualsToken | SyntaxKind.BarBarToken | SyntaxKind.BarBarEqualsToken | SyntaxKind.QuestionQuestionToken | SyntaxKind.QuestionQuestionEqualsToken | SyntaxKind.QuestionToken | SyntaxKind.ColonToken | SyntaxKind.AtToken | SyntaxKind.BacktickToken | SyntaxKind.HashToken | SyntaxKind.EqualsToken | SyntaxKind.PlusEqualsToken | SyntaxKind.MinusEqualsToken | SyntaxKind.AsteriskEqualsToken | SyntaxKind.AsteriskAsteriskEqualsToken | SyntaxKind.SlashEqualsToken | SyntaxKind.PercentEqualsToken | SyntaxKind.LessThanLessThanEqualsToken | SyntaxKind.GreaterThanGreaterThanEqualsToken | SyntaxKind.GreaterThanGreaterThanGreaterThanEqualsToken | SyntaxKind.AmpersandEqualsToken | SyntaxKind.BarEqualsToken | SyntaxKind.CaretEqualsToken; - type KeywordSyntaxKind = SyntaxKind.AbstractKeyword | SyntaxKind.AccessorKeyword | SyntaxKind.AnyKeyword | SyntaxKind.AsKeyword | SyntaxKind.AssertsKeyword | SyntaxKind.AssertKeyword | SyntaxKind.AsyncKeyword | SyntaxKind.AwaitKeyword | SyntaxKind.BigIntKeyword | SyntaxKind.BooleanKeyword | SyntaxKind.BreakKeyword | SyntaxKind.CaseKeyword | SyntaxKind.CatchKeyword | SyntaxKind.ClassKeyword | SyntaxKind.ConstKeyword | SyntaxKind.ConstructorKeyword | SyntaxKind.ContinueKeyword | SyntaxKind.DebuggerKeyword | SyntaxKind.DeclareKeyword | SyntaxKind.DefaultKeyword | SyntaxKind.DeleteKeyword | SyntaxKind.DoKeyword | SyntaxKind.ElseKeyword | SyntaxKind.EnumKeyword | SyntaxKind.ExportKeyword | SyntaxKind.ExtendsKeyword | SyntaxKind.FalseKeyword | SyntaxKind.FinallyKeyword | SyntaxKind.ForKeyword | SyntaxKind.FromKeyword | SyntaxKind.FunctionKeyword | SyntaxKind.GetKeyword | SyntaxKind.GlobalKeyword | SyntaxKind.IfKeyword | SyntaxKind.ImplementsKeyword | SyntaxKind.ImportKeyword | SyntaxKind.InferKeyword | SyntaxKind.InKeyword | SyntaxKind.InstanceOfKeyword | SyntaxKind.InterfaceKeyword | SyntaxKind.IntrinsicKeyword | SyntaxKind.IsKeyword | SyntaxKind.KeyOfKeyword | SyntaxKind.LetKeyword | SyntaxKind.ModuleKeyword | SyntaxKind.NamespaceKeyword | SyntaxKind.NeverKeyword | SyntaxKind.NewKeyword | SyntaxKind.NullKeyword | SyntaxKind.NumberKeyword | SyntaxKind.ObjectKeyword | SyntaxKind.OfKeyword | SyntaxKind.PackageKeyword | SyntaxKind.PrivateKeyword | SyntaxKind.ProtectedKeyword | SyntaxKind.PublicKeyword | SyntaxKind.ReadonlyKeyword | SyntaxKind.OutKeyword | SyntaxKind.OverrideKeyword | SyntaxKind.RequireKeyword | SyntaxKind.ReturnKeyword | SyntaxKind.SatisfiesKeyword | SyntaxKind.SetKeyword | SyntaxKind.StaticKeyword | SyntaxKind.StringKeyword | SyntaxKind.SuperKeyword | SyntaxKind.SwitchKeyword | SyntaxKind.SymbolKeyword | SyntaxKind.ThisKeyword | SyntaxKind.ThrowKeyword | SyntaxKind.TrueKeyword | SyntaxKind.TryKeyword | SyntaxKind.TypeKeyword | SyntaxKind.TypeOfKeyword | SyntaxKind.UndefinedKeyword | SyntaxKind.UniqueKeyword | SyntaxKind.UnknownKeyword | SyntaxKind.VarKeyword | SyntaxKind.VoidKeyword | SyntaxKind.WhileKeyword | SyntaxKind.WithKeyword | SyntaxKind.YieldKeyword; + type KeywordSyntaxKind = SyntaxKind.AbstractKeyword | SyntaxKind.AccessorKeyword | SyntaxKind.AnyKeyword | SyntaxKind.AsKeyword | SyntaxKind.AssertsKeyword | SyntaxKind.AssertKeyword | SyntaxKind.AsyncKeyword | SyntaxKind.AwaitKeyword | SyntaxKind.BigIntKeyword | SyntaxKind.BooleanKeyword | SyntaxKind.BreakKeyword | SyntaxKind.CaseKeyword | SyntaxKind.CatchKeyword | SyntaxKind.ClassKeyword | SyntaxKind.ConstKeyword | SyntaxKind.ConstructorKeyword | SyntaxKind.ContinueKeyword | SyntaxKind.DebuggerKeyword | SyntaxKind.DeclareKeyword | SyntaxKind.DefaultKeyword | SyntaxKind.DeleteKeyword | SyntaxKind.DoKeyword | SyntaxKind.ElseKeyword | SyntaxKind.EnumKeyword | SyntaxKind.ExportKeyword | SyntaxKind.ExtendsKeyword | SyntaxKind.FalseKeyword | SyntaxKind.FinallyKeyword | SyntaxKind.ForKeyword | SyntaxKind.FromKeyword | SyntaxKind.FunctionKeyword | SyntaxKind.GetKeyword | SyntaxKind.GlobalKeyword | SyntaxKind.IfKeyword | SyntaxKind.ImplementsKeyword | SyntaxKind.ImportKeyword | SyntaxKind.InferKeyword | SyntaxKind.InKeyword | SyntaxKind.InstanceOfKeyword | SyntaxKind.InterfaceKeyword | SyntaxKind.IntrinsicKeyword | SyntaxKind.IsKeyword | SyntaxKind.KeyOfKeyword | SyntaxKind.LetKeyword | SyntaxKind.ModuleKeyword | SyntaxKind.NamespaceKeyword | SyntaxKind.NeverKeyword | SyntaxKind.NewKeyword | SyntaxKind.NullKeyword | SyntaxKind.NumberKeyword | SyntaxKind.ObjectKeyword | SyntaxKind.OfKeyword | SyntaxKind.PackageKeyword | SyntaxKind.PrivateKeyword | SyntaxKind.ProtectedKeyword | SyntaxKind.PublicKeyword | SyntaxKind.ReadonlyKeyword | SyntaxKind.OutKeyword | SyntaxKind.OverrideKeyword | SyntaxKind.RequireKeyword | SyntaxKind.ReturnKeyword | SyntaxKind.SatisfiesKeyword | SyntaxKind.SetKeyword | SyntaxKind.StaticKeyword | SyntaxKind.StringKeyword | SyntaxKind.SuperKeyword | SyntaxKind.SwitchKeyword | SyntaxKind.SymbolKeyword | SyntaxKind.ThisKeyword | SyntaxKind.ThrowKeyword | SyntaxKind.TrueKeyword | SyntaxKind.TryKeyword | SyntaxKind.TypeKeyword | SyntaxKind.TypeOfKeyword | SyntaxKind.UndefinedKeyword | SyntaxKind.UniqueKeyword | SyntaxKind.UnknownKeyword | SyntaxKind.UsingKeyword | SyntaxKind.VarKeyword | SyntaxKind.VoidKeyword | SyntaxKind.WhileKeyword | SyntaxKind.WithKeyword | SyntaxKind.YieldKeyword; type ModifierSyntaxKind = SyntaxKind.AbstractKeyword | SyntaxKind.AccessorKeyword | SyntaxKind.AsyncKeyword | SyntaxKind.ConstKeyword | SyntaxKind.DeclareKeyword | SyntaxKind.DefaultKeyword | SyntaxKind.ExportKeyword | SyntaxKind.InKeyword | SyntaxKind.PrivateKeyword | SyntaxKind.ProtectedKeyword | SyntaxKind.PublicKeyword | SyntaxKind.ReadonlyKeyword | SyntaxKind.OutKeyword | SyntaxKind.OverrideKeyword | SyntaxKind.StaticKeyword; type KeywordTypeSyntaxKind = SyntaxKind.AnyKeyword | SyntaxKind.BigIntKeyword | SyntaxKind.BooleanKeyword | SyntaxKind.IntrinsicKeyword | SyntaxKind.NeverKeyword | SyntaxKind.NumberKeyword | SyntaxKind.ObjectKeyword | SyntaxKind.StringKeyword | SyntaxKind.SymbolKeyword | SyntaxKind.UndefinedKeyword | SyntaxKind.UnknownKeyword | SyntaxKind.VoidKeyword; type TokenSyntaxKind = SyntaxKind.Unknown | SyntaxKind.EndOfFileToken | TriviaSyntaxKind | LiteralSyntaxKind | PseudoLiteralSyntaxKind | PunctuationSyntaxKind | SyntaxKind.Identifier | KeywordSyntaxKind; @@ -4508,32 +4509,35 @@ declare namespace ts { None = 0, Let = 1, Const = 2, - NestedNamespace = 4, - Synthesized = 8, - Namespace = 16, - OptionalChain = 32, - ExportContext = 64, - ContainsThis = 128, - HasImplicitReturn = 256, - HasExplicitReturn = 512, - GlobalAugmentation = 1024, - HasAsyncFunctions = 2048, - DisallowInContext = 4096, - YieldContext = 8192, - DecoratorContext = 16384, - AwaitContext = 32768, - DisallowConditionalTypesContext = 65536, - ThisNodeHasError = 131072, - JavaScriptFile = 262144, - ThisNodeOrAnySubNodesHasError = 524288, - HasAggregatedChildData = 1048576, - JSDoc = 8388608, - JsonFile = 67108864, - BlockScoped = 3, - ReachabilityCheckFlags = 768, - ReachabilityAndEmitFlags = 2816, - ContextFlags = 50720768, - TypeExcludesFlags = 40960 + Using = 4, + AwaitUsing = 6, + NestedNamespace = 8, + Synthesized = 16, + Namespace = 32, + OptionalChain = 64, + ExportContext = 128, + ContainsThis = 256, + HasImplicitReturn = 512, + HasExplicitReturn = 1024, + GlobalAugmentation = 2048, + HasAsyncFunctions = 4096, + DisallowInContext = 8192, + YieldContext = 16384, + DecoratorContext = 32768, + AwaitContext = 65536, + DisallowConditionalTypesContext = 131072, + ThisNodeHasError = 262144, + JavaScriptFile = 524288, + ThisNodeOrAnySubNodesHasError = 1048576, + HasAggregatedChildData = 2097152, + JSDoc = 16777216, + JsonFile = 134217728, + BlockScoped = 7, + Constant = 6, + ReachabilityCheckFlags = 1536, + ReachabilityAndEmitFlags = 5632, + ContextFlags = 101441536, + TypeExcludesFlags = 81920 } enum ModifierFlags { None = 0, @@ -7588,7 +7592,14 @@ declare namespace ts { All = 15, ExcludeJSDocTypeAssertion = 16 } - type TypeOfTag = "undefined" | "number" | "bigint" | "boolean" | "string" | "symbol" | "object" | "function"; + type ImmediatelyInvokedFunctionExpression = CallExpression & { + readonly expression: FunctionExpression; + }; + type ImmediatelyInvokedArrowFunction = CallExpression & { + readonly expression: ParenthesizedExpression & { + readonly expression: ArrowFunction; + }; + }; interface NodeFactory { createNodeArray(elements?: readonly T[], hasTrailingComma?: boolean): NodeArray; createNumericLiteral(value: string | number, numericLiteralFlags?: TokenFlags): NumericLiteral; @@ -8058,8 +8069,8 @@ declare namespace ts { createPostfixDecrement(operand: Expression): PostfixUnaryExpression; createImmediatelyInvokedFunctionExpression(statements: readonly Statement[]): CallExpression; createImmediatelyInvokedFunctionExpression(statements: readonly Statement[], param: ParameterDeclaration, paramValue: Expression): CallExpression; - createImmediatelyInvokedArrowFunction(statements: readonly Statement[]): CallExpression; - createImmediatelyInvokedArrowFunction(statements: readonly Statement[], param: ParameterDeclaration, paramValue: Expression): CallExpression; + createImmediatelyInvokedArrowFunction(statements: readonly Statement[]): ImmediatelyInvokedArrowFunction; + createImmediatelyInvokedArrowFunction(statements: readonly Statement[], param: ParameterDeclaration, paramValue: Expression): ImmediatelyInvokedArrowFunction; createVoidZero(): VoidExpression; createExportDefault(expression: Expression): ExportAssignment; createExternalModuleExport(exportName: Identifier): ExportDeclaration; diff --git a/tests/baselines/reference/api/typescript.d.ts b/tests/baselines/reference/api/typescript.d.ts index 266025222bf36..3f78e1ae29a4d 100644 --- a/tests/baselines/reference/api/typescript.d.ts +++ b/tests/baselines/reference/api/typescript.d.ts @@ -204,211 +204,212 @@ declare namespace ts { UndefinedKeyword = 157, UniqueKeyword = 158, UnknownKeyword = 159, - FromKeyword = 160, - GlobalKeyword = 161, - BigIntKeyword = 162, - OverrideKeyword = 163, - OfKeyword = 164, - QualifiedName = 165, - ComputedPropertyName = 166, - TypeParameter = 167, - Parameter = 168, - Decorator = 169, - PropertySignature = 170, - PropertyDeclaration = 171, - MethodSignature = 172, - MethodDeclaration = 173, - ClassStaticBlockDeclaration = 174, - Constructor = 175, - GetAccessor = 176, - SetAccessor = 177, - CallSignature = 178, - ConstructSignature = 179, - IndexSignature = 180, - TypePredicate = 181, - TypeReference = 182, - FunctionType = 183, - ConstructorType = 184, - TypeQuery = 185, - TypeLiteral = 186, - ArrayType = 187, - TupleType = 188, - OptionalType = 189, - RestType = 190, - UnionType = 191, - IntersectionType = 192, - ConditionalType = 193, - InferType = 194, - ParenthesizedType = 195, - ThisType = 196, - TypeOperator = 197, - IndexedAccessType = 198, - MappedType = 199, - LiteralType = 200, - NamedTupleMember = 201, - TemplateLiteralType = 202, - TemplateLiteralTypeSpan = 203, - ImportType = 204, - ObjectBindingPattern = 205, - ArrayBindingPattern = 206, - BindingElement = 207, - ArrayLiteralExpression = 208, - ObjectLiteralExpression = 209, - PropertyAccessExpression = 210, - ElementAccessExpression = 211, - CallExpression = 212, - NewExpression = 213, - TaggedTemplateExpression = 214, - TypeAssertionExpression = 215, - ParenthesizedExpression = 216, - FunctionExpression = 217, - ArrowFunction = 218, - DeleteExpression = 219, - TypeOfExpression = 220, - VoidExpression = 221, - AwaitExpression = 222, - PrefixUnaryExpression = 223, - PostfixUnaryExpression = 224, - BinaryExpression = 225, - ConditionalExpression = 226, - TemplateExpression = 227, - YieldExpression = 228, - SpreadElement = 229, - ClassExpression = 230, - OmittedExpression = 231, - ExpressionWithTypeArguments = 232, - AsExpression = 233, - NonNullExpression = 234, - MetaProperty = 235, - SyntheticExpression = 236, - SatisfiesExpression = 237, - TemplateSpan = 238, - SemicolonClassElement = 239, - Block = 240, - EmptyStatement = 241, - VariableStatement = 242, - ExpressionStatement = 243, - IfStatement = 244, - DoStatement = 245, - WhileStatement = 246, - ForStatement = 247, - ForInStatement = 248, - ForOfStatement = 249, - ContinueStatement = 250, - BreakStatement = 251, - ReturnStatement = 252, - WithStatement = 253, - SwitchStatement = 254, - LabeledStatement = 255, - ThrowStatement = 256, - TryStatement = 257, - DebuggerStatement = 258, - VariableDeclaration = 259, - VariableDeclarationList = 260, - FunctionDeclaration = 261, - ClassDeclaration = 262, - InterfaceDeclaration = 263, - TypeAliasDeclaration = 264, - EnumDeclaration = 265, - ModuleDeclaration = 266, - ModuleBlock = 267, - CaseBlock = 268, - NamespaceExportDeclaration = 269, - ImportEqualsDeclaration = 270, - ImportDeclaration = 271, - ImportClause = 272, - NamespaceImport = 273, - NamedImports = 274, - ImportSpecifier = 275, - ExportAssignment = 276, - ExportDeclaration = 277, - NamedExports = 278, - NamespaceExport = 279, - ExportSpecifier = 280, - MissingDeclaration = 281, - ExternalModuleReference = 282, - JsxElement = 283, - JsxSelfClosingElement = 284, - JsxOpeningElement = 285, - JsxClosingElement = 286, - JsxFragment = 287, - JsxOpeningFragment = 288, - JsxClosingFragment = 289, - JsxAttribute = 290, - JsxAttributes = 291, - JsxSpreadAttribute = 292, - JsxExpression = 293, - JsxNamespacedName = 294, - CaseClause = 295, - DefaultClause = 296, - HeritageClause = 297, - CatchClause = 298, - AssertClause = 299, - AssertEntry = 300, - ImportTypeAssertionContainer = 301, - PropertyAssignment = 302, - ShorthandPropertyAssignment = 303, - SpreadAssignment = 304, - EnumMember = 305, - /** @deprecated */ UnparsedPrologue = 306, - /** @deprecated */ UnparsedPrepend = 307, - /** @deprecated */ UnparsedText = 308, - /** @deprecated */ UnparsedInternalText = 309, - /** @deprecated */ UnparsedSyntheticReference = 310, - SourceFile = 311, - Bundle = 312, - /** @deprecated */ UnparsedSource = 313, - /** @deprecated */ InputFiles = 314, - JSDocTypeExpression = 315, - JSDocNameReference = 316, - JSDocMemberName = 317, - JSDocAllType = 318, - JSDocUnknownType = 319, - JSDocNullableType = 320, - JSDocNonNullableType = 321, - JSDocOptionalType = 322, - JSDocFunctionType = 323, - JSDocVariadicType = 324, - JSDocNamepathType = 325, - JSDoc = 326, + UsingKeyword = 160, + FromKeyword = 161, + GlobalKeyword = 162, + BigIntKeyword = 163, + OverrideKeyword = 164, + OfKeyword = 165, + QualifiedName = 166, + ComputedPropertyName = 167, + TypeParameter = 168, + Parameter = 169, + Decorator = 170, + PropertySignature = 171, + PropertyDeclaration = 172, + MethodSignature = 173, + MethodDeclaration = 174, + ClassStaticBlockDeclaration = 175, + Constructor = 176, + GetAccessor = 177, + SetAccessor = 178, + CallSignature = 179, + ConstructSignature = 180, + IndexSignature = 181, + TypePredicate = 182, + TypeReference = 183, + FunctionType = 184, + ConstructorType = 185, + TypeQuery = 186, + TypeLiteral = 187, + ArrayType = 188, + TupleType = 189, + OptionalType = 190, + RestType = 191, + UnionType = 192, + IntersectionType = 193, + ConditionalType = 194, + InferType = 195, + ParenthesizedType = 196, + ThisType = 197, + TypeOperator = 198, + IndexedAccessType = 199, + MappedType = 200, + LiteralType = 201, + NamedTupleMember = 202, + TemplateLiteralType = 203, + TemplateLiteralTypeSpan = 204, + ImportType = 205, + ObjectBindingPattern = 206, + ArrayBindingPattern = 207, + BindingElement = 208, + ArrayLiteralExpression = 209, + ObjectLiteralExpression = 210, + PropertyAccessExpression = 211, + ElementAccessExpression = 212, + CallExpression = 213, + NewExpression = 214, + TaggedTemplateExpression = 215, + TypeAssertionExpression = 216, + ParenthesizedExpression = 217, + FunctionExpression = 218, + ArrowFunction = 219, + DeleteExpression = 220, + TypeOfExpression = 221, + VoidExpression = 222, + AwaitExpression = 223, + PrefixUnaryExpression = 224, + PostfixUnaryExpression = 225, + BinaryExpression = 226, + ConditionalExpression = 227, + TemplateExpression = 228, + YieldExpression = 229, + SpreadElement = 230, + ClassExpression = 231, + OmittedExpression = 232, + ExpressionWithTypeArguments = 233, + AsExpression = 234, + NonNullExpression = 235, + MetaProperty = 236, + SyntheticExpression = 237, + SatisfiesExpression = 238, + TemplateSpan = 239, + SemicolonClassElement = 240, + Block = 241, + EmptyStatement = 242, + VariableStatement = 243, + ExpressionStatement = 244, + IfStatement = 245, + DoStatement = 246, + WhileStatement = 247, + ForStatement = 248, + ForInStatement = 249, + ForOfStatement = 250, + ContinueStatement = 251, + BreakStatement = 252, + ReturnStatement = 253, + WithStatement = 254, + SwitchStatement = 255, + LabeledStatement = 256, + ThrowStatement = 257, + TryStatement = 258, + DebuggerStatement = 259, + VariableDeclaration = 260, + VariableDeclarationList = 261, + FunctionDeclaration = 262, + ClassDeclaration = 263, + InterfaceDeclaration = 264, + TypeAliasDeclaration = 265, + EnumDeclaration = 266, + ModuleDeclaration = 267, + ModuleBlock = 268, + CaseBlock = 269, + NamespaceExportDeclaration = 270, + ImportEqualsDeclaration = 271, + ImportDeclaration = 272, + ImportClause = 273, + NamespaceImport = 274, + NamedImports = 275, + ImportSpecifier = 276, + ExportAssignment = 277, + ExportDeclaration = 278, + NamedExports = 279, + NamespaceExport = 280, + ExportSpecifier = 281, + MissingDeclaration = 282, + ExternalModuleReference = 283, + JsxElement = 284, + JsxSelfClosingElement = 285, + JsxOpeningElement = 286, + JsxClosingElement = 287, + JsxFragment = 288, + JsxOpeningFragment = 289, + JsxClosingFragment = 290, + JsxAttribute = 291, + JsxAttributes = 292, + JsxSpreadAttribute = 293, + JsxExpression = 294, + JsxNamespacedName = 295, + CaseClause = 296, + DefaultClause = 297, + HeritageClause = 298, + CatchClause = 299, + AssertClause = 300, + AssertEntry = 301, + ImportTypeAssertionContainer = 302, + PropertyAssignment = 303, + ShorthandPropertyAssignment = 304, + SpreadAssignment = 305, + EnumMember = 306, + /** @deprecated */ UnparsedPrologue = 307, + /** @deprecated */ UnparsedPrepend = 308, + /** @deprecated */ UnparsedText = 309, + /** @deprecated */ UnparsedInternalText = 310, + /** @deprecated */ UnparsedSyntheticReference = 311, + SourceFile = 312, + Bundle = 313, + /** @deprecated */ UnparsedSource = 314, + /** @deprecated */ InputFiles = 315, + JSDocTypeExpression = 316, + JSDocNameReference = 317, + JSDocMemberName = 318, + JSDocAllType = 319, + JSDocUnknownType = 320, + JSDocNullableType = 321, + JSDocNonNullableType = 322, + JSDocOptionalType = 323, + JSDocFunctionType = 324, + JSDocVariadicType = 325, + JSDocNamepathType = 326, + JSDoc = 327, /** @deprecated Use SyntaxKind.JSDoc */ - JSDocComment = 326, - JSDocText = 327, - JSDocTypeLiteral = 328, - JSDocSignature = 329, - JSDocLink = 330, - JSDocLinkCode = 331, - JSDocLinkPlain = 332, - JSDocTag = 333, - JSDocAugmentsTag = 334, - JSDocImplementsTag = 335, - JSDocAuthorTag = 336, - JSDocDeprecatedTag = 337, - JSDocClassTag = 338, - JSDocPublicTag = 339, - JSDocPrivateTag = 340, - JSDocProtectedTag = 341, - JSDocReadonlyTag = 342, - JSDocOverrideTag = 343, - JSDocCallbackTag = 344, - JSDocOverloadTag = 345, - JSDocEnumTag = 346, - JSDocParameterTag = 347, - JSDocReturnTag = 348, - JSDocThisTag = 349, - JSDocTypeTag = 350, - JSDocTemplateTag = 351, - JSDocTypedefTag = 352, - JSDocSeeTag = 353, - JSDocPropertyTag = 354, - JSDocThrowsTag = 355, - JSDocSatisfiesTag = 356, - SyntaxList = 357, - NotEmittedStatement = 358, - PartiallyEmittedExpression = 359, - CommaListExpression = 360, - SyntheticReferenceExpression = 361, - Count = 362, + JSDocComment = 327, + JSDocText = 328, + JSDocTypeLiteral = 329, + JSDocSignature = 330, + JSDocLink = 331, + JSDocLinkCode = 332, + JSDocLinkPlain = 333, + JSDocTag = 334, + JSDocAugmentsTag = 335, + JSDocImplementsTag = 336, + JSDocAuthorTag = 337, + JSDocDeprecatedTag = 338, + JSDocClassTag = 339, + JSDocPublicTag = 340, + JSDocPrivateTag = 341, + JSDocProtectedTag = 342, + JSDocReadonlyTag = 343, + JSDocOverrideTag = 344, + JSDocCallbackTag = 345, + JSDocOverloadTag = 346, + JSDocEnumTag = 347, + JSDocParameterTag = 348, + JSDocReturnTag = 349, + JSDocThisTag = 350, + JSDocTypeTag = 351, + JSDocTemplateTag = 352, + JSDocTypedefTag = 353, + JSDocSeeTag = 354, + JSDocPropertyTag = 355, + JSDocThrowsTag = 356, + JSDocSatisfiesTag = 357, + SyntaxList = 358, + NotEmittedStatement = 359, + PartiallyEmittedExpression = 360, + CommaListExpression = 361, + SyntheticReferenceExpression = 362, + Count = 363, FirstAssignment = 64, LastAssignment = 79, FirstCompoundAssignment = 65, @@ -416,15 +417,15 @@ declare namespace ts { FirstReservedWord = 83, LastReservedWord = 118, FirstKeyword = 83, - LastKeyword = 164, + LastKeyword = 165, FirstFutureReservedWord = 119, LastFutureReservedWord = 127, - FirstTypeNode = 181, - LastTypeNode = 204, + FirstTypeNode = 182, + LastTypeNode = 205, FirstPunctuation = 19, LastPunctuation = 79, FirstToken = 0, - LastToken = 164, + LastToken = 165, FirstTriviaToken = 2, LastTriviaToken = 7, FirstLiteralToken = 9, @@ -433,19 +434,19 @@ declare namespace ts { LastTemplateToken = 18, FirstBinaryOperator = 30, LastBinaryOperator = 79, - FirstStatement = 242, - LastStatement = 258, - FirstNode = 165, - FirstJSDocNode = 315, - LastJSDocNode = 356, - FirstJSDocTagNode = 333, - LastJSDocTagNode = 356 + FirstStatement = 243, + LastStatement = 259, + FirstNode = 166, + FirstJSDocNode = 316, + LastJSDocNode = 357, + FirstJSDocTagNode = 334, + LastJSDocTagNode = 357 } type TriviaSyntaxKind = SyntaxKind.SingleLineCommentTrivia | SyntaxKind.MultiLineCommentTrivia | SyntaxKind.NewLineTrivia | SyntaxKind.WhitespaceTrivia | SyntaxKind.ShebangTrivia | SyntaxKind.ConflictMarkerTrivia; type LiteralSyntaxKind = SyntaxKind.NumericLiteral | SyntaxKind.BigIntLiteral | SyntaxKind.StringLiteral | SyntaxKind.JsxText | SyntaxKind.JsxTextAllWhiteSpaces | SyntaxKind.RegularExpressionLiteral | SyntaxKind.NoSubstitutionTemplateLiteral; type PseudoLiteralSyntaxKind = SyntaxKind.TemplateHead | SyntaxKind.TemplateMiddle | SyntaxKind.TemplateTail; type PunctuationSyntaxKind = SyntaxKind.OpenBraceToken | SyntaxKind.CloseBraceToken | SyntaxKind.OpenParenToken | SyntaxKind.CloseParenToken | SyntaxKind.OpenBracketToken | SyntaxKind.CloseBracketToken | SyntaxKind.DotToken | SyntaxKind.DotDotDotToken | SyntaxKind.SemicolonToken | SyntaxKind.CommaToken | SyntaxKind.QuestionDotToken | SyntaxKind.LessThanToken | SyntaxKind.LessThanSlashToken | SyntaxKind.GreaterThanToken | SyntaxKind.LessThanEqualsToken | SyntaxKind.GreaterThanEqualsToken | SyntaxKind.EqualsEqualsToken | SyntaxKind.ExclamationEqualsToken | SyntaxKind.EqualsEqualsEqualsToken | SyntaxKind.ExclamationEqualsEqualsToken | SyntaxKind.EqualsGreaterThanToken | SyntaxKind.PlusToken | SyntaxKind.MinusToken | SyntaxKind.AsteriskToken | SyntaxKind.AsteriskAsteriskToken | SyntaxKind.SlashToken | SyntaxKind.PercentToken | SyntaxKind.PlusPlusToken | SyntaxKind.MinusMinusToken | SyntaxKind.LessThanLessThanToken | SyntaxKind.GreaterThanGreaterThanToken | SyntaxKind.GreaterThanGreaterThanGreaterThanToken | SyntaxKind.AmpersandToken | SyntaxKind.BarToken | SyntaxKind.CaretToken | SyntaxKind.ExclamationToken | SyntaxKind.TildeToken | SyntaxKind.AmpersandAmpersandToken | SyntaxKind.AmpersandAmpersandEqualsToken | SyntaxKind.BarBarToken | SyntaxKind.BarBarEqualsToken | SyntaxKind.QuestionQuestionToken | SyntaxKind.QuestionQuestionEqualsToken | SyntaxKind.QuestionToken | SyntaxKind.ColonToken | SyntaxKind.AtToken | SyntaxKind.BacktickToken | SyntaxKind.HashToken | SyntaxKind.EqualsToken | SyntaxKind.PlusEqualsToken | SyntaxKind.MinusEqualsToken | SyntaxKind.AsteriskEqualsToken | SyntaxKind.AsteriskAsteriskEqualsToken | SyntaxKind.SlashEqualsToken | SyntaxKind.PercentEqualsToken | SyntaxKind.LessThanLessThanEqualsToken | SyntaxKind.GreaterThanGreaterThanEqualsToken | SyntaxKind.GreaterThanGreaterThanGreaterThanEqualsToken | SyntaxKind.AmpersandEqualsToken | SyntaxKind.BarEqualsToken | SyntaxKind.CaretEqualsToken; - type KeywordSyntaxKind = SyntaxKind.AbstractKeyword | SyntaxKind.AccessorKeyword | SyntaxKind.AnyKeyword | SyntaxKind.AsKeyword | SyntaxKind.AssertsKeyword | SyntaxKind.AssertKeyword | SyntaxKind.AsyncKeyword | SyntaxKind.AwaitKeyword | SyntaxKind.BigIntKeyword | SyntaxKind.BooleanKeyword | SyntaxKind.BreakKeyword | SyntaxKind.CaseKeyword | SyntaxKind.CatchKeyword | SyntaxKind.ClassKeyword | SyntaxKind.ConstKeyword | SyntaxKind.ConstructorKeyword | SyntaxKind.ContinueKeyword | SyntaxKind.DebuggerKeyword | SyntaxKind.DeclareKeyword | SyntaxKind.DefaultKeyword | SyntaxKind.DeleteKeyword | SyntaxKind.DoKeyword | SyntaxKind.ElseKeyword | SyntaxKind.EnumKeyword | SyntaxKind.ExportKeyword | SyntaxKind.ExtendsKeyword | SyntaxKind.FalseKeyword | SyntaxKind.FinallyKeyword | SyntaxKind.ForKeyword | SyntaxKind.FromKeyword | SyntaxKind.FunctionKeyword | SyntaxKind.GetKeyword | SyntaxKind.GlobalKeyword | SyntaxKind.IfKeyword | SyntaxKind.ImplementsKeyword | SyntaxKind.ImportKeyword | SyntaxKind.InferKeyword | SyntaxKind.InKeyword | SyntaxKind.InstanceOfKeyword | SyntaxKind.InterfaceKeyword | SyntaxKind.IntrinsicKeyword | SyntaxKind.IsKeyword | SyntaxKind.KeyOfKeyword | SyntaxKind.LetKeyword | SyntaxKind.ModuleKeyword | SyntaxKind.NamespaceKeyword | SyntaxKind.NeverKeyword | SyntaxKind.NewKeyword | SyntaxKind.NullKeyword | SyntaxKind.NumberKeyword | SyntaxKind.ObjectKeyword | SyntaxKind.OfKeyword | SyntaxKind.PackageKeyword | SyntaxKind.PrivateKeyword | SyntaxKind.ProtectedKeyword | SyntaxKind.PublicKeyword | SyntaxKind.ReadonlyKeyword | SyntaxKind.OutKeyword | SyntaxKind.OverrideKeyword | SyntaxKind.RequireKeyword | SyntaxKind.ReturnKeyword | SyntaxKind.SatisfiesKeyword | SyntaxKind.SetKeyword | SyntaxKind.StaticKeyword | SyntaxKind.StringKeyword | SyntaxKind.SuperKeyword | SyntaxKind.SwitchKeyword | SyntaxKind.SymbolKeyword | SyntaxKind.ThisKeyword | SyntaxKind.ThrowKeyword | SyntaxKind.TrueKeyword | SyntaxKind.TryKeyword | SyntaxKind.TypeKeyword | SyntaxKind.TypeOfKeyword | SyntaxKind.UndefinedKeyword | SyntaxKind.UniqueKeyword | SyntaxKind.UnknownKeyword | SyntaxKind.VarKeyword | SyntaxKind.VoidKeyword | SyntaxKind.WhileKeyword | SyntaxKind.WithKeyword | SyntaxKind.YieldKeyword; + type KeywordSyntaxKind = SyntaxKind.AbstractKeyword | SyntaxKind.AccessorKeyword | SyntaxKind.AnyKeyword | SyntaxKind.AsKeyword | SyntaxKind.AssertsKeyword | SyntaxKind.AssertKeyword | SyntaxKind.AsyncKeyword | SyntaxKind.AwaitKeyword | SyntaxKind.BigIntKeyword | SyntaxKind.BooleanKeyword | SyntaxKind.BreakKeyword | SyntaxKind.CaseKeyword | SyntaxKind.CatchKeyword | SyntaxKind.ClassKeyword | SyntaxKind.ConstKeyword | SyntaxKind.ConstructorKeyword | SyntaxKind.ContinueKeyword | SyntaxKind.DebuggerKeyword | SyntaxKind.DeclareKeyword | SyntaxKind.DefaultKeyword | SyntaxKind.DeleteKeyword | SyntaxKind.DoKeyword | SyntaxKind.ElseKeyword | SyntaxKind.EnumKeyword | SyntaxKind.ExportKeyword | SyntaxKind.ExtendsKeyword | SyntaxKind.FalseKeyword | SyntaxKind.FinallyKeyword | SyntaxKind.ForKeyword | SyntaxKind.FromKeyword | SyntaxKind.FunctionKeyword | SyntaxKind.GetKeyword | SyntaxKind.GlobalKeyword | SyntaxKind.IfKeyword | SyntaxKind.ImplementsKeyword | SyntaxKind.ImportKeyword | SyntaxKind.InferKeyword | SyntaxKind.InKeyword | SyntaxKind.InstanceOfKeyword | SyntaxKind.InterfaceKeyword | SyntaxKind.IntrinsicKeyword | SyntaxKind.IsKeyword | SyntaxKind.KeyOfKeyword | SyntaxKind.LetKeyword | SyntaxKind.ModuleKeyword | SyntaxKind.NamespaceKeyword | SyntaxKind.NeverKeyword | SyntaxKind.NewKeyword | SyntaxKind.NullKeyword | SyntaxKind.NumberKeyword | SyntaxKind.ObjectKeyword | SyntaxKind.OfKeyword | SyntaxKind.PackageKeyword | SyntaxKind.PrivateKeyword | SyntaxKind.ProtectedKeyword | SyntaxKind.PublicKeyword | SyntaxKind.ReadonlyKeyword | SyntaxKind.OutKeyword | SyntaxKind.OverrideKeyword | SyntaxKind.RequireKeyword | SyntaxKind.ReturnKeyword | SyntaxKind.SatisfiesKeyword | SyntaxKind.SetKeyword | SyntaxKind.StaticKeyword | SyntaxKind.StringKeyword | SyntaxKind.SuperKeyword | SyntaxKind.SwitchKeyword | SyntaxKind.SymbolKeyword | SyntaxKind.ThisKeyword | SyntaxKind.ThrowKeyword | SyntaxKind.TrueKeyword | SyntaxKind.TryKeyword | SyntaxKind.TypeKeyword | SyntaxKind.TypeOfKeyword | SyntaxKind.UndefinedKeyword | SyntaxKind.UniqueKeyword | SyntaxKind.UnknownKeyword | SyntaxKind.UsingKeyword | SyntaxKind.VarKeyword | SyntaxKind.VoidKeyword | SyntaxKind.WhileKeyword | SyntaxKind.WithKeyword | SyntaxKind.YieldKeyword; type ModifierSyntaxKind = SyntaxKind.AbstractKeyword | SyntaxKind.AccessorKeyword | SyntaxKind.AsyncKeyword | SyntaxKind.ConstKeyword | SyntaxKind.DeclareKeyword | SyntaxKind.DefaultKeyword | SyntaxKind.ExportKeyword | SyntaxKind.InKeyword | SyntaxKind.PrivateKeyword | SyntaxKind.ProtectedKeyword | SyntaxKind.PublicKeyword | SyntaxKind.ReadonlyKeyword | SyntaxKind.OutKeyword | SyntaxKind.OverrideKeyword | SyntaxKind.StaticKeyword; type KeywordTypeSyntaxKind = SyntaxKind.AnyKeyword | SyntaxKind.BigIntKeyword | SyntaxKind.BooleanKeyword | SyntaxKind.IntrinsicKeyword | SyntaxKind.NeverKeyword | SyntaxKind.NumberKeyword | SyntaxKind.ObjectKeyword | SyntaxKind.StringKeyword | SyntaxKind.SymbolKeyword | SyntaxKind.UndefinedKeyword | SyntaxKind.UnknownKeyword | SyntaxKind.VoidKeyword; type TokenSyntaxKind = SyntaxKind.Unknown | SyntaxKind.EndOfFileToken | TriviaSyntaxKind | LiteralSyntaxKind | PseudoLiteralSyntaxKind | PunctuationSyntaxKind | SyntaxKind.Identifier | KeywordSyntaxKind; @@ -455,32 +456,35 @@ declare namespace ts { None = 0, Let = 1, Const = 2, - NestedNamespace = 4, - Synthesized = 8, - Namespace = 16, - OptionalChain = 32, - ExportContext = 64, - ContainsThis = 128, - HasImplicitReturn = 256, - HasExplicitReturn = 512, - GlobalAugmentation = 1024, - HasAsyncFunctions = 2048, - DisallowInContext = 4096, - YieldContext = 8192, - DecoratorContext = 16384, - AwaitContext = 32768, - DisallowConditionalTypesContext = 65536, - ThisNodeHasError = 131072, - JavaScriptFile = 262144, - ThisNodeOrAnySubNodesHasError = 524288, - HasAggregatedChildData = 1048576, - JSDoc = 8388608, - JsonFile = 67108864, - BlockScoped = 3, - ReachabilityCheckFlags = 768, - ReachabilityAndEmitFlags = 2816, - ContextFlags = 50720768, - TypeExcludesFlags = 40960 + Using = 4, + AwaitUsing = 6, + NestedNamespace = 8, + Synthesized = 16, + Namespace = 32, + OptionalChain = 64, + ExportContext = 128, + ContainsThis = 256, + HasImplicitReturn = 512, + HasExplicitReturn = 1024, + GlobalAugmentation = 2048, + HasAsyncFunctions = 4096, + DisallowInContext = 8192, + YieldContext = 16384, + DecoratorContext = 32768, + AwaitContext = 65536, + DisallowConditionalTypesContext = 131072, + ThisNodeHasError = 262144, + JavaScriptFile = 524288, + ThisNodeOrAnySubNodesHasError = 1048576, + HasAggregatedChildData = 2097152, + JSDoc = 16777216, + JsonFile = 134217728, + BlockScoped = 7, + Constant = 6, + ReachabilityCheckFlags = 1536, + ReachabilityAndEmitFlags = 5632, + ContextFlags = 101441536, + TypeExcludesFlags = 81920 } enum ModifierFlags { None = 0, @@ -3535,7 +3539,14 @@ declare namespace ts { All = 15, ExcludeJSDocTypeAssertion = 16 } - type TypeOfTag = "undefined" | "number" | "bigint" | "boolean" | "string" | "symbol" | "object" | "function"; + type ImmediatelyInvokedFunctionExpression = CallExpression & { + readonly expression: FunctionExpression; + }; + type ImmediatelyInvokedArrowFunction = CallExpression & { + readonly expression: ParenthesizedExpression & { + readonly expression: ArrowFunction; + }; + }; interface NodeFactory { createNodeArray(elements?: readonly T[], hasTrailingComma?: boolean): NodeArray; createNumericLiteral(value: string | number, numericLiteralFlags?: TokenFlags): NumericLiteral; @@ -4005,8 +4016,8 @@ declare namespace ts { createPostfixDecrement(operand: Expression): PostfixUnaryExpression; createImmediatelyInvokedFunctionExpression(statements: readonly Statement[]): CallExpression; createImmediatelyInvokedFunctionExpression(statements: readonly Statement[], param: ParameterDeclaration, paramValue: Expression): CallExpression; - createImmediatelyInvokedArrowFunction(statements: readonly Statement[]): CallExpression; - createImmediatelyInvokedArrowFunction(statements: readonly Statement[], param: ParameterDeclaration, paramValue: Expression): CallExpression; + createImmediatelyInvokedArrowFunction(statements: readonly Statement[]): ImmediatelyInvokedArrowFunction; + createImmediatelyInvokedArrowFunction(statements: readonly Statement[], param: ParameterDeclaration, paramValue: Expression): ImmediatelyInvokedArrowFunction; createVoidZero(): VoidExpression; createExportDefault(expression: Expression): ExportAssignment; createExternalModuleExport(exportName: Identifier): ExportDeclaration; diff --git a/tests/baselines/reference/awaitUsingDeclarations.1(target=es2015).errors.txt b/tests/baselines/reference/awaitUsingDeclarations.1(target=es2015).errors.txt new file mode 100644 index 0000000000000..52470b2456f61 --- /dev/null +++ b/tests/baselines/reference/awaitUsingDeclarations.1(target=es2015).errors.txt @@ -0,0 +1,145 @@ +awaitUsingDeclarations.1.ts(1,1): error TS2854: Top-level 'await using' statements are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', 'node16', or 'nodenext', and the 'target' option is set to 'es2017' or higher. +awaitUsingDeclarations.1.ts(36,5): error TS2854: Top-level 'await using' statements are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', 'node16', or 'nodenext', and the 'target' option is set to 'es2017' or higher. +awaitUsingDeclarations.1.ts(41,9): error TS2854: Top-level 'await using' statements are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', 'node16', or 'nodenext', and the 'target' option is set to 'es2017' or higher. +awaitUsingDeclarations.1.ts(45,9): error TS2854: Top-level 'await using' statements are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', 'node16', or 'nodenext', and the 'target' option is set to 'es2017' or higher. +awaitUsingDeclarations.1.ts(52,13): error TS2854: Top-level 'await using' statements are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', 'node16', or 'nodenext', and the 'target' option is set to 'es2017' or higher. +awaitUsingDeclarations.1.ts(57,5): error TS2854: Top-level 'await using' statements are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', 'node16', or 'nodenext', and the 'target' option is set to 'es2017' or higher. +awaitUsingDeclarations.1.ts(60,5): error TS2854: Top-level 'await using' statements are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', 'node16', or 'nodenext', and the 'target' option is set to 'es2017' or higher. +awaitUsingDeclarations.1.ts(63,5): error TS2854: Top-level 'await using' statements are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', 'node16', or 'nodenext', and the 'target' option is set to 'es2017' or higher. +awaitUsingDeclarations.1.ts(67,5): error TS2854: Top-level 'await using' statements are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', 'node16', or 'nodenext', and the 'target' option is set to 'es2017' or higher. +awaitUsingDeclarations.1.ts(70,5): error TS2854: Top-level 'await using' statements are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', 'node16', or 'nodenext', and the 'target' option is set to 'es2017' or higher. +awaitUsingDeclarations.1.ts(74,5): error TS2854: Top-level 'await using' statements are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', 'node16', or 'nodenext', and the 'target' option is set to 'es2017' or higher. +awaitUsingDeclarations.1.ts(79,5): error TS2854: Top-level 'await using' statements are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', 'node16', or 'nodenext', and the 'target' option is set to 'es2017' or higher. +awaitUsingDeclarations.1.ts(85,5): error TS2854: Top-level 'await using' statements are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', 'node16', or 'nodenext', and the 'target' option is set to 'es2017' or higher. +awaitUsingDeclarations.1.ts(90,5): error TS2854: Top-level 'await using' statements are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', 'node16', or 'nodenext', and the 'target' option is set to 'es2017' or higher. +awaitUsingDeclarations.1.ts(94,5): error TS2854: Top-level 'await using' statements are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', 'node16', or 'nodenext', and the 'target' option is set to 'es2017' or higher. + + +==== awaitUsingDeclarations.1.ts (15 errors) ==== + await using d1 = { async [Symbol.asyncDispose]() {} }; + ~~~~~ +!!! error TS2854: Top-level 'await using' statements are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', 'node16', or 'nodenext', and the 'target' option is set to 'es2017' or higher. + + async function af() { + await using d3 = { async [Symbol.asyncDispose]() {} }; + await null; + } + + async function * ag() { + await using d5 = { async [Symbol.asyncDispose]() {} }; + yield; + await null; + } + + const a = async () => { + await using d6 = { async [Symbol.asyncDispose]() {} }; + }; + + class C1 { + a = async () => { + await using d7 = { async [Symbol.asyncDispose]() {} }; + }; + + async am() { + await using d13 = { async [Symbol.asyncDispose]() {} }; + await null; + } + + async * ag() { + await using d15 = { async [Symbol.asyncDispose]() {} }; + yield; + await null; + } + } + + { + await using d19 = { async [Symbol.asyncDispose]() {} }; + ~~~~~ +!!! error TS2854: Top-level 'await using' statements are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', 'node16', or 'nodenext', and the 'target' option is set to 'es2017' or higher. + } + + switch (Math.random()) { + case 0: + await using d20 = { async [Symbol.asyncDispose]() {} }; + ~~~~~ +!!! error TS2854: Top-level 'await using' statements are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', 'node16', or 'nodenext', and the 'target' option is set to 'es2017' or higher. + break; + + case 1: + await using d21 = { async [Symbol.asyncDispose]() {} }; + ~~~~~ +!!! error TS2854: Top-level 'await using' statements are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', 'node16', or 'nodenext', and the 'target' option is set to 'es2017' or higher. + break; + } + + if (true) + switch (0) { + case 0: + await using d22 = { async [Symbol.asyncDispose]() {} }; + ~~~~~ +!!! error TS2854: Top-level 'await using' statements are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', 'node16', or 'nodenext', and the 'target' option is set to 'es2017' or higher. + break; + } + + try { + await using d23 = { async [Symbol.asyncDispose]() {} }; + ~~~~~ +!!! error TS2854: Top-level 'await using' statements are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', 'node16', or 'nodenext', and the 'target' option is set to 'es2017' or higher. + } + catch { + await using d24 = { async [Symbol.asyncDispose]() {} }; + ~~~~~ +!!! error TS2854: Top-level 'await using' statements are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', 'node16', or 'nodenext', and the 'target' option is set to 'es2017' or higher. + } + finally { + await using d25 = { async [Symbol.asyncDispose]() {} }; + ~~~~~ +!!! error TS2854: Top-level 'await using' statements are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', 'node16', or 'nodenext', and the 'target' option is set to 'es2017' or higher. + } + + if (true) { + await using d26 = { async [Symbol.asyncDispose]() {} }; + ~~~~~ +!!! error TS2854: Top-level 'await using' statements are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', 'node16', or 'nodenext', and the 'target' option is set to 'es2017' or higher. + } + else { + await using d27 = { async [Symbol.asyncDispose]() {} }; + ~~~~~ +!!! error TS2854: Top-level 'await using' statements are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', 'node16', or 'nodenext', and the 'target' option is set to 'es2017' or higher. + } + + while (true) { + await using d28 = { async [Symbol.asyncDispose]() {} }; + ~~~~~ +!!! error TS2854: Top-level 'await using' statements are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', 'node16', or 'nodenext', and the 'target' option is set to 'es2017' or higher. + break; + } + + do { + await using d29 = { async [Symbol.asyncDispose]() {} }; + ~~~~~ +!!! error TS2854: Top-level 'await using' statements are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', 'node16', or 'nodenext', and the 'target' option is set to 'es2017' or higher. + break; + } + while (true); + + for (;;) { + await using d30 = { async [Symbol.asyncDispose]() {} }; + ~~~~~ +!!! error TS2854: Top-level 'await using' statements are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', 'node16', or 'nodenext', and the 'target' option is set to 'es2017' or higher. + break; + } + + for (const x in {}) { + await using d31 = { async [Symbol.asyncDispose]() {} }; + ~~~~~ +!!! error TS2854: Top-level 'await using' statements are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', 'node16', or 'nodenext', and the 'target' option is set to 'es2017' or higher. + } + + for (const x of []) { + await using d32 = { async [Symbol.asyncDispose]() {} }; + ~~~~~ +!!! error TS2854: Top-level 'await using' statements are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', 'node16', or 'nodenext', and the 'target' option is set to 'es2017' or higher. + } + + export {}; \ No newline at end of file diff --git a/tests/baselines/reference/awaitUsingDeclarations.1(target=es2015).js b/tests/baselines/reference/awaitUsingDeclarations.1(target=es2015).js new file mode 100644 index 0000000000000..0d1aa5282bb55 --- /dev/null +++ b/tests/baselines/reference/awaitUsingDeclarations.1(target=es2015).js @@ -0,0 +1,540 @@ +//// [tests/cases/conformance/statements/VariableStatements/usingDeclarations/awaitUsingDeclarations.1.ts] //// + +//// [awaitUsingDeclarations.1.ts] +await using d1 = { async [Symbol.asyncDispose]() {} }; + +async function af() { + await using d3 = { async [Symbol.asyncDispose]() {} }; + await null; +} + +async function * ag() { + await using d5 = { async [Symbol.asyncDispose]() {} }; + yield; + await null; +} + +const a = async () => { + await using d6 = { async [Symbol.asyncDispose]() {} }; +}; + +class C1 { + a = async () => { + await using d7 = { async [Symbol.asyncDispose]() {} }; + }; + + async am() { + await using d13 = { async [Symbol.asyncDispose]() {} }; + await null; + } + + async * ag() { + await using d15 = { async [Symbol.asyncDispose]() {} }; + yield; + await null; + } +} + +{ + await using d19 = { async [Symbol.asyncDispose]() {} }; +} + +switch (Math.random()) { + case 0: + await using d20 = { async [Symbol.asyncDispose]() {} }; + break; + + case 1: + await using d21 = { async [Symbol.asyncDispose]() {} }; + break; +} + +if (true) + switch (0) { + case 0: + await using d22 = { async [Symbol.asyncDispose]() {} }; + break; + } + +try { + await using d23 = { async [Symbol.asyncDispose]() {} }; +} +catch { + await using d24 = { async [Symbol.asyncDispose]() {} }; +} +finally { + await using d25 = { async [Symbol.asyncDispose]() {} }; +} + +if (true) { + await using d26 = { async [Symbol.asyncDispose]() {} }; +} +else { + await using d27 = { async [Symbol.asyncDispose]() {} }; +} + +while (true) { + await using d28 = { async [Symbol.asyncDispose]() {} }; + break; +} + +do { + await using d29 = { async [Symbol.asyncDispose]() {} }; + break; +} +while (true); + +for (;;) { + await using d30 = { async [Symbol.asyncDispose]() {} }; + break; +} + +for (const x in {}) { + await using d31 = { async [Symbol.asyncDispose]() {} }; +} + +for (const x of []) { + await using d32 = { async [Symbol.asyncDispose]() {} }; +} + +export {}; + +//// [awaitUsingDeclarations.1.js] +var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { + function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } + return new (P || (P = Promise))(function (resolve, reject) { + function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } + function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } + function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } + step((generator = generator.apply(thisArg, _arguments || [])).next()); + }); +}; +var __addDisposableResource = (this && this.__addDisposableResource) || function (env, value, async) { + if (value !== null && value !== void 0) { + if (typeof value !== "object") throw new TypeError("Object expected."); + var dispose; + if (async) { + if (!Symbol.asyncDispose) throw new TypeError("Symbol.asyncDispose is not defined."); + dispose = value[Symbol.asyncDispose]; + } + if (dispose === void 0) { + if (!Symbol.dispose) throw new TypeError("Symbol.dispose is not defined."); + dispose = value[Symbol.dispose]; + } + if (typeof dispose !== "function") throw new TypeError("Object not disposable."); + env.stack.push({ value: value, dispose: dispose, async: async }); + } + else if (async) { + env.stack.push({ async: true }); + } + return value; +}; +var __disposeResources = (this && this.__disposeResources) || (function (SuppressedError) { + return function (env) { + function fail(e) { + env.error = env.hasError ? new SuppressedError(e, env.error, "An error was suppressed during disposal.") : e; + env.hasError = true; + } + function next() { + while (env.stack.length) { + var rec = env.stack.pop(); + try { + var result = rec.dispose && rec.dispose.call(rec.value); + if (rec.async) return Promise.resolve(result).then(next, function(e) { fail(e); return next(); }); + } + catch (e) { + fail(e); + } + } + if (env.hasError) throw env.error; + } + return next(); + }; +})(typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) { + var e = new Error(message); + return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e; +}); +var __await = (this && this.__await) || function (v) { return this instanceof __await ? (this.v = v, this) : new __await(v); } +var __asyncGenerator = (this && this.__asyncGenerator) || function (thisArg, _arguments, generator) { + if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined."); + var g = generator.apply(thisArg, _arguments || []), i, q = []; + return i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i; + function verb(n) { if (g[n]) i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; } + function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(q[0][3], e); } } + function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); } + function fulfill(value) { resume("next", value); } + function reject(value) { resume("throw", value); } + function settle(f, v) { if (f(v), q.shift(), q.length) resume(q[0][0], q[0][1]); } +}; +function af() { + return __awaiter(this, void 0, void 0, function* () { + const env_15 = { stack: [], error: void 0, hasError: false }; + try { + const d3 = __addDisposableResource(env_15, { [Symbol.asyncDispose]() { + return __awaiter(this, void 0, void 0, function* () { }); + } }, true); + yield null; + } + catch (e_15) { + env_15.error = e_15; + env_15.hasError = true; + } + finally { + const result_15 = __disposeResources(env_15); + if (result_15) + yield result_15; + } + }); +} +function ag() { + return __asyncGenerator(this, arguments, function* ag_1() { + const env_16 = { stack: [], error: void 0, hasError: false }; + try { + const d5 = __addDisposableResource(env_16, { [Symbol.asyncDispose]() { + return __awaiter(this, void 0, void 0, function* () { }); + } }, true); + yield yield __await(void 0); + yield __await(null); + } + catch (e_16) { + env_16.error = e_16; + env_16.hasError = true; + } + finally { + const result_16 = __disposeResources(env_16); + if (result_16) + yield __await(result_16); + } + }); +} +var d1, a, C1, env_1; +const env_2 = { stack: [], error: void 0, hasError: false }; +try { + d1 = __addDisposableResource(env_2, { [Symbol.asyncDispose]() { + return __awaiter(this, void 0, void 0, function* () { }); + } }, true); + a = () => __awaiter(void 0, void 0, void 0, function* () { + const env_17 = { stack: [], error: void 0, hasError: false }; + try { + const d6 = __addDisposableResource(env_17, { [Symbol.asyncDispose]() { + return __awaiter(this, void 0, void 0, function* () { }); + } }, true); + } + catch (e_17) { + env_17.error = e_17; + env_17.hasError = true; + } + finally { + const result_17 = __disposeResources(env_17); + if (result_17) + yield result_17; + } + }); + C1 = class C1 { + constructor() { + this.a = () => __awaiter(this, void 0, void 0, function* () { + const env_18 = { stack: [], error: void 0, hasError: false }; + try { + const d7 = __addDisposableResource(env_18, { [Symbol.asyncDispose]() { + return __awaiter(this, void 0, void 0, function* () { }); + } }, true); + } + catch (e_18) { + env_18.error = e_18; + env_18.hasError = true; + } + finally { + const result_18 = __disposeResources(env_18); + if (result_18) + yield result_18; + } + }); + } + am() { + return __awaiter(this, void 0, void 0, function* () { + const env_19 = { stack: [], error: void 0, hasError: false }; + try { + const d13 = __addDisposableResource(env_19, { [Symbol.asyncDispose]() { + return __awaiter(this, void 0, void 0, function* () { }); + } }, true); + yield null; + } + catch (e_19) { + env_19.error = e_19; + env_19.hasError = true; + } + finally { + const result_19 = __disposeResources(env_19); + if (result_19) + yield result_19; + } + }); + } + ag() { + return __asyncGenerator(this, arguments, function* ag_2() { + const env_20 = { stack: [], error: void 0, hasError: false }; + try { + const d15 = __addDisposableResource(env_20, { [Symbol.asyncDispose]() { + return __awaiter(this, void 0, void 0, function* () { }); + } }, true); + yield yield __await(void 0); + yield __await(null); + } + catch (e_20) { + env_20.error = e_20; + env_20.hasError = true; + } + finally { + const result_20 = __disposeResources(env_20); + if (result_20) + yield __await(result_20); + } + }); + } + }; + { + const env_3 = { stack: [], error: void 0, hasError: false }; + try { + const d19 = __addDisposableResource(env_3, { [Symbol.asyncDispose]() { + return __awaiter(this, void 0, void 0, function* () { }); + } }, true); + } + catch (e_1) { + env_3.error = e_1; + env_3.hasError = true; + } + finally { + const result_1 = __disposeResources(env_3); + if (result_1) + await result_1; + } + } + env_1 = { stack: [], error: void 0, hasError: false }; + try { + switch (Math.random()) { + case 0: + const d20 = __addDisposableResource(env_1, { [Symbol.asyncDispose]() { + return __awaiter(this, void 0, void 0, function* () { }); + } }, true); + break; + case 1: + const d21 = __addDisposableResource(env_1, { [Symbol.asyncDispose]() { + return __awaiter(this, void 0, void 0, function* () { }); + } }, true); + break; + } + } + catch (e_2) { + env_1.error = e_2; + env_1.hasError = true; + } + finally { + const result_2 = __disposeResources(env_1); + if (result_2) + await result_2; + } + if (true) { + const env_4 = { stack: [], error: void 0, hasError: false }; + try { + switch (0) { + case 0: + const d22 = __addDisposableResource(env_4, { [Symbol.asyncDispose]() { + return __awaiter(this, void 0, void 0, function* () { }); + } }, true); + break; + } + } + catch (e_3) { + env_4.error = e_3; + env_4.hasError = true; + } + finally { + const result_3 = __disposeResources(env_4); + if (result_3) + await result_3; + } + } + try { + const env_5 = { stack: [], error: void 0, hasError: false }; + try { + const d23 = __addDisposableResource(env_5, { [Symbol.asyncDispose]() { + return __awaiter(this, void 0, void 0, function* () { }); + } }, true); + } + catch (e_4) { + env_5.error = e_4; + env_5.hasError = true; + } + finally { + const result_4 = __disposeResources(env_5); + if (result_4) + await result_4; + } + } + catch (_a) { + const env_6 = { stack: [], error: void 0, hasError: false }; + try { + const d24 = __addDisposableResource(env_6, { [Symbol.asyncDispose]() { + return __awaiter(this, void 0, void 0, function* () { }); + } }, true); + } + catch (e_5) { + env_6.error = e_5; + env_6.hasError = true; + } + finally { + const result_5 = __disposeResources(env_6); + if (result_5) + await result_5; + } + } + finally { + const env_7 = { stack: [], error: void 0, hasError: false }; + try { + const d25 = __addDisposableResource(env_7, { [Symbol.asyncDispose]() { + return __awaiter(this, void 0, void 0, function* () { }); + } }, true); + } + catch (e_6) { + env_7.error = e_6; + env_7.hasError = true; + } + finally { + const result_6 = __disposeResources(env_7); + if (result_6) + await result_6; + } + } + if (true) { + const env_8 = { stack: [], error: void 0, hasError: false }; + try { + const d26 = __addDisposableResource(env_8, { [Symbol.asyncDispose]() { + return __awaiter(this, void 0, void 0, function* () { }); + } }, true); + } + catch (e_7) { + env_8.error = e_7; + env_8.hasError = true; + } + finally { + const result_7 = __disposeResources(env_8); + if (result_7) + await result_7; + } + } + else { + const env_9 = { stack: [], error: void 0, hasError: false }; + try { + const d27 = __addDisposableResource(env_9, { [Symbol.asyncDispose]() { + return __awaiter(this, void 0, void 0, function* () { }); + } }, true); + } + catch (e_8) { + env_9.error = e_8; + env_9.hasError = true; + } + finally { + const result_8 = __disposeResources(env_9); + if (result_8) + await result_8; + } + } + while (true) { + const env_10 = { stack: [], error: void 0, hasError: false }; + try { + const d28 = __addDisposableResource(env_10, { [Symbol.asyncDispose]() { + return __awaiter(this, void 0, void 0, function* () { }); + } }, true); + break; + } + catch (e_9) { + env_10.error = e_9; + env_10.hasError = true; + } + finally { + const result_9 = __disposeResources(env_10); + if (result_9) + await result_9; + } + } + do { + const env_11 = { stack: [], error: void 0, hasError: false }; + try { + const d29 = __addDisposableResource(env_11, { [Symbol.asyncDispose]() { + return __awaiter(this, void 0, void 0, function* () { }); + } }, true); + break; + } + catch (e_10) { + env_11.error = e_10; + env_11.hasError = true; + } + finally { + const result_10 = __disposeResources(env_11); + if (result_10) + await result_10; + } + } while (true); + for (;;) { + const env_12 = { stack: [], error: void 0, hasError: false }; + try { + const d30 = __addDisposableResource(env_12, { [Symbol.asyncDispose]() { + return __awaiter(this, void 0, void 0, function* () { }); + } }, true); + break; + } + catch (e_11) { + env_12.error = e_11; + env_12.hasError = true; + } + finally { + const result_11 = __disposeResources(env_12); + if (result_11) + await result_11; + } + } + for (const x in {}) { + const env_13 = { stack: [], error: void 0, hasError: false }; + try { + const d31 = __addDisposableResource(env_13, { [Symbol.asyncDispose]() { + return __awaiter(this, void 0, void 0, function* () { }); + } }, true); + } + catch (e_12) { + env_13.error = e_12; + env_13.hasError = true; + } + finally { + const result_12 = __disposeResources(env_13); + if (result_12) + await result_12; + } + } + for (const x of []) { + const env_14 = { stack: [], error: void 0, hasError: false }; + try { + const d32 = __addDisposableResource(env_14, { [Symbol.asyncDispose]() { + return __awaiter(this, void 0, void 0, function* () { }); + } }, true); + } + catch (e_13) { + env_14.error = e_13; + env_14.hasError = true; + } + finally { + const result_13 = __disposeResources(env_14); + if (result_13) + await result_13; + } + } +} +catch (e_14) { + env_2.error = e_14; + env_2.hasError = true; +} +finally { + const result_14 = __disposeResources(env_2); + if (result_14) + await result_14; +} +export {}; diff --git a/tests/baselines/reference/awaitUsingDeclarations.1(target=es2017).js b/tests/baselines/reference/awaitUsingDeclarations.1(target=es2017).js new file mode 100644 index 0000000000000..9732d266f7fc5 --- /dev/null +++ b/tests/baselines/reference/awaitUsingDeclarations.1(target=es2017).js @@ -0,0 +1,485 @@ +//// [tests/cases/conformance/statements/VariableStatements/usingDeclarations/awaitUsingDeclarations.1.ts] //// + +//// [awaitUsingDeclarations.1.ts] +await using d1 = { async [Symbol.asyncDispose]() {} }; + +async function af() { + await using d3 = { async [Symbol.asyncDispose]() {} }; + await null; +} + +async function * ag() { + await using d5 = { async [Symbol.asyncDispose]() {} }; + yield; + await null; +} + +const a = async () => { + await using d6 = { async [Symbol.asyncDispose]() {} }; +}; + +class C1 { + a = async () => { + await using d7 = { async [Symbol.asyncDispose]() {} }; + }; + + async am() { + await using d13 = { async [Symbol.asyncDispose]() {} }; + await null; + } + + async * ag() { + await using d15 = { async [Symbol.asyncDispose]() {} }; + yield; + await null; + } +} + +{ + await using d19 = { async [Symbol.asyncDispose]() {} }; +} + +switch (Math.random()) { + case 0: + await using d20 = { async [Symbol.asyncDispose]() {} }; + break; + + case 1: + await using d21 = { async [Symbol.asyncDispose]() {} }; + break; +} + +if (true) + switch (0) { + case 0: + await using d22 = { async [Symbol.asyncDispose]() {} }; + break; + } + +try { + await using d23 = { async [Symbol.asyncDispose]() {} }; +} +catch { + await using d24 = { async [Symbol.asyncDispose]() {} }; +} +finally { + await using d25 = { async [Symbol.asyncDispose]() {} }; +} + +if (true) { + await using d26 = { async [Symbol.asyncDispose]() {} }; +} +else { + await using d27 = { async [Symbol.asyncDispose]() {} }; +} + +while (true) { + await using d28 = { async [Symbol.asyncDispose]() {} }; + break; +} + +do { + await using d29 = { async [Symbol.asyncDispose]() {} }; + break; +} +while (true); + +for (;;) { + await using d30 = { async [Symbol.asyncDispose]() {} }; + break; +} + +for (const x in {}) { + await using d31 = { async [Symbol.asyncDispose]() {} }; +} + +for (const x of []) { + await using d32 = { async [Symbol.asyncDispose]() {} }; +} + +export {}; + +//// [awaitUsingDeclarations.1.js] +var __addDisposableResource = (this && this.__addDisposableResource) || function (env, value, async) { + if (value !== null && value !== void 0) { + if (typeof value !== "object") throw new TypeError("Object expected."); + var dispose; + if (async) { + if (!Symbol.asyncDispose) throw new TypeError("Symbol.asyncDispose is not defined."); + dispose = value[Symbol.asyncDispose]; + } + if (dispose === void 0) { + if (!Symbol.dispose) throw new TypeError("Symbol.dispose is not defined."); + dispose = value[Symbol.dispose]; + } + if (typeof dispose !== "function") throw new TypeError("Object not disposable."); + env.stack.push({ value: value, dispose: dispose, async: async }); + } + else if (async) { + env.stack.push({ async: true }); + } + return value; +}; +var __disposeResources = (this && this.__disposeResources) || (function (SuppressedError) { + return function (env) { + function fail(e) { + env.error = env.hasError ? new SuppressedError(e, env.error, "An error was suppressed during disposal.") : e; + env.hasError = true; + } + function next() { + while (env.stack.length) { + var rec = env.stack.pop(); + try { + var result = rec.dispose && rec.dispose.call(rec.value); + if (rec.async) return Promise.resolve(result).then(next, function(e) { fail(e); return next(); }); + } + catch (e) { + fail(e); + } + } + if (env.hasError) throw env.error; + } + return next(); + }; +})(typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) { + var e = new Error(message); + return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e; +}); +var __await = (this && this.__await) || function (v) { return this instanceof __await ? (this.v = v, this) : new __await(v); } +var __asyncGenerator = (this && this.__asyncGenerator) || function (thisArg, _arguments, generator) { + if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined."); + var g = generator.apply(thisArg, _arguments || []), i, q = []; + return i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i; + function verb(n) { if (g[n]) i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; } + function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(q[0][3], e); } } + function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); } + function fulfill(value) { resume("next", value); } + function reject(value) { resume("throw", value); } + function settle(f, v) { if (f(v), q.shift(), q.length) resume(q[0][0], q[0][1]); } +}; +async function af() { + const env_15 = { stack: [], error: void 0, hasError: false }; + try { + const d3 = __addDisposableResource(env_15, { async [Symbol.asyncDispose]() { } }, true); + await null; + } + catch (e_15) { + env_15.error = e_15; + env_15.hasError = true; + } + finally { + const result_15 = __disposeResources(env_15); + if (result_15) + await result_15; + } +} +function ag() { + return __asyncGenerator(this, arguments, function* ag_1() { + const env_16 = { stack: [], error: void 0, hasError: false }; + try { + const d5 = __addDisposableResource(env_16, { async [Symbol.asyncDispose]() { } }, true); + yield yield __await(void 0); + yield __await(null); + } + catch (e_16) { + env_16.error = e_16; + env_16.hasError = true; + } + finally { + const result_16 = __disposeResources(env_16); + if (result_16) + yield __await(result_16); + } + }); +} +var d1, a, C1, env_1; +const env_2 = { stack: [], error: void 0, hasError: false }; +try { + d1 = __addDisposableResource(env_2, { async [Symbol.asyncDispose]() { } }, true); + a = async () => { + const env_17 = { stack: [], error: void 0, hasError: false }; + try { + const d6 = __addDisposableResource(env_17, { async [Symbol.asyncDispose]() { } }, true); + } + catch (e_17) { + env_17.error = e_17; + env_17.hasError = true; + } + finally { + const result_17 = __disposeResources(env_17); + if (result_17) + await result_17; + } + }; + C1 = class C1 { + constructor() { + this.a = async () => { + const env_18 = { stack: [], error: void 0, hasError: false }; + try { + const d7 = __addDisposableResource(env_18, { async [Symbol.asyncDispose]() { } }, true); + } + catch (e_18) { + env_18.error = e_18; + env_18.hasError = true; + } + finally { + const result_18 = __disposeResources(env_18); + if (result_18) + await result_18; + } + }; + } + async am() { + const env_19 = { stack: [], error: void 0, hasError: false }; + try { + const d13 = __addDisposableResource(env_19, { async [Symbol.asyncDispose]() { } }, true); + await null; + } + catch (e_19) { + env_19.error = e_19; + env_19.hasError = true; + } + finally { + const result_19 = __disposeResources(env_19); + if (result_19) + await result_19; + } + } + ag() { + return __asyncGenerator(this, arguments, function* ag_2() { + const env_20 = { stack: [], error: void 0, hasError: false }; + try { + const d15 = __addDisposableResource(env_20, { async [Symbol.asyncDispose]() { } }, true); + yield yield __await(void 0); + yield __await(null); + } + catch (e_20) { + env_20.error = e_20; + env_20.hasError = true; + } + finally { + const result_20 = __disposeResources(env_20); + if (result_20) + yield __await(result_20); + } + }); + } + }; + { + const env_3 = { stack: [], error: void 0, hasError: false }; + try { + const d19 = __addDisposableResource(env_3, { async [Symbol.asyncDispose]() { } }, true); + } + catch (e_1) { + env_3.error = e_1; + env_3.hasError = true; + } + finally { + const result_1 = __disposeResources(env_3); + if (result_1) + await result_1; + } + } + env_1 = { stack: [], error: void 0, hasError: false }; + try { + switch (Math.random()) { + case 0: + const d20 = __addDisposableResource(env_1, { async [Symbol.asyncDispose]() { } }, true); + break; + case 1: + const d21 = __addDisposableResource(env_1, { async [Symbol.asyncDispose]() { } }, true); + break; + } + } + catch (e_2) { + env_1.error = e_2; + env_1.hasError = true; + } + finally { + const result_2 = __disposeResources(env_1); + if (result_2) + await result_2; + } + if (true) { + const env_4 = { stack: [], error: void 0, hasError: false }; + try { + switch (0) { + case 0: + const d22 = __addDisposableResource(env_4, { async [Symbol.asyncDispose]() { } }, true); + break; + } + } + catch (e_3) { + env_4.error = e_3; + env_4.hasError = true; + } + finally { + const result_3 = __disposeResources(env_4); + if (result_3) + await result_3; + } + } + try { + const env_5 = { stack: [], error: void 0, hasError: false }; + try { + const d23 = __addDisposableResource(env_5, { async [Symbol.asyncDispose]() { } }, true); + } + catch (e_4) { + env_5.error = e_4; + env_5.hasError = true; + } + finally { + const result_4 = __disposeResources(env_5); + if (result_4) + await result_4; + } + } + catch (_a) { + const env_6 = { stack: [], error: void 0, hasError: false }; + try { + const d24 = __addDisposableResource(env_6, { async [Symbol.asyncDispose]() { } }, true); + } + catch (e_5) { + env_6.error = e_5; + env_6.hasError = true; + } + finally { + const result_5 = __disposeResources(env_6); + if (result_5) + await result_5; + } + } + finally { + const env_7 = { stack: [], error: void 0, hasError: false }; + try { + const d25 = __addDisposableResource(env_7, { async [Symbol.asyncDispose]() { } }, true); + } + catch (e_6) { + env_7.error = e_6; + env_7.hasError = true; + } + finally { + const result_6 = __disposeResources(env_7); + if (result_6) + await result_6; + } + } + if (true) { + const env_8 = { stack: [], error: void 0, hasError: false }; + try { + const d26 = __addDisposableResource(env_8, { async [Symbol.asyncDispose]() { } }, true); + } + catch (e_7) { + env_8.error = e_7; + env_8.hasError = true; + } + finally { + const result_7 = __disposeResources(env_8); + if (result_7) + await result_7; + } + } + else { + const env_9 = { stack: [], error: void 0, hasError: false }; + try { + const d27 = __addDisposableResource(env_9, { async [Symbol.asyncDispose]() { } }, true); + } + catch (e_8) { + env_9.error = e_8; + env_9.hasError = true; + } + finally { + const result_8 = __disposeResources(env_9); + if (result_8) + await result_8; + } + } + while (true) { + const env_10 = { stack: [], error: void 0, hasError: false }; + try { + const d28 = __addDisposableResource(env_10, { async [Symbol.asyncDispose]() { } }, true); + break; + } + catch (e_9) { + env_10.error = e_9; + env_10.hasError = true; + } + finally { + const result_9 = __disposeResources(env_10); + if (result_9) + await result_9; + } + } + do { + const env_11 = { stack: [], error: void 0, hasError: false }; + try { + const d29 = __addDisposableResource(env_11, { async [Symbol.asyncDispose]() { } }, true); + break; + } + catch (e_10) { + env_11.error = e_10; + env_11.hasError = true; + } + finally { + const result_10 = __disposeResources(env_11); + if (result_10) + await result_10; + } + } while (true); + for (;;) { + const env_12 = { stack: [], error: void 0, hasError: false }; + try { + const d30 = __addDisposableResource(env_12, { async [Symbol.asyncDispose]() { } }, true); + break; + } + catch (e_11) { + env_12.error = e_11; + env_12.hasError = true; + } + finally { + const result_11 = __disposeResources(env_12); + if (result_11) + await result_11; + } + } + for (const x in {}) { + const env_13 = { stack: [], error: void 0, hasError: false }; + try { + const d31 = __addDisposableResource(env_13, { async [Symbol.asyncDispose]() { } }, true); + } + catch (e_12) { + env_13.error = e_12; + env_13.hasError = true; + } + finally { + const result_12 = __disposeResources(env_13); + if (result_12) + await result_12; + } + } + for (const x of []) { + const env_14 = { stack: [], error: void 0, hasError: false }; + try { + const d32 = __addDisposableResource(env_14, { async [Symbol.asyncDispose]() { } }, true); + } + catch (e_13) { + env_14.error = e_13; + env_14.hasError = true; + } + finally { + const result_13 = __disposeResources(env_14); + if (result_13) + await result_13; + } + } +} +catch (e_14) { + env_2.error = e_14; + env_2.hasError = true; +} +finally { + const result_14 = __disposeResources(env_2); + if (result_14) + await result_14; +} +export {}; diff --git a/tests/baselines/reference/awaitUsingDeclarations.1(target=es2022).js b/tests/baselines/reference/awaitUsingDeclarations.1(target=es2022).js new file mode 100644 index 0000000000000..41ca069585c62 --- /dev/null +++ b/tests/baselines/reference/awaitUsingDeclarations.1(target=es2022).js @@ -0,0 +1,467 @@ +//// [tests/cases/conformance/statements/VariableStatements/usingDeclarations/awaitUsingDeclarations.1.ts] //// + +//// [awaitUsingDeclarations.1.ts] +await using d1 = { async [Symbol.asyncDispose]() {} }; + +async function af() { + await using d3 = { async [Symbol.asyncDispose]() {} }; + await null; +} + +async function * ag() { + await using d5 = { async [Symbol.asyncDispose]() {} }; + yield; + await null; +} + +const a = async () => { + await using d6 = { async [Symbol.asyncDispose]() {} }; +}; + +class C1 { + a = async () => { + await using d7 = { async [Symbol.asyncDispose]() {} }; + }; + + async am() { + await using d13 = { async [Symbol.asyncDispose]() {} }; + await null; + } + + async * ag() { + await using d15 = { async [Symbol.asyncDispose]() {} }; + yield; + await null; + } +} + +{ + await using d19 = { async [Symbol.asyncDispose]() {} }; +} + +switch (Math.random()) { + case 0: + await using d20 = { async [Symbol.asyncDispose]() {} }; + break; + + case 1: + await using d21 = { async [Symbol.asyncDispose]() {} }; + break; +} + +if (true) + switch (0) { + case 0: + await using d22 = { async [Symbol.asyncDispose]() {} }; + break; + } + +try { + await using d23 = { async [Symbol.asyncDispose]() {} }; +} +catch { + await using d24 = { async [Symbol.asyncDispose]() {} }; +} +finally { + await using d25 = { async [Symbol.asyncDispose]() {} }; +} + +if (true) { + await using d26 = { async [Symbol.asyncDispose]() {} }; +} +else { + await using d27 = { async [Symbol.asyncDispose]() {} }; +} + +while (true) { + await using d28 = { async [Symbol.asyncDispose]() {} }; + break; +} + +do { + await using d29 = { async [Symbol.asyncDispose]() {} }; + break; +} +while (true); + +for (;;) { + await using d30 = { async [Symbol.asyncDispose]() {} }; + break; +} + +for (const x in {}) { + await using d31 = { async [Symbol.asyncDispose]() {} }; +} + +for (const x of []) { + await using d32 = { async [Symbol.asyncDispose]() {} }; +} + +export {}; + +//// [awaitUsingDeclarations.1.js] +var __addDisposableResource = (this && this.__addDisposableResource) || function (env, value, async) { + if (value !== null && value !== void 0) { + if (typeof value !== "object") throw new TypeError("Object expected."); + var dispose; + if (async) { + if (!Symbol.asyncDispose) throw new TypeError("Symbol.asyncDispose is not defined."); + dispose = value[Symbol.asyncDispose]; + } + if (dispose === void 0) { + if (!Symbol.dispose) throw new TypeError("Symbol.dispose is not defined."); + dispose = value[Symbol.dispose]; + } + if (typeof dispose !== "function") throw new TypeError("Object not disposable."); + env.stack.push({ value: value, dispose: dispose, async: async }); + } + else if (async) { + env.stack.push({ async: true }); + } + return value; +}; +var __disposeResources = (this && this.__disposeResources) || (function (SuppressedError) { + return function (env) { + function fail(e) { + env.error = env.hasError ? new SuppressedError(e, env.error, "An error was suppressed during disposal.") : e; + env.hasError = true; + } + function next() { + while (env.stack.length) { + var rec = env.stack.pop(); + try { + var result = rec.dispose && rec.dispose.call(rec.value); + if (rec.async) return Promise.resolve(result).then(next, function(e) { fail(e); return next(); }); + } + catch (e) { + fail(e); + } + } + if (env.hasError) throw env.error; + } + return next(); + }; +})(typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) { + var e = new Error(message); + return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e; +}); +async function af() { + const env_15 = { stack: [], error: void 0, hasError: false }; + try { + const d3 = __addDisposableResource(env_15, { async [Symbol.asyncDispose]() { } }, true); + await null; + } + catch (e_15) { + env_15.error = e_15; + env_15.hasError = true; + } + finally { + const result_15 = __disposeResources(env_15); + if (result_15) + await result_15; + } +} +async function* ag() { + const env_16 = { stack: [], error: void 0, hasError: false }; + try { + const d5 = __addDisposableResource(env_16, { async [Symbol.asyncDispose]() { } }, true); + yield; + await null; + } + catch (e_16) { + env_16.error = e_16; + env_16.hasError = true; + } + finally { + const result_16 = __disposeResources(env_16); + if (result_16) + await result_16; + } +} +var d1, a, C1, env_1; +const env_2 = { stack: [], error: void 0, hasError: false }; +try { + d1 = __addDisposableResource(env_2, { async [Symbol.asyncDispose]() { } }, true); + a = async () => { + const env_17 = { stack: [], error: void 0, hasError: false }; + try { + const d6 = __addDisposableResource(env_17, { async [Symbol.asyncDispose]() { } }, true); + } + catch (e_17) { + env_17.error = e_17; + env_17.hasError = true; + } + finally { + const result_17 = __disposeResources(env_17); + if (result_17) + await result_17; + } + }; + C1 = class C1 { + a = async () => { + const env_18 = { stack: [], error: void 0, hasError: false }; + try { + const d7 = __addDisposableResource(env_18, { async [Symbol.asyncDispose]() { } }, true); + } + catch (e_18) { + env_18.error = e_18; + env_18.hasError = true; + } + finally { + const result_18 = __disposeResources(env_18); + if (result_18) + await result_18; + } + }; + async am() { + const env_19 = { stack: [], error: void 0, hasError: false }; + try { + const d13 = __addDisposableResource(env_19, { async [Symbol.asyncDispose]() { } }, true); + await null; + } + catch (e_19) { + env_19.error = e_19; + env_19.hasError = true; + } + finally { + const result_19 = __disposeResources(env_19); + if (result_19) + await result_19; + } + } + async *ag() { + const env_20 = { stack: [], error: void 0, hasError: false }; + try { + const d15 = __addDisposableResource(env_20, { async [Symbol.asyncDispose]() { } }, true); + yield; + await null; + } + catch (e_20) { + env_20.error = e_20; + env_20.hasError = true; + } + finally { + const result_20 = __disposeResources(env_20); + if (result_20) + await result_20; + } + } + }; + { + const env_3 = { stack: [], error: void 0, hasError: false }; + try { + const d19 = __addDisposableResource(env_3, { async [Symbol.asyncDispose]() { } }, true); + } + catch (e_1) { + env_3.error = e_1; + env_3.hasError = true; + } + finally { + const result_1 = __disposeResources(env_3); + if (result_1) + await result_1; + } + } + env_1 = { stack: [], error: void 0, hasError: false }; + try { + switch (Math.random()) { + case 0: + const d20 = __addDisposableResource(env_1, { async [Symbol.asyncDispose]() { } }, true); + break; + case 1: + const d21 = __addDisposableResource(env_1, { async [Symbol.asyncDispose]() { } }, true); + break; + } + } + catch (e_2) { + env_1.error = e_2; + env_1.hasError = true; + } + finally { + const result_2 = __disposeResources(env_1); + if (result_2) + await result_2; + } + if (true) { + const env_4 = { stack: [], error: void 0, hasError: false }; + try { + switch (0) { + case 0: + const d22 = __addDisposableResource(env_4, { async [Symbol.asyncDispose]() { } }, true); + break; + } + } + catch (e_3) { + env_4.error = e_3; + env_4.hasError = true; + } + finally { + const result_3 = __disposeResources(env_4); + if (result_3) + await result_3; + } + } + try { + const env_5 = { stack: [], error: void 0, hasError: false }; + try { + const d23 = __addDisposableResource(env_5, { async [Symbol.asyncDispose]() { } }, true); + } + catch (e_4) { + env_5.error = e_4; + env_5.hasError = true; + } + finally { + const result_4 = __disposeResources(env_5); + if (result_4) + await result_4; + } + } + catch { + const env_6 = { stack: [], error: void 0, hasError: false }; + try { + const d24 = __addDisposableResource(env_6, { async [Symbol.asyncDispose]() { } }, true); + } + catch (e_5) { + env_6.error = e_5; + env_6.hasError = true; + } + finally { + const result_5 = __disposeResources(env_6); + if (result_5) + await result_5; + } + } + finally { + const env_7 = { stack: [], error: void 0, hasError: false }; + try { + const d25 = __addDisposableResource(env_7, { async [Symbol.asyncDispose]() { } }, true); + } + catch (e_6) { + env_7.error = e_6; + env_7.hasError = true; + } + finally { + const result_6 = __disposeResources(env_7); + if (result_6) + await result_6; + } + } + if (true) { + const env_8 = { stack: [], error: void 0, hasError: false }; + try { + const d26 = __addDisposableResource(env_8, { async [Symbol.asyncDispose]() { } }, true); + } + catch (e_7) { + env_8.error = e_7; + env_8.hasError = true; + } + finally { + const result_7 = __disposeResources(env_8); + if (result_7) + await result_7; + } + } + else { + const env_9 = { stack: [], error: void 0, hasError: false }; + try { + const d27 = __addDisposableResource(env_9, { async [Symbol.asyncDispose]() { } }, true); + } + catch (e_8) { + env_9.error = e_8; + env_9.hasError = true; + } + finally { + const result_8 = __disposeResources(env_9); + if (result_8) + await result_8; + } + } + while (true) { + const env_10 = { stack: [], error: void 0, hasError: false }; + try { + const d28 = __addDisposableResource(env_10, { async [Symbol.asyncDispose]() { } }, true); + break; + } + catch (e_9) { + env_10.error = e_9; + env_10.hasError = true; + } + finally { + const result_9 = __disposeResources(env_10); + if (result_9) + await result_9; + } + } + do { + const env_11 = { stack: [], error: void 0, hasError: false }; + try { + const d29 = __addDisposableResource(env_11, { async [Symbol.asyncDispose]() { } }, true); + break; + } + catch (e_10) { + env_11.error = e_10; + env_11.hasError = true; + } + finally { + const result_10 = __disposeResources(env_11); + if (result_10) + await result_10; + } + } while (true); + for (;;) { + const env_12 = { stack: [], error: void 0, hasError: false }; + try { + const d30 = __addDisposableResource(env_12, { async [Symbol.asyncDispose]() { } }, true); + break; + } + catch (e_11) { + env_12.error = e_11; + env_12.hasError = true; + } + finally { + const result_11 = __disposeResources(env_12); + if (result_11) + await result_11; + } + } + for (const x in {}) { + const env_13 = { stack: [], error: void 0, hasError: false }; + try { + const d31 = __addDisposableResource(env_13, { async [Symbol.asyncDispose]() { } }, true); + } + catch (e_12) { + env_13.error = e_12; + env_13.hasError = true; + } + finally { + const result_12 = __disposeResources(env_13); + if (result_12) + await result_12; + } + } + for (const x of []) { + const env_14 = { stack: [], error: void 0, hasError: false }; + try { + const d32 = __addDisposableResource(env_14, { async [Symbol.asyncDispose]() { } }, true); + } + catch (e_13) { + env_14.error = e_13; + env_14.hasError = true; + } + finally { + const result_13 = __disposeResources(env_14); + if (result_13) + await result_13; + } + } +} +catch (e_14) { + env_2.error = e_14; + env_2.hasError = true; +} +finally { + const result_14 = __disposeResources(env_2); + if (result_14) + await result_14; +} +export {}; diff --git a/tests/baselines/reference/awaitUsingDeclarations.1(target=es5).errors.txt b/tests/baselines/reference/awaitUsingDeclarations.1(target=es5).errors.txt new file mode 100644 index 0000000000000..52470b2456f61 --- /dev/null +++ b/tests/baselines/reference/awaitUsingDeclarations.1(target=es5).errors.txt @@ -0,0 +1,145 @@ +awaitUsingDeclarations.1.ts(1,1): error TS2854: Top-level 'await using' statements are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', 'node16', or 'nodenext', and the 'target' option is set to 'es2017' or higher. +awaitUsingDeclarations.1.ts(36,5): error TS2854: Top-level 'await using' statements are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', 'node16', or 'nodenext', and the 'target' option is set to 'es2017' or higher. +awaitUsingDeclarations.1.ts(41,9): error TS2854: Top-level 'await using' statements are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', 'node16', or 'nodenext', and the 'target' option is set to 'es2017' or higher. +awaitUsingDeclarations.1.ts(45,9): error TS2854: Top-level 'await using' statements are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', 'node16', or 'nodenext', and the 'target' option is set to 'es2017' or higher. +awaitUsingDeclarations.1.ts(52,13): error TS2854: Top-level 'await using' statements are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', 'node16', or 'nodenext', and the 'target' option is set to 'es2017' or higher. +awaitUsingDeclarations.1.ts(57,5): error TS2854: Top-level 'await using' statements are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', 'node16', or 'nodenext', and the 'target' option is set to 'es2017' or higher. +awaitUsingDeclarations.1.ts(60,5): error TS2854: Top-level 'await using' statements are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', 'node16', or 'nodenext', and the 'target' option is set to 'es2017' or higher. +awaitUsingDeclarations.1.ts(63,5): error TS2854: Top-level 'await using' statements are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', 'node16', or 'nodenext', and the 'target' option is set to 'es2017' or higher. +awaitUsingDeclarations.1.ts(67,5): error TS2854: Top-level 'await using' statements are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', 'node16', or 'nodenext', and the 'target' option is set to 'es2017' or higher. +awaitUsingDeclarations.1.ts(70,5): error TS2854: Top-level 'await using' statements are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', 'node16', or 'nodenext', and the 'target' option is set to 'es2017' or higher. +awaitUsingDeclarations.1.ts(74,5): error TS2854: Top-level 'await using' statements are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', 'node16', or 'nodenext', and the 'target' option is set to 'es2017' or higher. +awaitUsingDeclarations.1.ts(79,5): error TS2854: Top-level 'await using' statements are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', 'node16', or 'nodenext', and the 'target' option is set to 'es2017' or higher. +awaitUsingDeclarations.1.ts(85,5): error TS2854: Top-level 'await using' statements are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', 'node16', or 'nodenext', and the 'target' option is set to 'es2017' or higher. +awaitUsingDeclarations.1.ts(90,5): error TS2854: Top-level 'await using' statements are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', 'node16', or 'nodenext', and the 'target' option is set to 'es2017' or higher. +awaitUsingDeclarations.1.ts(94,5): error TS2854: Top-level 'await using' statements are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', 'node16', or 'nodenext', and the 'target' option is set to 'es2017' or higher. + + +==== awaitUsingDeclarations.1.ts (15 errors) ==== + await using d1 = { async [Symbol.asyncDispose]() {} }; + ~~~~~ +!!! error TS2854: Top-level 'await using' statements are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', 'node16', or 'nodenext', and the 'target' option is set to 'es2017' or higher. + + async function af() { + await using d3 = { async [Symbol.asyncDispose]() {} }; + await null; + } + + async function * ag() { + await using d5 = { async [Symbol.asyncDispose]() {} }; + yield; + await null; + } + + const a = async () => { + await using d6 = { async [Symbol.asyncDispose]() {} }; + }; + + class C1 { + a = async () => { + await using d7 = { async [Symbol.asyncDispose]() {} }; + }; + + async am() { + await using d13 = { async [Symbol.asyncDispose]() {} }; + await null; + } + + async * ag() { + await using d15 = { async [Symbol.asyncDispose]() {} }; + yield; + await null; + } + } + + { + await using d19 = { async [Symbol.asyncDispose]() {} }; + ~~~~~ +!!! error TS2854: Top-level 'await using' statements are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', 'node16', or 'nodenext', and the 'target' option is set to 'es2017' or higher. + } + + switch (Math.random()) { + case 0: + await using d20 = { async [Symbol.asyncDispose]() {} }; + ~~~~~ +!!! error TS2854: Top-level 'await using' statements are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', 'node16', or 'nodenext', and the 'target' option is set to 'es2017' or higher. + break; + + case 1: + await using d21 = { async [Symbol.asyncDispose]() {} }; + ~~~~~ +!!! error TS2854: Top-level 'await using' statements are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', 'node16', or 'nodenext', and the 'target' option is set to 'es2017' or higher. + break; + } + + if (true) + switch (0) { + case 0: + await using d22 = { async [Symbol.asyncDispose]() {} }; + ~~~~~ +!!! error TS2854: Top-level 'await using' statements are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', 'node16', or 'nodenext', and the 'target' option is set to 'es2017' or higher. + break; + } + + try { + await using d23 = { async [Symbol.asyncDispose]() {} }; + ~~~~~ +!!! error TS2854: Top-level 'await using' statements are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', 'node16', or 'nodenext', and the 'target' option is set to 'es2017' or higher. + } + catch { + await using d24 = { async [Symbol.asyncDispose]() {} }; + ~~~~~ +!!! error TS2854: Top-level 'await using' statements are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', 'node16', or 'nodenext', and the 'target' option is set to 'es2017' or higher. + } + finally { + await using d25 = { async [Symbol.asyncDispose]() {} }; + ~~~~~ +!!! error TS2854: Top-level 'await using' statements are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', 'node16', or 'nodenext', and the 'target' option is set to 'es2017' or higher. + } + + if (true) { + await using d26 = { async [Symbol.asyncDispose]() {} }; + ~~~~~ +!!! error TS2854: Top-level 'await using' statements are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', 'node16', or 'nodenext', and the 'target' option is set to 'es2017' or higher. + } + else { + await using d27 = { async [Symbol.asyncDispose]() {} }; + ~~~~~ +!!! error TS2854: Top-level 'await using' statements are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', 'node16', or 'nodenext', and the 'target' option is set to 'es2017' or higher. + } + + while (true) { + await using d28 = { async [Symbol.asyncDispose]() {} }; + ~~~~~ +!!! error TS2854: Top-level 'await using' statements are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', 'node16', or 'nodenext', and the 'target' option is set to 'es2017' or higher. + break; + } + + do { + await using d29 = { async [Symbol.asyncDispose]() {} }; + ~~~~~ +!!! error TS2854: Top-level 'await using' statements are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', 'node16', or 'nodenext', and the 'target' option is set to 'es2017' or higher. + break; + } + while (true); + + for (;;) { + await using d30 = { async [Symbol.asyncDispose]() {} }; + ~~~~~ +!!! error TS2854: Top-level 'await using' statements are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', 'node16', or 'nodenext', and the 'target' option is set to 'es2017' or higher. + break; + } + + for (const x in {}) { + await using d31 = { async [Symbol.asyncDispose]() {} }; + ~~~~~ +!!! error TS2854: Top-level 'await using' statements are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', 'node16', or 'nodenext', and the 'target' option is set to 'es2017' or higher. + } + + for (const x of []) { + await using d32 = { async [Symbol.asyncDispose]() {} }; + ~~~~~ +!!! error TS2854: Top-level 'await using' statements are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', 'node16', or 'nodenext', and the 'target' option is set to 'es2017' or higher. + } + + export {}; \ No newline at end of file diff --git a/tests/baselines/reference/awaitUsingDeclarations.1(target=es5).js b/tests/baselines/reference/awaitUsingDeclarations.1(target=es5).js new file mode 100644 index 0000000000000..7d7ec33b23b09 --- /dev/null +++ b/tests/baselines/reference/awaitUsingDeclarations.1(target=es5).js @@ -0,0 +1,711 @@ +//// [tests/cases/conformance/statements/VariableStatements/usingDeclarations/awaitUsingDeclarations.1.ts] //// + +//// [awaitUsingDeclarations.1.ts] +await using d1 = { async [Symbol.asyncDispose]() {} }; + +async function af() { + await using d3 = { async [Symbol.asyncDispose]() {} }; + await null; +} + +async function * ag() { + await using d5 = { async [Symbol.asyncDispose]() {} }; + yield; + await null; +} + +const a = async () => { + await using d6 = { async [Symbol.asyncDispose]() {} }; +}; + +class C1 { + a = async () => { + await using d7 = { async [Symbol.asyncDispose]() {} }; + }; + + async am() { + await using d13 = { async [Symbol.asyncDispose]() {} }; + await null; + } + + async * ag() { + await using d15 = { async [Symbol.asyncDispose]() {} }; + yield; + await null; + } +} + +{ + await using d19 = { async [Symbol.asyncDispose]() {} }; +} + +switch (Math.random()) { + case 0: + await using d20 = { async [Symbol.asyncDispose]() {} }; + break; + + case 1: + await using d21 = { async [Symbol.asyncDispose]() {} }; + break; +} + +if (true) + switch (0) { + case 0: + await using d22 = { async [Symbol.asyncDispose]() {} }; + break; + } + +try { + await using d23 = { async [Symbol.asyncDispose]() {} }; +} +catch { + await using d24 = { async [Symbol.asyncDispose]() {} }; +} +finally { + await using d25 = { async [Symbol.asyncDispose]() {} }; +} + +if (true) { + await using d26 = { async [Symbol.asyncDispose]() {} }; +} +else { + await using d27 = { async [Symbol.asyncDispose]() {} }; +} + +while (true) { + await using d28 = { async [Symbol.asyncDispose]() {} }; + break; +} + +do { + await using d29 = { async [Symbol.asyncDispose]() {} }; + break; +} +while (true); + +for (;;) { + await using d30 = { async [Symbol.asyncDispose]() {} }; + break; +} + +for (const x in {}) { + await using d31 = { async [Symbol.asyncDispose]() {} }; +} + +for (const x of []) { + await using d32 = { async [Symbol.asyncDispose]() {} }; +} + +export {}; + +//// [awaitUsingDeclarations.1.js] +var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { + function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } + return new (P || (P = Promise))(function (resolve, reject) { + function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } + function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } + function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } + step((generator = generator.apply(thisArg, _arguments || [])).next()); + }); +}; +var __generator = (this && this.__generator) || function (thisArg, body) { + var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g; + return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g; + function verb(n) { return function (v) { return step([n, v]); }; } + function step(op) { + if (f) throw new TypeError("Generator is already executing."); + while (g && (g = 0, op[0] && (_ = 0)), _) try { + if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t; + if (y = 0, t) op = [op[0] & 2, t.value]; + switch (op[0]) { + case 0: case 1: t = op; break; + case 4: _.label++; return { value: op[1], done: false }; + case 5: _.label++; y = op[1]; op = [0]; continue; + case 7: op = _.ops.pop(); _.trys.pop(); continue; + default: + if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; } + if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; } + if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; } + if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; } + if (t[2]) _.ops.pop(); + _.trys.pop(); continue; + } + op = body.call(thisArg, _); + } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; } + if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true }; + } +}; +var __addDisposableResource = (this && this.__addDisposableResource) || function (env, value, async) { + if (value !== null && value !== void 0) { + if (typeof value !== "object") throw new TypeError("Object expected."); + var dispose; + if (async) { + if (!Symbol.asyncDispose) throw new TypeError("Symbol.asyncDispose is not defined."); + dispose = value[Symbol.asyncDispose]; + } + if (dispose === void 0) { + if (!Symbol.dispose) throw new TypeError("Symbol.dispose is not defined."); + dispose = value[Symbol.dispose]; + } + if (typeof dispose !== "function") throw new TypeError("Object not disposable."); + env.stack.push({ value: value, dispose: dispose, async: async }); + } + else if (async) { + env.stack.push({ async: true }); + } + return value; +}; +var __disposeResources = (this && this.__disposeResources) || (function (SuppressedError) { + return function (env) { + function fail(e) { + env.error = env.hasError ? new SuppressedError(e, env.error, "An error was suppressed during disposal.") : e; + env.hasError = true; + } + function next() { + while (env.stack.length) { + var rec = env.stack.pop(); + try { + var result = rec.dispose && rec.dispose.call(rec.value); + if (rec.async) return Promise.resolve(result).then(next, function(e) { fail(e); return next(); }); + } + catch (e) { + fail(e); + } + } + if (env.hasError) throw env.error; + } + return next(); + }; +})(typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) { + var e = new Error(message); + return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e; +}); +var __await = (this && this.__await) || function (v) { return this instanceof __await ? (this.v = v, this) : new __await(v); } +var __asyncGenerator = (this && this.__asyncGenerator) || function (thisArg, _arguments, generator) { + if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined."); + var g = generator.apply(thisArg, _arguments || []), i, q = []; + return i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i; + function verb(n) { if (g[n]) i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; } + function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(q[0][3], e); } } + function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); } + function fulfill(value) { resume("next", value); } + function reject(value) { resume("throw", value); } + function settle(f, v) { if (f(v), q.shift(), q.length) resume(q[0][0], q[0][1]); } +}; +var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q; +function af() { + return __awaiter(this, void 0, void 0, function () { + var env_15, d3, e_15, result_15; + var _a; + return __generator(this, function (_b) { + switch (_b.label) { + case 0: + env_15 = { stack: [], error: void 0, hasError: false }; + _b.label = 1; + case 1: + _b.trys.push([1, 3, 4, 7]); + d3 = __addDisposableResource(env_15, (_a = {}, _a[Symbol.asyncDispose] = function () { + return __awaiter(this, void 0, void 0, function () { return __generator(this, function (_a) { + return [2 /*return*/]; + }); }); + }, _a), true); + return [4 /*yield*/, null]; + case 2: + _b.sent(); + return [3 /*break*/, 7]; + case 3: + e_15 = _b.sent(); + env_15.error = e_15; + env_15.hasError = true; + return [3 /*break*/, 7]; + case 4: + result_15 = __disposeResources(env_15); + if (!result_15) return [3 /*break*/, 6]; + return [4 /*yield*/, result_15]; + case 5: + _b.sent(); + _b.label = 6; + case 6: return [7 /*endfinally*/]; + case 7: return [2 /*return*/]; + } + }); + }); +} +function ag() { + return __asyncGenerator(this, arguments, function ag_1() { + var env_16, d5, e_16, result_16; + var _a; + return __generator(this, function (_b) { + switch (_b.label) { + case 0: + env_16 = { stack: [], error: void 0, hasError: false }; + _b.label = 1; + case 1: + _b.trys.push([1, 5, 6, 9]); + d5 = __addDisposableResource(env_16, (_a = {}, _a[Symbol.asyncDispose] = function () { + return __awaiter(this, void 0, void 0, function () { return __generator(this, function (_a) { + return [2 /*return*/]; + }); }); + }, _a), true); + return [4 /*yield*/, __await(void 0)]; + case 2: return [4 /*yield*/, _b.sent()]; + case 3: + _b.sent(); + return [4 /*yield*/, __await(null)]; + case 4: + _b.sent(); + return [3 /*break*/, 9]; + case 5: + e_16 = _b.sent(); + env_16.error = e_16; + env_16.hasError = true; + return [3 /*break*/, 9]; + case 6: + result_16 = __disposeResources(env_16); + if (!result_16) return [3 /*break*/, 8]; + return [4 /*yield*/, __await(result_16)]; + case 7: + _b.sent(); + _b.label = 8; + case 8: return [7 /*endfinally*/]; + case 9: return [2 /*return*/]; + } + }); + }); +} +var d1, a, C1, env_1; +var env_2 = { stack: [], error: void 0, hasError: false }; +try { + d1 = __addDisposableResource(env_2, (_a = {}, _a[Symbol.asyncDispose] = function () { + return __awaiter(this, void 0, void 0, function () { return __generator(this, function (_a) { + return [2 /*return*/]; + }); }); + }, _a), true); + a = function () { return __awaiter(void 0, void 0, void 0, function () { + var env_17, d6, e_17, result_17; + var _a; + return __generator(this, function (_b) { + switch (_b.label) { + case 0: + env_17 = { stack: [], error: void 0, hasError: false }; + _b.label = 1; + case 1: + _b.trys.push([1, 2, 3, 6]); + d6 = __addDisposableResource(env_17, (_a = {}, _a[Symbol.asyncDispose] = function () { + return __awaiter(this, void 0, void 0, function () { return __generator(this, function (_a) { + return [2 /*return*/]; + }); }); + }, _a), true); + return [3 /*break*/, 6]; + case 2: + e_17 = _b.sent(); + env_17.error = e_17; + env_17.hasError = true; + return [3 /*break*/, 6]; + case 3: + result_17 = __disposeResources(env_17); + if (!result_17) return [3 /*break*/, 5]; + return [4 /*yield*/, result_17]; + case 4: + _b.sent(); + _b.label = 5; + case 5: return [7 /*endfinally*/]; + case 6: return [2 /*return*/]; + } + }); + }); }; + C1 = /** @class */ (function () { + function C1() { + var _this = this; + this.a = function () { return __awaiter(_this, void 0, void 0, function () { + var env_18, d7, e_18, result_18; + var _a; + return __generator(this, function (_b) { + switch (_b.label) { + case 0: + env_18 = { stack: [], error: void 0, hasError: false }; + _b.label = 1; + case 1: + _b.trys.push([1, 2, 3, 6]); + d7 = __addDisposableResource(env_18, (_a = {}, _a[Symbol.asyncDispose] = function () { + return __awaiter(this, void 0, void 0, function () { return __generator(this, function (_a) { + return [2 /*return*/]; + }); }); + }, _a), true); + return [3 /*break*/, 6]; + case 2: + e_18 = _b.sent(); + env_18.error = e_18; + env_18.hasError = true; + return [3 /*break*/, 6]; + case 3: + result_18 = __disposeResources(env_18); + if (!result_18) return [3 /*break*/, 5]; + return [4 /*yield*/, result_18]; + case 4: + _b.sent(); + _b.label = 5; + case 5: return [7 /*endfinally*/]; + case 6: return [2 /*return*/]; + } + }); + }); }; + } + C1.prototype.am = function () { + return __awaiter(this, void 0, void 0, function () { + var env_19, d13, e_19, result_19; + var _a; + return __generator(this, function (_b) { + switch (_b.label) { + case 0: + env_19 = { stack: [], error: void 0, hasError: false }; + _b.label = 1; + case 1: + _b.trys.push([1, 3, 4, 7]); + d13 = __addDisposableResource(env_19, (_a = {}, _a[Symbol.asyncDispose] = function () { + return __awaiter(this, void 0, void 0, function () { return __generator(this, function (_a) { + return [2 /*return*/]; + }); }); + }, _a), true); + return [4 /*yield*/, null]; + case 2: + _b.sent(); + return [3 /*break*/, 7]; + case 3: + e_19 = _b.sent(); + env_19.error = e_19; + env_19.hasError = true; + return [3 /*break*/, 7]; + case 4: + result_19 = __disposeResources(env_19); + if (!result_19) return [3 /*break*/, 6]; + return [4 /*yield*/, result_19]; + case 5: + _b.sent(); + _b.label = 6; + case 6: return [7 /*endfinally*/]; + case 7: return [2 /*return*/]; + } + }); + }); + }; + C1.prototype.ag = function () { + return __asyncGenerator(this, arguments, function ag_2() { + var env_20, d15, e_20, result_20; + var _a; + return __generator(this, function (_b) { + switch (_b.label) { + case 0: + env_20 = { stack: [], error: void 0, hasError: false }; + _b.label = 1; + case 1: + _b.trys.push([1, 5, 6, 9]); + d15 = __addDisposableResource(env_20, (_a = {}, _a[Symbol.asyncDispose] = function () { + return __awaiter(this, void 0, void 0, function () { return __generator(this, function (_a) { + return [2 /*return*/]; + }); }); + }, _a), true); + return [4 /*yield*/, __await(void 0)]; + case 2: return [4 /*yield*/, _b.sent()]; + case 3: + _b.sent(); + return [4 /*yield*/, __await(null)]; + case 4: + _b.sent(); + return [3 /*break*/, 9]; + case 5: + e_20 = _b.sent(); + env_20.error = e_20; + env_20.hasError = true; + return [3 /*break*/, 9]; + case 6: + result_20 = __disposeResources(env_20); + if (!result_20) return [3 /*break*/, 8]; + return [4 /*yield*/, __await(result_20)]; + case 7: + _b.sent(); + _b.label = 8; + case 8: return [7 /*endfinally*/]; + case 9: return [2 /*return*/]; + } + }); + }); + }; + return C1; + }()); + { + var env_3 = { stack: [], error: void 0, hasError: false }; + try { + var d19 = __addDisposableResource(env_3, (_b = {}, _b[Symbol.asyncDispose] = function () { + return __awaiter(this, void 0, void 0, function () { return __generator(this, function (_a) { + return [2 /*return*/]; + }); }); + }, _b), true); + } + catch (e_1) { + env_3.error = e_1; + env_3.hasError = true; + } + finally { + var result_1 = __disposeResources(env_3); + if (result_1) + await result_1; + } + } + env_1 = { stack: [], error: void 0, hasError: false }; + try { + switch (Math.random()) { + case 0: + var d20 = __addDisposableResource(env_1, (_c = {}, _c[Symbol.asyncDispose] = function () { + return __awaiter(this, void 0, void 0, function () { return __generator(this, function (_a) { + return [2 /*return*/]; + }); }); + }, _c), true); + break; + case 1: + var d21 = __addDisposableResource(env_1, (_d = {}, _d[Symbol.asyncDispose] = function () { + return __awaiter(this, void 0, void 0, function () { return __generator(this, function (_a) { + return [2 /*return*/]; + }); }); + }, _d), true); + break; + } + } + catch (e_2) { + env_1.error = e_2; + env_1.hasError = true; + } + finally { + var result_2 = __disposeResources(env_1); + if (result_2) + await result_2; + } + if (true) { + var env_4 = { stack: [], error: void 0, hasError: false }; + try { + switch (0) { + case 0: + var d22 = __addDisposableResource(env_4, (_e = {}, _e[Symbol.asyncDispose] = function () { + return __awaiter(this, void 0, void 0, function () { return __generator(this, function (_a) { + return [2 /*return*/]; + }); }); + }, _e), true); + break; + } + } + catch (e_3) { + env_4.error = e_3; + env_4.hasError = true; + } + finally { + var result_3 = __disposeResources(env_4); + if (result_3) + await result_3; + } + } + try { + var env_5 = { stack: [], error: void 0, hasError: false }; + try { + var d23 = __addDisposableResource(env_5, (_f = {}, _f[Symbol.asyncDispose] = function () { + return __awaiter(this, void 0, void 0, function () { return __generator(this, function (_a) { + return [2 /*return*/]; + }); }); + }, _f), true); + } + catch (e_4) { + env_5.error = e_4; + env_5.hasError = true; + } + finally { + var result_4 = __disposeResources(env_5); + if (result_4) + await result_4; + } + } + catch (_r) { + var env_6 = { stack: [], error: void 0, hasError: false }; + try { + var d24 = __addDisposableResource(env_6, (_g = {}, _g[Symbol.asyncDispose] = function () { + return __awaiter(this, void 0, void 0, function () { return __generator(this, function (_a) { + return [2 /*return*/]; + }); }); + }, _g), true); + } + catch (e_5) { + env_6.error = e_5; + env_6.hasError = true; + } + finally { + var result_5 = __disposeResources(env_6); + if (result_5) + await result_5; + } + } + finally { + var env_7 = { stack: [], error: void 0, hasError: false }; + try { + var d25 = __addDisposableResource(env_7, (_h = {}, _h[Symbol.asyncDispose] = function () { + return __awaiter(this, void 0, void 0, function () { return __generator(this, function (_a) { + return [2 /*return*/]; + }); }); + }, _h), true); + } + catch (e_6) { + env_7.error = e_6; + env_7.hasError = true; + } + finally { + var result_6 = __disposeResources(env_7); + if (result_6) + await result_6; + } + } + if (true) { + var env_8 = { stack: [], error: void 0, hasError: false }; + try { + var d26 = __addDisposableResource(env_8, (_j = {}, _j[Symbol.asyncDispose] = function () { + return __awaiter(this, void 0, void 0, function () { return __generator(this, function (_a) { + return [2 /*return*/]; + }); }); + }, _j), true); + } + catch (e_7) { + env_8.error = e_7; + env_8.hasError = true; + } + finally { + var result_7 = __disposeResources(env_8); + if (result_7) + await result_7; + } + } + else { + var env_9 = { stack: [], error: void 0, hasError: false }; + try { + var d27 = __addDisposableResource(env_9, (_k = {}, _k[Symbol.asyncDispose] = function () { + return __awaiter(this, void 0, void 0, function () { return __generator(this, function (_a) { + return [2 /*return*/]; + }); }); + }, _k), true); + } + catch (e_8) { + env_9.error = e_8; + env_9.hasError = true; + } + finally { + var result_8 = __disposeResources(env_9); + if (result_8) + await result_8; + } + } + while (true) { + var env_10 = { stack: [], error: void 0, hasError: false }; + try { + var d28 = __addDisposableResource(env_10, (_l = {}, _l[Symbol.asyncDispose] = function () { + return __awaiter(this, void 0, void 0, function () { return __generator(this, function (_a) { + return [2 /*return*/]; + }); }); + }, _l), true); + break; + } + catch (e_9) { + env_10.error = e_9; + env_10.hasError = true; + } + finally { + var result_9 = __disposeResources(env_10); + if (result_9) + await result_9; + } + } + do { + var env_11 = { stack: [], error: void 0, hasError: false }; + try { + var d29 = __addDisposableResource(env_11, (_m = {}, _m[Symbol.asyncDispose] = function () { + return __awaiter(this, void 0, void 0, function () { return __generator(this, function (_a) { + return [2 /*return*/]; + }); }); + }, _m), true); + break; + } + catch (e_10) { + env_11.error = e_10; + env_11.hasError = true; + } + finally { + var result_10 = __disposeResources(env_11); + if (result_10) + await result_10; + } + } while (true); + for (;;) { + var env_12 = { stack: [], error: void 0, hasError: false }; + try { + var d30 = __addDisposableResource(env_12, (_o = {}, _o[Symbol.asyncDispose] = function () { + return __awaiter(this, void 0, void 0, function () { return __generator(this, function (_a) { + return [2 /*return*/]; + }); }); + }, _o), true); + break; + } + catch (e_11) { + env_12.error = e_11; + env_12.hasError = true; + } + finally { + var result_11 = __disposeResources(env_12); + if (result_11) + await result_11; + } + } + for (var x in {}) { + var env_13 = { stack: [], error: void 0, hasError: false }; + try { + var d31 = __addDisposableResource(env_13, (_p = {}, _p[Symbol.asyncDispose] = function () { + return __awaiter(this, void 0, void 0, function () { return __generator(this, function (_a) { + return [2 /*return*/]; + }); }); + }, _p), true); + } + catch (e_12) { + env_13.error = e_12; + env_13.hasError = true; + } + finally { + var result_12 = __disposeResources(env_13); + if (result_12) + await result_12; + } + } + for (var _i = 0, _s = []; _i < _s.length; _i++) { + var x = _s[_i]; + var env_14 = { stack: [], error: void 0, hasError: false }; + try { + var d32 = __addDisposableResource(env_14, (_q = {}, _q[Symbol.asyncDispose] = function () { + return __awaiter(this, void 0, void 0, function () { return __generator(this, function (_a) { + return [2 /*return*/]; + }); }); + }, _q), true); + } + catch (e_13) { + env_14.error = e_13; + env_14.hasError = true; + } + finally { + var result_13 = __disposeResources(env_14); + if (result_13) + await result_13; + } + } +} +catch (e_14) { + env_2.error = e_14; + env_2.hasError = true; +} +finally { + var result_14 = __disposeResources(env_2); + if (result_14) + await result_14; +} +export {}; diff --git a/tests/baselines/reference/awaitUsingDeclarations.1(target=esnext).js b/tests/baselines/reference/awaitUsingDeclarations.1(target=esnext).js new file mode 100644 index 0000000000000..66107e393d6f8 --- /dev/null +++ b/tests/baselines/reference/awaitUsingDeclarations.1(target=esnext).js @@ -0,0 +1,180 @@ +//// [tests/cases/conformance/statements/VariableStatements/usingDeclarations/awaitUsingDeclarations.1.ts] //// + +//// [awaitUsingDeclarations.1.ts] +await using d1 = { async [Symbol.asyncDispose]() {} }; + +async function af() { + await using d3 = { async [Symbol.asyncDispose]() {} }; + await null; +} + +async function * ag() { + await using d5 = { async [Symbol.asyncDispose]() {} }; + yield; + await null; +} + +const a = async () => { + await using d6 = { async [Symbol.asyncDispose]() {} }; +}; + +class C1 { + a = async () => { + await using d7 = { async [Symbol.asyncDispose]() {} }; + }; + + async am() { + await using d13 = { async [Symbol.asyncDispose]() {} }; + await null; + } + + async * ag() { + await using d15 = { async [Symbol.asyncDispose]() {} }; + yield; + await null; + } +} + +{ + await using d19 = { async [Symbol.asyncDispose]() {} }; +} + +switch (Math.random()) { + case 0: + await using d20 = { async [Symbol.asyncDispose]() {} }; + break; + + case 1: + await using d21 = { async [Symbol.asyncDispose]() {} }; + break; +} + +if (true) + switch (0) { + case 0: + await using d22 = { async [Symbol.asyncDispose]() {} }; + break; + } + +try { + await using d23 = { async [Symbol.asyncDispose]() {} }; +} +catch { + await using d24 = { async [Symbol.asyncDispose]() {} }; +} +finally { + await using d25 = { async [Symbol.asyncDispose]() {} }; +} + +if (true) { + await using d26 = { async [Symbol.asyncDispose]() {} }; +} +else { + await using d27 = { async [Symbol.asyncDispose]() {} }; +} + +while (true) { + await using d28 = { async [Symbol.asyncDispose]() {} }; + break; +} + +do { + await using d29 = { async [Symbol.asyncDispose]() {} }; + break; +} +while (true); + +for (;;) { + await using d30 = { async [Symbol.asyncDispose]() {} }; + break; +} + +for (const x in {}) { + await using d31 = { async [Symbol.asyncDispose]() {} }; +} + +for (const x of []) { + await using d32 = { async [Symbol.asyncDispose]() {} }; +} + +export {}; + +//// [awaitUsingDeclarations.1.js] +await using d1 = { async [Symbol.asyncDispose]() { } }; +async function af() { + await using d3 = { async [Symbol.asyncDispose]() { } }; + await null; +} +async function* ag() { + await using d5 = { async [Symbol.asyncDispose]() { } }; + yield; + await null; +} +const a = async () => { + await using d6 = { async [Symbol.asyncDispose]() { } }; +}; +class C1 { + a = async () => { + await using d7 = { async [Symbol.asyncDispose]() { } }; + }; + async am() { + await using d13 = { async [Symbol.asyncDispose]() { } }; + await null; + } + async *ag() { + await using d15 = { async [Symbol.asyncDispose]() { } }; + yield; + await null; + } +} +{ + await using d19 = { async [Symbol.asyncDispose]() { } }; +} +switch (Math.random()) { + case 0: + await using d20 = { async [Symbol.asyncDispose]() { } }; + break; + case 1: + await using d21 = { async [Symbol.asyncDispose]() { } }; + break; +} +if (true) + switch (0) { + case 0: + await using d22 = { async [Symbol.asyncDispose]() { } }; + break; + } +try { + await using d23 = { async [Symbol.asyncDispose]() { } }; +} +catch { + await using d24 = { async [Symbol.asyncDispose]() { } }; +} +finally { + await using d25 = { async [Symbol.asyncDispose]() { } }; +} +if (true) { + await using d26 = { async [Symbol.asyncDispose]() { } }; +} +else { + await using d27 = { async [Symbol.asyncDispose]() { } }; +} +while (true) { + await using d28 = { async [Symbol.asyncDispose]() { } }; + break; +} +do { + await using d29 = { async [Symbol.asyncDispose]() { } }; + break; +} while (true); +for (;;) { + await using d30 = { async [Symbol.asyncDispose]() { } }; + break; +} +for (const x in {}) { + await using d31 = { async [Symbol.asyncDispose]() { } }; +} +for (const x of []) { + await using d32 = { async [Symbol.asyncDispose]() { } }; +} +export {}; diff --git a/tests/baselines/reference/awaitUsingDeclarations.10.errors.txt b/tests/baselines/reference/awaitUsingDeclarations.10.errors.txt new file mode 100644 index 0000000000000..897a5a03a1181 --- /dev/null +++ b/tests/baselines/reference/awaitUsingDeclarations.10.errors.txt @@ -0,0 +1,12 @@ +awaitUsingDeclarations.10.ts(5,12): error TS1156: 'await using' declarations can only be declared inside a block. + + +==== awaitUsingDeclarations.10.ts (1 errors) ==== + export {}; + + declare var x: any; + async function f() { + if (x) await using a = null; + ~~~~~~~~~~~~~~~~~~~~~ +!!! error TS1156: 'await using' declarations can only be declared inside a block. + } \ No newline at end of file diff --git a/tests/baselines/reference/awaitUsingDeclarations.10.js b/tests/baselines/reference/awaitUsingDeclarations.10.js new file mode 100644 index 0000000000000..6ddcffab885ae --- /dev/null +++ b/tests/baselines/reference/awaitUsingDeclarations.10.js @@ -0,0 +1,16 @@ +//// [tests/cases/conformance/statements/VariableStatements/usingDeclarations/awaitUsingDeclarations.10.ts] //// + +//// [awaitUsingDeclarations.10.ts] +export {}; + +declare var x: any; +async function f() { + if (x) await using a = null; +} + +//// [awaitUsingDeclarations.10.js] +async function f() { + if (x) + await using a = null; +} +export {}; diff --git a/tests/baselines/reference/awaitUsingDeclarations.11.errors.txt b/tests/baselines/reference/awaitUsingDeclarations.11.errors.txt new file mode 100644 index 0000000000000..51de3ea074156 --- /dev/null +++ b/tests/baselines/reference/awaitUsingDeclarations.11.errors.txt @@ -0,0 +1,12 @@ +awaitUsingDeclarations.11.ts(1,1): error TS1495: 'export' modifier cannot appear on an 'await using' declaration. +awaitUsingDeclarations.11.ts(2,1): error TS1495: 'declare' modifier cannot appear on an 'await using' declaration. + + +==== awaitUsingDeclarations.11.ts (2 errors) ==== + export await using x = null; + ~~~~~~ +!!! error TS1495: 'export' modifier cannot appear on an 'await using' declaration. + declare await using y: null; + ~~~~~~~ +!!! error TS1495: 'declare' modifier cannot appear on an 'await using' declaration. + \ No newline at end of file diff --git a/tests/baselines/reference/awaitUsingDeclarations.11.js b/tests/baselines/reference/awaitUsingDeclarations.11.js new file mode 100644 index 0000000000000..76087f4f9f26e --- /dev/null +++ b/tests/baselines/reference/awaitUsingDeclarations.11.js @@ -0,0 +1,9 @@ +//// [tests/cases/conformance/statements/VariableStatements/usingDeclarations/awaitUsingDeclarations.11.ts] //// + +//// [awaitUsingDeclarations.11.ts] +export await using x = null; +declare await using y: null; + + +//// [awaitUsingDeclarations.11.js] +export await using x = null; diff --git a/tests/baselines/reference/awaitUsingDeclarations.12.errors.txt b/tests/baselines/reference/awaitUsingDeclarations.12.errors.txt new file mode 100644 index 0000000000000..623aecbad99b6 --- /dev/null +++ b/tests/baselines/reference/awaitUsingDeclarations.12.errors.txt @@ -0,0 +1,9 @@ +awaitUsingDeclarations.12.ts(2,21): error TS2851: The initializer of an 'await using' declaration must be either an object with a '[Symbol.asyncDispose]()' or '[Symbol.dispose]()' method, or be 'null' or 'undefined'. + + +==== awaitUsingDeclarations.12.ts (1 errors) ==== + async function f() { + await using x = {}; + ~~ +!!! error TS2851: The initializer of an 'await using' declaration must be either an object with a '[Symbol.asyncDispose]()' or '[Symbol.dispose]()' method, or be 'null' or 'undefined'. + } \ No newline at end of file diff --git a/tests/baselines/reference/awaitUsingDeclarations.12.js b/tests/baselines/reference/awaitUsingDeclarations.12.js new file mode 100644 index 0000000000000..32de989383c3c --- /dev/null +++ b/tests/baselines/reference/awaitUsingDeclarations.12.js @@ -0,0 +1,11 @@ +//// [tests/cases/conformance/statements/VariableStatements/usingDeclarations/awaitUsingDeclarations.12.ts] //// + +//// [awaitUsingDeclarations.12.ts] +async function f() { + await using x = {}; +} + +//// [awaitUsingDeclarations.12.js] +async function f() { + await using x = {}; +} diff --git a/tests/baselines/reference/awaitUsingDeclarations.13.errors.txt b/tests/baselines/reference/awaitUsingDeclarations.13.errors.txt new file mode 100644 index 0000000000000..abe9121a84204 --- /dev/null +++ b/tests/baselines/reference/awaitUsingDeclarations.13.errors.txt @@ -0,0 +1,15 @@ +awaitUsingDeclarations.13.ts(1,1): error TS2853: 'await using' statements are only allowed at the top level of a file when that file is a module, but this file has no imports or exports. Consider adding an empty 'export {}' to make this file a module. +awaitUsingDeclarations.13.ts(4,5): error TS2852: 'await using' statements are only allowed within async functions and at the top levels of modules. + + +==== awaitUsingDeclarations.13.ts (2 errors) ==== + await using x = null; + ~~~~~ +!!! error TS2853: 'await using' statements are only allowed at the top level of a file when that file is a module, but this file has no imports or exports. Consider adding an empty 'export {}' to make this file a module. + + function f() { + await using x = null; + ~~~~~ +!!! error TS2852: 'await using' statements are only allowed within async functions and at the top levels of modules. +!!! related TS1356 awaitUsingDeclarations.13.ts:3:10: Did you mean to mark this function as 'async'? + } \ No newline at end of file diff --git a/tests/baselines/reference/awaitUsingDeclarations.13.js b/tests/baselines/reference/awaitUsingDeclarations.13.js new file mode 100644 index 0000000000000..f8a1d89e9f2ee --- /dev/null +++ b/tests/baselines/reference/awaitUsingDeclarations.13.js @@ -0,0 +1,14 @@ +//// [tests/cases/conformance/statements/VariableStatements/usingDeclarations/awaitUsingDeclarations.13.ts] //// + +//// [awaitUsingDeclarations.13.ts] +await using x = null; + +function f() { + await using x = null; +} + +//// [awaitUsingDeclarations.13.js] +await using x = null; +function f() { + await using x = null; +} diff --git a/tests/baselines/reference/awaitUsingDeclarations.14.errors.txt b/tests/baselines/reference/awaitUsingDeclarations.14.errors.txt new file mode 100644 index 0000000000000..bffdf3a179e43 --- /dev/null +++ b/tests/baselines/reference/awaitUsingDeclarations.14.errors.txt @@ -0,0 +1,18 @@ +awaitUsingDeclarations.14.ts(3,9): error TS18054: 'await using' statements cannot be used inside a class static block. +awaitUsingDeclarations.14.ts(5,13): error TS18054: 'await using' statements cannot be used inside a class static block. + + +==== awaitUsingDeclarations.14.ts (2 errors) ==== + class C { + static { + await using x = null; + ~~~~~~~~~~~~~~~~~~~~ +!!! error TS18054: 'await using' statements cannot be used inside a class static block. + { + await using y = null; + ~~~~~~~~~~~~~~~~~~~~ +!!! error TS18054: 'await using' statements cannot be used inside a class static block. + } + } + } + \ No newline at end of file diff --git a/tests/baselines/reference/awaitUsingDeclarations.14.js b/tests/baselines/reference/awaitUsingDeclarations.14.js new file mode 100644 index 0000000000000..223c913e74869 --- /dev/null +++ b/tests/baselines/reference/awaitUsingDeclarations.14.js @@ -0,0 +1,22 @@ +//// [tests/cases/conformance/statements/VariableStatements/usingDeclarations/awaitUsingDeclarations.14.ts] //// + +//// [awaitUsingDeclarations.14.ts] +class C { + static { + await using x = null; + { + await using y = null; + } + } +} + + +//// [awaitUsingDeclarations.14.js] +class C { + static { + await using x = null; + { + await using y = null; + } + } +} diff --git a/tests/baselines/reference/awaitUsingDeclarations.15.js b/tests/baselines/reference/awaitUsingDeclarations.15.js new file mode 100644 index 0000000000000..af20512995cc6 --- /dev/null +++ b/tests/baselines/reference/awaitUsingDeclarations.15.js @@ -0,0 +1,11 @@ +//// [tests/cases/conformance/statements/VariableStatements/usingDeclarations/awaitUsingDeclarations.15.ts] //// + +//// [awaitUsingDeclarations.15.ts] +async function f() { + await using _ = { async [Symbol.asyncDispose]() {} }; +} + +//// [awaitUsingDeclarations.15.js] +async function f() { + await using _ = { async [Symbol.asyncDispose]() { } }; +} diff --git a/tests/baselines/reference/awaitUsingDeclarations.2(target=es2015).errors.txt b/tests/baselines/reference/awaitUsingDeclarations.2(target=es2015).errors.txt new file mode 100644 index 0000000000000..b6d2d529f8b04 --- /dev/null +++ b/tests/baselines/reference/awaitUsingDeclarations.2(target=es2015).errors.txt @@ -0,0 +1,12 @@ +awaitUsingDeclarations.2.ts(2,5): error TS2854: Top-level 'await using' statements are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', 'node16', or 'nodenext', and the 'target' option is set to 'es2017' or higher. + + +==== awaitUsingDeclarations.2.ts (1 errors) ==== + { + await using d1 = { async [Symbol.asyncDispose]() {} }, + ~~~~~ +!!! error TS2854: Top-level 'await using' statements are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', 'node16', or 'nodenext', and the 'target' option is set to 'es2017' or higher. + d2 = { async [Symbol.asyncDispose]() {} }; + } + + export {}; \ No newline at end of file diff --git a/tests/baselines/reference/awaitUsingDeclarations.2(target=es2015).js b/tests/baselines/reference/awaitUsingDeclarations.2(target=es2015).js new file mode 100644 index 0000000000000..03565e6b338af --- /dev/null +++ b/tests/baselines/reference/awaitUsingDeclarations.2(target=es2015).js @@ -0,0 +1,85 @@ +//// [tests/cases/conformance/statements/VariableStatements/usingDeclarations/awaitUsingDeclarations.2.ts] //// + +//// [awaitUsingDeclarations.2.ts] +{ + await using d1 = { async [Symbol.asyncDispose]() {} }, + d2 = { async [Symbol.asyncDispose]() {} }; +} + +export {}; + +//// [awaitUsingDeclarations.2.js] +var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { + function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } + return new (P || (P = Promise))(function (resolve, reject) { + function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } + function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } + function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } + step((generator = generator.apply(thisArg, _arguments || [])).next()); + }); +}; +var __addDisposableResource = (this && this.__addDisposableResource) || function (env, value, async) { + if (value !== null && value !== void 0) { + if (typeof value !== "object") throw new TypeError("Object expected."); + var dispose; + if (async) { + if (!Symbol.asyncDispose) throw new TypeError("Symbol.asyncDispose is not defined."); + dispose = value[Symbol.asyncDispose]; + } + if (dispose === void 0) { + if (!Symbol.dispose) throw new TypeError("Symbol.dispose is not defined."); + dispose = value[Symbol.dispose]; + } + if (typeof dispose !== "function") throw new TypeError("Object not disposable."); + env.stack.push({ value: value, dispose: dispose, async: async }); + } + else if (async) { + env.stack.push({ async: true }); + } + return value; +}; +var __disposeResources = (this && this.__disposeResources) || (function (SuppressedError) { + return function (env) { + function fail(e) { + env.error = env.hasError ? new SuppressedError(e, env.error, "An error was suppressed during disposal.") : e; + env.hasError = true; + } + function next() { + while (env.stack.length) { + var rec = env.stack.pop(); + try { + var result = rec.dispose && rec.dispose.call(rec.value); + if (rec.async) return Promise.resolve(result).then(next, function(e) { fail(e); return next(); }); + } + catch (e) { + fail(e); + } + } + if (env.hasError) throw env.error; + } + return next(); + }; +})(typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) { + var e = new Error(message); + return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e; +}); +{ + const env_1 = { stack: [], error: void 0, hasError: false }; + try { + const d1 = __addDisposableResource(env_1, { [Symbol.asyncDispose]() { + return __awaiter(this, void 0, void 0, function* () { }); + } }, true), d2 = __addDisposableResource(env_1, { [Symbol.asyncDispose]() { + return __awaiter(this, void 0, void 0, function* () { }); + } }, true); + } + catch (e_1) { + env_1.error = e_1; + env_1.hasError = true; + } + finally { + const result_1 = __disposeResources(env_1); + if (result_1) + await result_1; + } +} +export {}; diff --git a/tests/baselines/reference/awaitUsingDeclarations.2(target=es2017).js b/tests/baselines/reference/awaitUsingDeclarations.2(target=es2017).js new file mode 100644 index 0000000000000..ab37b86fcecef --- /dev/null +++ b/tests/baselines/reference/awaitUsingDeclarations.2(target=es2017).js @@ -0,0 +1,72 @@ +//// [tests/cases/conformance/statements/VariableStatements/usingDeclarations/awaitUsingDeclarations.2.ts] //// + +//// [awaitUsingDeclarations.2.ts] +{ + await using d1 = { async [Symbol.asyncDispose]() {} }, + d2 = { async [Symbol.asyncDispose]() {} }; +} + +export {}; + +//// [awaitUsingDeclarations.2.js] +var __addDisposableResource = (this && this.__addDisposableResource) || function (env, value, async) { + if (value !== null && value !== void 0) { + if (typeof value !== "object") throw new TypeError("Object expected."); + var dispose; + if (async) { + if (!Symbol.asyncDispose) throw new TypeError("Symbol.asyncDispose is not defined."); + dispose = value[Symbol.asyncDispose]; + } + if (dispose === void 0) { + if (!Symbol.dispose) throw new TypeError("Symbol.dispose is not defined."); + dispose = value[Symbol.dispose]; + } + if (typeof dispose !== "function") throw new TypeError("Object not disposable."); + env.stack.push({ value: value, dispose: dispose, async: async }); + } + else if (async) { + env.stack.push({ async: true }); + } + return value; +}; +var __disposeResources = (this && this.__disposeResources) || (function (SuppressedError) { + return function (env) { + function fail(e) { + env.error = env.hasError ? new SuppressedError(e, env.error, "An error was suppressed during disposal.") : e; + env.hasError = true; + } + function next() { + while (env.stack.length) { + var rec = env.stack.pop(); + try { + var result = rec.dispose && rec.dispose.call(rec.value); + if (rec.async) return Promise.resolve(result).then(next, function(e) { fail(e); return next(); }); + } + catch (e) { + fail(e); + } + } + if (env.hasError) throw env.error; + } + return next(); + }; +})(typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) { + var e = new Error(message); + return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e; +}); +{ + const env_1 = { stack: [], error: void 0, hasError: false }; + try { + const d1 = __addDisposableResource(env_1, { async [Symbol.asyncDispose]() { } }, true), d2 = __addDisposableResource(env_1, { async [Symbol.asyncDispose]() { } }, true); + } + catch (e_1) { + env_1.error = e_1; + env_1.hasError = true; + } + finally { + const result_1 = __disposeResources(env_1); + if (result_1) + await result_1; + } +} +export {}; diff --git a/tests/baselines/reference/awaitUsingDeclarations.2(target=es2022).js b/tests/baselines/reference/awaitUsingDeclarations.2(target=es2022).js new file mode 100644 index 0000000000000..ab37b86fcecef --- /dev/null +++ b/tests/baselines/reference/awaitUsingDeclarations.2(target=es2022).js @@ -0,0 +1,72 @@ +//// [tests/cases/conformance/statements/VariableStatements/usingDeclarations/awaitUsingDeclarations.2.ts] //// + +//// [awaitUsingDeclarations.2.ts] +{ + await using d1 = { async [Symbol.asyncDispose]() {} }, + d2 = { async [Symbol.asyncDispose]() {} }; +} + +export {}; + +//// [awaitUsingDeclarations.2.js] +var __addDisposableResource = (this && this.__addDisposableResource) || function (env, value, async) { + if (value !== null && value !== void 0) { + if (typeof value !== "object") throw new TypeError("Object expected."); + var dispose; + if (async) { + if (!Symbol.asyncDispose) throw new TypeError("Symbol.asyncDispose is not defined."); + dispose = value[Symbol.asyncDispose]; + } + if (dispose === void 0) { + if (!Symbol.dispose) throw new TypeError("Symbol.dispose is not defined."); + dispose = value[Symbol.dispose]; + } + if (typeof dispose !== "function") throw new TypeError("Object not disposable."); + env.stack.push({ value: value, dispose: dispose, async: async }); + } + else if (async) { + env.stack.push({ async: true }); + } + return value; +}; +var __disposeResources = (this && this.__disposeResources) || (function (SuppressedError) { + return function (env) { + function fail(e) { + env.error = env.hasError ? new SuppressedError(e, env.error, "An error was suppressed during disposal.") : e; + env.hasError = true; + } + function next() { + while (env.stack.length) { + var rec = env.stack.pop(); + try { + var result = rec.dispose && rec.dispose.call(rec.value); + if (rec.async) return Promise.resolve(result).then(next, function(e) { fail(e); return next(); }); + } + catch (e) { + fail(e); + } + } + if (env.hasError) throw env.error; + } + return next(); + }; +})(typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) { + var e = new Error(message); + return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e; +}); +{ + const env_1 = { stack: [], error: void 0, hasError: false }; + try { + const d1 = __addDisposableResource(env_1, { async [Symbol.asyncDispose]() { } }, true), d2 = __addDisposableResource(env_1, { async [Symbol.asyncDispose]() { } }, true); + } + catch (e_1) { + env_1.error = e_1; + env_1.hasError = true; + } + finally { + const result_1 = __disposeResources(env_1); + if (result_1) + await result_1; + } +} +export {}; diff --git a/tests/baselines/reference/awaitUsingDeclarations.2(target=es5).errors.txt b/tests/baselines/reference/awaitUsingDeclarations.2(target=es5).errors.txt new file mode 100644 index 0000000000000..b6d2d529f8b04 --- /dev/null +++ b/tests/baselines/reference/awaitUsingDeclarations.2(target=es5).errors.txt @@ -0,0 +1,12 @@ +awaitUsingDeclarations.2.ts(2,5): error TS2854: Top-level 'await using' statements are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', 'node16', or 'nodenext', and the 'target' option is set to 'es2017' or higher. + + +==== awaitUsingDeclarations.2.ts (1 errors) ==== + { + await using d1 = { async [Symbol.asyncDispose]() {} }, + ~~~~~ +!!! error TS2854: Top-level 'await using' statements are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', 'node16', or 'nodenext', and the 'target' option is set to 'es2017' or higher. + d2 = { async [Symbol.asyncDispose]() {} }; + } + + export {}; \ No newline at end of file diff --git a/tests/baselines/reference/awaitUsingDeclarations.2(target=es5).js b/tests/baselines/reference/awaitUsingDeclarations.2(target=es5).js new file mode 100644 index 0000000000000..e9a87c08a112e --- /dev/null +++ b/tests/baselines/reference/awaitUsingDeclarations.2(target=es5).js @@ -0,0 +1,117 @@ +//// [tests/cases/conformance/statements/VariableStatements/usingDeclarations/awaitUsingDeclarations.2.ts] //// + +//// [awaitUsingDeclarations.2.ts] +{ + await using d1 = { async [Symbol.asyncDispose]() {} }, + d2 = { async [Symbol.asyncDispose]() {} }; +} + +export {}; + +//// [awaitUsingDeclarations.2.js] +var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { + function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } + return new (P || (P = Promise))(function (resolve, reject) { + function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } + function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } + function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } + step((generator = generator.apply(thisArg, _arguments || [])).next()); + }); +}; +var __generator = (this && this.__generator) || function (thisArg, body) { + var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g; + return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g; + function verb(n) { return function (v) { return step([n, v]); }; } + function step(op) { + if (f) throw new TypeError("Generator is already executing."); + while (g && (g = 0, op[0] && (_ = 0)), _) try { + if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t; + if (y = 0, t) op = [op[0] & 2, t.value]; + switch (op[0]) { + case 0: case 1: t = op; break; + case 4: _.label++; return { value: op[1], done: false }; + case 5: _.label++; y = op[1]; op = [0]; continue; + case 7: op = _.ops.pop(); _.trys.pop(); continue; + default: + if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; } + if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; } + if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; } + if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; } + if (t[2]) _.ops.pop(); + _.trys.pop(); continue; + } + op = body.call(thisArg, _); + } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; } + if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true }; + } +}; +var __addDisposableResource = (this && this.__addDisposableResource) || function (env, value, async) { + if (value !== null && value !== void 0) { + if (typeof value !== "object") throw new TypeError("Object expected."); + var dispose; + if (async) { + if (!Symbol.asyncDispose) throw new TypeError("Symbol.asyncDispose is not defined."); + dispose = value[Symbol.asyncDispose]; + } + if (dispose === void 0) { + if (!Symbol.dispose) throw new TypeError("Symbol.dispose is not defined."); + dispose = value[Symbol.dispose]; + } + if (typeof dispose !== "function") throw new TypeError("Object not disposable."); + env.stack.push({ value: value, dispose: dispose, async: async }); + } + else if (async) { + env.stack.push({ async: true }); + } + return value; +}; +var __disposeResources = (this && this.__disposeResources) || (function (SuppressedError) { + return function (env) { + function fail(e) { + env.error = env.hasError ? new SuppressedError(e, env.error, "An error was suppressed during disposal.") : e; + env.hasError = true; + } + function next() { + while (env.stack.length) { + var rec = env.stack.pop(); + try { + var result = rec.dispose && rec.dispose.call(rec.value); + if (rec.async) return Promise.resolve(result).then(next, function(e) { fail(e); return next(); }); + } + catch (e) { + fail(e); + } + } + if (env.hasError) throw env.error; + } + return next(); + }; +})(typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) { + var e = new Error(message); + return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e; +}); +var _a, _b; +{ + var env_1 = { stack: [], error: void 0, hasError: false }; + try { + var d1 = __addDisposableResource(env_1, (_a = {}, _a[Symbol.asyncDispose] = function () { + return __awaiter(this, void 0, void 0, function () { return __generator(this, function (_a) { + return [2 /*return*/]; + }); }); + }, _a), true), d2 = __addDisposableResource(env_1, (_b = {}, _b[Symbol.asyncDispose] = function () { + return __awaiter(this, void 0, void 0, function () { return __generator(this, function (_a) { + return [2 /*return*/]; + }); }); + }, _b), true); + } + catch (e_1) { + env_1.error = e_1; + env_1.hasError = true; + } + finally { + var result_1 = __disposeResources(env_1); + if (result_1) + await result_1; + } +} +export {}; diff --git a/tests/baselines/reference/awaitUsingDeclarations.2(target=esnext).js b/tests/baselines/reference/awaitUsingDeclarations.2(target=esnext).js new file mode 100644 index 0000000000000..081606105eef8 --- /dev/null +++ b/tests/baselines/reference/awaitUsingDeclarations.2(target=esnext).js @@ -0,0 +1,15 @@ +//// [tests/cases/conformance/statements/VariableStatements/usingDeclarations/awaitUsingDeclarations.2.ts] //// + +//// [awaitUsingDeclarations.2.ts] +{ + await using d1 = { async [Symbol.asyncDispose]() {} }, + d2 = { async [Symbol.asyncDispose]() {} }; +} + +export {}; + +//// [awaitUsingDeclarations.2.js] +{ + await using d1 = { async [Symbol.asyncDispose]() { } }, d2 = { async [Symbol.asyncDispose]() { } }; +} +export {}; diff --git a/tests/baselines/reference/awaitUsingDeclarations.3(target=es2015).errors.txt b/tests/baselines/reference/awaitUsingDeclarations.3(target=es2015).errors.txt new file mode 100644 index 0000000000000..955e5041b7826 --- /dev/null +++ b/tests/baselines/reference/awaitUsingDeclarations.3(target=es2015).errors.txt @@ -0,0 +1,14 @@ +awaitUsingDeclarations.3.ts(2,5): error TS2854: Top-level 'await using' statements are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', 'node16', or 'nodenext', and the 'target' option is set to 'es2017' or higher. + + +==== awaitUsingDeclarations.3.ts (1 errors) ==== + { + await using d1 = { async [Symbol.asyncDispose]() {} }, + ~~~~~ +!!! error TS2854: Top-level 'await using' statements are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', 'node16', or 'nodenext', and the 'target' option is set to 'es2017' or higher. + d2 = null, + d3 = undefined, + d4 = { [Symbol.dispose]() {} }; + } + + export {}; \ No newline at end of file diff --git a/tests/baselines/reference/awaitUsingDeclarations.3(target=es2015).js b/tests/baselines/reference/awaitUsingDeclarations.3(target=es2015).js new file mode 100644 index 0000000000000..4b8939b215b64 --- /dev/null +++ b/tests/baselines/reference/awaitUsingDeclarations.3(target=es2015).js @@ -0,0 +1,85 @@ +//// [tests/cases/conformance/statements/VariableStatements/usingDeclarations/awaitUsingDeclarations.3.ts] //// + +//// [awaitUsingDeclarations.3.ts] +{ + await using d1 = { async [Symbol.asyncDispose]() {} }, + d2 = null, + d3 = undefined, + d4 = { [Symbol.dispose]() {} }; +} + +export {}; + +//// [awaitUsingDeclarations.3.js] +var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { + function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } + return new (P || (P = Promise))(function (resolve, reject) { + function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } + function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } + function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } + step((generator = generator.apply(thisArg, _arguments || [])).next()); + }); +}; +var __addDisposableResource = (this && this.__addDisposableResource) || function (env, value, async) { + if (value !== null && value !== void 0) { + if (typeof value !== "object") throw new TypeError("Object expected."); + var dispose; + if (async) { + if (!Symbol.asyncDispose) throw new TypeError("Symbol.asyncDispose is not defined."); + dispose = value[Symbol.asyncDispose]; + } + if (dispose === void 0) { + if (!Symbol.dispose) throw new TypeError("Symbol.dispose is not defined."); + dispose = value[Symbol.dispose]; + } + if (typeof dispose !== "function") throw new TypeError("Object not disposable."); + env.stack.push({ value: value, dispose: dispose, async: async }); + } + else if (async) { + env.stack.push({ async: true }); + } + return value; +}; +var __disposeResources = (this && this.__disposeResources) || (function (SuppressedError) { + return function (env) { + function fail(e) { + env.error = env.hasError ? new SuppressedError(e, env.error, "An error was suppressed during disposal.") : e; + env.hasError = true; + } + function next() { + while (env.stack.length) { + var rec = env.stack.pop(); + try { + var result = rec.dispose && rec.dispose.call(rec.value); + if (rec.async) return Promise.resolve(result).then(next, function(e) { fail(e); return next(); }); + } + catch (e) { + fail(e); + } + } + if (env.hasError) throw env.error; + } + return next(); + }; +})(typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) { + var e = new Error(message); + return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e; +}); +{ + const env_1 = { stack: [], error: void 0, hasError: false }; + try { + const d1 = __addDisposableResource(env_1, { [Symbol.asyncDispose]() { + return __awaiter(this, void 0, void 0, function* () { }); + } }, true), d2 = __addDisposableResource(env_1, null, true), d3 = __addDisposableResource(env_1, undefined, true), d4 = __addDisposableResource(env_1, { [Symbol.dispose]() { } }, true); + } + catch (e_1) { + env_1.error = e_1; + env_1.hasError = true; + } + finally { + const result_1 = __disposeResources(env_1); + if (result_1) + await result_1; + } +} +export {}; diff --git a/tests/baselines/reference/awaitUsingDeclarations.3(target=es2017).js b/tests/baselines/reference/awaitUsingDeclarations.3(target=es2017).js new file mode 100644 index 0000000000000..2edb5db731e2c --- /dev/null +++ b/tests/baselines/reference/awaitUsingDeclarations.3(target=es2017).js @@ -0,0 +1,74 @@ +//// [tests/cases/conformance/statements/VariableStatements/usingDeclarations/awaitUsingDeclarations.3.ts] //// + +//// [awaitUsingDeclarations.3.ts] +{ + await using d1 = { async [Symbol.asyncDispose]() {} }, + d2 = null, + d3 = undefined, + d4 = { [Symbol.dispose]() {} }; +} + +export {}; + +//// [awaitUsingDeclarations.3.js] +var __addDisposableResource = (this && this.__addDisposableResource) || function (env, value, async) { + if (value !== null && value !== void 0) { + if (typeof value !== "object") throw new TypeError("Object expected."); + var dispose; + if (async) { + if (!Symbol.asyncDispose) throw new TypeError("Symbol.asyncDispose is not defined."); + dispose = value[Symbol.asyncDispose]; + } + if (dispose === void 0) { + if (!Symbol.dispose) throw new TypeError("Symbol.dispose is not defined."); + dispose = value[Symbol.dispose]; + } + if (typeof dispose !== "function") throw new TypeError("Object not disposable."); + env.stack.push({ value: value, dispose: dispose, async: async }); + } + else if (async) { + env.stack.push({ async: true }); + } + return value; +}; +var __disposeResources = (this && this.__disposeResources) || (function (SuppressedError) { + return function (env) { + function fail(e) { + env.error = env.hasError ? new SuppressedError(e, env.error, "An error was suppressed during disposal.") : e; + env.hasError = true; + } + function next() { + while (env.stack.length) { + var rec = env.stack.pop(); + try { + var result = rec.dispose && rec.dispose.call(rec.value); + if (rec.async) return Promise.resolve(result).then(next, function(e) { fail(e); return next(); }); + } + catch (e) { + fail(e); + } + } + if (env.hasError) throw env.error; + } + return next(); + }; +})(typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) { + var e = new Error(message); + return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e; +}); +{ + const env_1 = { stack: [], error: void 0, hasError: false }; + try { + const d1 = __addDisposableResource(env_1, { async [Symbol.asyncDispose]() { } }, true), d2 = __addDisposableResource(env_1, null, true), d3 = __addDisposableResource(env_1, undefined, true), d4 = __addDisposableResource(env_1, { [Symbol.dispose]() { } }, true); + } + catch (e_1) { + env_1.error = e_1; + env_1.hasError = true; + } + finally { + const result_1 = __disposeResources(env_1); + if (result_1) + await result_1; + } +} +export {}; diff --git a/tests/baselines/reference/awaitUsingDeclarations.3(target=es2022).js b/tests/baselines/reference/awaitUsingDeclarations.3(target=es2022).js new file mode 100644 index 0000000000000..2edb5db731e2c --- /dev/null +++ b/tests/baselines/reference/awaitUsingDeclarations.3(target=es2022).js @@ -0,0 +1,74 @@ +//// [tests/cases/conformance/statements/VariableStatements/usingDeclarations/awaitUsingDeclarations.3.ts] //// + +//// [awaitUsingDeclarations.3.ts] +{ + await using d1 = { async [Symbol.asyncDispose]() {} }, + d2 = null, + d3 = undefined, + d4 = { [Symbol.dispose]() {} }; +} + +export {}; + +//// [awaitUsingDeclarations.3.js] +var __addDisposableResource = (this && this.__addDisposableResource) || function (env, value, async) { + if (value !== null && value !== void 0) { + if (typeof value !== "object") throw new TypeError("Object expected."); + var dispose; + if (async) { + if (!Symbol.asyncDispose) throw new TypeError("Symbol.asyncDispose is not defined."); + dispose = value[Symbol.asyncDispose]; + } + if (dispose === void 0) { + if (!Symbol.dispose) throw new TypeError("Symbol.dispose is not defined."); + dispose = value[Symbol.dispose]; + } + if (typeof dispose !== "function") throw new TypeError("Object not disposable."); + env.stack.push({ value: value, dispose: dispose, async: async }); + } + else if (async) { + env.stack.push({ async: true }); + } + return value; +}; +var __disposeResources = (this && this.__disposeResources) || (function (SuppressedError) { + return function (env) { + function fail(e) { + env.error = env.hasError ? new SuppressedError(e, env.error, "An error was suppressed during disposal.") : e; + env.hasError = true; + } + function next() { + while (env.stack.length) { + var rec = env.stack.pop(); + try { + var result = rec.dispose && rec.dispose.call(rec.value); + if (rec.async) return Promise.resolve(result).then(next, function(e) { fail(e); return next(); }); + } + catch (e) { + fail(e); + } + } + if (env.hasError) throw env.error; + } + return next(); + }; +})(typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) { + var e = new Error(message); + return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e; +}); +{ + const env_1 = { stack: [], error: void 0, hasError: false }; + try { + const d1 = __addDisposableResource(env_1, { async [Symbol.asyncDispose]() { } }, true), d2 = __addDisposableResource(env_1, null, true), d3 = __addDisposableResource(env_1, undefined, true), d4 = __addDisposableResource(env_1, { [Symbol.dispose]() { } }, true); + } + catch (e_1) { + env_1.error = e_1; + env_1.hasError = true; + } + finally { + const result_1 = __disposeResources(env_1); + if (result_1) + await result_1; + } +} +export {}; diff --git a/tests/baselines/reference/awaitUsingDeclarations.3(target=es5).errors.txt b/tests/baselines/reference/awaitUsingDeclarations.3(target=es5).errors.txt new file mode 100644 index 0000000000000..955e5041b7826 --- /dev/null +++ b/tests/baselines/reference/awaitUsingDeclarations.3(target=es5).errors.txt @@ -0,0 +1,14 @@ +awaitUsingDeclarations.3.ts(2,5): error TS2854: Top-level 'await using' statements are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', 'node16', or 'nodenext', and the 'target' option is set to 'es2017' or higher. + + +==== awaitUsingDeclarations.3.ts (1 errors) ==== + { + await using d1 = { async [Symbol.asyncDispose]() {} }, + ~~~~~ +!!! error TS2854: Top-level 'await using' statements are only allowed when the 'module' option is set to 'es2022', 'esnext', 'system', 'node16', or 'nodenext', and the 'target' option is set to 'es2017' or higher. + d2 = null, + d3 = undefined, + d4 = { [Symbol.dispose]() {} }; + } + + export {}; \ No newline at end of file diff --git a/tests/baselines/reference/awaitUsingDeclarations.3(target=es5).js b/tests/baselines/reference/awaitUsingDeclarations.3(target=es5).js new file mode 100644 index 0000000000000..2cc2c25f5f459 --- /dev/null +++ b/tests/baselines/reference/awaitUsingDeclarations.3(target=es5).js @@ -0,0 +1,115 @@ +//// [tests/cases/conformance/statements/VariableStatements/usingDeclarations/awaitUsingDeclarations.3.ts] //// + +//// [awaitUsingDeclarations.3.ts] +{ + await using d1 = { async [Symbol.asyncDispose]() {} }, + d2 = null, + d3 = undefined, + d4 = { [Symbol.dispose]() {} }; +} + +export {}; + +//// [awaitUsingDeclarations.3.js] +var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { + function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } + return new (P || (P = Promise))(function (resolve, reject) { + function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } + function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } + function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } + step((generator = generator.apply(thisArg, _arguments || [])).next()); + }); +}; +var __generator = (this && this.__generator) || function (thisArg, body) { + var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g; + return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g; + function verb(n) { return function (v) { return step([n, v]); }; } + function step(op) { + if (f) throw new TypeError("Generator is already executing."); + while (g && (g = 0, op[0] && (_ = 0)), _) try { + if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t; + if (y = 0, t) op = [op[0] & 2, t.value]; + switch (op[0]) { + case 0: case 1: t = op; break; + case 4: _.label++; return { value: op[1], done: false }; + case 5: _.label++; y = op[1]; op = [0]; continue; + case 7: op = _.ops.pop(); _.trys.pop(); continue; + default: + if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; } + if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; } + if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; } + if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; } + if (t[2]) _.ops.pop(); + _.trys.pop(); continue; + } + op = body.call(thisArg, _); + } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; } + if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true }; + } +}; +var __addDisposableResource = (this && this.__addDisposableResource) || function (env, value, async) { + if (value !== null && value !== void 0) { + if (typeof value !== "object") throw new TypeError("Object expected."); + var dispose; + if (async) { + if (!Symbol.asyncDispose) throw new TypeError("Symbol.asyncDispose is not defined."); + dispose = value[Symbol.asyncDispose]; + } + if (dispose === void 0) { + if (!Symbol.dispose) throw new TypeError("Symbol.dispose is not defined."); + dispose = value[Symbol.dispose]; + } + if (typeof dispose !== "function") throw new TypeError("Object not disposable."); + env.stack.push({ value: value, dispose: dispose, async: async }); + } + else if (async) { + env.stack.push({ async: true }); + } + return value; +}; +var __disposeResources = (this && this.__disposeResources) || (function (SuppressedError) { + return function (env) { + function fail(e) { + env.error = env.hasError ? new SuppressedError(e, env.error, "An error was suppressed during disposal.") : e; + env.hasError = true; + } + function next() { + while (env.stack.length) { + var rec = env.stack.pop(); + try { + var result = rec.dispose && rec.dispose.call(rec.value); + if (rec.async) return Promise.resolve(result).then(next, function(e) { fail(e); return next(); }); + } + catch (e) { + fail(e); + } + } + if (env.hasError) throw env.error; + } + return next(); + }; +})(typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) { + var e = new Error(message); + return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e; +}); +var _a, _b; +{ + var env_1 = { stack: [], error: void 0, hasError: false }; + try { + var d1 = __addDisposableResource(env_1, (_a = {}, _a[Symbol.asyncDispose] = function () { + return __awaiter(this, void 0, void 0, function () { return __generator(this, function (_a) { + return [2 /*return*/]; + }); }); + }, _a), true), d2 = __addDisposableResource(env_1, null, true), d3 = __addDisposableResource(env_1, undefined, true), d4 = __addDisposableResource(env_1, (_b = {}, _b[Symbol.dispose] = function () { }, _b), true); + } + catch (e_1) { + env_1.error = e_1; + env_1.hasError = true; + } + finally { + var result_1 = __disposeResources(env_1); + if (result_1) + await result_1; + } +} +export {}; diff --git a/tests/baselines/reference/awaitUsingDeclarations.3(target=esnext).js b/tests/baselines/reference/awaitUsingDeclarations.3(target=esnext).js new file mode 100644 index 0000000000000..fa149c69753d2 --- /dev/null +++ b/tests/baselines/reference/awaitUsingDeclarations.3(target=esnext).js @@ -0,0 +1,17 @@ +//// [tests/cases/conformance/statements/VariableStatements/usingDeclarations/awaitUsingDeclarations.3.ts] //// + +//// [awaitUsingDeclarations.3.ts] +{ + await using d1 = { async [Symbol.asyncDispose]() {} }, + d2 = null, + d3 = undefined, + d4 = { [Symbol.dispose]() {} }; +} + +export {}; + +//// [awaitUsingDeclarations.3.js] +{ + await using d1 = { async [Symbol.asyncDispose]() { } }, d2 = null, d3 = undefined, d4 = { [Symbol.dispose]() { } }; +} +export {}; diff --git a/tests/baselines/reference/awaitUsingDeclarations.4.errors.txt b/tests/baselines/reference/awaitUsingDeclarations.4.errors.txt new file mode 100644 index 0000000000000..7fb6182713739 --- /dev/null +++ b/tests/baselines/reference/awaitUsingDeclarations.4.errors.txt @@ -0,0 +1,17 @@ +awaitUsingDeclarations.4.ts(2,11): error TS2304: Cannot find name 'using'. +awaitUsingDeclarations.4.ts(2,18): error TS2304: Cannot find name 'a'. +awaitUsingDeclarations.4.ts(2,21): error TS1005: ';' expected. + + +==== awaitUsingDeclarations.4.ts (3 errors) ==== + { + await using [a] = null; + ~~~~~ +!!! error TS2304: Cannot find name 'using'. + ~ +!!! error TS2304: Cannot find name 'a'. + ~ +!!! error TS1005: ';' expected. + } + + export {}; \ No newline at end of file diff --git a/tests/baselines/reference/awaitUsingDeclarations.4.js b/tests/baselines/reference/awaitUsingDeclarations.4.js new file mode 100644 index 0000000000000..887cb629eba02 --- /dev/null +++ b/tests/baselines/reference/awaitUsingDeclarations.4.js @@ -0,0 +1,15 @@ +//// [tests/cases/conformance/statements/VariableStatements/usingDeclarations/awaitUsingDeclarations.4.ts] //// + +//// [awaitUsingDeclarations.4.ts] +{ + await using [a] = null; +} + +export {}; + +//// [awaitUsingDeclarations.4.js] +{ + await using[a]; + null; +} +export {}; diff --git a/tests/baselines/reference/awaitUsingDeclarations.5.errors.txt b/tests/baselines/reference/awaitUsingDeclarations.5.errors.txt new file mode 100644 index 0000000000000..370cc3a6c7a45 --- /dev/null +++ b/tests/baselines/reference/awaitUsingDeclarations.5.errors.txt @@ -0,0 +1,16 @@ +awaitUsingDeclarations.5.ts(3,17): error TS1492: 'await using' declarations may not have binding patterns. +awaitUsingDeclarations.5.ts(3,17): error TS2488: Type 'null' must have a '[Symbol.iterator]()' method that returns an iterator. + + +==== awaitUsingDeclarations.5.ts (2 errors) ==== + { + await using a = null, + [b] = null, + ~~~ +!!! error TS1492: 'await using' declarations may not have binding patterns. + ~~~ +!!! error TS2488: Type 'null' must have a '[Symbol.iterator]()' method that returns an iterator. + c = null; + } + + export {}; \ No newline at end of file diff --git a/tests/baselines/reference/awaitUsingDeclarations.5.js b/tests/baselines/reference/awaitUsingDeclarations.5.js new file mode 100644 index 0000000000000..8a436907cdc89 --- /dev/null +++ b/tests/baselines/reference/awaitUsingDeclarations.5.js @@ -0,0 +1,16 @@ +//// [tests/cases/conformance/statements/VariableStatements/usingDeclarations/awaitUsingDeclarations.5.ts] //// + +//// [awaitUsingDeclarations.5.ts] +{ + await using a = null, + [b] = null, + c = null; +} + +export {}; + +//// [awaitUsingDeclarations.5.js] +{ + await using a = null, [b] = null, c = null; +} +export {}; diff --git a/tests/baselines/reference/awaitUsingDeclarations.6.errors.txt b/tests/baselines/reference/awaitUsingDeclarations.6.errors.txt new file mode 100644 index 0000000000000..7f471afa221e7 --- /dev/null +++ b/tests/baselines/reference/awaitUsingDeclarations.6.errors.txt @@ -0,0 +1,15 @@ +awaitUsingDeclarations.6.ts(2,17): error TS1492: 'await using' declarations may not have binding patterns. +awaitUsingDeclarations.6.ts(2,18): error TS2339: Property 'a' does not exist on type 'null'. + + +==== awaitUsingDeclarations.6.ts (2 errors) ==== + { + await using {a} = null; + ~~~ +!!! error TS1492: 'await using' declarations may not have binding patterns. + ~ +!!! error TS2339: Property 'a' does not exist on type 'null'. + } + + + export {}; \ No newline at end of file diff --git a/tests/baselines/reference/awaitUsingDeclarations.6.js b/tests/baselines/reference/awaitUsingDeclarations.6.js new file mode 100644 index 0000000000000..56ee8073b9dbd --- /dev/null +++ b/tests/baselines/reference/awaitUsingDeclarations.6.js @@ -0,0 +1,15 @@ +//// [tests/cases/conformance/statements/VariableStatements/usingDeclarations/awaitUsingDeclarations.6.ts] //// + +//// [awaitUsingDeclarations.6.ts] +{ + await using {a} = null; +} + + +export {}; + +//// [awaitUsingDeclarations.6.js] +{ + await using { a } = null; +} +export {}; diff --git a/tests/baselines/reference/awaitUsingDeclarations.7.errors.txt b/tests/baselines/reference/awaitUsingDeclarations.7.errors.txt new file mode 100644 index 0000000000000..c3061741e4f39 --- /dev/null +++ b/tests/baselines/reference/awaitUsingDeclarations.7.errors.txt @@ -0,0 +1,17 @@ +awaitUsingDeclarations.7.ts(2,5): error TS2853: 'await using' statements are only allowed at the top level of a file when that file is a module, but this file has no imports or exports. Consider adding an empty 'export {}' to make this file a module. +awaitUsingDeclarations.7.ts(3,17): error TS1492: 'await using' declarations may not have binding patterns. +awaitUsingDeclarations.7.ts(3,18): error TS2339: Property 'b' does not exist on type 'null'. + + +==== awaitUsingDeclarations.7.ts (3 errors) ==== + { + await using a = null, + ~~~~~ +!!! error TS2853: 'await using' statements are only allowed at the top level of a file when that file is a module, but this file has no imports or exports. Consider adding an empty 'export {}' to make this file a module. + {b} = null, + ~~~ +!!! error TS1492: 'await using' declarations may not have binding patterns. + ~ +!!! error TS2339: Property 'b' does not exist on type 'null'. + c = null; + } \ No newline at end of file diff --git a/tests/baselines/reference/awaitUsingDeclarations.7.js b/tests/baselines/reference/awaitUsingDeclarations.7.js new file mode 100644 index 0000000000000..c409558f39f9e --- /dev/null +++ b/tests/baselines/reference/awaitUsingDeclarations.7.js @@ -0,0 +1,13 @@ +//// [tests/cases/conformance/statements/VariableStatements/usingDeclarations/awaitUsingDeclarations.7.ts] //// + +//// [awaitUsingDeclarations.7.ts] +{ + await using a = null, + {b} = null, + c = null; +} + +//// [awaitUsingDeclarations.7.js] +{ + await using a = null, { b } = null, c = null; +} diff --git a/tests/baselines/reference/awaitUsingDeclarations.8.errors.txt b/tests/baselines/reference/awaitUsingDeclarations.8.errors.txt new file mode 100644 index 0000000000000..f564b8c3004c1 --- /dev/null +++ b/tests/baselines/reference/awaitUsingDeclarations.8.errors.txt @@ -0,0 +1,11 @@ +awaitUsingDeclarations.8.ts(2,17): error TS1155: 'await using' declarations must be initialized. + + +==== awaitUsingDeclarations.8.ts (1 errors) ==== + { + await using a; + ~ +!!! error TS1155: 'await using' declarations must be initialized. + } + + export {}; \ No newline at end of file diff --git a/tests/baselines/reference/awaitUsingDeclarations.8.js b/tests/baselines/reference/awaitUsingDeclarations.8.js new file mode 100644 index 0000000000000..5e42d69e70c57 --- /dev/null +++ b/tests/baselines/reference/awaitUsingDeclarations.8.js @@ -0,0 +1,14 @@ +//// [tests/cases/conformance/statements/VariableStatements/usingDeclarations/awaitUsingDeclarations.8.ts] //// + +//// [awaitUsingDeclarations.8.ts] +{ + await using a; +} + +export {}; + +//// [awaitUsingDeclarations.8.js] +{ + await using a; +} +export {}; diff --git a/tests/baselines/reference/awaitUsingDeclarations.9.errors.txt b/tests/baselines/reference/awaitUsingDeclarations.9.errors.txt new file mode 100644 index 0000000000000..51b6a5e7d194a --- /dev/null +++ b/tests/baselines/reference/awaitUsingDeclarations.9.errors.txt @@ -0,0 +1,12 @@ +error TS2318: Cannot find global type 'AsyncDisposable'. +error TS2318: Cannot find global type 'Disposable'. + + +!!! error TS2318: Cannot find global type 'AsyncDisposable'. +!!! error TS2318: Cannot find global type 'Disposable'. +==== awaitUsingDeclarations.9.ts (0 errors) ==== + { + await using a = null; + } + + export {}; \ No newline at end of file diff --git a/tests/baselines/reference/awaitUsingDeclarations.9.js b/tests/baselines/reference/awaitUsingDeclarations.9.js new file mode 100644 index 0000000000000..291c6d1330279 --- /dev/null +++ b/tests/baselines/reference/awaitUsingDeclarations.9.js @@ -0,0 +1,14 @@ +//// [tests/cases/conformance/statements/VariableStatements/usingDeclarations/awaitUsingDeclarations.9.ts] //// + +//// [awaitUsingDeclarations.9.ts] +{ + await using a = null; +} + +export {}; + +//// [awaitUsingDeclarations.9.js] +{ + await using a = null; +} +export {}; diff --git a/tests/baselines/reference/awaitUsingDeclarationsInFor(target=es2015).js b/tests/baselines/reference/awaitUsingDeclarationsInFor(target=es2015).js new file mode 100644 index 0000000000000..53a07f9602f37 --- /dev/null +++ b/tests/baselines/reference/awaitUsingDeclarationsInFor(target=es2015).js @@ -0,0 +1,89 @@ +//// [tests/cases/conformance/statements/VariableStatements/usingDeclarations/awaitUsingDeclarationsInFor.ts] //// + +//// [awaitUsingDeclarationsInFor.ts] +async function main() { + for (await using d1 = { [Symbol.dispose]() {} }, + d2 = { async [Symbol.asyncDispose]() {} }, + d3 = null, + d4 = undefined;;) { + } +} + +//// [awaitUsingDeclarationsInFor.js] +var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { + function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } + return new (P || (P = Promise))(function (resolve, reject) { + function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } + function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } + function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } + step((generator = generator.apply(thisArg, _arguments || [])).next()); + }); +}; +var __addDisposableResource = (this && this.__addDisposableResource) || function (env, value, async) { + if (value !== null && value !== void 0) { + if (typeof value !== "object") throw new TypeError("Object expected."); + var dispose; + if (async) { + if (!Symbol.asyncDispose) throw new TypeError("Symbol.asyncDispose is not defined."); + dispose = value[Symbol.asyncDispose]; + } + if (dispose === void 0) { + if (!Symbol.dispose) throw new TypeError("Symbol.dispose is not defined."); + dispose = value[Symbol.dispose]; + } + if (typeof dispose !== "function") throw new TypeError("Object not disposable."); + env.stack.push({ value: value, dispose: dispose, async: async }); + } + else if (async) { + env.stack.push({ async: true }); + } + return value; +}; +var __disposeResources = (this && this.__disposeResources) || (function (SuppressedError) { + return function (env) { + function fail(e) { + env.error = env.hasError ? new SuppressedError(e, env.error, "An error was suppressed during disposal.") : e; + env.hasError = true; + } + function next() { + while (env.stack.length) { + var rec = env.stack.pop(); + try { + var result = rec.dispose && rec.dispose.call(rec.value); + if (rec.async) return Promise.resolve(result).then(next, function(e) { fail(e); return next(); }); + } + catch (e) { + fail(e); + } + } + if (env.hasError) throw env.error; + } + return next(); + }; +})(typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) { + var e = new Error(message); + return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e; +}); +function main() { + return __awaiter(this, void 0, void 0, function* () { + { + const env_1 = { stack: [], error: void 0, hasError: false }; + try { + const d1 = __addDisposableResource(env_1, { [Symbol.dispose]() { } }, true), d2 = __addDisposableResource(env_1, { [Symbol.asyncDispose]() { + return __awaiter(this, void 0, void 0, function* () { }); + } }, true), d3 = __addDisposableResource(env_1, null, true), d4 = __addDisposableResource(env_1, undefined, true); + for (;;) { + } + } + catch (e_1) { + env_1.error = e_1; + env_1.hasError = true; + } + finally { + const result_1 = __disposeResources(env_1); + if (result_1) + yield result_1; + } + } + }); +} diff --git a/tests/baselines/reference/awaitUsingDeclarationsInFor(target=es2017).js b/tests/baselines/reference/awaitUsingDeclarationsInFor(target=es2017).js new file mode 100644 index 0000000000000..bbfca93a9c7d3 --- /dev/null +++ b/tests/baselines/reference/awaitUsingDeclarationsInFor(target=es2017).js @@ -0,0 +1,76 @@ +//// [tests/cases/conformance/statements/VariableStatements/usingDeclarations/awaitUsingDeclarationsInFor.ts] //// + +//// [awaitUsingDeclarationsInFor.ts] +async function main() { + for (await using d1 = { [Symbol.dispose]() {} }, + d2 = { async [Symbol.asyncDispose]() {} }, + d3 = null, + d4 = undefined;;) { + } +} + +//// [awaitUsingDeclarationsInFor.js] +var __addDisposableResource = (this && this.__addDisposableResource) || function (env, value, async) { + if (value !== null && value !== void 0) { + if (typeof value !== "object") throw new TypeError("Object expected."); + var dispose; + if (async) { + if (!Symbol.asyncDispose) throw new TypeError("Symbol.asyncDispose is not defined."); + dispose = value[Symbol.asyncDispose]; + } + if (dispose === void 0) { + if (!Symbol.dispose) throw new TypeError("Symbol.dispose is not defined."); + dispose = value[Symbol.dispose]; + } + if (typeof dispose !== "function") throw new TypeError("Object not disposable."); + env.stack.push({ value: value, dispose: dispose, async: async }); + } + else if (async) { + env.stack.push({ async: true }); + } + return value; +}; +var __disposeResources = (this && this.__disposeResources) || (function (SuppressedError) { + return function (env) { + function fail(e) { + env.error = env.hasError ? new SuppressedError(e, env.error, "An error was suppressed during disposal.") : e; + env.hasError = true; + } + function next() { + while (env.stack.length) { + var rec = env.stack.pop(); + try { + var result = rec.dispose && rec.dispose.call(rec.value); + if (rec.async) return Promise.resolve(result).then(next, function(e) { fail(e); return next(); }); + } + catch (e) { + fail(e); + } + } + if (env.hasError) throw env.error; + } + return next(); + }; +})(typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) { + var e = new Error(message); + return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e; +}); +async function main() { + { + const env_1 = { stack: [], error: void 0, hasError: false }; + try { + const d1 = __addDisposableResource(env_1, { [Symbol.dispose]() { } }, true), d2 = __addDisposableResource(env_1, { async [Symbol.asyncDispose]() { } }, true), d3 = __addDisposableResource(env_1, null, true), d4 = __addDisposableResource(env_1, undefined, true); + for (;;) { + } + } + catch (e_1) { + env_1.error = e_1; + env_1.hasError = true; + } + finally { + const result_1 = __disposeResources(env_1); + if (result_1) + await result_1; + } + } +} diff --git a/tests/baselines/reference/awaitUsingDeclarationsInFor(target=es2022).js b/tests/baselines/reference/awaitUsingDeclarationsInFor(target=es2022).js new file mode 100644 index 0000000000000..bbfca93a9c7d3 --- /dev/null +++ b/tests/baselines/reference/awaitUsingDeclarationsInFor(target=es2022).js @@ -0,0 +1,76 @@ +//// [tests/cases/conformance/statements/VariableStatements/usingDeclarations/awaitUsingDeclarationsInFor.ts] //// + +//// [awaitUsingDeclarationsInFor.ts] +async function main() { + for (await using d1 = { [Symbol.dispose]() {} }, + d2 = { async [Symbol.asyncDispose]() {} }, + d3 = null, + d4 = undefined;;) { + } +} + +//// [awaitUsingDeclarationsInFor.js] +var __addDisposableResource = (this && this.__addDisposableResource) || function (env, value, async) { + if (value !== null && value !== void 0) { + if (typeof value !== "object") throw new TypeError("Object expected."); + var dispose; + if (async) { + if (!Symbol.asyncDispose) throw new TypeError("Symbol.asyncDispose is not defined."); + dispose = value[Symbol.asyncDispose]; + } + if (dispose === void 0) { + if (!Symbol.dispose) throw new TypeError("Symbol.dispose is not defined."); + dispose = value[Symbol.dispose]; + } + if (typeof dispose !== "function") throw new TypeError("Object not disposable."); + env.stack.push({ value: value, dispose: dispose, async: async }); + } + else if (async) { + env.stack.push({ async: true }); + } + return value; +}; +var __disposeResources = (this && this.__disposeResources) || (function (SuppressedError) { + return function (env) { + function fail(e) { + env.error = env.hasError ? new SuppressedError(e, env.error, "An error was suppressed during disposal.") : e; + env.hasError = true; + } + function next() { + while (env.stack.length) { + var rec = env.stack.pop(); + try { + var result = rec.dispose && rec.dispose.call(rec.value); + if (rec.async) return Promise.resolve(result).then(next, function(e) { fail(e); return next(); }); + } + catch (e) { + fail(e); + } + } + if (env.hasError) throw env.error; + } + return next(); + }; +})(typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) { + var e = new Error(message); + return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e; +}); +async function main() { + { + const env_1 = { stack: [], error: void 0, hasError: false }; + try { + const d1 = __addDisposableResource(env_1, { [Symbol.dispose]() { } }, true), d2 = __addDisposableResource(env_1, { async [Symbol.asyncDispose]() { } }, true), d3 = __addDisposableResource(env_1, null, true), d4 = __addDisposableResource(env_1, undefined, true); + for (;;) { + } + } + catch (e_1) { + env_1.error = e_1; + env_1.hasError = true; + } + finally { + const result_1 = __disposeResources(env_1); + if (result_1) + await result_1; + } + } +} diff --git a/tests/baselines/reference/awaitUsingDeclarationsInFor(target=es5).js b/tests/baselines/reference/awaitUsingDeclarationsInFor(target=es5).js new file mode 100644 index 0000000000000..1ba3ab31d9458 --- /dev/null +++ b/tests/baselines/reference/awaitUsingDeclarationsInFor(target=es5).js @@ -0,0 +1,130 @@ +//// [tests/cases/conformance/statements/VariableStatements/usingDeclarations/awaitUsingDeclarationsInFor.ts] //// + +//// [awaitUsingDeclarationsInFor.ts] +async function main() { + for (await using d1 = { [Symbol.dispose]() {} }, + d2 = { async [Symbol.asyncDispose]() {} }, + d3 = null, + d4 = undefined;;) { + } +} + +//// [awaitUsingDeclarationsInFor.js] +var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { + function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } + return new (P || (P = Promise))(function (resolve, reject) { + function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } + function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } + function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } + step((generator = generator.apply(thisArg, _arguments || [])).next()); + }); +}; +var __generator = (this && this.__generator) || function (thisArg, body) { + var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g; + return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g; + function verb(n) { return function (v) { return step([n, v]); }; } + function step(op) { + if (f) throw new TypeError("Generator is already executing."); + while (g && (g = 0, op[0] && (_ = 0)), _) try { + if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t; + if (y = 0, t) op = [op[0] & 2, t.value]; + switch (op[0]) { + case 0: case 1: t = op; break; + case 4: _.label++; return { value: op[1], done: false }; + case 5: _.label++; y = op[1]; op = [0]; continue; + case 7: op = _.ops.pop(); _.trys.pop(); continue; + default: + if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; } + if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; } + if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; } + if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; } + if (t[2]) _.ops.pop(); + _.trys.pop(); continue; + } + op = body.call(thisArg, _); + } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; } + if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true }; + } +}; +var __addDisposableResource = (this && this.__addDisposableResource) || function (env, value, async) { + if (value !== null && value !== void 0) { + if (typeof value !== "object") throw new TypeError("Object expected."); + var dispose; + if (async) { + if (!Symbol.asyncDispose) throw new TypeError("Symbol.asyncDispose is not defined."); + dispose = value[Symbol.asyncDispose]; + } + if (dispose === void 0) { + if (!Symbol.dispose) throw new TypeError("Symbol.dispose is not defined."); + dispose = value[Symbol.dispose]; + } + if (typeof dispose !== "function") throw new TypeError("Object not disposable."); + env.stack.push({ value: value, dispose: dispose, async: async }); + } + else if (async) { + env.stack.push({ async: true }); + } + return value; +}; +var __disposeResources = (this && this.__disposeResources) || (function (SuppressedError) { + return function (env) { + function fail(e) { + env.error = env.hasError ? new SuppressedError(e, env.error, "An error was suppressed during disposal.") : e; + env.hasError = true; + } + function next() { + while (env.stack.length) { + var rec = env.stack.pop(); + try { + var result = rec.dispose && rec.dispose.call(rec.value); + if (rec.async) return Promise.resolve(result).then(next, function(e) { fail(e); return next(); }); + } + catch (e) { + fail(e); + } + } + if (env.hasError) throw env.error; + } + return next(); + }; +})(typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) { + var e = new Error(message); + return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e; +}); +function main() { + return __awaiter(this, void 0, void 0, function () { + var env_1, d1, d2, d3, d4, e_1, result_1; + var _a, _b; + return __generator(this, function (_c) { + switch (_c.label) { + case 0: + env_1 = { stack: [], error: void 0, hasError: false }; + _c.label = 1; + case 1: + _c.trys.push([1, 2, 3, 6]); + d1 = __addDisposableResource(env_1, (_a = {}, _a[Symbol.dispose] = function () { }, _a), true), d2 = __addDisposableResource(env_1, (_b = {}, _b[Symbol.asyncDispose] = function () { + return __awaiter(this, void 0, void 0, function () { return __generator(this, function (_a) { + return [2 /*return*/]; + }); }); + }, _b), true), d3 = __addDisposableResource(env_1, null, true), d4 = __addDisposableResource(env_1, undefined, true); + for (;;) { + } + return [3 /*break*/, 6]; + case 2: + e_1 = _c.sent(); + env_1.error = e_1; + env_1.hasError = true; + return [3 /*break*/, 6]; + case 3: + result_1 = __disposeResources(env_1); + if (!result_1) return [3 /*break*/, 5]; + return [4 /*yield*/, result_1]; + case 4: + _c.sent(); + _c.label = 5; + case 5: return [7 /*endfinally*/]; + case 6: return [2 /*return*/]; + } + }); + }); +} diff --git a/tests/baselines/reference/awaitUsingDeclarationsInFor(target=esnext).js b/tests/baselines/reference/awaitUsingDeclarationsInFor(target=esnext).js new file mode 100644 index 0000000000000..d7e96493ed8a3 --- /dev/null +++ b/tests/baselines/reference/awaitUsingDeclarationsInFor(target=esnext).js @@ -0,0 +1,16 @@ +//// [tests/cases/conformance/statements/VariableStatements/usingDeclarations/awaitUsingDeclarationsInFor.ts] //// + +//// [awaitUsingDeclarationsInFor.ts] +async function main() { + for (await using d1 = { [Symbol.dispose]() {} }, + d2 = { async [Symbol.asyncDispose]() {} }, + d3 = null, + d4 = undefined;;) { + } +} + +//// [awaitUsingDeclarationsInFor.js] +async function main() { + for (await using d1 = { [Symbol.dispose]() { } }, d2 = { async [Symbol.asyncDispose]() { } }, d3 = null, d4 = undefined;;) { + } +} diff --git a/tests/baselines/reference/awaitUsingDeclarationsInForAwaitOf(target=es2015).js b/tests/baselines/reference/awaitUsingDeclarationsInForAwaitOf(target=es2015).js new file mode 100644 index 0000000000000..187f098c833d7 --- /dev/null +++ b/tests/baselines/reference/awaitUsingDeclarationsInForAwaitOf(target=es2015).js @@ -0,0 +1,104 @@ +//// [tests/cases/conformance/statements/VariableStatements/usingDeclarations/awaitUsingDeclarationsInForAwaitOf.ts] //// + +//// [awaitUsingDeclarationsInForAwaitOf.ts] +async function main() { + for await (await using d1 of [{ async [Symbol.asyncDispose]() {} }, { [Symbol.dispose]() {} }, null, undefined]) { + } +} + +//// [awaitUsingDeclarationsInForAwaitOf.js] +var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { + function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } + return new (P || (P = Promise))(function (resolve, reject) { + function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } + function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } + function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } + step((generator = generator.apply(thisArg, _arguments || [])).next()); + }); +}; +var __addDisposableResource = (this && this.__addDisposableResource) || function (env, value, async) { + if (value !== null && value !== void 0) { + if (typeof value !== "object") throw new TypeError("Object expected."); + var dispose; + if (async) { + if (!Symbol.asyncDispose) throw new TypeError("Symbol.asyncDispose is not defined."); + dispose = value[Symbol.asyncDispose]; + } + if (dispose === void 0) { + if (!Symbol.dispose) throw new TypeError("Symbol.dispose is not defined."); + dispose = value[Symbol.dispose]; + } + if (typeof dispose !== "function") throw new TypeError("Object not disposable."); + env.stack.push({ value: value, dispose: dispose, async: async }); + } + else if (async) { + env.stack.push({ async: true }); + } + return value; +}; +var __disposeResources = (this && this.__disposeResources) || (function (SuppressedError) { + return function (env) { + function fail(e) { + env.error = env.hasError ? new SuppressedError(e, env.error, "An error was suppressed during disposal.") : e; + env.hasError = true; + } + function next() { + while (env.stack.length) { + var rec = env.stack.pop(); + try { + var result = rec.dispose && rec.dispose.call(rec.value); + if (rec.async) return Promise.resolve(result).then(next, function(e) { fail(e); return next(); }); + } + catch (e) { + fail(e); + } + } + if (env.hasError) throw env.error; + } + return next(); + }; +})(typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) { + var e = new Error(message); + return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e; +}); +var __asyncValues = (this && this.__asyncValues) || function (o) { + if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined."); + var m = o[Symbol.asyncIterator], i; + return m ? m.call(o) : (o = typeof __values === "function" ? __values(o) : o[Symbol.iterator](), i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i); + function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; } + function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); } +}; +function main() { + var _a, e_1, _b, _c; + return __awaiter(this, void 0, void 0, function* () { + try { + for (var _d = true, _e = __asyncValues([{ [Symbol.asyncDispose]() { + return __awaiter(this, void 0, void 0, function* () { }); + } }, { [Symbol.dispose]() { } }, null, undefined]), _f; _f = yield _e.next(), _a = _f.done, !_a; _d = true) { + _c = _f.value; + _d = false; + const d1_1 = _c; + const env_1 = { stack: [], error: void 0, hasError: false }; + try { + const d1 = __addDisposableResource(env_1, d1_1, true); + } + catch (e_2) { + env_1.error = e_2; + env_1.hasError = true; + } + finally { + const result_1 = __disposeResources(env_1); + if (result_1) + yield result_1; + } + } + } + catch (e_1_1) { e_1 = { error: e_1_1 }; } + finally { + try { + if (!_d && !_a && (_b = _e.return)) yield _b.call(_e); + } + finally { if (e_1) throw e_1.error; } + } + }); +} diff --git a/tests/baselines/reference/awaitUsingDeclarationsInForAwaitOf(target=es2017).js b/tests/baselines/reference/awaitUsingDeclarationsInForAwaitOf(target=es2017).js new file mode 100644 index 0000000000000..845789f9a5f4f --- /dev/null +++ b/tests/baselines/reference/awaitUsingDeclarationsInForAwaitOf(target=es2017).js @@ -0,0 +1,91 @@ +//// [tests/cases/conformance/statements/VariableStatements/usingDeclarations/awaitUsingDeclarationsInForAwaitOf.ts] //// + +//// [awaitUsingDeclarationsInForAwaitOf.ts] +async function main() { + for await (await using d1 of [{ async [Symbol.asyncDispose]() {} }, { [Symbol.dispose]() {} }, null, undefined]) { + } +} + +//// [awaitUsingDeclarationsInForAwaitOf.js] +var __addDisposableResource = (this && this.__addDisposableResource) || function (env, value, async) { + if (value !== null && value !== void 0) { + if (typeof value !== "object") throw new TypeError("Object expected."); + var dispose; + if (async) { + if (!Symbol.asyncDispose) throw new TypeError("Symbol.asyncDispose is not defined."); + dispose = value[Symbol.asyncDispose]; + } + if (dispose === void 0) { + if (!Symbol.dispose) throw new TypeError("Symbol.dispose is not defined."); + dispose = value[Symbol.dispose]; + } + if (typeof dispose !== "function") throw new TypeError("Object not disposable."); + env.stack.push({ value: value, dispose: dispose, async: async }); + } + else if (async) { + env.stack.push({ async: true }); + } + return value; +}; +var __disposeResources = (this && this.__disposeResources) || (function (SuppressedError) { + return function (env) { + function fail(e) { + env.error = env.hasError ? new SuppressedError(e, env.error, "An error was suppressed during disposal.") : e; + env.hasError = true; + } + function next() { + while (env.stack.length) { + var rec = env.stack.pop(); + try { + var result = rec.dispose && rec.dispose.call(rec.value); + if (rec.async) return Promise.resolve(result).then(next, function(e) { fail(e); return next(); }); + } + catch (e) { + fail(e); + } + } + if (env.hasError) throw env.error; + } + return next(); + }; +})(typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) { + var e = new Error(message); + return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e; +}); +var __asyncValues = (this && this.__asyncValues) || function (o) { + if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined."); + var m = o[Symbol.asyncIterator], i; + return m ? m.call(o) : (o = typeof __values === "function" ? __values(o) : o[Symbol.iterator](), i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i); + function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; } + function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); } +}; +async function main() { + var _a, e_1, _b, _c; + try { + for (var _d = true, _e = __asyncValues([{ async [Symbol.asyncDispose]() { } }, { [Symbol.dispose]() { } }, null, undefined]), _f; _f = await _e.next(), _a = _f.done, !_a; _d = true) { + _c = _f.value; + _d = false; + const d1_1 = _c; + const env_1 = { stack: [], error: void 0, hasError: false }; + try { + const d1 = __addDisposableResource(env_1, d1_1, true); + } + catch (e_2) { + env_1.error = e_2; + env_1.hasError = true; + } + finally { + const result_1 = __disposeResources(env_1); + if (result_1) + await result_1; + } + } + } + catch (e_1_1) { e_1 = { error: e_1_1 }; } + finally { + try { + if (!_d && !_a && (_b = _e.return)) await _b.call(_e); + } + finally { if (e_1) throw e_1.error; } + } +} diff --git a/tests/baselines/reference/awaitUsingDeclarationsInForAwaitOf(target=es2022).js b/tests/baselines/reference/awaitUsingDeclarationsInForAwaitOf(target=es2022).js new file mode 100644 index 0000000000000..1d6ca04cdf4af --- /dev/null +++ b/tests/baselines/reference/awaitUsingDeclarationsInForAwaitOf(target=es2022).js @@ -0,0 +1,71 @@ +//// [tests/cases/conformance/statements/VariableStatements/usingDeclarations/awaitUsingDeclarationsInForAwaitOf.ts] //// + +//// [awaitUsingDeclarationsInForAwaitOf.ts] +async function main() { + for await (await using d1 of [{ async [Symbol.asyncDispose]() {} }, { [Symbol.dispose]() {} }, null, undefined]) { + } +} + +//// [awaitUsingDeclarationsInForAwaitOf.js] +var __addDisposableResource = (this && this.__addDisposableResource) || function (env, value, async) { + if (value !== null && value !== void 0) { + if (typeof value !== "object") throw new TypeError("Object expected."); + var dispose; + if (async) { + if (!Symbol.asyncDispose) throw new TypeError("Symbol.asyncDispose is not defined."); + dispose = value[Symbol.asyncDispose]; + } + if (dispose === void 0) { + if (!Symbol.dispose) throw new TypeError("Symbol.dispose is not defined."); + dispose = value[Symbol.dispose]; + } + if (typeof dispose !== "function") throw new TypeError("Object not disposable."); + env.stack.push({ value: value, dispose: dispose, async: async }); + } + else if (async) { + env.stack.push({ async: true }); + } + return value; +}; +var __disposeResources = (this && this.__disposeResources) || (function (SuppressedError) { + return function (env) { + function fail(e) { + env.error = env.hasError ? new SuppressedError(e, env.error, "An error was suppressed during disposal.") : e; + env.hasError = true; + } + function next() { + while (env.stack.length) { + var rec = env.stack.pop(); + try { + var result = rec.dispose && rec.dispose.call(rec.value); + if (rec.async) return Promise.resolve(result).then(next, function(e) { fail(e); return next(); }); + } + catch (e) { + fail(e); + } + } + if (env.hasError) throw env.error; + } + return next(); + }; +})(typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) { + var e = new Error(message); + return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e; +}); +async function main() { + for await (const d1_1 of [{ async [Symbol.asyncDispose]() { } }, { [Symbol.dispose]() { } }, null, undefined]) { + const env_1 = { stack: [], error: void 0, hasError: false }; + try { + const d1 = __addDisposableResource(env_1, d1_1, true); + } + catch (e_1) { + env_1.error = e_1; + env_1.hasError = true; + } + finally { + const result_1 = __disposeResources(env_1); + if (result_1) + await result_1; + } + } +} diff --git a/tests/baselines/reference/awaitUsingDeclarationsInForAwaitOf(target=es5).js b/tests/baselines/reference/awaitUsingDeclarationsInForAwaitOf(target=es5).js new file mode 100644 index 0000000000000..070dfbd44400e --- /dev/null +++ b/tests/baselines/reference/awaitUsingDeclarationsInForAwaitOf(target=es5).js @@ -0,0 +1,162 @@ +//// [tests/cases/conformance/statements/VariableStatements/usingDeclarations/awaitUsingDeclarationsInForAwaitOf.ts] //// + +//// [awaitUsingDeclarationsInForAwaitOf.ts] +async function main() { + for await (await using d1 of [{ async [Symbol.asyncDispose]() {} }, { [Symbol.dispose]() {} }, null, undefined]) { + } +} + +//// [awaitUsingDeclarationsInForAwaitOf.js] +var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { + function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } + return new (P || (P = Promise))(function (resolve, reject) { + function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } + function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } + function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } + step((generator = generator.apply(thisArg, _arguments || [])).next()); + }); +}; +var __generator = (this && this.__generator) || function (thisArg, body) { + var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g; + return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g; + function verb(n) { return function (v) { return step([n, v]); }; } + function step(op) { + if (f) throw new TypeError("Generator is already executing."); + while (g && (g = 0, op[0] && (_ = 0)), _) try { + if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t; + if (y = 0, t) op = [op[0] & 2, t.value]; + switch (op[0]) { + case 0: case 1: t = op; break; + case 4: _.label++; return { value: op[1], done: false }; + case 5: _.label++; y = op[1]; op = [0]; continue; + case 7: op = _.ops.pop(); _.trys.pop(); continue; + default: + if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; } + if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; } + if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; } + if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; } + if (t[2]) _.ops.pop(); + _.trys.pop(); continue; + } + op = body.call(thisArg, _); + } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; } + if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true }; + } +}; +var __addDisposableResource = (this && this.__addDisposableResource) || function (env, value, async) { + if (value !== null && value !== void 0) { + if (typeof value !== "object") throw new TypeError("Object expected."); + var dispose; + if (async) { + if (!Symbol.asyncDispose) throw new TypeError("Symbol.asyncDispose is not defined."); + dispose = value[Symbol.asyncDispose]; + } + if (dispose === void 0) { + if (!Symbol.dispose) throw new TypeError("Symbol.dispose is not defined."); + dispose = value[Symbol.dispose]; + } + if (typeof dispose !== "function") throw new TypeError("Object not disposable."); + env.stack.push({ value: value, dispose: dispose, async: async }); + } + else if (async) { + env.stack.push({ async: true }); + } + return value; +}; +var __disposeResources = (this && this.__disposeResources) || (function (SuppressedError) { + return function (env) { + function fail(e) { + env.error = env.hasError ? new SuppressedError(e, env.error, "An error was suppressed during disposal.") : e; + env.hasError = true; + } + function next() { + while (env.stack.length) { + var rec = env.stack.pop(); + try { + var result = rec.dispose && rec.dispose.call(rec.value); + if (rec.async) return Promise.resolve(result).then(next, function(e) { fail(e); return next(); }); + } + catch (e) { + fail(e); + } + } + if (env.hasError) throw env.error; + } + return next(); + }; +})(typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) { + var e = new Error(message); + return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e; +}); +var __asyncValues = (this && this.__asyncValues) || function (o) { + if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined."); + var m = o[Symbol.asyncIterator], i; + return m ? m.call(o) : (o = typeof __values === "function" ? __values(o) : o[Symbol.iterator](), i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i); + function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; } + function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); } +}; +function main() { + var _a, e_1, _b, _c; + return __awaiter(this, void 0, void 0, function () { + var _d, _e, _f, d1_1, env_1, d1, e_2, result_1, e_1_1; + var _g, _h; + return __generator(this, function (_j) { + switch (_j.label) { + case 0: + _j.trys.push([0, 10, 11, 16]); + _d = true, _e = __asyncValues([(_g = {}, _g[Symbol.asyncDispose] = function () { + return __awaiter(this, void 0, void 0, function () { return __generator(this, function (_a) { + return [2 /*return*/]; + }); }); + }, _g), (_h = {}, _h[Symbol.dispose] = function () { }, _h), null, undefined]); + _j.label = 1; + case 1: return [4 /*yield*/, _e.next()]; + case 2: + if (!(_f = _j.sent(), _a = _f.done, !_a)) return [3 /*break*/, 9]; + _c = _f.value; + _d = false; + d1_1 = _c; + env_1 = { stack: [], error: void 0, hasError: false }; + _j.label = 3; + case 3: + _j.trys.push([3, 4, 5, 8]); + d1 = __addDisposableResource(env_1, d1_1, true); + return [3 /*break*/, 8]; + case 4: + e_2 = _j.sent(); + env_1.error = e_2; + env_1.hasError = true; + return [3 /*break*/, 8]; + case 5: + result_1 = __disposeResources(env_1); + if (!result_1) return [3 /*break*/, 7]; + return [4 /*yield*/, result_1]; + case 6: + _j.sent(); + _j.label = 7; + case 7: return [7 /*endfinally*/]; + case 8: + _d = true; + return [3 /*break*/, 1]; + case 9: return [3 /*break*/, 16]; + case 10: + e_1_1 = _j.sent(); + e_1 = { error: e_1_1 }; + return [3 /*break*/, 16]; + case 11: + _j.trys.push([11, , 14, 15]); + if (!(!_d && !_a && (_b = _e.return))) return [3 /*break*/, 13]; + return [4 /*yield*/, _b.call(_e)]; + case 12: + _j.sent(); + _j.label = 13; + case 13: return [3 /*break*/, 15]; + case 14: + if (e_1) throw e_1.error; + return [7 /*endfinally*/]; + case 15: return [7 /*endfinally*/]; + case 16: return [2 /*return*/]; + } + }); + }); +} diff --git a/tests/baselines/reference/awaitUsingDeclarationsInForAwaitOf(target=esnext).js b/tests/baselines/reference/awaitUsingDeclarationsInForAwaitOf(target=esnext).js new file mode 100644 index 0000000000000..454e995313d07 --- /dev/null +++ b/tests/baselines/reference/awaitUsingDeclarationsInForAwaitOf(target=esnext).js @@ -0,0 +1,13 @@ +//// [tests/cases/conformance/statements/VariableStatements/usingDeclarations/awaitUsingDeclarationsInForAwaitOf.ts] //// + +//// [awaitUsingDeclarationsInForAwaitOf.ts] +async function main() { + for await (await using d1 of [{ async [Symbol.asyncDispose]() {} }, { [Symbol.dispose]() {} }, null, undefined]) { + } +} + +//// [awaitUsingDeclarationsInForAwaitOf.js] +async function main() { + for await (await using d1 of [{ async [Symbol.asyncDispose]() { } }, { [Symbol.dispose]() { } }, null, undefined]) { + } +} diff --git a/tests/baselines/reference/awaitUsingDeclarationsInForIn.errors.txt b/tests/baselines/reference/awaitUsingDeclarationsInForIn.errors.txt new file mode 100644 index 0000000000000..50f340e645a6b --- /dev/null +++ b/tests/baselines/reference/awaitUsingDeclarationsInForIn.errors.txt @@ -0,0 +1,11 @@ +awaitUsingDeclarationsInForIn.ts(2,10): error TS1494: The left-hand side of a 'for...in' statement cannot be an 'await using' declaration. + + +==== awaitUsingDeclarationsInForIn.ts (1 errors) ==== + async function main() { + for (await using x in {}) { + ~~~~~~~~~~~~~ +!!! error TS1494: The left-hand side of a 'for...in' statement cannot be an 'await using' declaration. + } + } + \ No newline at end of file diff --git a/tests/baselines/reference/awaitUsingDeclarationsInForIn.js b/tests/baselines/reference/awaitUsingDeclarationsInForIn.js new file mode 100644 index 0000000000000..60b8eecfdcdac --- /dev/null +++ b/tests/baselines/reference/awaitUsingDeclarationsInForIn.js @@ -0,0 +1,14 @@ +//// [tests/cases/conformance/statements/VariableStatements/usingDeclarations/awaitUsingDeclarationsInForIn.ts] //// + +//// [awaitUsingDeclarationsInForIn.ts] +async function main() { + for (await using x in {}) { + } +} + + +//// [awaitUsingDeclarationsInForIn.js] +async function main() { + for (await using x in {}) { + } +} diff --git a/tests/baselines/reference/awaitUsingDeclarationsInForOf.1(target=es2015).js b/tests/baselines/reference/awaitUsingDeclarationsInForOf.1(target=es2015).js new file mode 100644 index 0000000000000..3f34c45822e44 --- /dev/null +++ b/tests/baselines/reference/awaitUsingDeclarationsInForOf.1(target=es2015).js @@ -0,0 +1,85 @@ +//// [tests/cases/conformance/statements/VariableStatements/usingDeclarations/awaitUsingDeclarationsInForOf.1.ts] //// + +//// [awaitUsingDeclarationsInForOf.1.ts] +async function main() { + for (await using d1 of [{ async [Symbol.asyncDispose]() {} }, { [Symbol.dispose]() {} }, null, undefined]) { + } +} + + +//// [awaitUsingDeclarationsInForOf.1.js] +var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { + function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } + return new (P || (P = Promise))(function (resolve, reject) { + function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } + function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } + function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } + step((generator = generator.apply(thisArg, _arguments || [])).next()); + }); +}; +var __addDisposableResource = (this && this.__addDisposableResource) || function (env, value, async) { + if (value !== null && value !== void 0) { + if (typeof value !== "object") throw new TypeError("Object expected."); + var dispose; + if (async) { + if (!Symbol.asyncDispose) throw new TypeError("Symbol.asyncDispose is not defined."); + dispose = value[Symbol.asyncDispose]; + } + if (dispose === void 0) { + if (!Symbol.dispose) throw new TypeError("Symbol.dispose is not defined."); + dispose = value[Symbol.dispose]; + } + if (typeof dispose !== "function") throw new TypeError("Object not disposable."); + env.stack.push({ value: value, dispose: dispose, async: async }); + } + else if (async) { + env.stack.push({ async: true }); + } + return value; +}; +var __disposeResources = (this && this.__disposeResources) || (function (SuppressedError) { + return function (env) { + function fail(e) { + env.error = env.hasError ? new SuppressedError(e, env.error, "An error was suppressed during disposal.") : e; + env.hasError = true; + } + function next() { + while (env.stack.length) { + var rec = env.stack.pop(); + try { + var result = rec.dispose && rec.dispose.call(rec.value); + if (rec.async) return Promise.resolve(result).then(next, function(e) { fail(e); return next(); }); + } + catch (e) { + fail(e); + } + } + if (env.hasError) throw env.error; + } + return next(); + }; +})(typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) { + var e = new Error(message); + return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e; +}); +function main() { + return __awaiter(this, void 0, void 0, function* () { + for (const d1_1 of [{ [Symbol.asyncDispose]() { + return __awaiter(this, void 0, void 0, function* () { }); + } }, { [Symbol.dispose]() { } }, null, undefined]) { + const env_1 = { stack: [], error: void 0, hasError: false }; + try { + const d1 = __addDisposableResource(env_1, d1_1, true); + } + catch (e_1) { + env_1.error = e_1; + env_1.hasError = true; + } + finally { + const result_1 = __disposeResources(env_1); + if (result_1) + yield result_1; + } + } + }); +} diff --git a/tests/baselines/reference/awaitUsingDeclarationsInForOf.1(target=es2017).js b/tests/baselines/reference/awaitUsingDeclarationsInForOf.1(target=es2017).js new file mode 100644 index 0000000000000..a9555cf3fb0e2 --- /dev/null +++ b/tests/baselines/reference/awaitUsingDeclarationsInForOf.1(target=es2017).js @@ -0,0 +1,72 @@ +//// [tests/cases/conformance/statements/VariableStatements/usingDeclarations/awaitUsingDeclarationsInForOf.1.ts] //// + +//// [awaitUsingDeclarationsInForOf.1.ts] +async function main() { + for (await using d1 of [{ async [Symbol.asyncDispose]() {} }, { [Symbol.dispose]() {} }, null, undefined]) { + } +} + + +//// [awaitUsingDeclarationsInForOf.1.js] +var __addDisposableResource = (this && this.__addDisposableResource) || function (env, value, async) { + if (value !== null && value !== void 0) { + if (typeof value !== "object") throw new TypeError("Object expected."); + var dispose; + if (async) { + if (!Symbol.asyncDispose) throw new TypeError("Symbol.asyncDispose is not defined."); + dispose = value[Symbol.asyncDispose]; + } + if (dispose === void 0) { + if (!Symbol.dispose) throw new TypeError("Symbol.dispose is not defined."); + dispose = value[Symbol.dispose]; + } + if (typeof dispose !== "function") throw new TypeError("Object not disposable."); + env.stack.push({ value: value, dispose: dispose, async: async }); + } + else if (async) { + env.stack.push({ async: true }); + } + return value; +}; +var __disposeResources = (this && this.__disposeResources) || (function (SuppressedError) { + return function (env) { + function fail(e) { + env.error = env.hasError ? new SuppressedError(e, env.error, "An error was suppressed during disposal.") : e; + env.hasError = true; + } + function next() { + while (env.stack.length) { + var rec = env.stack.pop(); + try { + var result = rec.dispose && rec.dispose.call(rec.value); + if (rec.async) return Promise.resolve(result).then(next, function(e) { fail(e); return next(); }); + } + catch (e) { + fail(e); + } + } + if (env.hasError) throw env.error; + } + return next(); + }; +})(typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) { + var e = new Error(message); + return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e; +}); +async function main() { + for (const d1_1 of [{ async [Symbol.asyncDispose]() { } }, { [Symbol.dispose]() { } }, null, undefined]) { + const env_1 = { stack: [], error: void 0, hasError: false }; + try { + const d1 = __addDisposableResource(env_1, d1_1, true); + } + catch (e_1) { + env_1.error = e_1; + env_1.hasError = true; + } + finally { + const result_1 = __disposeResources(env_1); + if (result_1) + await result_1; + } + } +} diff --git a/tests/baselines/reference/awaitUsingDeclarationsInForOf.1(target=es2022).js b/tests/baselines/reference/awaitUsingDeclarationsInForOf.1(target=es2022).js new file mode 100644 index 0000000000000..a9555cf3fb0e2 --- /dev/null +++ b/tests/baselines/reference/awaitUsingDeclarationsInForOf.1(target=es2022).js @@ -0,0 +1,72 @@ +//// [tests/cases/conformance/statements/VariableStatements/usingDeclarations/awaitUsingDeclarationsInForOf.1.ts] //// + +//// [awaitUsingDeclarationsInForOf.1.ts] +async function main() { + for (await using d1 of [{ async [Symbol.asyncDispose]() {} }, { [Symbol.dispose]() {} }, null, undefined]) { + } +} + + +//// [awaitUsingDeclarationsInForOf.1.js] +var __addDisposableResource = (this && this.__addDisposableResource) || function (env, value, async) { + if (value !== null && value !== void 0) { + if (typeof value !== "object") throw new TypeError("Object expected."); + var dispose; + if (async) { + if (!Symbol.asyncDispose) throw new TypeError("Symbol.asyncDispose is not defined."); + dispose = value[Symbol.asyncDispose]; + } + if (dispose === void 0) { + if (!Symbol.dispose) throw new TypeError("Symbol.dispose is not defined."); + dispose = value[Symbol.dispose]; + } + if (typeof dispose !== "function") throw new TypeError("Object not disposable."); + env.stack.push({ value: value, dispose: dispose, async: async }); + } + else if (async) { + env.stack.push({ async: true }); + } + return value; +}; +var __disposeResources = (this && this.__disposeResources) || (function (SuppressedError) { + return function (env) { + function fail(e) { + env.error = env.hasError ? new SuppressedError(e, env.error, "An error was suppressed during disposal.") : e; + env.hasError = true; + } + function next() { + while (env.stack.length) { + var rec = env.stack.pop(); + try { + var result = rec.dispose && rec.dispose.call(rec.value); + if (rec.async) return Promise.resolve(result).then(next, function(e) { fail(e); return next(); }); + } + catch (e) { + fail(e); + } + } + if (env.hasError) throw env.error; + } + return next(); + }; +})(typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) { + var e = new Error(message); + return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e; +}); +async function main() { + for (const d1_1 of [{ async [Symbol.asyncDispose]() { } }, { [Symbol.dispose]() { } }, null, undefined]) { + const env_1 = { stack: [], error: void 0, hasError: false }; + try { + const d1 = __addDisposableResource(env_1, d1_1, true); + } + catch (e_1) { + env_1.error = e_1; + env_1.hasError = true; + } + finally { + const result_1 = __disposeResources(env_1); + if (result_1) + await result_1; + } + } +} diff --git a/tests/baselines/reference/awaitUsingDeclarationsInForOf.1(target=es5).js b/tests/baselines/reference/awaitUsingDeclarationsInForOf.1(target=es5).js new file mode 100644 index 0000000000000..d9514c078d97a --- /dev/null +++ b/tests/baselines/reference/awaitUsingDeclarationsInForOf.1(target=es5).js @@ -0,0 +1,134 @@ +//// [tests/cases/conformance/statements/VariableStatements/usingDeclarations/awaitUsingDeclarationsInForOf.1.ts] //// + +//// [awaitUsingDeclarationsInForOf.1.ts] +async function main() { + for (await using d1 of [{ async [Symbol.asyncDispose]() {} }, { [Symbol.dispose]() {} }, null, undefined]) { + } +} + + +//// [awaitUsingDeclarationsInForOf.1.js] +var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { + function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } + return new (P || (P = Promise))(function (resolve, reject) { + function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } + function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } + function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } + step((generator = generator.apply(thisArg, _arguments || [])).next()); + }); +}; +var __generator = (this && this.__generator) || function (thisArg, body) { + var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g; + return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g; + function verb(n) { return function (v) { return step([n, v]); }; } + function step(op) { + if (f) throw new TypeError("Generator is already executing."); + while (g && (g = 0, op[0] && (_ = 0)), _) try { + if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t; + if (y = 0, t) op = [op[0] & 2, t.value]; + switch (op[0]) { + case 0: case 1: t = op; break; + case 4: _.label++; return { value: op[1], done: false }; + case 5: _.label++; y = op[1]; op = [0]; continue; + case 7: op = _.ops.pop(); _.trys.pop(); continue; + default: + if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; } + if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; } + if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; } + if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; } + if (t[2]) _.ops.pop(); + _.trys.pop(); continue; + } + op = body.call(thisArg, _); + } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; } + if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true }; + } +}; +var __addDisposableResource = (this && this.__addDisposableResource) || function (env, value, async) { + if (value !== null && value !== void 0) { + if (typeof value !== "object") throw new TypeError("Object expected."); + var dispose; + if (async) { + if (!Symbol.asyncDispose) throw new TypeError("Symbol.asyncDispose is not defined."); + dispose = value[Symbol.asyncDispose]; + } + if (dispose === void 0) { + if (!Symbol.dispose) throw new TypeError("Symbol.dispose is not defined."); + dispose = value[Symbol.dispose]; + } + if (typeof dispose !== "function") throw new TypeError("Object not disposable."); + env.stack.push({ value: value, dispose: dispose, async: async }); + } + else if (async) { + env.stack.push({ async: true }); + } + return value; +}; +var __disposeResources = (this && this.__disposeResources) || (function (SuppressedError) { + return function (env) { + function fail(e) { + env.error = env.hasError ? new SuppressedError(e, env.error, "An error was suppressed during disposal.") : e; + env.hasError = true; + } + function next() { + while (env.stack.length) { + var rec = env.stack.pop(); + try { + var result = rec.dispose && rec.dispose.call(rec.value); + if (rec.async) return Promise.resolve(result).then(next, function(e) { fail(e); return next(); }); + } + catch (e) { + fail(e); + } + } + if (env.hasError) throw env.error; + } + return next(); + }; +})(typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) { + var e = new Error(message); + return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e; +}); +function main() { + return __awaiter(this, void 0, void 0, function () { + var _i, _a, d1_1, env_1, d1, e_1, result_1; + var _b, _c; + return __generator(this, function (_d) { + switch (_d.label) { + case 0: + _i = 0, _a = [(_b = {}, _b[Symbol.asyncDispose] = function () { + return __awaiter(this, void 0, void 0, function () { return __generator(this, function (_a) { + return [2 /*return*/]; + }); }); + }, _b), (_c = {}, _c[Symbol.dispose] = function () { }, _c), null, undefined]; + _d.label = 1; + case 1: + if (!(_i < _a.length)) return [3 /*break*/, 8]; + d1_1 = _a[_i]; + env_1 = { stack: [], error: void 0, hasError: false }; + _d.label = 2; + case 2: + _d.trys.push([2, 3, 4, 7]); + d1 = __addDisposableResource(env_1, d1_1, true); + return [3 /*break*/, 7]; + case 3: + e_1 = _d.sent(); + env_1.error = e_1; + env_1.hasError = true; + return [3 /*break*/, 7]; + case 4: + result_1 = __disposeResources(env_1); + if (!result_1) return [3 /*break*/, 6]; + return [4 /*yield*/, result_1]; + case 5: + _d.sent(); + _d.label = 6; + case 6: return [7 /*endfinally*/]; + case 7: + _i++; + return [3 /*break*/, 1]; + case 8: return [2 /*return*/]; + } + }); + }); +} diff --git a/tests/baselines/reference/awaitUsingDeclarationsInForOf.1(target=esnext).js b/tests/baselines/reference/awaitUsingDeclarationsInForOf.1(target=esnext).js new file mode 100644 index 0000000000000..28c6d451bf2ae --- /dev/null +++ b/tests/baselines/reference/awaitUsingDeclarationsInForOf.1(target=esnext).js @@ -0,0 +1,14 @@ +//// [tests/cases/conformance/statements/VariableStatements/usingDeclarations/awaitUsingDeclarationsInForOf.1.ts] //// + +//// [awaitUsingDeclarationsInForOf.1.ts] +async function main() { + for (await using d1 of [{ async [Symbol.asyncDispose]() {} }, { [Symbol.dispose]() {} }, null, undefined]) { + } +} + + +//// [awaitUsingDeclarationsInForOf.1.js] +async function main() { + for (await using d1 of [{ async [Symbol.asyncDispose]() { } }, { [Symbol.dispose]() { } }, null, undefined]) { + } +} diff --git a/tests/baselines/reference/awaitUsingDeclarationsInForOf.2.errors.txt b/tests/baselines/reference/awaitUsingDeclarationsInForOf.2.errors.txt new file mode 100644 index 0000000000000..2fd47176982f0 --- /dev/null +++ b/tests/baselines/reference/awaitUsingDeclarationsInForOf.2.errors.txt @@ -0,0 +1,20 @@ +awaitUsingDeclarationsInForOf.2.ts(2,10): error TS2487: The left-hand side of a 'for...of' statement must be a variable or a property access. +awaitUsingDeclarationsInForOf.2.ts(2,16): error TS2304: Cannot find name 'using'. +awaitUsingDeclarationsInForOf.2.ts(2,25): error TS2304: Cannot find name 'of'. +awaitUsingDeclarationsInForOf.2.ts(2,29): error TS1011: An element access expression should take an argument. + + +==== awaitUsingDeclarationsInForOf.2.ts (4 errors) ==== + async function main() { + for (await using of of []) { + ~~~~~~~~~~~ +!!! error TS2487: The left-hand side of a 'for...of' statement must be a variable or a property access. + ~~~~~ +!!! error TS2304: Cannot find name 'using'. + ~~ +!!! error TS2304: Cannot find name 'of'. + +!!! error TS1011: An element access expression should take an argument. + } + } + \ No newline at end of file diff --git a/tests/baselines/reference/awaitUsingDeclarationsInForOf.2.js b/tests/baselines/reference/awaitUsingDeclarationsInForOf.2.js new file mode 100644 index 0000000000000..19d7b7d575da2 --- /dev/null +++ b/tests/baselines/reference/awaitUsingDeclarationsInForOf.2.js @@ -0,0 +1,14 @@ +//// [tests/cases/conformance/statements/VariableStatements/usingDeclarations/awaitUsingDeclarationsInForOf.2.ts] //// + +//// [awaitUsingDeclarationsInForOf.2.ts] +async function main() { + for (await using of of []) { + } +} + + +//// [awaitUsingDeclarationsInForOf.2.js] +async function main() { + for (await using of of[]) { + } +} diff --git a/tests/baselines/reference/awaitUsingDeclarationsInForOf.3.errors.txt b/tests/baselines/reference/awaitUsingDeclarationsInForOf.3.errors.txt new file mode 100644 index 0000000000000..1379bfb713d0d --- /dev/null +++ b/tests/baselines/reference/awaitUsingDeclarationsInForOf.3.errors.txt @@ -0,0 +1,11 @@ +awaitUsingDeclarationsInForOf.3.ts(2,22): error TS1492: 'await using' declarations may not have binding patterns. + + +==== awaitUsingDeclarationsInForOf.3.ts (1 errors) ==== + async function main() { + for (await using {} of []) { + ~~ +!!! error TS1492: 'await using' declarations may not have binding patterns. + } + } + \ No newline at end of file diff --git a/tests/baselines/reference/awaitUsingDeclarationsInForOf.3.js b/tests/baselines/reference/awaitUsingDeclarationsInForOf.3.js new file mode 100644 index 0000000000000..0b25f1b2cb39e --- /dev/null +++ b/tests/baselines/reference/awaitUsingDeclarationsInForOf.3.js @@ -0,0 +1,14 @@ +//// [tests/cases/conformance/statements/VariableStatements/usingDeclarations/awaitUsingDeclarationsInForOf.3.ts] //// + +//// [awaitUsingDeclarationsInForOf.3.ts] +async function main() { + for (await using {} of []) { + } +} + + +//// [awaitUsingDeclarationsInForOf.3.js] +async function main() { + for (await using {} of []) { + } +} diff --git a/tests/baselines/reference/awaitUsingDeclarationsTopLevelOfModule.1(module=esnext).js b/tests/baselines/reference/awaitUsingDeclarationsTopLevelOfModule.1(module=esnext).js new file mode 100644 index 0000000000000..6d86c80c6c9ad --- /dev/null +++ b/tests/baselines/reference/awaitUsingDeclarationsTopLevelOfModule.1(module=esnext).js @@ -0,0 +1,40 @@ +//// [tests/cases/conformance/statements/VariableStatements/usingDeclarations/awaitUsingDeclarationsTopLevelOfModule.1.ts] //// + +//// [awaitUsingDeclarationsTopLevelOfModule.1.ts] +export const x = 1; +export { y }; + +await using z = { async [Symbol.asyncDispose]() {} }; + +const y = 2; + +export const w = 3; + +export default 4; + +console.log(w, x, y, z); + + +//// [awaitUsingDeclarationsTopLevelOfModule.1.js] +export const x = 1; +export { y }; +export { _default as default }; +var z, y, _default; +export let w; +const env_1 = { stack: [], error: void 0, hasError: false }; +try { + z = __addDisposableResource(env_1, { async [Symbol.asyncDispose]() { } }, true); + y = 2; + w = 3; + _default = 4; + console.log(w, x, y, z); +} +catch (e_1) { + env_1.error = e_1; + env_1.hasError = true; +} +finally { + const result_1 = __disposeResources(env_1); + if (result_1) + await result_1; +} diff --git a/tests/baselines/reference/awaitUsingDeclarationsTopLevelOfModule.1(module=system).js b/tests/baselines/reference/awaitUsingDeclarationsTopLevelOfModule.1(module=system).js new file mode 100644 index 0000000000000..f321eda5ed28c --- /dev/null +++ b/tests/baselines/reference/awaitUsingDeclarationsTopLevelOfModule.1(module=system).js @@ -0,0 +1,46 @@ +//// [tests/cases/conformance/statements/VariableStatements/usingDeclarations/awaitUsingDeclarationsTopLevelOfModule.1.ts] //// + +//// [awaitUsingDeclarationsTopLevelOfModule.1.ts] +export const x = 1; +export { y }; + +await using z = { async [Symbol.asyncDispose]() {} }; + +const y = 2; + +export const w = 3; + +export default 4; + +console.log(w, x, y, z); + + +//// [awaitUsingDeclarationsTopLevelOfModule.1.js] +System.register([], function (exports_1, context_1) { + "use strict"; + var x, z, y, _default, w, env_1; + var __moduleName = context_1 && context_1.id; + return { + setters: [], + execute: async function () { + exports_1("x", x = 1); + env_1 = { stack: [], error: void 0, hasError: false }; + try { + z = __addDisposableResource(env_1, { async [Symbol.asyncDispose]() { } }, true); + exports_1("y", y = 2); + exports_1("w", w = 3); + exports_1("default", _default = 4); + console.log(w, x, y, z); + } + catch (e_1) { + env_1.error = e_1; + env_1.hasError = true; + } + finally { + const result_1 = __disposeResources(env_1); + if (result_1) + await result_1; + } + } + }; +}); diff --git a/tests/baselines/reference/awaitUsingDeclarationsWithImportHelpers.errors.txt b/tests/baselines/reference/awaitUsingDeclarationsWithImportHelpers.errors.txt new file mode 100644 index 0000000000000..42a94f7728dcc --- /dev/null +++ b/tests/baselines/reference/awaitUsingDeclarationsWithImportHelpers.errors.txt @@ -0,0 +1,11 @@ +awaitUsingDeclarationsWithImportHelpers.ts(4,5): error TS2354: This syntax requires an imported helper but module 'tslib' cannot be found. + + +==== awaitUsingDeclarationsWithImportHelpers.ts (1 errors) ==== + export {}; + + async function f() { + await using a = null; + ~~~~~~~~~~~~~~~~~~~~ +!!! error TS2354: This syntax requires an imported helper but module 'tslib' cannot be found. + } \ No newline at end of file diff --git a/tests/baselines/reference/awaitUsingDeclarationsWithImportHelpers.js b/tests/baselines/reference/awaitUsingDeclarationsWithImportHelpers.js new file mode 100644 index 0000000000000..fcc0a66c43116 --- /dev/null +++ b/tests/baselines/reference/awaitUsingDeclarationsWithImportHelpers.js @@ -0,0 +1,14 @@ +//// [tests/cases/conformance/statements/VariableStatements/usingDeclarations/awaitUsingDeclarationsWithImportHelpers.ts] //// + +//// [awaitUsingDeclarationsWithImportHelpers.ts] +export {}; + +async function f() { + await using a = null; +} + +//// [awaitUsingDeclarationsWithImportHelpers.js] +async function f() { + await using a = null; +} +export {}; diff --git a/tests/baselines/reference/classStaticBlock23(target=es2022).errors.txt b/tests/baselines/reference/classStaticBlock23(target=es2022).errors.txt index de958d0625e73..6868d85c1f467 100644 --- a/tests/baselines/reference/classStaticBlock23(target=es2022).errors.txt +++ b/tests/baselines/reference/classStaticBlock23(target=es2022).errors.txt @@ -1,5 +1,5 @@ -classStaticBlock23.ts(5,9): error TS18038: 'For await' loops cannot be used inside a class static block. -classStaticBlock23.ts(14,11): error TS18038: 'For await' loops cannot be used inside a class static block. +classStaticBlock23.ts(5,9): error TS18038: 'for await' loops cannot be used inside a class static block. +classStaticBlock23.ts(14,11): error TS18038: 'for await' loops cannot be used inside a class static block. ==== classStaticBlock23.ts (2 errors) ==== @@ -9,7 +9,7 @@ classStaticBlock23.ts(14,11): error TS18038: 'For await' loops cannot be used in static { for await (const nn of nums) { ~~~~~ -!!! error TS18038: 'For await' loops cannot be used inside a class static block. +!!! error TS18038: 'for await' loops cannot be used inside a class static block. console.log(nn) } } @@ -20,7 +20,7 @@ classStaticBlock23.ts(14,11): error TS18038: 'For await' loops cannot be used in static { for await (const nn of nums) { ~~~~~ -!!! error TS18038: 'For await' loops cannot be used inside a class static block. +!!! error TS18038: 'for await' loops cannot be used inside a class static block. console.log(nn) } } diff --git a/tests/baselines/reference/classStaticBlock23(target=esnext).errors.txt b/tests/baselines/reference/classStaticBlock23(target=esnext).errors.txt index de958d0625e73..6868d85c1f467 100644 --- a/tests/baselines/reference/classStaticBlock23(target=esnext).errors.txt +++ b/tests/baselines/reference/classStaticBlock23(target=esnext).errors.txt @@ -1,5 +1,5 @@ -classStaticBlock23.ts(5,9): error TS18038: 'For await' loops cannot be used inside a class static block. -classStaticBlock23.ts(14,11): error TS18038: 'For await' loops cannot be used inside a class static block. +classStaticBlock23.ts(5,9): error TS18038: 'for await' loops cannot be used inside a class static block. +classStaticBlock23.ts(14,11): error TS18038: 'for await' loops cannot be used inside a class static block. ==== classStaticBlock23.ts (2 errors) ==== @@ -9,7 +9,7 @@ classStaticBlock23.ts(14,11): error TS18038: 'For await' loops cannot be used in static { for await (const nn of nums) { ~~~~~ -!!! error TS18038: 'For await' loops cannot be used inside a class static block. +!!! error TS18038: 'for await' loops cannot be used inside a class static block. console.log(nn) } } @@ -20,7 +20,7 @@ classStaticBlock23.ts(14,11): error TS18038: 'For await' loops cannot be used in static { for await (const nn of nums) { ~~~~~ -!!! error TS18038: 'For await' loops cannot be used inside a class static block. +!!! error TS18038: 'for await' loops cannot be used inside a class static block. console.log(nn) } } diff --git a/tests/baselines/reference/classStaticBlock26(target=es2022).errors.txt b/tests/baselines/reference/classStaticBlock26(target=es2022).errors.txt index 841adafab26ed..108e2368dad7f 100644 --- a/tests/baselines/reference/classStaticBlock26(target=es2022).errors.txt +++ b/tests/baselines/reference/classStaticBlock26(target=es2022).errors.txt @@ -1,20 +1,20 @@ -classStaticBlock26.ts(3,9): error TS18037: Await expression cannot be used inside a class static block. +classStaticBlock26.ts(3,9): error TS18037: 'await' expression cannot be used inside a class static block. classStaticBlock26.ts(3,14): error TS1109: Expression expected. -classStaticBlock26.ts(6,9): error TS18037: Await expression cannot be used inside a class static block. -classStaticBlock26.ts(9,13): error TS18037: Await expression cannot be used inside a class static block. +classStaticBlock26.ts(6,9): error TS18037: 'await' expression cannot be used inside a class static block. +classStaticBlock26.ts(9,13): error TS18037: 'await' expression cannot be used inside a class static block. classStaticBlock26.ts(9,18): error TS1109: Expression expected. -classStaticBlock26.ts(13,14): error TS18037: Await expression cannot be used inside a class static block. +classStaticBlock26.ts(13,14): error TS18037: 'await' expression cannot be used inside a class static block. classStaticBlock26.ts(13,19): error TS1109: Expression expected. classStaticBlock26.ts(17,18): error TS1005: ':' expected. -classStaticBlock26.ts(20,9): error TS18037: Await expression cannot be used inside a class static block. +classStaticBlock26.ts(20,9): error TS18037: 'await' expression cannot be used inside a class static block. classStaticBlock26.ts(20,14): error TS1109: Expression expected. classStaticBlock26.ts(21,15): error TS1003: Identifier expected. -classStaticBlock26.ts(21,15): error TS18037: Await expression cannot be used inside a class static block. +classStaticBlock26.ts(21,15): error TS18037: 'await' expression cannot be used inside a class static block. classStaticBlock26.ts(21,20): error TS1109: Expression expected. -classStaticBlock26.ts(25,21): error TS18037: Await expression cannot be used inside a class static block. +classStaticBlock26.ts(25,21): error TS18037: 'await' expression cannot be used inside a class static block. classStaticBlock26.ts(25,26): error TS1109: Expression expected. classStaticBlock26.ts(25,28): error TS1005: ';' expected. -classStaticBlock26.ts(26,21): error TS18037: Await expression cannot be used inside a class static block. +classStaticBlock26.ts(26,21): error TS18037: 'await' expression cannot be used inside a class static block. classStaticBlock26.ts(26,27): error TS1109: Expression expected. @@ -23,19 +23,19 @@ classStaticBlock26.ts(26,27): error TS1109: Expression expected. static { await; // illegal ~~~~~ -!!! error TS18037: Await expression cannot be used inside a class static block. +!!! error TS18037: 'await' expression cannot be used inside a class static block. ~ !!! error TS1109: Expression expected. } static { await (1); // illegal ~~~~~~~~~ -!!! error TS18037: Await expression cannot be used inside a class static block. +!!! error TS18037: 'await' expression cannot be used inside a class static block. } static { ({ [await]: 1 }); // illegal ~~~~~ -!!! error TS18037: Await expression cannot be used inside a class static block. +!!! error TS18037: 'await' expression cannot be used inside a class static block. ~ !!! error TS1109: Expression expected. } @@ -43,7 +43,7 @@ classStaticBlock26.ts(26,27): error TS1109: Expression expected. class D { [await] = 1; // illegal (computed property names are evaluated outside of a class body ~~~~~ -!!! error TS18037: Await expression cannot be used inside a class static block. +!!! error TS18037: 'await' expression cannot be used inside a class static block. ~ !!! error TS1109: Expression expected. }; @@ -56,14 +56,14 @@ classStaticBlock26.ts(26,27): error TS1109: Expression expected. static { await: // illegal, 'await' cannot be used as a label ~~~~~ -!!! error TS18037: Await expression cannot be used inside a class static block. +!!! error TS18037: 'await' expression cannot be used inside a class static block. ~ !!! error TS1109: Expression expected. break await; // illegal, 'await' cannot be used as a label ~~~~~ !!! error TS1003: Identifier expected. ~~~~~ -!!! error TS18037: Await expression cannot be used inside a class static block. +!!! error TS18037: 'await' expression cannot be used inside a class static block. ~ !!! error TS1109: Expression expected. } @@ -71,14 +71,14 @@ classStaticBlock26.ts(26,27): error TS1109: Expression expected. function f(await) { } const ff = (await) => { } ~~~~~ -!!! error TS18037: Await expression cannot be used inside a class static block. +!!! error TS18037: 'await' expression cannot be used inside a class static block. ~ !!! error TS1109: Expression expected. ~~ !!! error TS1005: ';' expected. const fff = await => { } ~~~~~ -!!! error TS18037: Await expression cannot be used inside a class static block. +!!! error TS18037: 'await' expression cannot be used inside a class static block. ~~ !!! error TS1109: Expression expected. } diff --git a/tests/baselines/reference/classStaticBlock26(target=esnext).errors.txt b/tests/baselines/reference/classStaticBlock26(target=esnext).errors.txt index 841adafab26ed..108e2368dad7f 100644 --- a/tests/baselines/reference/classStaticBlock26(target=esnext).errors.txt +++ b/tests/baselines/reference/classStaticBlock26(target=esnext).errors.txt @@ -1,20 +1,20 @@ -classStaticBlock26.ts(3,9): error TS18037: Await expression cannot be used inside a class static block. +classStaticBlock26.ts(3,9): error TS18037: 'await' expression cannot be used inside a class static block. classStaticBlock26.ts(3,14): error TS1109: Expression expected. -classStaticBlock26.ts(6,9): error TS18037: Await expression cannot be used inside a class static block. -classStaticBlock26.ts(9,13): error TS18037: Await expression cannot be used inside a class static block. +classStaticBlock26.ts(6,9): error TS18037: 'await' expression cannot be used inside a class static block. +classStaticBlock26.ts(9,13): error TS18037: 'await' expression cannot be used inside a class static block. classStaticBlock26.ts(9,18): error TS1109: Expression expected. -classStaticBlock26.ts(13,14): error TS18037: Await expression cannot be used inside a class static block. +classStaticBlock26.ts(13,14): error TS18037: 'await' expression cannot be used inside a class static block. classStaticBlock26.ts(13,19): error TS1109: Expression expected. classStaticBlock26.ts(17,18): error TS1005: ':' expected. -classStaticBlock26.ts(20,9): error TS18037: Await expression cannot be used inside a class static block. +classStaticBlock26.ts(20,9): error TS18037: 'await' expression cannot be used inside a class static block. classStaticBlock26.ts(20,14): error TS1109: Expression expected. classStaticBlock26.ts(21,15): error TS1003: Identifier expected. -classStaticBlock26.ts(21,15): error TS18037: Await expression cannot be used inside a class static block. +classStaticBlock26.ts(21,15): error TS18037: 'await' expression cannot be used inside a class static block. classStaticBlock26.ts(21,20): error TS1109: Expression expected. -classStaticBlock26.ts(25,21): error TS18037: Await expression cannot be used inside a class static block. +classStaticBlock26.ts(25,21): error TS18037: 'await' expression cannot be used inside a class static block. classStaticBlock26.ts(25,26): error TS1109: Expression expected. classStaticBlock26.ts(25,28): error TS1005: ';' expected. -classStaticBlock26.ts(26,21): error TS18037: Await expression cannot be used inside a class static block. +classStaticBlock26.ts(26,21): error TS18037: 'await' expression cannot be used inside a class static block. classStaticBlock26.ts(26,27): error TS1109: Expression expected. @@ -23,19 +23,19 @@ classStaticBlock26.ts(26,27): error TS1109: Expression expected. static { await; // illegal ~~~~~ -!!! error TS18037: Await expression cannot be used inside a class static block. +!!! error TS18037: 'await' expression cannot be used inside a class static block. ~ !!! error TS1109: Expression expected. } static { await (1); // illegal ~~~~~~~~~ -!!! error TS18037: Await expression cannot be used inside a class static block. +!!! error TS18037: 'await' expression cannot be used inside a class static block. } static { ({ [await]: 1 }); // illegal ~~~~~ -!!! error TS18037: Await expression cannot be used inside a class static block. +!!! error TS18037: 'await' expression cannot be used inside a class static block. ~ !!! error TS1109: Expression expected. } @@ -43,7 +43,7 @@ classStaticBlock26.ts(26,27): error TS1109: Expression expected. class D { [await] = 1; // illegal (computed property names are evaluated outside of a class body ~~~~~ -!!! error TS18037: Await expression cannot be used inside a class static block. +!!! error TS18037: 'await' expression cannot be used inside a class static block. ~ !!! error TS1109: Expression expected. }; @@ -56,14 +56,14 @@ classStaticBlock26.ts(26,27): error TS1109: Expression expected. static { await: // illegal, 'await' cannot be used as a label ~~~~~ -!!! error TS18037: Await expression cannot be used inside a class static block. +!!! error TS18037: 'await' expression cannot be used inside a class static block. ~ !!! error TS1109: Expression expected. break await; // illegal, 'await' cannot be used as a label ~~~~~ !!! error TS1003: Identifier expected. ~~~~~ -!!! error TS18037: Await expression cannot be used inside a class static block. +!!! error TS18037: 'await' expression cannot be used inside a class static block. ~ !!! error TS1109: Expression expected. } @@ -71,14 +71,14 @@ classStaticBlock26.ts(26,27): error TS1109: Expression expected. function f(await) { } const ff = (await) => { } ~~~~~ -!!! error TS18037: Await expression cannot be used inside a class static block. +!!! error TS18037: 'await' expression cannot be used inside a class static block. ~ !!! error TS1109: Expression expected. ~~ !!! error TS1005: ';' expected. const fff = await => { } ~~~~~ -!!! error TS18037: Await expression cannot be used inside a class static block. +!!! error TS18037: 'await' expression cannot be used inside a class static block. ~~ !!! error TS1109: Expression expected. } diff --git a/tests/baselines/reference/classStaticBlock5(target=es5).js b/tests/baselines/reference/classStaticBlock5(target=es5).js index b514bcbae1ce3..e12b8213aff5f 100644 --- a/tests/baselines/reference/classStaticBlock5(target=es5).js +++ b/tests/baselines/reference/classStaticBlock5(target=es5).js @@ -34,7 +34,6 @@ var __extends = (this && this.__extends) || (function () { d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; })(); -var _this = this; var B = /** @class */ (function () { function B() { } diff --git a/tests/baselines/reference/classStaticBlock6.errors.txt b/tests/baselines/reference/classStaticBlock6.errors.txt index 899187fc64798..fad78cc7db292 100644 --- a/tests/baselines/reference/classStaticBlock6.errors.txt +++ b/tests/baselines/reference/classStaticBlock6.errors.txt @@ -1,14 +1,14 @@ classStaticBlock6.ts(8,13): error TS1210: Code contained in a class is evaluated in JavaScript's strict mode which does not allow this use of 'arguments'. For more information, see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Strict_mode. classStaticBlock6.ts(9,13): error TS1210: Code contained in a class is evaluated in JavaScript's strict mode which does not allow this use of 'eval'. For more information, see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Strict_mode. -classStaticBlock6.ts(13,9): error TS18037: Await expression cannot be used inside a class static block. +classStaticBlock6.ts(13,9): error TS18037: 'await' expression cannot be used inside a class static block. classStaticBlock6.ts(13,14): error TS1109: Expression expected. classStaticBlock6.ts(17,9): error TS2662: Cannot find name 'arguments'. Did you mean the static member 'C.arguments'? -classStaticBlock6.ts(18,9): error TS18037: Await expression cannot be used inside a class static block. +classStaticBlock6.ts(18,9): error TS18037: 'await' expression cannot be used inside a class static block. classStaticBlock6.ts(18,14): error TS1109: Expression expected. classStaticBlock6.ts(19,9): error TS2337: Super calls are not permitted outside constructors or in nested functions inside constructors. classStaticBlock6.ts(32,17): error TS2337: Super calls are not permitted outside constructors or in nested functions inside constructors. classStaticBlock6.ts(41,13): error TS2815: 'arguments' cannot be referenced in property initializers. -classStaticBlock6.ts(42,13): error TS18037: Await expression cannot be used inside a class static block. +classStaticBlock6.ts(42,13): error TS18037: 'await' expression cannot be used inside a class static block. classStaticBlock6.ts(42,18): error TS1109: Expression expected. classStaticBlock6.ts(45,17): error TS2522: The 'arguments' object cannot be referenced in an async function or method in ES3 and ES5. Consider using a standard function or method. classStaticBlock6.ts(46,22): error TS1109: Expression expected. @@ -34,7 +34,7 @@ classStaticBlock6.ts(55,13): error TS2815: 'arguments' cannot be referenced in p static { await: if (true) { ~~~~~ -!!! error TS18037: Await expression cannot be used inside a class static block. +!!! error TS18037: 'await' expression cannot be used inside a class static block. ~ !!! error TS1109: Expression expected. @@ -45,7 +45,7 @@ classStaticBlock6.ts(55,13): error TS2815: 'arguments' cannot be referenced in p !!! error TS2662: Cannot find name 'arguments'. Did you mean the static member 'C.arguments'? await; ~~~~~ -!!! error TS18037: Await expression cannot be used inside a class static block. +!!! error TS18037: 'await' expression cannot be used inside a class static block. ~ !!! error TS1109: Expression expected. super(); @@ -79,7 +79,7 @@ classStaticBlock6.ts(55,13): error TS2815: 'arguments' cannot be referenced in p !!! error TS2815: 'arguments' cannot be referenced in property initializers. await; ~~~~~ -!!! error TS18037: Await expression cannot be used inside a class static block. +!!! error TS18037: 'await' expression cannot be used inside a class static block. ~ !!! error TS1109: Expression expected. diff --git a/tests/baselines/reference/classStaticBlock7.errors.txt b/tests/baselines/reference/classStaticBlock7.errors.txt index 89dabc6e0b5e2..d149e5bfaf01a 100644 --- a/tests/baselines/reference/classStaticBlock7.errors.txt +++ b/tests/baselines/reference/classStaticBlock7.errors.txt @@ -1,8 +1,8 @@ error TS2318: Cannot find global type 'IterableIterator'. -classStaticBlock7.ts(3,9): error TS18037: Await expression cannot be used inside a class static block. +classStaticBlock7.ts(3,9): error TS18037: 'await' expression cannot be used inside a class static block. classStaticBlock7.ts(4,9): error TS1163: A 'yield' expression is only allowed in a generator body. classStaticBlock7.ts(5,9): error TS18041: A 'return' statement cannot be used inside a class static block. -classStaticBlock7.ts(12,13): error TS18037: Await expression cannot be used inside a class static block. +classStaticBlock7.ts(12,13): error TS18037: 'await' expression cannot be used inside a class static block. classStaticBlock7.ts(24,13): error TS1163: A 'yield' expression is only allowed in a generator body. classStaticBlock7.ts(36,13): error TS18041: A 'return' statement cannot be used inside a class static block. @@ -13,7 +13,7 @@ classStaticBlock7.ts(36,13): error TS18041: A 'return' statement cannot be used static { await 1; ~~~~~~~ -!!! error TS18037: Await expression cannot be used inside a class static block. +!!! error TS18037: 'await' expression cannot be used inside a class static block. yield 1; ~~~~~ !!! error TS1163: A 'yield' expression is only allowed in a generator body. @@ -28,7 +28,7 @@ classStaticBlock7.ts(36,13): error TS18041: A 'return' statement cannot be used static { await 1; ~~~~~~~ -!!! error TS18037: Await expression cannot be used inside a class static block. +!!! error TS18037: 'await' expression cannot be used inside a class static block. async function ff () { await 1; diff --git a/tests/baselines/reference/commonJSImportAsPrimaryExpression.js b/tests/baselines/reference/commonJSImportAsPrimaryExpression.js index 566de077611a7..a02e7388fbfa8 100644 --- a/tests/baselines/reference/commonJSImportAsPrimaryExpression.js +++ b/tests/baselines/reference/commonJSImportAsPrimaryExpression.js @@ -17,13 +17,14 @@ if(foo.C1.s1){ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.C1 = void 0; -var C1 = exports.C1 = /** @class */ (function () { +var C1 = /** @class */ (function () { function C1() { this.m1 = 42; } C1.s1 = true; return C1; }()); +exports.C1 = C1; //// [foo_1.js] "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); diff --git a/tests/baselines/reference/commonJSImportNotAsPrimaryExpression.js b/tests/baselines/reference/commonJSImportNotAsPrimaryExpression.js index d569a47d39231..8ce80ce2db472 100644 --- a/tests/baselines/reference/commonJSImportNotAsPrimaryExpression.js +++ b/tests/baselines/reference/commonJSImportNotAsPrimaryExpression.js @@ -35,13 +35,14 @@ var e: number = 0; "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.E1 = exports.C1 = void 0; -var C1 = exports.C1 = /** @class */ (function () { +var C1 = /** @class */ (function () { function C1() { this.m1 = 42; } C1.s1 = true; return C1; }()); +exports.C1 = C1; var E1; (function (E1) { E1[E1["A"] = 0] = "A"; diff --git a/tests/baselines/reference/compoundExponentiationAssignmentLHSIsValue.js b/tests/baselines/reference/compoundExponentiationAssignmentLHSIsValue.js index 6b9c08c23fcfa..b6b07e6b08cd6 100644 --- a/tests/baselines/reference/compoundExponentiationAssignmentLHSIsValue.js +++ b/tests/baselines/reference/compoundExponentiationAssignmentLHSIsValue.js @@ -152,9 +152,8 @@ _a = Math.pow(['', ''], value), '' = _a[0], '' = _a[1]; var Derived = /** @class */ (function (_super) { __extends(Derived, _super); function Derived() { - var _this = this; var _a; - _this = _super.call(this) || this; + var _this = _super.call(this) || this; (_a = _super.prototype). = Math.pow(_a., value); return _this; } diff --git a/tests/baselines/reference/config/commandLineParsing/parseCommandLine/Parse --lib option with extra comma.js b/tests/baselines/reference/config/commandLineParsing/parseCommandLine/Parse --lib option with extra comma.js index 59c64e4c74698..8a71d8443a5d4 100644 --- a/tests/baselines/reference/config/commandLineParsing/parseCommandLine/Parse --lib option with extra comma.js +++ b/tests/baselines/reference/config/commandLineParsing/parseCommandLine/Parse --lib option with extra comma.js @@ -10,4 +10,4 @@ WatchOptions:: FileNames:: es7,0.ts Errors:: -error TS6046: Argument for '--lib' option must be: 'es5', 'es6', 'es2015', 'es7', 'es2016', 'es2017', 'es2018', 'es2019', 'es2020', 'es2021', 'es2022', 'es2023', 'esnext', 'dom', 'dom.iterable', 'webworker', 'webworker.importscripts', 'webworker.iterable', 'scripthost', 'es2015.core', 'es2015.collection', 'es2015.generator', 'es2015.iterable', 'es2015.promise', 'es2015.proxy', 'es2015.reflect', 'es2015.symbol', 'es2015.symbol.wellknown', 'es2016.array.include', 'es2017.date', 'es2017.object', 'es2017.sharedmemory', 'es2017.string', 'es2017.intl', 'es2017.typedarrays', 'es2018.asyncgenerator', 'es2018.asynciterable', 'es2018.intl', 'es2018.promise', 'es2018.regexp', 'es2019.array', 'es2019.object', 'es2019.string', 'es2019.symbol', 'es2019.intl', 'es2020.bigint', 'es2020.date', 'es2020.promise', 'es2020.sharedmemory', 'es2020.string', 'es2020.symbol.wellknown', 'es2020.intl', 'es2020.number', 'es2021.promise', 'es2021.string', 'es2021.weakref', 'es2021.intl', 'es2022.array', 'es2022.error', 'es2022.intl', 'es2022.object', 'es2022.sharedmemory', 'es2022.string', 'es2022.regexp', 'es2023.array', 'es2023.collection', 'esnext.array', 'esnext.collection', 'esnext.symbol', 'esnext.asynciterable', 'esnext.intl', 'esnext.bigint', 'esnext.string', 'esnext.promise', 'esnext.weakref', 'decorators', 'decorators.legacy'. +error TS6046: Argument for '--lib' option must be: 'es5', 'es6', 'es2015', 'es7', 'es2016', 'es2017', 'es2018', 'es2019', 'es2020', 'es2021', 'es2022', 'es2023', 'esnext', 'dom', 'dom.iterable', 'webworker', 'webworker.importscripts', 'webworker.iterable', 'scripthost', 'es2015.core', 'es2015.collection', 'es2015.generator', 'es2015.iterable', 'es2015.promise', 'es2015.proxy', 'es2015.reflect', 'es2015.symbol', 'es2015.symbol.wellknown', 'es2016.array.include', 'es2017.date', 'es2017.object', 'es2017.sharedmemory', 'es2017.string', 'es2017.intl', 'es2017.typedarrays', 'es2018.asyncgenerator', 'es2018.asynciterable', 'es2018.intl', 'es2018.promise', 'es2018.regexp', 'es2019.array', 'es2019.object', 'es2019.string', 'es2019.symbol', 'es2019.intl', 'es2020.bigint', 'es2020.date', 'es2020.promise', 'es2020.sharedmemory', 'es2020.string', 'es2020.symbol.wellknown', 'es2020.intl', 'es2020.number', 'es2021.promise', 'es2021.string', 'es2021.weakref', 'es2021.intl', 'es2022.array', 'es2022.error', 'es2022.intl', 'es2022.object', 'es2022.sharedmemory', 'es2022.string', 'es2022.regexp', 'es2023.array', 'es2023.collection', 'esnext.array', 'esnext.collection', 'esnext.symbol', 'esnext.asynciterable', 'esnext.intl', 'esnext.disposable', 'esnext.bigint', 'esnext.string', 'esnext.promise', 'esnext.weakref', 'decorators', 'decorators.legacy'. diff --git a/tests/baselines/reference/config/commandLineParsing/parseCommandLine/Parse --lib option with trailing white-space.js b/tests/baselines/reference/config/commandLineParsing/parseCommandLine/Parse --lib option with trailing white-space.js index c51ff3925997f..ec3c309cdec68 100644 --- a/tests/baselines/reference/config/commandLineParsing/parseCommandLine/Parse --lib option with trailing white-space.js +++ b/tests/baselines/reference/config/commandLineParsing/parseCommandLine/Parse --lib option with trailing white-space.js @@ -10,4 +10,4 @@ WatchOptions:: FileNames:: es7,0.ts Errors:: -error TS6046: Argument for '--lib' option must be: 'es5', 'es6', 'es2015', 'es7', 'es2016', 'es2017', 'es2018', 'es2019', 'es2020', 'es2021', 'es2022', 'es2023', 'esnext', 'dom', 'dom.iterable', 'webworker', 'webworker.importscripts', 'webworker.iterable', 'scripthost', 'es2015.core', 'es2015.collection', 'es2015.generator', 'es2015.iterable', 'es2015.promise', 'es2015.proxy', 'es2015.reflect', 'es2015.symbol', 'es2015.symbol.wellknown', 'es2016.array.include', 'es2017.date', 'es2017.object', 'es2017.sharedmemory', 'es2017.string', 'es2017.intl', 'es2017.typedarrays', 'es2018.asyncgenerator', 'es2018.asynciterable', 'es2018.intl', 'es2018.promise', 'es2018.regexp', 'es2019.array', 'es2019.object', 'es2019.string', 'es2019.symbol', 'es2019.intl', 'es2020.bigint', 'es2020.date', 'es2020.promise', 'es2020.sharedmemory', 'es2020.string', 'es2020.symbol.wellknown', 'es2020.intl', 'es2020.number', 'es2021.promise', 'es2021.string', 'es2021.weakref', 'es2021.intl', 'es2022.array', 'es2022.error', 'es2022.intl', 'es2022.object', 'es2022.sharedmemory', 'es2022.string', 'es2022.regexp', 'es2023.array', 'es2023.collection', 'esnext.array', 'esnext.collection', 'esnext.symbol', 'esnext.asynciterable', 'esnext.intl', 'esnext.bigint', 'esnext.string', 'esnext.promise', 'esnext.weakref', 'decorators', 'decorators.legacy'. +error TS6046: Argument for '--lib' option must be: 'es5', 'es6', 'es2015', 'es7', 'es2016', 'es2017', 'es2018', 'es2019', 'es2020', 'es2021', 'es2022', 'es2023', 'esnext', 'dom', 'dom.iterable', 'webworker', 'webworker.importscripts', 'webworker.iterable', 'scripthost', 'es2015.core', 'es2015.collection', 'es2015.generator', 'es2015.iterable', 'es2015.promise', 'es2015.proxy', 'es2015.reflect', 'es2015.symbol', 'es2015.symbol.wellknown', 'es2016.array.include', 'es2017.date', 'es2017.object', 'es2017.sharedmemory', 'es2017.string', 'es2017.intl', 'es2017.typedarrays', 'es2018.asyncgenerator', 'es2018.asynciterable', 'es2018.intl', 'es2018.promise', 'es2018.regexp', 'es2019.array', 'es2019.object', 'es2019.string', 'es2019.symbol', 'es2019.intl', 'es2020.bigint', 'es2020.date', 'es2020.promise', 'es2020.sharedmemory', 'es2020.string', 'es2020.symbol.wellknown', 'es2020.intl', 'es2020.number', 'es2021.promise', 'es2021.string', 'es2021.weakref', 'es2021.intl', 'es2022.array', 'es2022.error', 'es2022.intl', 'es2022.object', 'es2022.sharedmemory', 'es2022.string', 'es2022.regexp', 'es2023.array', 'es2023.collection', 'esnext.array', 'esnext.collection', 'esnext.symbol', 'esnext.asynciterable', 'esnext.intl', 'esnext.disposable', 'esnext.bigint', 'esnext.string', 'esnext.promise', 'esnext.weakref', 'decorators', 'decorators.legacy'. diff --git a/tests/baselines/reference/config/commandLineParsing/parseCommandLine/Parse invalid option of library flags.js b/tests/baselines/reference/config/commandLineParsing/parseCommandLine/Parse invalid option of library flags.js index b4473aa3f2b95..2fcb1cb1d263e 100644 --- a/tests/baselines/reference/config/commandLineParsing/parseCommandLine/Parse invalid option of library flags.js +++ b/tests/baselines/reference/config/commandLineParsing/parseCommandLine/Parse invalid option of library flags.js @@ -10,4 +10,4 @@ WatchOptions:: FileNames:: 0.ts Errors:: -error TS6046: Argument for '--lib' option must be: 'es5', 'es6', 'es2015', 'es7', 'es2016', 'es2017', 'es2018', 'es2019', 'es2020', 'es2021', 'es2022', 'es2023', 'esnext', 'dom', 'dom.iterable', 'webworker', 'webworker.importscripts', 'webworker.iterable', 'scripthost', 'es2015.core', 'es2015.collection', 'es2015.generator', 'es2015.iterable', 'es2015.promise', 'es2015.proxy', 'es2015.reflect', 'es2015.symbol', 'es2015.symbol.wellknown', 'es2016.array.include', 'es2017.date', 'es2017.object', 'es2017.sharedmemory', 'es2017.string', 'es2017.intl', 'es2017.typedarrays', 'es2018.asyncgenerator', 'es2018.asynciterable', 'es2018.intl', 'es2018.promise', 'es2018.regexp', 'es2019.array', 'es2019.object', 'es2019.string', 'es2019.symbol', 'es2019.intl', 'es2020.bigint', 'es2020.date', 'es2020.promise', 'es2020.sharedmemory', 'es2020.string', 'es2020.symbol.wellknown', 'es2020.intl', 'es2020.number', 'es2021.promise', 'es2021.string', 'es2021.weakref', 'es2021.intl', 'es2022.array', 'es2022.error', 'es2022.intl', 'es2022.object', 'es2022.sharedmemory', 'es2022.string', 'es2022.regexp', 'es2023.array', 'es2023.collection', 'esnext.array', 'esnext.collection', 'esnext.symbol', 'esnext.asynciterable', 'esnext.intl', 'esnext.bigint', 'esnext.string', 'esnext.promise', 'esnext.weakref', 'decorators', 'decorators.legacy'. +error TS6046: Argument for '--lib' option must be: 'es5', 'es6', 'es2015', 'es7', 'es2016', 'es2017', 'es2018', 'es2019', 'es2020', 'es2021', 'es2022', 'es2023', 'esnext', 'dom', 'dom.iterable', 'webworker', 'webworker.importscripts', 'webworker.iterable', 'scripthost', 'es2015.core', 'es2015.collection', 'es2015.generator', 'es2015.iterable', 'es2015.promise', 'es2015.proxy', 'es2015.reflect', 'es2015.symbol', 'es2015.symbol.wellknown', 'es2016.array.include', 'es2017.date', 'es2017.object', 'es2017.sharedmemory', 'es2017.string', 'es2017.intl', 'es2017.typedarrays', 'es2018.asyncgenerator', 'es2018.asynciterable', 'es2018.intl', 'es2018.promise', 'es2018.regexp', 'es2019.array', 'es2019.object', 'es2019.string', 'es2019.symbol', 'es2019.intl', 'es2020.bigint', 'es2020.date', 'es2020.promise', 'es2020.sharedmemory', 'es2020.string', 'es2020.symbol.wellknown', 'es2020.intl', 'es2020.number', 'es2021.promise', 'es2021.string', 'es2021.weakref', 'es2021.intl', 'es2022.array', 'es2022.error', 'es2022.intl', 'es2022.object', 'es2022.sharedmemory', 'es2022.string', 'es2022.regexp', 'es2023.array', 'es2023.collection', 'esnext.array', 'esnext.collection', 'esnext.symbol', 'esnext.asynciterable', 'esnext.intl', 'esnext.disposable', 'esnext.bigint', 'esnext.string', 'esnext.promise', 'esnext.weakref', 'decorators', 'decorators.legacy'. diff --git a/tests/baselines/reference/config/convertCompilerOptionsFromJson/Convert empty string option of libs array to compiler-options with json api.js b/tests/baselines/reference/config/convertCompilerOptionsFromJson/Convert empty string option of libs array to compiler-options with json api.js index 5844a15bc14e9..36276be0123a5 100644 --- a/tests/baselines/reference/config/convertCompilerOptionsFromJson/Convert empty string option of libs array to compiler-options with json api.js +++ b/tests/baselines/reference/config/convertCompilerOptionsFromJson/Convert empty string option of libs array to compiler-options with json api.js @@ -30,5 +30,5 @@ CompilerOptions:: "configFilePath": "tsconfig.json" } Errors:: -error TS6046: Argument for '--lib' option must be: 'es5', 'es6', 'es2015', 'es7', 'es2016', 'es2017', 'es2018', 'es2019', 'es2020', 'es2021', 'es2022', 'es2023', 'esnext', 'dom', 'dom.iterable', 'webworker', 'webworker.importscripts', 'webworker.iterable', 'scripthost', 'es2015.core', 'es2015.collection', 'es2015.generator', 'es2015.iterable', 'es2015.promise', 'es2015.proxy', 'es2015.reflect', 'es2015.symbol', 'es2015.symbol.wellknown', 'es2016.array.include', 'es2017.date', 'es2017.object', 'es2017.sharedmemory', 'es2017.string', 'es2017.intl', 'es2017.typedarrays', 'es2018.asyncgenerator', 'es2018.asynciterable', 'es2018.intl', 'es2018.promise', 'es2018.regexp', 'es2019.array', 'es2019.object', 'es2019.string', 'es2019.symbol', 'es2019.intl', 'es2020.bigint', 'es2020.date', 'es2020.promise', 'es2020.sharedmemory', 'es2020.string', 'es2020.symbol.wellknown', 'es2020.intl', 'es2020.number', 'es2021.promise', 'es2021.string', 'es2021.weakref', 'es2021.intl', 'es2022.array', 'es2022.error', 'es2022.intl', 'es2022.object', 'es2022.sharedmemory', 'es2022.string', 'es2022.regexp', 'es2023.array', 'es2023.collection', 'esnext.array', 'esnext.collection', 'esnext.symbol', 'esnext.asynciterable', 'esnext.intl', 'esnext.bigint', 'esnext.string', 'esnext.promise', 'esnext.weakref', 'decorators', 'decorators.legacy'. +error TS6046: Argument for '--lib' option must be: 'es5', 'es6', 'es2015', 'es7', 'es2016', 'es2017', 'es2018', 'es2019', 'es2020', 'es2021', 'es2022', 'es2023', 'esnext', 'dom', 'dom.iterable', 'webworker', 'webworker.importscripts', 'webworker.iterable', 'scripthost', 'es2015.core', 'es2015.collection', 'es2015.generator', 'es2015.iterable', 'es2015.promise', 'es2015.proxy', 'es2015.reflect', 'es2015.symbol', 'es2015.symbol.wellknown', 'es2016.array.include', 'es2017.date', 'es2017.object', 'es2017.sharedmemory', 'es2017.string', 'es2017.intl', 'es2017.typedarrays', 'es2018.asyncgenerator', 'es2018.asynciterable', 'es2018.intl', 'es2018.promise', 'es2018.regexp', 'es2019.array', 'es2019.object', 'es2019.string', 'es2019.symbol', 'es2019.intl', 'es2020.bigint', 'es2020.date', 'es2020.promise', 'es2020.sharedmemory', 'es2020.string', 'es2020.symbol.wellknown', 'es2020.intl', 'es2020.number', 'es2021.promise', 'es2021.string', 'es2021.weakref', 'es2021.intl', 'es2022.array', 'es2022.error', 'es2022.intl', 'es2022.object', 'es2022.sharedmemory', 'es2022.string', 'es2022.regexp', 'es2023.array', 'es2023.collection', 'esnext.array', 'esnext.collection', 'esnext.symbol', 'esnext.asynciterable', 'esnext.intl', 'esnext.disposable', 'esnext.bigint', 'esnext.string', 'esnext.promise', 'esnext.weakref', 'decorators', 'decorators.legacy'. diff --git a/tests/baselines/reference/config/convertCompilerOptionsFromJson/Convert empty string option of libs array to compiler-options with jsonSourceFile api.js b/tests/baselines/reference/config/convertCompilerOptionsFromJson/Convert empty string option of libs array to compiler-options with jsonSourceFile api.js index 6122b24401c05..1519a62551298 100644 --- a/tests/baselines/reference/config/convertCompilerOptionsFromJson/Convert empty string option of libs array to compiler-options with jsonSourceFile api.js +++ b/tests/baselines/reference/config/convertCompilerOptionsFromJson/Convert empty string option of libs array to compiler-options with jsonSourceFile api.js @@ -30,7 +30,7 @@ CompilerOptions:: "configFilePath": "tsconfig.json" } Errors:: -tsconfig.json:8:4 - error TS6046: Argument for '--lib' option must be: 'es5', 'es6', 'es2015', 'es7', 'es2016', 'es2017', 'es2018', 'es2019', 'es2020', 'es2021', 'es2022', 'es2023', 'esnext', 'dom', 'dom.iterable', 'webworker', 'webworker.importscripts', 'webworker.iterable', 'scripthost', 'es2015.core', 'es2015.collection', 'es2015.generator', 'es2015.iterable', 'es2015.promise', 'es2015.proxy', 'es2015.reflect', 'es2015.symbol', 'es2015.symbol.wellknown', 'es2016.array.include', 'es2017.date', 'es2017.object', 'es2017.sharedmemory', 'es2017.string', 'es2017.intl', 'es2017.typedarrays', 'es2018.asyncgenerator', 'es2018.asynciterable', 'es2018.intl', 'es2018.promise', 'es2018.regexp', 'es2019.array', 'es2019.object', 'es2019.string', 'es2019.symbol', 'es2019.intl', 'es2020.bigint', 'es2020.date', 'es2020.promise', 'es2020.sharedmemory', 'es2020.string', 'es2020.symbol.wellknown', 'es2020.intl', 'es2020.number', 'es2021.promise', 'es2021.string', 'es2021.weakref', 'es2021.intl', 'es2022.array', 'es2022.error', 'es2022.intl', 'es2022.object', 'es2022.sharedmemory', 'es2022.string', 'es2022.regexp', 'es2023.array', 'es2023.collection', 'esnext.array', 'esnext.collection', 'esnext.symbol', 'esnext.asynciterable', 'esnext.intl', 'esnext.bigint', 'esnext.string', 'esnext.promise', 'esnext.weakref', 'decorators', 'decorators.legacy'. +tsconfig.json:8:4 - error TS6046: Argument for '--lib' option must be: 'es5', 'es6', 'es2015', 'es7', 'es2016', 'es2017', 'es2018', 'es2019', 'es2020', 'es2021', 'es2022', 'es2023', 'esnext', 'dom', 'dom.iterable', 'webworker', 'webworker.importscripts', 'webworker.iterable', 'scripthost', 'es2015.core', 'es2015.collection', 'es2015.generator', 'es2015.iterable', 'es2015.promise', 'es2015.proxy', 'es2015.reflect', 'es2015.symbol', 'es2015.symbol.wellknown', 'es2016.array.include', 'es2017.date', 'es2017.object', 'es2017.sharedmemory', 'es2017.string', 'es2017.intl', 'es2017.typedarrays', 'es2018.asyncgenerator', 'es2018.asynciterable', 'es2018.intl', 'es2018.promise', 'es2018.regexp', 'es2019.array', 'es2019.object', 'es2019.string', 'es2019.symbol', 'es2019.intl', 'es2020.bigint', 'es2020.date', 'es2020.promise', 'es2020.sharedmemory', 'es2020.string', 'es2020.symbol.wellknown', 'es2020.intl', 'es2020.number', 'es2021.promise', 'es2021.string', 'es2021.weakref', 'es2021.intl', 'es2022.array', 'es2022.error', 'es2022.intl', 'es2022.object', 'es2022.sharedmemory', 'es2022.string', 'es2022.regexp', 'es2023.array', 'es2023.collection', 'esnext.array', 'esnext.collection', 'esnext.symbol', 'esnext.asynciterable', 'esnext.intl', 'esnext.disposable', 'esnext.bigint', 'esnext.string', 'esnext.promise', 'esnext.weakref', 'decorators', 'decorators.legacy'. 8 ""    ~~ diff --git a/tests/baselines/reference/config/convertCompilerOptionsFromJson/Convert empty string option of libs to compiler-options with json api.js b/tests/baselines/reference/config/convertCompilerOptionsFromJson/Convert empty string option of libs to compiler-options with json api.js index f089381ab7632..f6aec65ca3ae4 100644 --- a/tests/baselines/reference/config/convertCompilerOptionsFromJson/Convert empty string option of libs to compiler-options with json api.js +++ b/tests/baselines/reference/config/convertCompilerOptionsFromJson/Convert empty string option of libs to compiler-options with json api.js @@ -33,5 +33,5 @@ CompilerOptions:: "configFilePath": "tsconfig.json" } Errors:: -error TS6046: Argument for '--lib' option must be: 'es5', 'es6', 'es2015', 'es7', 'es2016', 'es2017', 'es2018', 'es2019', 'es2020', 'es2021', 'es2022', 'es2023', 'esnext', 'dom', 'dom.iterable', 'webworker', 'webworker.importscripts', 'webworker.iterable', 'scripthost', 'es2015.core', 'es2015.collection', 'es2015.generator', 'es2015.iterable', 'es2015.promise', 'es2015.proxy', 'es2015.reflect', 'es2015.symbol', 'es2015.symbol.wellknown', 'es2016.array.include', 'es2017.date', 'es2017.object', 'es2017.sharedmemory', 'es2017.string', 'es2017.intl', 'es2017.typedarrays', 'es2018.asyncgenerator', 'es2018.asynciterable', 'es2018.intl', 'es2018.promise', 'es2018.regexp', 'es2019.array', 'es2019.object', 'es2019.string', 'es2019.symbol', 'es2019.intl', 'es2020.bigint', 'es2020.date', 'es2020.promise', 'es2020.sharedmemory', 'es2020.string', 'es2020.symbol.wellknown', 'es2020.intl', 'es2020.number', 'es2021.promise', 'es2021.string', 'es2021.weakref', 'es2021.intl', 'es2022.array', 'es2022.error', 'es2022.intl', 'es2022.object', 'es2022.sharedmemory', 'es2022.string', 'es2022.regexp', 'es2023.array', 'es2023.collection', 'esnext.array', 'esnext.collection', 'esnext.symbol', 'esnext.asynciterable', 'esnext.intl', 'esnext.bigint', 'esnext.string', 'esnext.promise', 'esnext.weakref', 'decorators', 'decorators.legacy'. +error TS6046: Argument for '--lib' option must be: 'es5', 'es6', 'es2015', 'es7', 'es2016', 'es2017', 'es2018', 'es2019', 'es2020', 'es2021', 'es2022', 'es2023', 'esnext', 'dom', 'dom.iterable', 'webworker', 'webworker.importscripts', 'webworker.iterable', 'scripthost', 'es2015.core', 'es2015.collection', 'es2015.generator', 'es2015.iterable', 'es2015.promise', 'es2015.proxy', 'es2015.reflect', 'es2015.symbol', 'es2015.symbol.wellknown', 'es2016.array.include', 'es2017.date', 'es2017.object', 'es2017.sharedmemory', 'es2017.string', 'es2017.intl', 'es2017.typedarrays', 'es2018.asyncgenerator', 'es2018.asynciterable', 'es2018.intl', 'es2018.promise', 'es2018.regexp', 'es2019.array', 'es2019.object', 'es2019.string', 'es2019.symbol', 'es2019.intl', 'es2020.bigint', 'es2020.date', 'es2020.promise', 'es2020.sharedmemory', 'es2020.string', 'es2020.symbol.wellknown', 'es2020.intl', 'es2020.number', 'es2021.promise', 'es2021.string', 'es2021.weakref', 'es2021.intl', 'es2022.array', 'es2022.error', 'es2022.intl', 'es2022.object', 'es2022.sharedmemory', 'es2022.string', 'es2022.regexp', 'es2023.array', 'es2023.collection', 'esnext.array', 'esnext.collection', 'esnext.symbol', 'esnext.asynciterable', 'esnext.intl', 'esnext.disposable', 'esnext.bigint', 'esnext.string', 'esnext.promise', 'esnext.weakref', 'decorators', 'decorators.legacy'. diff --git a/tests/baselines/reference/config/convertCompilerOptionsFromJson/Convert empty string option of libs to compiler-options with jsonSourceFile api.js b/tests/baselines/reference/config/convertCompilerOptionsFromJson/Convert empty string option of libs to compiler-options with jsonSourceFile api.js index 6a996e3a80cea..66b7ccff8d015 100644 --- a/tests/baselines/reference/config/convertCompilerOptionsFromJson/Convert empty string option of libs to compiler-options with jsonSourceFile api.js +++ b/tests/baselines/reference/config/convertCompilerOptionsFromJson/Convert empty string option of libs to compiler-options with jsonSourceFile api.js @@ -33,7 +33,7 @@ CompilerOptions:: "configFilePath": "tsconfig.json" } Errors:: -tsconfig.json:9:4 - error TS6046: Argument for '--lib' option must be: 'es5', 'es6', 'es2015', 'es7', 'es2016', 'es2017', 'es2018', 'es2019', 'es2020', 'es2021', 'es2022', 'es2023', 'esnext', 'dom', 'dom.iterable', 'webworker', 'webworker.importscripts', 'webworker.iterable', 'scripthost', 'es2015.core', 'es2015.collection', 'es2015.generator', 'es2015.iterable', 'es2015.promise', 'es2015.proxy', 'es2015.reflect', 'es2015.symbol', 'es2015.symbol.wellknown', 'es2016.array.include', 'es2017.date', 'es2017.object', 'es2017.sharedmemory', 'es2017.string', 'es2017.intl', 'es2017.typedarrays', 'es2018.asyncgenerator', 'es2018.asynciterable', 'es2018.intl', 'es2018.promise', 'es2018.regexp', 'es2019.array', 'es2019.object', 'es2019.string', 'es2019.symbol', 'es2019.intl', 'es2020.bigint', 'es2020.date', 'es2020.promise', 'es2020.sharedmemory', 'es2020.string', 'es2020.symbol.wellknown', 'es2020.intl', 'es2020.number', 'es2021.promise', 'es2021.string', 'es2021.weakref', 'es2021.intl', 'es2022.array', 'es2022.error', 'es2022.intl', 'es2022.object', 'es2022.sharedmemory', 'es2022.string', 'es2022.regexp', 'es2023.array', 'es2023.collection', 'esnext.array', 'esnext.collection', 'esnext.symbol', 'esnext.asynciterable', 'esnext.intl', 'esnext.bigint', 'esnext.string', 'esnext.promise', 'esnext.weakref', 'decorators', 'decorators.legacy'. +tsconfig.json:9:4 - error TS6046: Argument for '--lib' option must be: 'es5', 'es6', 'es2015', 'es7', 'es2016', 'es2017', 'es2018', 'es2019', 'es2020', 'es2021', 'es2022', 'es2023', 'esnext', 'dom', 'dom.iterable', 'webworker', 'webworker.importscripts', 'webworker.iterable', 'scripthost', 'es2015.core', 'es2015.collection', 'es2015.generator', 'es2015.iterable', 'es2015.promise', 'es2015.proxy', 'es2015.reflect', 'es2015.symbol', 'es2015.symbol.wellknown', 'es2016.array.include', 'es2017.date', 'es2017.object', 'es2017.sharedmemory', 'es2017.string', 'es2017.intl', 'es2017.typedarrays', 'es2018.asyncgenerator', 'es2018.asynciterable', 'es2018.intl', 'es2018.promise', 'es2018.regexp', 'es2019.array', 'es2019.object', 'es2019.string', 'es2019.symbol', 'es2019.intl', 'es2020.bigint', 'es2020.date', 'es2020.promise', 'es2020.sharedmemory', 'es2020.string', 'es2020.symbol.wellknown', 'es2020.intl', 'es2020.number', 'es2021.promise', 'es2021.string', 'es2021.weakref', 'es2021.intl', 'es2022.array', 'es2022.error', 'es2022.intl', 'es2022.object', 'es2022.sharedmemory', 'es2022.string', 'es2022.regexp', 'es2023.array', 'es2023.collection', 'esnext.array', 'esnext.collection', 'esnext.symbol', 'esnext.asynciterable', 'esnext.intl', 'esnext.disposable', 'esnext.bigint', 'esnext.string', 'esnext.promise', 'esnext.weakref', 'decorators', 'decorators.legacy'. 9 ""    ~~ diff --git a/tests/baselines/reference/config/convertCompilerOptionsFromJson/Convert incorrect option of libs to compiler-options with json api.js b/tests/baselines/reference/config/convertCompilerOptionsFromJson/Convert incorrect option of libs to compiler-options with json api.js index 0aea5a2fe93a4..16074f2751946 100644 --- a/tests/baselines/reference/config/convertCompilerOptionsFromJson/Convert incorrect option of libs to compiler-options with json api.js +++ b/tests/baselines/reference/config/convertCompilerOptionsFromJson/Convert incorrect option of libs to compiler-options with json api.js @@ -35,5 +35,5 @@ CompilerOptions:: "configFilePath": "tsconfig.json" } Errors:: -error TS6046: Argument for '--lib' option must be: 'es5', 'es6', 'es2015', 'es7', 'es2016', 'es2017', 'es2018', 'es2019', 'es2020', 'es2021', 'es2022', 'es2023', 'esnext', 'dom', 'dom.iterable', 'webworker', 'webworker.importscripts', 'webworker.iterable', 'scripthost', 'es2015.core', 'es2015.collection', 'es2015.generator', 'es2015.iterable', 'es2015.promise', 'es2015.proxy', 'es2015.reflect', 'es2015.symbol', 'es2015.symbol.wellknown', 'es2016.array.include', 'es2017.date', 'es2017.object', 'es2017.sharedmemory', 'es2017.string', 'es2017.intl', 'es2017.typedarrays', 'es2018.asyncgenerator', 'es2018.asynciterable', 'es2018.intl', 'es2018.promise', 'es2018.regexp', 'es2019.array', 'es2019.object', 'es2019.string', 'es2019.symbol', 'es2019.intl', 'es2020.bigint', 'es2020.date', 'es2020.promise', 'es2020.sharedmemory', 'es2020.string', 'es2020.symbol.wellknown', 'es2020.intl', 'es2020.number', 'es2021.promise', 'es2021.string', 'es2021.weakref', 'es2021.intl', 'es2022.array', 'es2022.error', 'es2022.intl', 'es2022.object', 'es2022.sharedmemory', 'es2022.string', 'es2022.regexp', 'es2023.array', 'es2023.collection', 'esnext.array', 'esnext.collection', 'esnext.symbol', 'esnext.asynciterable', 'esnext.intl', 'esnext.bigint', 'esnext.string', 'esnext.promise', 'esnext.weakref', 'decorators', 'decorators.legacy'. +error TS6046: Argument for '--lib' option must be: 'es5', 'es6', 'es2015', 'es7', 'es2016', 'es2017', 'es2018', 'es2019', 'es2020', 'es2021', 'es2022', 'es2023', 'esnext', 'dom', 'dom.iterable', 'webworker', 'webworker.importscripts', 'webworker.iterable', 'scripthost', 'es2015.core', 'es2015.collection', 'es2015.generator', 'es2015.iterable', 'es2015.promise', 'es2015.proxy', 'es2015.reflect', 'es2015.symbol', 'es2015.symbol.wellknown', 'es2016.array.include', 'es2017.date', 'es2017.object', 'es2017.sharedmemory', 'es2017.string', 'es2017.intl', 'es2017.typedarrays', 'es2018.asyncgenerator', 'es2018.asynciterable', 'es2018.intl', 'es2018.promise', 'es2018.regexp', 'es2019.array', 'es2019.object', 'es2019.string', 'es2019.symbol', 'es2019.intl', 'es2020.bigint', 'es2020.date', 'es2020.promise', 'es2020.sharedmemory', 'es2020.string', 'es2020.symbol.wellknown', 'es2020.intl', 'es2020.number', 'es2021.promise', 'es2021.string', 'es2021.weakref', 'es2021.intl', 'es2022.array', 'es2022.error', 'es2022.intl', 'es2022.object', 'es2022.sharedmemory', 'es2022.string', 'es2022.regexp', 'es2023.array', 'es2023.collection', 'esnext.array', 'esnext.collection', 'esnext.symbol', 'esnext.asynciterable', 'esnext.intl', 'esnext.disposable', 'esnext.bigint', 'esnext.string', 'esnext.promise', 'esnext.weakref', 'decorators', 'decorators.legacy'. diff --git a/tests/baselines/reference/config/convertCompilerOptionsFromJson/Convert incorrect option of libs to compiler-options with jsonSourceFile api.js b/tests/baselines/reference/config/convertCompilerOptionsFromJson/Convert incorrect option of libs to compiler-options with jsonSourceFile api.js index bdaa64c07be95..72c476e7e2fe3 100644 --- a/tests/baselines/reference/config/convertCompilerOptionsFromJson/Convert incorrect option of libs to compiler-options with jsonSourceFile api.js +++ b/tests/baselines/reference/config/convertCompilerOptionsFromJson/Convert incorrect option of libs to compiler-options with jsonSourceFile api.js @@ -35,7 +35,7 @@ CompilerOptions:: "configFilePath": "tsconfig.json" } Errors:: -tsconfig.json:10:4 - error TS6046: Argument for '--lib' option must be: 'es5', 'es6', 'es2015', 'es7', 'es2016', 'es2017', 'es2018', 'es2019', 'es2020', 'es2021', 'es2022', 'es2023', 'esnext', 'dom', 'dom.iterable', 'webworker', 'webworker.importscripts', 'webworker.iterable', 'scripthost', 'es2015.core', 'es2015.collection', 'es2015.generator', 'es2015.iterable', 'es2015.promise', 'es2015.proxy', 'es2015.reflect', 'es2015.symbol', 'es2015.symbol.wellknown', 'es2016.array.include', 'es2017.date', 'es2017.object', 'es2017.sharedmemory', 'es2017.string', 'es2017.intl', 'es2017.typedarrays', 'es2018.asyncgenerator', 'es2018.asynciterable', 'es2018.intl', 'es2018.promise', 'es2018.regexp', 'es2019.array', 'es2019.object', 'es2019.string', 'es2019.symbol', 'es2019.intl', 'es2020.bigint', 'es2020.date', 'es2020.promise', 'es2020.sharedmemory', 'es2020.string', 'es2020.symbol.wellknown', 'es2020.intl', 'es2020.number', 'es2021.promise', 'es2021.string', 'es2021.weakref', 'es2021.intl', 'es2022.array', 'es2022.error', 'es2022.intl', 'es2022.object', 'es2022.sharedmemory', 'es2022.string', 'es2022.regexp', 'es2023.array', 'es2023.collection', 'esnext.array', 'esnext.collection', 'esnext.symbol', 'esnext.asynciterable', 'esnext.intl', 'esnext.bigint', 'esnext.string', 'esnext.promise', 'esnext.weakref', 'decorators', 'decorators.legacy'. +tsconfig.json:10:4 - error TS6046: Argument for '--lib' option must be: 'es5', 'es6', 'es2015', 'es7', 'es2016', 'es2017', 'es2018', 'es2019', 'es2020', 'es2021', 'es2022', 'es2023', 'esnext', 'dom', 'dom.iterable', 'webworker', 'webworker.importscripts', 'webworker.iterable', 'scripthost', 'es2015.core', 'es2015.collection', 'es2015.generator', 'es2015.iterable', 'es2015.promise', 'es2015.proxy', 'es2015.reflect', 'es2015.symbol', 'es2015.symbol.wellknown', 'es2016.array.include', 'es2017.date', 'es2017.object', 'es2017.sharedmemory', 'es2017.string', 'es2017.intl', 'es2017.typedarrays', 'es2018.asyncgenerator', 'es2018.asynciterable', 'es2018.intl', 'es2018.promise', 'es2018.regexp', 'es2019.array', 'es2019.object', 'es2019.string', 'es2019.symbol', 'es2019.intl', 'es2020.bigint', 'es2020.date', 'es2020.promise', 'es2020.sharedmemory', 'es2020.string', 'es2020.symbol.wellknown', 'es2020.intl', 'es2020.number', 'es2021.promise', 'es2021.string', 'es2021.weakref', 'es2021.intl', 'es2022.array', 'es2022.error', 'es2022.intl', 'es2022.object', 'es2022.sharedmemory', 'es2022.string', 'es2022.regexp', 'es2023.array', 'es2023.collection', 'esnext.array', 'esnext.collection', 'esnext.symbol', 'esnext.asynciterable', 'esnext.intl', 'esnext.disposable', 'esnext.bigint', 'esnext.string', 'esnext.promise', 'esnext.weakref', 'decorators', 'decorators.legacy'. 10 "incorrectLib"    ~~~~~~~~~~~~~~ diff --git a/tests/baselines/reference/config/convertCompilerOptionsFromJson/Convert trailing-whitespace string option of libs to compiler-options with json api.js b/tests/baselines/reference/config/convertCompilerOptionsFromJson/Convert trailing-whitespace string option of libs to compiler-options with json api.js index 7722a1dc4d9c0..55d1a73bf2295 100644 --- a/tests/baselines/reference/config/convertCompilerOptionsFromJson/Convert trailing-whitespace string option of libs to compiler-options with json api.js +++ b/tests/baselines/reference/config/convertCompilerOptionsFromJson/Convert trailing-whitespace string option of libs to compiler-options with json api.js @@ -30,5 +30,5 @@ CompilerOptions:: "configFilePath": "tsconfig.json" } Errors:: -error TS6046: Argument for '--lib' option must be: 'es5', 'es6', 'es2015', 'es7', 'es2016', 'es2017', 'es2018', 'es2019', 'es2020', 'es2021', 'es2022', 'es2023', 'esnext', 'dom', 'dom.iterable', 'webworker', 'webworker.importscripts', 'webworker.iterable', 'scripthost', 'es2015.core', 'es2015.collection', 'es2015.generator', 'es2015.iterable', 'es2015.promise', 'es2015.proxy', 'es2015.reflect', 'es2015.symbol', 'es2015.symbol.wellknown', 'es2016.array.include', 'es2017.date', 'es2017.object', 'es2017.sharedmemory', 'es2017.string', 'es2017.intl', 'es2017.typedarrays', 'es2018.asyncgenerator', 'es2018.asynciterable', 'es2018.intl', 'es2018.promise', 'es2018.regexp', 'es2019.array', 'es2019.object', 'es2019.string', 'es2019.symbol', 'es2019.intl', 'es2020.bigint', 'es2020.date', 'es2020.promise', 'es2020.sharedmemory', 'es2020.string', 'es2020.symbol.wellknown', 'es2020.intl', 'es2020.number', 'es2021.promise', 'es2021.string', 'es2021.weakref', 'es2021.intl', 'es2022.array', 'es2022.error', 'es2022.intl', 'es2022.object', 'es2022.sharedmemory', 'es2022.string', 'es2022.regexp', 'es2023.array', 'es2023.collection', 'esnext.array', 'esnext.collection', 'esnext.symbol', 'esnext.asynciterable', 'esnext.intl', 'esnext.bigint', 'esnext.string', 'esnext.promise', 'esnext.weakref', 'decorators', 'decorators.legacy'. +error TS6046: Argument for '--lib' option must be: 'es5', 'es6', 'es2015', 'es7', 'es2016', 'es2017', 'es2018', 'es2019', 'es2020', 'es2021', 'es2022', 'es2023', 'esnext', 'dom', 'dom.iterable', 'webworker', 'webworker.importscripts', 'webworker.iterable', 'scripthost', 'es2015.core', 'es2015.collection', 'es2015.generator', 'es2015.iterable', 'es2015.promise', 'es2015.proxy', 'es2015.reflect', 'es2015.symbol', 'es2015.symbol.wellknown', 'es2016.array.include', 'es2017.date', 'es2017.object', 'es2017.sharedmemory', 'es2017.string', 'es2017.intl', 'es2017.typedarrays', 'es2018.asyncgenerator', 'es2018.asynciterable', 'es2018.intl', 'es2018.promise', 'es2018.regexp', 'es2019.array', 'es2019.object', 'es2019.string', 'es2019.symbol', 'es2019.intl', 'es2020.bigint', 'es2020.date', 'es2020.promise', 'es2020.sharedmemory', 'es2020.string', 'es2020.symbol.wellknown', 'es2020.intl', 'es2020.number', 'es2021.promise', 'es2021.string', 'es2021.weakref', 'es2021.intl', 'es2022.array', 'es2022.error', 'es2022.intl', 'es2022.object', 'es2022.sharedmemory', 'es2022.string', 'es2022.regexp', 'es2023.array', 'es2023.collection', 'esnext.array', 'esnext.collection', 'esnext.symbol', 'esnext.asynciterable', 'esnext.intl', 'esnext.disposable', 'esnext.bigint', 'esnext.string', 'esnext.promise', 'esnext.weakref', 'decorators', 'decorators.legacy'. diff --git a/tests/baselines/reference/config/convertCompilerOptionsFromJson/Convert trailing-whitespace string option of libs to compiler-options with jsonSourceFile api.js b/tests/baselines/reference/config/convertCompilerOptionsFromJson/Convert trailing-whitespace string option of libs to compiler-options with jsonSourceFile api.js index 10f48ec0d2d3a..015e00b37f9ab 100644 --- a/tests/baselines/reference/config/convertCompilerOptionsFromJson/Convert trailing-whitespace string option of libs to compiler-options with jsonSourceFile api.js +++ b/tests/baselines/reference/config/convertCompilerOptionsFromJson/Convert trailing-whitespace string option of libs to compiler-options with jsonSourceFile api.js @@ -30,7 +30,7 @@ CompilerOptions:: "configFilePath": "tsconfig.json" } Errors:: -tsconfig.json:8:4 - error TS6046: Argument for '--lib' option must be: 'es5', 'es6', 'es2015', 'es7', 'es2016', 'es2017', 'es2018', 'es2019', 'es2020', 'es2021', 'es2022', 'es2023', 'esnext', 'dom', 'dom.iterable', 'webworker', 'webworker.importscripts', 'webworker.iterable', 'scripthost', 'es2015.core', 'es2015.collection', 'es2015.generator', 'es2015.iterable', 'es2015.promise', 'es2015.proxy', 'es2015.reflect', 'es2015.symbol', 'es2015.symbol.wellknown', 'es2016.array.include', 'es2017.date', 'es2017.object', 'es2017.sharedmemory', 'es2017.string', 'es2017.intl', 'es2017.typedarrays', 'es2018.asyncgenerator', 'es2018.asynciterable', 'es2018.intl', 'es2018.promise', 'es2018.regexp', 'es2019.array', 'es2019.object', 'es2019.string', 'es2019.symbol', 'es2019.intl', 'es2020.bigint', 'es2020.date', 'es2020.promise', 'es2020.sharedmemory', 'es2020.string', 'es2020.symbol.wellknown', 'es2020.intl', 'es2020.number', 'es2021.promise', 'es2021.string', 'es2021.weakref', 'es2021.intl', 'es2022.array', 'es2022.error', 'es2022.intl', 'es2022.object', 'es2022.sharedmemory', 'es2022.string', 'es2022.regexp', 'es2023.array', 'es2023.collection', 'esnext.array', 'esnext.collection', 'esnext.symbol', 'esnext.asynciterable', 'esnext.intl', 'esnext.bigint', 'esnext.string', 'esnext.promise', 'esnext.weakref', 'decorators', 'decorators.legacy'. +tsconfig.json:8:4 - error TS6046: Argument for '--lib' option must be: 'es5', 'es6', 'es2015', 'es7', 'es2016', 'es2017', 'es2018', 'es2019', 'es2020', 'es2021', 'es2022', 'es2023', 'esnext', 'dom', 'dom.iterable', 'webworker', 'webworker.importscripts', 'webworker.iterable', 'scripthost', 'es2015.core', 'es2015.collection', 'es2015.generator', 'es2015.iterable', 'es2015.promise', 'es2015.proxy', 'es2015.reflect', 'es2015.symbol', 'es2015.symbol.wellknown', 'es2016.array.include', 'es2017.date', 'es2017.object', 'es2017.sharedmemory', 'es2017.string', 'es2017.intl', 'es2017.typedarrays', 'es2018.asyncgenerator', 'es2018.asynciterable', 'es2018.intl', 'es2018.promise', 'es2018.regexp', 'es2019.array', 'es2019.object', 'es2019.string', 'es2019.symbol', 'es2019.intl', 'es2020.bigint', 'es2020.date', 'es2020.promise', 'es2020.sharedmemory', 'es2020.string', 'es2020.symbol.wellknown', 'es2020.intl', 'es2020.number', 'es2021.promise', 'es2021.string', 'es2021.weakref', 'es2021.intl', 'es2022.array', 'es2022.error', 'es2022.intl', 'es2022.object', 'es2022.sharedmemory', 'es2022.string', 'es2022.regexp', 'es2023.array', 'es2023.collection', 'esnext.array', 'esnext.collection', 'esnext.symbol', 'esnext.asynciterable', 'esnext.intl', 'esnext.disposable', 'esnext.bigint', 'esnext.string', 'esnext.promise', 'esnext.weakref', 'decorators', 'decorators.legacy'. 8 " "    ~~~~~ diff --git a/tests/baselines/reference/customTransforms/before+decorators.js b/tests/baselines/reference/customTransforms/before+decorators.js index 7901f9846d9ce..ef705f0c9d850 100644 --- a/tests/baselines/reference/customTransforms/before+decorators.js +++ b/tests/baselines/reference/customTransforms/before+decorators.js @@ -13,7 +13,7 @@ var B = /** @class */ (function () { } return B; }()); -export var C = /** @class */ (function () { +var C = /** @class */ (function () { function C(b) { } C = __decorate([ @@ -22,4 +22,5 @@ export var C = /** @class */ (function () { ], C); return C; }()); +export { C }; "changed"; diff --git a/tests/baselines/reference/declarationEmitLocalClassHasRequiredDeclare.js b/tests/baselines/reference/declarationEmitLocalClassHasRequiredDeclare.js index c2cd9b4915fc5..e0379df804b79 100644 --- a/tests/baselines/reference/declarationEmitLocalClassHasRequiredDeclare.js +++ b/tests/baselines/reference/declarationEmitLocalClassHasRequiredDeclare.js @@ -26,12 +26,13 @@ var X = /** @class */ (function () { } return X; }()); -var A = exports.A = /** @class */ (function () { +var A = /** @class */ (function () { function A() { } A.X = X; return A; }()); +exports.A = A; var Y = /** @class */ (function () { function Y() { } diff --git a/tests/baselines/reference/decoratedClassExportsCommonJS1.js b/tests/baselines/reference/decoratedClassExportsCommonJS1.js index 11842c166be7a..0cb283c09cd7a 100644 --- a/tests/baselines/reference/decoratedClassExportsCommonJS1.js +++ b/tests/baselines/reference/decoratedClassExportsCommonJS1.js @@ -19,8 +19,9 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key, var Testing123_1; Object.defineProperty(exports, "__esModule", { value: true }); exports.Testing123 = void 0; -let Testing123 = exports.Testing123 = Testing123_1 = class Testing123 { +let Testing123 = Testing123_1 = class Testing123 { }; +exports.Testing123 = Testing123; Testing123.prop1 = Testing123_1.prop0; exports.Testing123 = Testing123 = Testing123_1 = __decorate([ Something({ v: () => Testing123_1 }) diff --git a/tests/baselines/reference/decoratedClassExportsCommonJS2.js b/tests/baselines/reference/decoratedClassExportsCommonJS2.js index 8751b844eb8c3..6d9ba9cc9d3e2 100644 --- a/tests/baselines/reference/decoratedClassExportsCommonJS2.js +++ b/tests/baselines/reference/decoratedClassExportsCommonJS2.js @@ -17,8 +17,9 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key, var Testing123_1; Object.defineProperty(exports, "__esModule", { value: true }); exports.Testing123 = void 0; -let Testing123 = exports.Testing123 = Testing123_1 = class Testing123 { +let Testing123 = Testing123_1 = class Testing123 { }; +exports.Testing123 = Testing123; exports.Testing123 = Testing123 = Testing123_1 = __decorate([ Something({ v: () => Testing123_1 }) ], Testing123); diff --git a/tests/baselines/reference/decoratedClassExportsSystem1.js b/tests/baselines/reference/decoratedClassExportsSystem1.js index 9d552b38a6f2d..1ed6fa3daa219 100644 --- a/tests/baselines/reference/decoratedClassExportsSystem1.js +++ b/tests/baselines/reference/decoratedClassExportsSystem1.js @@ -23,8 +23,9 @@ System.register([], function (exports_1, context_1) { return { setters: [], execute: function () { - exports_1("Testing123", Testing123 = Testing123_1 = class Testing123 { - }); + Testing123 = Testing123_1 = class Testing123 { + }; + exports_1("Testing123", Testing123); Testing123.prop1 = Testing123_1.prop0; exports_1("Testing123", Testing123 = Testing123_1 = __decorate([ Something({ v: () => Testing123_1 }) diff --git a/tests/baselines/reference/decoratedClassExportsSystem2.js b/tests/baselines/reference/decoratedClassExportsSystem2.js index 19724806e262c..321aa309b60b2 100644 --- a/tests/baselines/reference/decoratedClassExportsSystem2.js +++ b/tests/baselines/reference/decoratedClassExportsSystem2.js @@ -20,8 +20,9 @@ System.register([], function (exports_1, context_1) { return { setters: [], execute: function () { - exports_1("Testing123", Testing123 = Testing123_1 = class Testing123 { - }); + Testing123 = Testing123_1 = class Testing123 { + }; + exports_1("Testing123", Testing123); exports_1("Testing123", Testing123 = Testing123_1 = __decorate([ Something({ v: () => Testing123_1 }) ], Testing123)); diff --git a/tests/baselines/reference/decoratorMetadataGenericTypeVariable.js b/tests/baselines/reference/decoratorMetadataGenericTypeVariable.js index 6660ebe0487fe..fd751b3a17ae7 100644 --- a/tests/baselines/reference/decoratorMetadataGenericTypeVariable.js +++ b/tests/baselines/reference/decoratorMetadataGenericTypeVariable.js @@ -20,7 +20,7 @@ var __metadata = (this && this.__metadata) || function (k, v) { }; Object.defineProperty(exports, "__esModule", { value: true }); exports.C = void 0; -var C = exports.C = /** @class */ (function () { +var C = /** @class */ (function () { function C() { } __decorate([ @@ -29,3 +29,4 @@ var C = exports.C = /** @class */ (function () { ], C.prototype, "member", void 0); return C; }()); +exports.C = C; diff --git a/tests/baselines/reference/decoratorMetadataGenericTypeVariableDefault.js b/tests/baselines/reference/decoratorMetadataGenericTypeVariableDefault.js index 8a64577cb2136..ad13025fb7407 100644 --- a/tests/baselines/reference/decoratorMetadataGenericTypeVariableDefault.js +++ b/tests/baselines/reference/decoratorMetadataGenericTypeVariableDefault.js @@ -20,7 +20,7 @@ var __metadata = (this && this.__metadata) || function (k, v) { }; Object.defineProperty(exports, "__esModule", { value: true }); exports.C = void 0; -var C = exports.C = /** @class */ (function () { +var C = /** @class */ (function () { function C() { } __decorate([ @@ -29,3 +29,4 @@ var C = exports.C = /** @class */ (function () { ], C.prototype, "member", void 0); return C; }()); +exports.C = C; diff --git a/tests/baselines/reference/decoratorMetadataGenericTypeVariableInScope.js b/tests/baselines/reference/decoratorMetadataGenericTypeVariableInScope.js index 9505b27f3fb82..dafb8244c6c69 100644 --- a/tests/baselines/reference/decoratorMetadataGenericTypeVariableInScope.js +++ b/tests/baselines/reference/decoratorMetadataGenericTypeVariableInScope.js @@ -29,7 +29,7 @@ var TypeVariable = /** @class */ (function () { } return TypeVariable; }()); -var C = exports.C = /** @class */ (function () { +var C = /** @class */ (function () { function C() { } __decorate([ @@ -38,3 +38,4 @@ var C = exports.C = /** @class */ (function () { ], C.prototype, "member", void 0); return C; }()); +exports.C = C; diff --git a/tests/baselines/reference/decoratorMetadataNoLibIsolatedModulesTypes.js b/tests/baselines/reference/decoratorMetadataNoLibIsolatedModulesTypes.js index 21af819a2c112..b09ce5b6c7bee 100644 --- a/tests/baselines/reference/decoratorMetadataNoLibIsolatedModulesTypes.js +++ b/tests/baselines/reference/decoratorMetadataNoLibIsolatedModulesTypes.js @@ -20,7 +20,7 @@ var __metadata = (this && this.__metadata) || function (k, v) { }; Object.defineProperty(exports, "__esModule", { value: true }); exports.B = void 0; -var B = exports.B = /** @class */ (function () { +var B = /** @class */ (function () { function B() { } var _a; @@ -30,3 +30,4 @@ var B = exports.B = /** @class */ (function () { ], B.prototype, "member", void 0); return B; }()); +exports.B = B; diff --git a/tests/baselines/reference/decoratorMetadataOnInferredType.js b/tests/baselines/reference/decoratorMetadataOnInferredType.js index fdf12d9a46541..6a5152b5e8a2c 100644 --- a/tests/baselines/reference/decoratorMetadataOnInferredType.js +++ b/tests/baselines/reference/decoratorMetadataOnInferredType.js @@ -30,7 +30,7 @@ var A = /** @class */ (function () { }()); function decorator(target, propertyKey) { } -var B = exports.B = /** @class */ (function () { +var B = /** @class */ (function () { function B() { this.x = new A(); } @@ -40,3 +40,4 @@ var B = exports.B = /** @class */ (function () { ], B.prototype, "x", void 0); return B; }()); +exports.B = B; diff --git a/tests/baselines/reference/decoratorMetadataRestParameterWithImportedType.js b/tests/baselines/reference/decoratorMetadataRestParameterWithImportedType.js index ddb84dfe491a4..c42cb65faa1de 100644 --- a/tests/baselines/reference/decoratorMetadataRestParameterWithImportedType.js +++ b/tests/baselines/reference/decoratorMetadataRestParameterWithImportedType.js @@ -90,7 +90,7 @@ function annotation() { function annotation1() { return function (target) { }; } -var ClassA = exports.ClassA = /** @class */ (function () { +var ClassA = /** @class */ (function () { function ClassA() { var init = []; for (var _i = 0; _i < arguments.length; _i++) { @@ -116,3 +116,4 @@ var ClassA = exports.ClassA = /** @class */ (function () { ], ClassA); return ClassA; }()); +exports.ClassA = ClassA; diff --git a/tests/baselines/reference/decoratorMetadataWithConstructorType.js b/tests/baselines/reference/decoratorMetadataWithConstructorType.js index 6c48ec6f0ada6..b9de65b0a796a 100644 --- a/tests/baselines/reference/decoratorMetadataWithConstructorType.js +++ b/tests/baselines/reference/decoratorMetadataWithConstructorType.js @@ -30,7 +30,7 @@ var A = /** @class */ (function () { }()); function decorator(target, propertyKey) { } -var B = exports.B = /** @class */ (function () { +var B = /** @class */ (function () { function B() { this.x = new A(); } @@ -40,3 +40,4 @@ var B = exports.B = /** @class */ (function () { ], B.prototype, "x", void 0); return B; }()); +exports.B = B; diff --git a/tests/baselines/reference/decoratorMetadataWithTypeOnlyImport2.js b/tests/baselines/reference/decoratorMetadataWithTypeOnlyImport2.js index de8f0aef7a018..1f55126d1799d 100644 --- a/tests/baselines/reference/decoratorMetadataWithTypeOnlyImport2.js +++ b/tests/baselines/reference/decoratorMetadataWithTypeOnlyImport2.js @@ -41,7 +41,7 @@ var __metadata = (this && this.__metadata) || function (k, v) { }; Object.defineProperty(exports, "__esModule", { value: true }); exports.Main = void 0; -var Main = exports.Main = /** @class */ (function () { +var Main = /** @class */ (function () { function Main() { } __decorate([ @@ -50,3 +50,4 @@ var Main = exports.Main = /** @class */ (function () { ], Main.prototype, "field", void 0); return Main; }()); +exports.Main = Main; diff --git a/tests/baselines/reference/decoratorOnClass2.es6.js b/tests/baselines/reference/decoratorOnClass2.es6.js index 59dec2f5a2cfe..608d9827052b2 100644 --- a/tests/baselines/reference/decoratorOnClass2.es6.js +++ b/tests/baselines/reference/decoratorOnClass2.es6.js @@ -16,9 +16,10 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key, else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; return c > 3 && r && Object.defineProperty(target, key, r), r; }; -export let C = class C { +let C = class C { }; C = __decorate([ dec ], C); +export { C }; let c = new C(); diff --git a/tests/baselines/reference/decoratorOnClass2.js b/tests/baselines/reference/decoratorOnClass2.js index 649c3e9b0be2c..a86c5a411d9ea 100644 --- a/tests/baselines/reference/decoratorOnClass2.js +++ b/tests/baselines/reference/decoratorOnClass2.js @@ -17,7 +17,7 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key, }; Object.defineProperty(exports, "__esModule", { value: true }); exports.C = void 0; -var C = exports.C = /** @class */ (function () { +var C = /** @class */ (function () { function C() { } C = __decorate([ @@ -25,3 +25,4 @@ var C = exports.C = /** @class */ (function () { ], C); return C; }()); +exports.C = C; diff --git a/tests/baselines/reference/decoratorOnClass3.js b/tests/baselines/reference/decoratorOnClass3.js index 28a7f2221125f..ffb6027845cba 100644 --- a/tests/baselines/reference/decoratorOnClass3.js +++ b/tests/baselines/reference/decoratorOnClass3.js @@ -18,7 +18,7 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key, }; Object.defineProperty(exports, "__esModule", { value: true }); exports.C = void 0; -var C = exports.C = /** @class */ (function () { +var C = /** @class */ (function () { function C() { } C = __decorate([ @@ -26,3 +26,4 @@ var C = exports.C = /** @class */ (function () { ], C); return C; }()); +exports.C = C; diff --git a/tests/baselines/reference/decoratorOnClass6.es6.js b/tests/baselines/reference/decoratorOnClass6.es6.js index 079578f499148..cf9238b9ca8f0 100644 --- a/tests/baselines/reference/decoratorOnClass6.es6.js +++ b/tests/baselines/reference/decoratorOnClass6.es6.js @@ -19,11 +19,12 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key, return c > 3 && r && Object.defineProperty(target, key, r), r; }; var C_1; -export let C = C_1 = class C { +let C = C_1 = class C { static x() { return C_1.y; } }; C.y = 1; C = C_1 = __decorate([ dec ], C); +export { C }; let c = new C(); diff --git a/tests/baselines/reference/decoratorOnClass8.es6.js b/tests/baselines/reference/decoratorOnClass8.es6.js index 65733d82ecb20..629737f9910f3 100644 --- a/tests/baselines/reference/decoratorOnClass8.es6.js +++ b/tests/baselines/reference/decoratorOnClass8.es6.js @@ -19,9 +19,10 @@ var __setFunctionName = (this && this.__setFunctionName) || function (f, name, p if (typeof name === "symbol") name = name.description ? "[".concat(name.description, "]") : ""; return Object.defineProperty(f, "name", { configurable: true, value: prefix ? "".concat(prefix, " ", name) : name }); }; -let default_1 = class { +var _a; +let default_1 = _a = class { }; -__setFunctionName(default_1, "default"); +__setFunctionName(_a, "default"); default_1.y = 1; default_1 = __decorate([ dec diff --git a/tests/baselines/reference/decoratorOnClassConstructor2.js b/tests/baselines/reference/decoratorOnClassConstructor2.js index dff6101a9edf0..23dbbf69036da 100644 --- a/tests/baselines/reference/decoratorOnClassConstructor2.js +++ b/tests/baselines/reference/decoratorOnClassConstructor2.js @@ -55,7 +55,7 @@ Object.defineProperty(exports, "__esModule", { value: true }); exports.C = void 0; var _0_ts_1 = require("./0.ts"); var _0_ts_2 = require("./0.ts"); -var C = exports.C = /** @class */ (function (_super) { +var C = /** @class */ (function (_super) { __extends(C, _super); function C(prop) { return _super.call(this) || this; @@ -65,3 +65,4 @@ var C = exports.C = /** @class */ (function (_super) { ], C); return C; }(_0_ts_1.base)); +exports.C = C; diff --git a/tests/baselines/reference/decoratorOnClassConstructor3.js b/tests/baselines/reference/decoratorOnClassConstructor3.js index c81f6d873558d..ff584adb5f043 100644 --- a/tests/baselines/reference/decoratorOnClassConstructor3.js +++ b/tests/baselines/reference/decoratorOnClassConstructor3.js @@ -58,7 +58,7 @@ exports.C = void 0; var _0_1 = require("./0"); var _0_2 = require("./0"); /* Comment on the Class Declaration */ -var C = exports.C = /** @class */ (function (_super) { +var C = /** @class */ (function (_super) { __extends(C, _super); function C(prop) { return _super.call(this) || this; @@ -68,3 +68,4 @@ var C = exports.C = /** @class */ (function (_super) { ], C); return C; }(_0_1.base)); +exports.C = C; diff --git a/tests/baselines/reference/derivedClassSuperProperties.js b/tests/baselines/reference/derivedClassSuperProperties.js index b76dd228643b9..e87fd91b7d1ef 100644 --- a/tests/baselines/reference/derivedClassSuperProperties.js +++ b/tests/baselines/reference/derivedClassSuperProperties.js @@ -814,9 +814,9 @@ var DerivedWithObjectAccessors = /** @class */ (function (_super) { return DerivedWithObjectAccessors; }(Base)); var DerivedWithObjectAccessorsUsingThisInKeys = /** @class */ (function (_super) { - var _a; __extends(DerivedWithObjectAccessorsUsingThisInKeys, _super); function DerivedWithObjectAccessorsUsingThisInKeys() { + var _a; var _this = this; var obj = (_a = { _prop: "prop" @@ -875,13 +875,13 @@ var DerivedWithObjectComputedPropertyBody = /** @class */ (function (_super) { return DerivedWithObjectComputedPropertyBody; }(Base)); var DerivedWithObjectComputedPropertyName = /** @class */ (function (_super) { - var _b; __extends(DerivedWithObjectComputedPropertyName, _super); function DerivedWithObjectComputedPropertyName() { + var _a; var _this = this; - var obj = (_b = {}, - _b[_this.propName] = true, - _b); + var obj = (_a = {}, + _a[_this.propName] = true, + _a); _this = _super.call(this) || this; _this.propName = "prop"; return _this; diff --git a/tests/baselines/reference/derivedClassSuperStatementPosition.js b/tests/baselines/reference/derivedClassSuperStatementPosition.js index dcbfd4dd78bea..dccc2730c4c39 100644 --- a/tests/baselines/reference/derivedClassSuperStatementPosition.js +++ b/tests/baselines/reference/derivedClassSuperStatementPosition.js @@ -126,8 +126,8 @@ var DerivedBasic = /** @class */ (function (_super) { var DerivedAfterParameterDefault = /** @class */ (function (_super) { __extends(DerivedAfterParameterDefault, _super); function DerivedAfterParameterDefault(x) { - if (x === void 0) { x = false; } var _this = this; + if (x === void 0) { x = false; } _this.x1 = x; _this = _super.call(this, x) || this; _this.x2 = x; @@ -138,11 +138,11 @@ var DerivedAfterParameterDefault = /** @class */ (function (_super) { var DerivedAfterRestParameter = /** @class */ (function (_super) { __extends(DerivedAfterRestParameter, _super); function DerivedAfterRestParameter() { + var _this = this; var x = []; for (var _i = 0; _i < arguments.length; _i++) { x[_i] = arguments[_i]; } - var _this = this; _this.x1 = x; _this = _super.call(this, x) || this; _this.x2 = x; diff --git a/tests/baselines/reference/emitHelpersWithLocalCollisions(module=amd).js b/tests/baselines/reference/emitHelpersWithLocalCollisions(module=amd).js index bc2b95802fe0f..84f85ae584c7c 100644 --- a/tests/baselines/reference/emitHelpersWithLocalCollisions(module=amd).js +++ b/tests/baselines/reference/emitHelpersWithLocalCollisions(module=amd).js @@ -20,8 +20,9 @@ define(["require", "exports"], function (require, exports) { "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.A = void 0; - let A = exports.A = class A { + let A = class A { }; + exports.A = A; exports.A = A = __decorate([ dec ], A); diff --git a/tests/baselines/reference/emitHelpersWithLocalCollisions(module=commonjs).js b/tests/baselines/reference/emitHelpersWithLocalCollisions(module=commonjs).js index 18f8435b4976d..2bf5641f43b50 100644 --- a/tests/baselines/reference/emitHelpersWithLocalCollisions(module=commonjs).js +++ b/tests/baselines/reference/emitHelpersWithLocalCollisions(module=commonjs).js @@ -19,8 +19,9 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key, }; Object.defineProperty(exports, "__esModule", { value: true }); exports.A = void 0; -let A = exports.A = class A { +let A = class A { }; +exports.A = A; exports.A = A = __decorate([ dec ], A); diff --git a/tests/baselines/reference/emitHelpersWithLocalCollisions(module=es2020).js b/tests/baselines/reference/emitHelpersWithLocalCollisions(module=es2020).js index f66b391363c6b..47204b7a76f30 100644 --- a/tests/baselines/reference/emitHelpersWithLocalCollisions(module=es2020).js +++ b/tests/baselines/reference/emitHelpersWithLocalCollisions(module=es2020).js @@ -16,10 +16,11 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key, else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; return c > 3 && r && Object.defineProperty(target, key, r), r; }; -export let A = class A { +let A = class A { }; A = __decorate([ dec ], A); +export { A }; const o = { a: 1 }; const y = Object.assign({}, o); diff --git a/tests/baselines/reference/emitHelpersWithLocalCollisions(module=es2022).js b/tests/baselines/reference/emitHelpersWithLocalCollisions(module=es2022).js index f66b391363c6b..47204b7a76f30 100644 --- a/tests/baselines/reference/emitHelpersWithLocalCollisions(module=es2022).js +++ b/tests/baselines/reference/emitHelpersWithLocalCollisions(module=es2022).js @@ -16,10 +16,11 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key, else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; return c > 3 && r && Object.defineProperty(target, key, r), r; }; -export let A = class A { +let A = class A { }; A = __decorate([ dec ], A); +export { A }; const o = { a: 1 }; const y = Object.assign({}, o); diff --git a/tests/baselines/reference/emitHelpersWithLocalCollisions(module=es6).js b/tests/baselines/reference/emitHelpersWithLocalCollisions(module=es6).js index f66b391363c6b..47204b7a76f30 100644 --- a/tests/baselines/reference/emitHelpersWithLocalCollisions(module=es6).js +++ b/tests/baselines/reference/emitHelpersWithLocalCollisions(module=es6).js @@ -16,10 +16,11 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key, else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; return c > 3 && r && Object.defineProperty(target, key, r), r; }; -export let A = class A { +let A = class A { }; A = __decorate([ dec ], A); +export { A }; const o = { a: 1 }; const y = Object.assign({}, o); diff --git a/tests/baselines/reference/emitHelpersWithLocalCollisions(module=esnext).js b/tests/baselines/reference/emitHelpersWithLocalCollisions(module=esnext).js index f66b391363c6b..47204b7a76f30 100644 --- a/tests/baselines/reference/emitHelpersWithLocalCollisions(module=esnext).js +++ b/tests/baselines/reference/emitHelpersWithLocalCollisions(module=esnext).js @@ -16,10 +16,11 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key, else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; return c > 3 && r && Object.defineProperty(target, key, r), r; }; -export let A = class A { +let A = class A { }; A = __decorate([ dec ], A); +export { A }; const o = { a: 1 }; const y = Object.assign({}, o); diff --git a/tests/baselines/reference/emitHelpersWithLocalCollisions(module=node16).js b/tests/baselines/reference/emitHelpersWithLocalCollisions(module=node16).js index 18f8435b4976d..2bf5641f43b50 100644 --- a/tests/baselines/reference/emitHelpersWithLocalCollisions(module=node16).js +++ b/tests/baselines/reference/emitHelpersWithLocalCollisions(module=node16).js @@ -19,8 +19,9 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key, }; Object.defineProperty(exports, "__esModule", { value: true }); exports.A = void 0; -let A = exports.A = class A { +let A = class A { }; +exports.A = A; exports.A = A = __decorate([ dec ], A); diff --git a/tests/baselines/reference/emitHelpersWithLocalCollisions(module=nodenext).js b/tests/baselines/reference/emitHelpersWithLocalCollisions(module=nodenext).js index 18f8435b4976d..2bf5641f43b50 100644 --- a/tests/baselines/reference/emitHelpersWithLocalCollisions(module=nodenext).js +++ b/tests/baselines/reference/emitHelpersWithLocalCollisions(module=nodenext).js @@ -19,8 +19,9 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key, }; Object.defineProperty(exports, "__esModule", { value: true }); exports.A = void 0; -let A = exports.A = class A { +let A = class A { }; +exports.A = A; exports.A = A = __decorate([ dec ], A); diff --git a/tests/baselines/reference/emitHelpersWithLocalCollisions(module=none).js b/tests/baselines/reference/emitHelpersWithLocalCollisions(module=none).js index 18f8435b4976d..2bf5641f43b50 100644 --- a/tests/baselines/reference/emitHelpersWithLocalCollisions(module=none).js +++ b/tests/baselines/reference/emitHelpersWithLocalCollisions(module=none).js @@ -19,8 +19,9 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key, }; Object.defineProperty(exports, "__esModule", { value: true }); exports.A = void 0; -let A = exports.A = class A { +let A = class A { }; +exports.A = A; exports.A = A = __decorate([ dec ], A); diff --git a/tests/baselines/reference/emitHelpersWithLocalCollisions(module=system).js b/tests/baselines/reference/emitHelpersWithLocalCollisions(module=system).js index 541e086b22d92..bc2a54a4528b5 100644 --- a/tests/baselines/reference/emitHelpersWithLocalCollisions(module=system).js +++ b/tests/baselines/reference/emitHelpersWithLocalCollisions(module=system).js @@ -23,8 +23,9 @@ System.register([], function (exports_1, context_1) { return { setters: [], execute: function () { - exports_1("A", A = class A { - }); + A = class A { + }; + exports_1("A", A); exports_1("A", A = __decorate([ dec ], A)); diff --git a/tests/baselines/reference/emitHelpersWithLocalCollisions(module=umd).js b/tests/baselines/reference/emitHelpersWithLocalCollisions(module=umd).js index 451d285e66ac0..19538ce4e5241 100644 --- a/tests/baselines/reference/emitHelpersWithLocalCollisions(module=umd).js +++ b/tests/baselines/reference/emitHelpersWithLocalCollisions(module=umd).js @@ -28,8 +28,9 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key, "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.A = void 0; - let A = exports.A = class A { + let A = class A { }; + exports.A = A; exports.A = A = __decorate([ dec ], A); diff --git a/tests/baselines/reference/es3defaultAliasIsQuoted.js b/tests/baselines/reference/es3defaultAliasIsQuoted.js index c8ae85c5bdf7f..a486ad614046b 100644 --- a/tests/baselines/reference/es3defaultAliasIsQuoted.js +++ b/tests/baselines/reference/es3defaultAliasIsQuoted.js @@ -17,12 +17,13 @@ assert(Foo.CONSTANT === "Foo"); "use strict"; exports.__esModule = true; exports.Foo = void 0; -var Foo = exports.Foo = /** @class */ (function () { +var Foo = /** @class */ (function () { function Foo() { } Foo.CONSTANT = "Foo"; return Foo; }()); +exports.Foo = Foo; function assert(value) { if (!value) throw new Error("Assertion failed!"); diff --git a/tests/baselines/reference/es6modulekindWithES5Target.js b/tests/baselines/reference/es6modulekindWithES5Target.js index d1930d6b2cdff..cf06a98bd6822 100644 --- a/tests/baselines/reference/es6modulekindWithES5Target.js +++ b/tests/baselines/reference/es6modulekindWithES5Target.js @@ -28,7 +28,7 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key, else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; return c > 3 && r && Object.defineProperty(target, key, r), r; }; -export var C = /** @class */ (function () { +var C = /** @class */ (function () { function C() { this.p = 1; } @@ -36,8 +36,9 @@ export var C = /** @class */ (function () { C.s = 0; return C; }()); +export { C }; export { C as C2 }; -export var D = /** @class */ (function () { +var D = /** @class */ (function () { function D() { this.p = 1; } @@ -48,6 +49,7 @@ export var D = /** @class */ (function () { ], D); return D; }()); +export { D }; export { D as D2 }; var E = /** @class */ (function () { function E() { diff --git a/tests/baselines/reference/esDecorators-classDeclaration-accessors-nonStatic(target=es5).js b/tests/baselines/reference/esDecorators-classDeclaration-accessors-nonStatic(target=es5).js index 2a06295af0f20..84e8663f0744f 100644 --- a/tests/baselines/reference/esDecorators-classDeclaration-accessors-nonStatic(target=es5).js +++ b/tests/baselines/reference/esDecorators-classDeclaration-accessors-nonStatic(target=es5).js @@ -16,7 +16,6 @@ class C { //// [esDecorators-classDeclaration-accessors-nonStatic.js] -var _this = this; var method3 = "method3"; var C = function () { var _a; diff --git a/tests/baselines/reference/esDecorators-classDeclaration-accessors-static(target=es5).js b/tests/baselines/reference/esDecorators-classDeclaration-accessors-static(target=es5).js index 4b2145d6f919f..e4a789cc1b53a 100644 --- a/tests/baselines/reference/esDecorators-classDeclaration-accessors-static(target=es5).js +++ b/tests/baselines/reference/esDecorators-classDeclaration-accessors-static(target=es5).js @@ -16,7 +16,6 @@ class C { //// [esDecorators-classDeclaration-accessors-static.js] -var _this = this; var method3 = "method3"; var C = function () { var _a; diff --git a/tests/baselines/reference/esDecorators-classDeclaration-accessors-staticPrivate(target=es2015).js b/tests/baselines/reference/esDecorators-classDeclaration-accessors-staticPrivate(target=es2015).js index 99000eedb6c06..6cc43a1146333 100644 --- a/tests/baselines/reference/esDecorators-classDeclaration-accessors-staticPrivate(target=es2015).js +++ b/tests/baselines/reference/esDecorators-classDeclaration-accessors-staticPrivate(target=es2015).js @@ -41,23 +41,23 @@ let C = (() => { _a; })(); let D = (() => { - var _method1_get, _method1_set; + var _D_method1_get, _D_method1_set; let _classDecorators = [dec]; let _classDescriptor; let _classExtraInitializers = []; let _classThis; var D = _classThis = class { }; - _method1_get = function _method1_get() { return 0; }; - _method1_set = function _method1_set(value) { }; + _D_method1_get = function _D_method1_get() { return 0; }; + _D_method1_set = function _D_method1_set(value) { }; __setFunctionName(_classThis, "D"); (() => { __esDecorate(null, _classDescriptor = { value: _classThis }, _classDecorators, { kind: "class", name: _classThis.name }, null, _classExtraInitializers); D = _classThis = _classDescriptor.value; })(); (() => { - __classPrivateFieldGet(_classThis, _classThis, "a", _method1_get); - __classPrivateFieldSet(_classThis, _classThis, 1, "a", _method1_set); + __classPrivateFieldGet(_classThis, _classThis, "a", _D_method1_get); + __classPrivateFieldSet(_classThis, _classThis, 1, "a", _D_method1_set); })(); (() => { __runInitializers(_classThis, _classExtraInitializers); diff --git a/tests/baselines/reference/esDecorators-classDeclaration-accessors-staticPrivate(target=es2022).js b/tests/baselines/reference/esDecorators-classDeclaration-accessors-staticPrivate(target=es2022).js index 9c6884476cd75..11ec0762346a9 100644 --- a/tests/baselines/reference/esDecorators-classDeclaration-accessors-staticPrivate(target=es2022).js +++ b/tests/baselines/reference/esDecorators-classDeclaration-accessors-staticPrivate(target=es2022).js @@ -39,21 +39,22 @@ let C = (() => { }; })(); let D = (() => { - var _method1_get, _method1_set; + var _D_method1_get, _D_method1_set; let _classDecorators = [dec]; let _classDescriptor; let _classExtraInitializers = []; let _classThis; var D = class { + static { _classThis = this; } static { __setFunctionName(this, "D"); } - static { _method1_get = function _method1_get() { return 0; }, _method1_set = function _method1_set(value) { }; } + static { _D_method1_get = function _D_method1_get() { return 0; }, _D_method1_set = function _D_method1_set(value) { }; } static { - __esDecorate(null, _classDescriptor = { value: this }, _classDecorators, { kind: "class", name: this.name }, null, _classExtraInitializers); + __esDecorate(null, _classDescriptor = { value: _classThis }, _classDecorators, { kind: "class", name: _classThis.name }, null, _classExtraInitializers); D = _classThis = _classDescriptor.value; } static { - __classPrivateFieldGet(_classThis, _classThis, "a", _method1_get); - __classPrivateFieldSet(_classThis, _classThis, 1, "a", _method1_set); + __classPrivateFieldGet(_classThis, _classThis, "a", _D_method1_get); + __classPrivateFieldSet(_classThis, _classThis, 1, "a", _D_method1_set); } static { __runInitializers(_classThis, _classExtraInitializers); diff --git a/tests/baselines/reference/esDecorators-classDeclaration-classSuper.1.js b/tests/baselines/reference/esDecorators-classDeclaration-classSuper.1.js index 9c19a1b1c3f9e..9eca68691d60d 100644 --- a/tests/baselines/reference/esDecorators-classDeclaration-classSuper.1.js +++ b/tests/baselines/reference/esDecorators-classDeclaration-classSuper.1.js @@ -32,8 +32,9 @@ let C = (() => { let _classThis; let _classSuper = Base; var C = class extends _classSuper { + static { _classThis = this; } static { - __esDecorate(null, _classDescriptor = { value: this }, _classDecorators, { kind: "class", name: this.name }, null, _classExtraInitializers); + __esDecorate(null, _classDescriptor = { value: _classThis }, _classDecorators, { kind: "class", name: _classThis.name }, null, _classExtraInitializers); C = _classThis = _classDescriptor.value; } static { diff --git a/tests/baselines/reference/esDecorators-classDeclaration-classSuper.2.js b/tests/baselines/reference/esDecorators-classDeclaration-classSuper.2.js index 09a3a34b0b835..489e29eb0a195 100644 --- a/tests/baselines/reference/esDecorators-classDeclaration-classSuper.2.js +++ b/tests/baselines/reference/esDecorators-classDeclaration-classSuper.2.js @@ -38,8 +38,9 @@ let C1 = (() => { let _classSuper = (0, class { }); var C1 = class extends _classSuper { + static { _classThis = this; } static { - __esDecorate(null, _classDescriptor = { value: this }, _classDecorators, { kind: "class", name: this.name }, null, _classExtraInitializers); + __esDecorate(null, _classDescriptor = { value: _classThis }, _classDecorators, { kind: "class", name: _classThis.name }, null, _classExtraInitializers); C1 = _classThis = _classDescriptor.value; } static { @@ -53,43 +54,45 @@ let C1 = (() => { })(); // function expression in extends should not get an assigned name let C2 = (() => { - let _classDecorators_1 = [dec]; - let _classDescriptor_1; - let _classExtraInitializers_1 = []; - let _classThis_1; - let _classSuper_1 = (0, function () { }); - var C2 = class extends _classSuper_1 { + let _classDecorators = [dec]; + let _classDescriptor; + let _classExtraInitializers = []; + let _classThis; + let _classSuper = (0, function () { }); + var C2 = class extends _classSuper { + static { _classThis = this; } static { - __esDecorate(null, _classDescriptor_1 = { value: this }, _classDecorators_1, { kind: "class", name: this.name }, null, _classExtraInitializers_1); - C2 = _classThis_1 = _classDescriptor_1.value; + __esDecorate(null, _classDescriptor = { value: _classThis }, _classDecorators, { kind: "class", name: _classThis.name }, null, _classExtraInitializers); + C2 = _classThis = _classDescriptor.value; } static { - Reflect.get(_classSuper_1, "name", _classThis_1); + Reflect.get(_classSuper, "name", _classThis); } static { - __runInitializers(_classThis_1, _classExtraInitializers_1); + __runInitializers(_classThis, _classExtraInitializers); } }; - return C2 = _classThis_1; + return C2 = _classThis; })(); // arrow function in extends should not get an assigned name let C3 = (() => { - let _classDecorators_2 = [dec]; - let _classDescriptor_2; - let _classExtraInitializers_2 = []; - let _classThis_2; - let _classSuper_2 = (0, (() => { })); - var C3 = class extends _classSuper_2 { + let _classDecorators = [dec]; + let _classDescriptor; + let _classExtraInitializers = []; + let _classThis; + let _classSuper = (0, (() => { })); + var C3 = class extends _classSuper { + static { _classThis = this; } static { - __esDecorate(null, _classDescriptor_2 = { value: this }, _classDecorators_2, { kind: "class", name: this.name }, null, _classExtraInitializers_2); - C3 = _classThis_2 = _classDescriptor_2.value; + __esDecorate(null, _classDescriptor = { value: _classThis }, _classDecorators, { kind: "class", name: _classThis.name }, null, _classExtraInitializers); + C3 = _classThis = _classDescriptor.value; } static { - Reflect.get(_classSuper_2, "name", _classThis_2); + Reflect.get(_classSuper, "name", _classThis); } static { - __runInitializers(_classThis_2, _classExtraInitializers_2); + __runInitializers(_classThis, _classExtraInitializers); } }; - return C3 = _classThis_2; + return C3 = _classThis; })(); diff --git a/tests/baselines/reference/esDecorators-classDeclaration-classSuper.3.js b/tests/baselines/reference/esDecorators-classDeclaration-classSuper.3.js index bb7b5c3890bc1..17b21ab7cd05f 100644 --- a/tests/baselines/reference/esDecorators-classDeclaration-classSuper.3.js +++ b/tests/baselines/reference/esDecorators-classDeclaration-classSuper.3.js @@ -54,8 +54,9 @@ let C = (() => { let _classThis; let _classSuper = Base; var C = class extends _classSuper { + static { _classThis = this; } static { - __esDecorate(null, _classDescriptor = { value: this }, _classDecorators, { kind: "class", name: this.name }, null, _classExtraInitializers); + __esDecorate(null, _classDescriptor = { value: _classThis }, _classDecorators, { kind: "class", name: _classThis.name }, null, _classExtraInitializers); C = _classThis = _classDescriptor.value; } static { diff --git a/tests/baselines/reference/esDecorators-classDeclaration-classSuper.4.js b/tests/baselines/reference/esDecorators-classDeclaration-classSuper.4.js index 7f79fba3112c4..8a3503ccd0c12 100644 --- a/tests/baselines/reference/esDecorators-classDeclaration-classSuper.4.js +++ b/tests/baselines/reference/esDecorators-classDeclaration-classSuper.4.js @@ -29,8 +29,9 @@ let C = (() => { let _classThis; let _classSuper = Base; var C = class extends _classSuper { + static { _classThis = this; } static { - __esDecorate(null, _classDescriptor = { value: this }, _classDecorators, { kind: "class", name: this.name }, null, _classExtraInitializers); + __esDecorate(null, _classDescriptor = { value: _classThis }, _classDecorators, { kind: "class", name: _classThis.name }, null, _classExtraInitializers); C = _classThis = _classDescriptor.value; } static a = Reflect.get(_classSuper, "method", _classThis).call(_classThis); diff --git a/tests/baselines/reference/esDecorators-classDeclaration-classSuper.5.js b/tests/baselines/reference/esDecorators-classDeclaration-classSuper.5.js index 7bcc607444fb4..f32ee7620dd37 100644 --- a/tests/baselines/reference/esDecorators-classDeclaration-classSuper.5.js +++ b/tests/baselines/reference/esDecorators-classDeclaration-classSuper.5.js @@ -58,8 +58,9 @@ let C1 = (() => { let _classThis; let _classSuper = Base; var C1 = class extends _classSuper { + static { _classThis = this; } static { - __esDecorate(null, _classDescriptor = { value: this }, _classDecorators, { kind: "class", name: this.name }, null, _classExtraInitializers); + __esDecorate(null, _classDescriptor = { value: _classThis }, _classDecorators, { kind: "class", name: _classThis.name }, null, _classExtraInitializers); C1 = _classThis = _classDescriptor.value; } static a = Reflect.get(_classSuper, "x", _classThis); @@ -96,90 +97,92 @@ let C1 = (() => { return C1 = _classThis; })(); let C2 = (() => { - let _classDecorators_1 = [dec]; - let _classDescriptor_1; - let _classExtraInitializers_1 = []; - let _classThis_1; - let _classSuper_1 = Base; - var C2 = class extends _classSuper_1 { + let _classDecorators = [dec]; + let _classDescriptor; + let _classExtraInitializers = []; + let _classThis; + let _classSuper = Base; + var C2 = class extends _classSuper { + static { _classThis = this; } static { - __esDecorate(null, _classDescriptor_1 = { value: this }, _classDecorators_1, { kind: "class", name: this.name }, null, _classExtraInitializers_1); - C2 = _classThis_1 = _classDescriptor_1.value; + __esDecorate(null, _classDescriptor = { value: _classThis }, _classDecorators, { kind: "class", name: _classThis.name }, null, _classExtraInitializers); + C2 = _classThis = _classDescriptor.value; } - static a = Reflect.get(_classSuper_1, "x", _classThis_1); + static a = Reflect.get(_classSuper, "x", _classThis); static b = (() => { var _a; - return Reflect.set(_classSuper_1, "x", _a = 1, _classThis_1), _a; + return Reflect.set(_classSuper, "x", _a = 1, _classThis), _a; })(); static c = (() => { var _a; - return Reflect.set(_classSuper_1, "x", _a = Reflect.get(_classSuper_1, "x", _classThis_1) + 1, _classThis_1), _a; + return Reflect.set(_classSuper, "x", _a = Reflect.get(_classSuper, "x", _classThis) + 1, _classThis), _a; })(); static d = (() => { var _a, _b; - return Reflect.set(_classSuper_1, "x", (_b = Reflect.get(_classSuper_1, "x", _classThis_1), _a = _b++, _b), _classThis_1), _a; + return Reflect.set(_classSuper, "x", (_b = Reflect.get(_classSuper, "x", _classThis), _a = _b++, _b), _classThis), _a; })(); static e = (() => { var _a, _b; - return Reflect.set(_classSuper_1, "x", (_b = Reflect.get(_classSuper_1, "x", _classThis_1), _a = _b--, _b), _classThis_1), _a; + return Reflect.set(_classSuper, "x", (_b = Reflect.get(_classSuper, "x", _classThis), _a = _b--, _b), _classThis), _a; })(); static f = (() => { var _a, _b; - return Reflect.set(_classSuper_1, "x", (_b = Reflect.get(_classSuper_1, "x", _classThis_1), _a = ++_b), _classThis_1), _a; + return Reflect.set(_classSuper, "x", (_b = Reflect.get(_classSuper, "x", _classThis), _a = ++_b), _classThis), _a; })(); static g = (() => { var _a, _b; - return Reflect.set(_classSuper_1, "x", (_b = Reflect.get(_classSuper_1, "x", _classThis_1), _a = --_b), _classThis_1), _a; + return Reflect.set(_classSuper, "x", (_b = Reflect.get(_classSuper, "x", _classThis), _a = --_b), _classThis), _a; })(); - static h = ({ x: ({ set value(_a) { Reflect.set(_classSuper_1, "x", _a, _classThis_1); } }).value } = { x: 1 }); - static i = [({ set value(_a) { Reflect.set(_classSuper_1, "x", _a, _classThis_1); } }).value] = [1]; + static h = ({ x: ({ set value(_a) { Reflect.set(_classSuper, "x", _a, _classThis); } }).value } = { x: 1 }); + static i = [({ set value(_a) { Reflect.set(_classSuper, "x", _a, _classThis); } }).value] = [1]; static { - __runInitializers(_classThis_1, _classExtraInitializers_1); + __runInitializers(_classThis, _classExtraInitializers); } }; - return C2 = _classThis_1; + return C2 = _classThis; })(); let C3 = (() => { - let _classDecorators_2 = [dec]; - let _classDescriptor_2; - let _classExtraInitializers_2 = []; - let _classThis_2; - let _classSuper_2 = Base; - var C3 = class extends _classSuper_2 { + let _classDecorators = [dec]; + let _classDescriptor; + let _classExtraInitializers = []; + let _classThis; + let _classSuper = Base; + var C3 = class extends _classSuper { + static { _classThis = this; } static { - __esDecorate(null, _classDescriptor_2 = { value: this }, _classDecorators_2, { kind: "class", name: this.name }, null, _classExtraInitializers_2); - C3 = _classThis_2 = _classDescriptor_2.value; + __esDecorate(null, _classDescriptor = { value: _classThis }, _classDecorators, { kind: "class", name: _classThis.name }, null, _classExtraInitializers); + C3 = _classThis = _classDescriptor.value; } - static a = Reflect.get(_classSuper_2, x, _classThis_2); + static a = Reflect.get(_classSuper, x, _classThis); static b = (() => { var _a; - return Reflect.set(_classSuper_2, x, _a = 1, _classThis_2), _a; + return Reflect.set(_classSuper, x, _a = 1, _classThis), _a; })(); static c = (() => { var _a, _b; - return Reflect.set(_classSuper_2, _a = x, _b = Reflect.get(_classSuper_2, _a, _classThis_2) + 1, _classThis_2), _b; + return Reflect.set(_classSuper, _a = x, _b = Reflect.get(_classSuper, _a, _classThis) + 1, _classThis), _b; })(); static d = (() => { var _a, _b, _c; - return Reflect.set(_classSuper_2, _a = x, (_c = Reflect.get(_classSuper_2, _a, _classThis_2), _b = _c++, _c), _classThis_2), _b; + return Reflect.set(_classSuper, _a = x, (_c = Reflect.get(_classSuper, _a, _classThis), _b = _c++, _c), _classThis), _b; })(); static e = (() => { var _a, _b, _c; - return Reflect.set(_classSuper_2, _a = x, (_c = Reflect.get(_classSuper_2, _a, _classThis_2), _b = _c--, _c), _classThis_2), _b; + return Reflect.set(_classSuper, _a = x, (_c = Reflect.get(_classSuper, _a, _classThis), _b = _c--, _c), _classThis), _b; })(); static f = (() => { var _a, _b, _c; - return Reflect.set(_classSuper_2, _a = x, (_c = Reflect.get(_classSuper_2, _a, _classThis_2), _b = ++_c), _classThis_2), _b; + return Reflect.set(_classSuper, _a = x, (_c = Reflect.get(_classSuper, _a, _classThis), _b = ++_c), _classThis), _b; })(); static g = (() => { var _a, _b, _c; - return Reflect.set(_classSuper_2, _a = x, (_c = Reflect.get(_classSuper_2, _a, _classThis_2), _b = --_c), _classThis_2), _b; + return Reflect.set(_classSuper, _a = x, (_c = Reflect.get(_classSuper, _a, _classThis), _b = --_c), _classThis), _b; })(); - static h = ({ x: ({ set value(_a) { Reflect.set(_classSuper_2, x, _a, _classThis_2); } }).value } = { x: 1 }); - static i = [({ set value(_a) { Reflect.set(_classSuper_2, x, _a, _classThis_2); } }).value] = [1]; + static h = ({ x: ({ set value(_a) { Reflect.set(_classSuper, x, _a, _classThis); } }).value } = { x: 1 }); + static i = [({ set value(_a) { Reflect.set(_classSuper, x, _a, _classThis); } }).value] = [1]; static { - __runInitializers(_classThis_2, _classExtraInitializers_2); + __runInitializers(_classThis, _classExtraInitializers); } }; - return C3 = _classThis_2; + return C3 = _classThis; })(); diff --git a/tests/baselines/reference/esDecorators-classDeclaration-classSuper.6.js b/tests/baselines/reference/esDecorators-classDeclaration-classSuper.6.js index def3ef1208dc0..ec4181df86bff 100644 --- a/tests/baselines/reference/esDecorators-classDeclaration-classSuper.6.js +++ b/tests/baselines/reference/esDecorators-classDeclaration-classSuper.6.js @@ -35,8 +35,9 @@ let C = (() => { let _classExtraInitializers = []; let _classThis; var C = class extends Base { + static { _classThis = this; } static { - __esDecorate(null, _classDescriptor = { value: this }, _classDecorators, { kind: "class", name: this.name }, null, _classExtraInitializers); + __esDecorate(null, _classDescriptor = { value: _classThis }, _classDecorators, { kind: "class", name: _classThis.name }, null, _classExtraInitializers); C = _classThis = _classDescriptor.value; __runInitializers(_classThis, _classExtraInitializers); } diff --git a/tests/baselines/reference/esDecorators-classDeclaration-classSuper.7.js b/tests/baselines/reference/esDecorators-classDeclaration-classSuper.7.js index 0072e715044bc..a10338a6a8ce6 100644 --- a/tests/baselines/reference/esDecorators-classDeclaration-classSuper.7.js +++ b/tests/baselines/reference/esDecorators-classDeclaration-classSuper.7.js @@ -71,31 +71,31 @@ function foo(method, _context) { new B(); // https://github.com/microsoft/TypeScript/issues/53448 let C = (() => { - let _instanceExtraInitializers_1 = []; + let _instanceExtraInitializers = []; let _get_val_decorators; return class C { static { _get_val_decorators = [foo]; - __esDecorate(this, null, _get_val_decorators, { kind: "getter", name: "val", static: false, private: false, access: { has: obj => "val" in obj, get: obj => obj.val } }, null, _instanceExtraInitializers_1); + __esDecorate(this, null, _get_val_decorators, { kind: "getter", name: "val", static: false, private: false, access: { has: obj => "val" in obj, get: obj => obj.val } }, null, _instanceExtraInitializers); } constructor() { - __runInitializers(this, _instanceExtraInitializers_1); + __runInitializers(this, _instanceExtraInitializers); this.val; } get val() { return 3; } }; })(); let D = (() => { - let _instanceExtraInitializers_2 = []; + let _instanceExtraInitializers = []; let _get_val_decorators; return class D extends A { static { _get_val_decorators = [foo]; - __esDecorate(this, null, _get_val_decorators, { kind: "getter", name: "val", static: false, private: false, access: { has: obj => "val" in obj, get: obj => obj.val } }, null, _instanceExtraInitializers_2); + __esDecorate(this, null, _get_val_decorators, { kind: "getter", name: "val", static: false, private: false, access: { has: obj => "val" in obj, get: obj => obj.val } }, null, _instanceExtraInitializers); } constructor() { super(); - __runInitializers(this, _instanceExtraInitializers_2); + __runInitializers(this, _instanceExtraInitializers); this.val; } get val() { return 3; } diff --git a/tests/baselines/reference/esDecorators-classDeclaration-classThisReference(target=es2015).js b/tests/baselines/reference/esDecorators-classDeclaration-classThisReference(target=es2015).js index ec04ba624335f..3438801f46244 100644 --- a/tests/baselines/reference/esDecorators-classDeclaration-classThisReference(target=es2015).js +++ b/tests/baselines/reference/esDecorators-classDeclaration-classThisReference(target=es2015).js @@ -15,14 +15,14 @@ class C { //// [esDecorators-classDeclaration-classThisReference.js] let C = (() => { - var _a_accessor_storage; + var _C_a_accessor_storage; let _classDecorators = [dec]; let _classDescriptor; let _classExtraInitializers = []; let _classThis; var C = _classThis = class { - static get a() { return __classPrivateFieldGet(this, _classThis, "f", _a_accessor_storage); } - static set a(value) { __classPrivateFieldSet(this, _classThis, value, "f", _a_accessor_storage); } + static get a() { return __classPrivateFieldGet(this, _classThis, "f", _C_a_accessor_storage); } + static set a(value) { __classPrivateFieldSet(this, _classThis, value, "f", _C_a_accessor_storage); } static m() { this; } static get g() { return this; } }; @@ -35,7 +35,7 @@ let C = (() => { _classThis; })(); _classThis.x = _classThis; - _a_accessor_storage = { value: _classThis }; + _C_a_accessor_storage = { value: _classThis }; (() => { __runInitializers(_classThis, _classExtraInitializers); })(); diff --git a/tests/baselines/reference/esDecorators-classDeclaration-classThisReference(target=es2022).js b/tests/baselines/reference/esDecorators-classDeclaration-classThisReference(target=es2022).js index 616b3afdff5dc..18a9b11fb4409 100644 --- a/tests/baselines/reference/esDecorators-classDeclaration-classThisReference(target=es2022).js +++ b/tests/baselines/reference/esDecorators-classDeclaration-classThisReference(target=es2022).js @@ -15,24 +15,25 @@ class C { //// [esDecorators-classDeclaration-classThisReference.js] let C = (() => { - var _a_accessor_storage; + var _C_a_accessor_storage; let _classDecorators = [dec]; let _classDescriptor; let _classExtraInitializers = []; let _classThis; var C = class { + static { _classThis = this; } static { __setFunctionName(this, "C"); } static { - __esDecorate(null, _classDescriptor = { value: this }, _classDecorators, { kind: "class", name: this.name }, null, _classExtraInitializers); + __esDecorate(null, _classDescriptor = { value: _classThis }, _classDecorators, { kind: "class", name: _classThis.name }, null, _classExtraInitializers); C = _classThis = _classDescriptor.value; } static { _classThis; } static x = _classThis; static { - _a_accessor_storage = { value: _classThis }; + _C_a_accessor_storage = { value: _classThis }; } - static get a() { return __classPrivateFieldGet(this, _classThis, "f", _a_accessor_storage); } - static set a(value) { __classPrivateFieldSet(this, _classThis, value, "f", _a_accessor_storage); } + static get a() { return __classPrivateFieldGet(this, _classThis, "f", _C_a_accessor_storage); } + static set a(value) { __classPrivateFieldSet(this, _classThis, value, "f", _C_a_accessor_storage); } static m() { this; } static get g() { return this; } static { diff --git a/tests/baselines/reference/esDecorators-classDeclaration-classThisReference.es5.js b/tests/baselines/reference/esDecorators-classDeclaration-classThisReference.es5.js index 8e7ed7b6511b8..29c1235e7624f 100644 --- a/tests/baselines/reference/esDecorators-classDeclaration-classThisReference.es5.js +++ b/tests/baselines/reference/esDecorators-classDeclaration-classThisReference.es5.js @@ -13,7 +13,6 @@ class C { //// [esDecorators-classDeclaration-classThisReference.es5.js] -var _this = this; var C = function () { var _classDecorators = [dec]; var _classDescriptor; diff --git a/tests/baselines/reference/esDecorators-classDeclaration-commentPreservation(module=commonjs,target=es2015).js b/tests/baselines/reference/esDecorators-classDeclaration-commentPreservation(module=commonjs,target=es2015).js index bc92f15ecde04..152531f2772e3 100644 --- a/tests/baselines/reference/esDecorators-classDeclaration-commentPreservation(module=commonjs,target=es2015).js +++ b/tests/baselines/reference/esDecorators-classDeclaration-commentPreservation(module=commonjs,target=es2015).js @@ -122,7 +122,7 @@ class G { //// [file1.js] /*1*/ let C = (() => { - var _method_get, _x_get, _x_set, _y, _z_accessor_storage, _z_get, _z_set, _z_1_accessor_storage; + var _C_method_get, _C_x_get, _C_x_set, _C_y, _C_z_accessor_storage, _C_z_get, _C_z_set, _C_z_1_accessor_storage; let _classDecorators = [dec, dec]; let _classDescriptor; let _classExtraInitializers = []; @@ -151,7 +151,7 @@ let C = (() => { constructor() { /*13*/ this.y = (__runInitializers(this, _instanceExtraInitializers), __runInitializers(this, _y_initializers, 1)); - _z_1_accessor_storage.set(this, __runInitializers(this, _z_initializers, 1)); + _C_z_1_accessor_storage.set(this, __runInitializers(this, _z_initializers, 1)); } /*4*/ method() { } @@ -160,15 +160,15 @@ let C = (() => { /*10*/ set x(value) { } /*16*/ - get z() { return __classPrivateFieldGet(this, _z_1_accessor_storage, "f"); } - set z(value) { __classPrivateFieldSet(this, _z_1_accessor_storage, value, "f"); } + get z() { return __classPrivateFieldGet(this, _C_z_1_accessor_storage, "f"); } + set z(value) { __classPrivateFieldSet(this, _C_z_1_accessor_storage, value, "f"); } }; - _z_1_accessor_storage = new WeakMap(); - _method_get = function _method_get() { return _static_private_method_descriptor.value; }; - _x_get = function _x_get() { return _static_private_get_x_descriptor.get.call(this); }; - _x_set = function _x_set(value) { return _static_private_set_x_descriptor.set.call(this, value); }; - _z_get = function _z_get() { return _static_private_z_descriptor.get.call(this); }; - _z_set = function _z_set(value) { return _static_private_z_descriptor.set.call(this, value); }; + _C_z_1_accessor_storage = new WeakMap(); + _C_method_get = function _C_method_get() { return _static_private_method_descriptor.value; }; + _C_x_get = function _C_x_get() { return _static_private_get_x_descriptor.get.call(this); }; + _C_x_set = function _C_x_set(value) { return _static_private_set_x_descriptor.set.call(this, value); }; + _C_z_get = function _C_z_get() { return _static_private_z_descriptor.get.call(this); }; + _C_z_set = function _C_z_set(value) { return _static_private_z_descriptor.set.call(this, value); }; __setFunctionName(_classThis, "C"); (() => { _method_decorators = [dec, dec]; @@ -181,23 +181,23 @@ let C = (() => { _static_private_set_x_decorators = [dec, dec]; _static_private_y_decorators = [dec, dec]; _static_private_z_decorators = [dec, dec]; - __esDecorate(_classThis, _static_private_method_descriptor = { value: __setFunctionName(function () { }, "#method") }, _static_private_method_decorators, { kind: "method", name: "#method", static: true, private: true, access: { has: obj => __classPrivateFieldIn(_classThis, obj), get: obj => __classPrivateFieldGet(obj, _classThis, "a", _method_get) } }, null, _staticExtraInitializers); - __esDecorate(_classThis, _static_private_get_x_descriptor = { get: __setFunctionName(function () { return 1; }, "#x", "get") }, _static_private_get_x_decorators, { kind: "getter", name: "#x", static: true, private: true, access: { has: obj => __classPrivateFieldIn(_classThis, obj), get: obj => __classPrivateFieldGet(obj, _classThis, "a", _x_get) } }, null, _staticExtraInitializers); - __esDecorate(_classThis, _static_private_set_x_descriptor = { set: __setFunctionName(function (value) { }, "#x", "set") }, _static_private_set_x_decorators, { kind: "setter", name: "#x", static: true, private: true, access: { has: obj => __classPrivateFieldIn(_classThis, obj), set: (obj, value) => { __classPrivateFieldSet(obj, _classThis, value, "a", _x_set); } } }, null, _staticExtraInitializers); - __esDecorate(_classThis, _static_private_z_descriptor = { get: __setFunctionName(function () { return __classPrivateFieldGet(_classThis, _classThis, "f", _z_accessor_storage); }, "#z", "get"), set: __setFunctionName(function (value) { __classPrivateFieldSet(_classThis, _classThis, value, "f", _z_accessor_storage); }, "#z", "set") }, _static_private_z_decorators, { kind: "accessor", name: "#z", static: true, private: true, access: { has: obj => __classPrivateFieldIn(_classThis, obj), get: obj => __classPrivateFieldGet(obj, _classThis, "a", _z_get), set: (obj, value) => { __classPrivateFieldSet(obj, _classThis, value, "a", _z_set); } } }, _static_private_z_initializers, _staticExtraInitializers); + __esDecorate(_classThis, _static_private_method_descriptor = { value: __setFunctionName(function () { }, "#method") }, _static_private_method_decorators, { kind: "method", name: "#method", static: true, private: true, access: { has: obj => __classPrivateFieldIn(_classThis, obj), get: obj => __classPrivateFieldGet(obj, _classThis, "a", _C_method_get) } }, null, _staticExtraInitializers); + __esDecorate(_classThis, _static_private_get_x_descriptor = { get: __setFunctionName(function () { return 1; }, "#x", "get") }, _static_private_get_x_decorators, { kind: "getter", name: "#x", static: true, private: true, access: { has: obj => __classPrivateFieldIn(_classThis, obj), get: obj => __classPrivateFieldGet(obj, _classThis, "a", _C_x_get) } }, null, _staticExtraInitializers); + __esDecorate(_classThis, _static_private_set_x_descriptor = { set: __setFunctionName(function (value) { }, "#x", "set") }, _static_private_set_x_decorators, { kind: "setter", name: "#x", static: true, private: true, access: { has: obj => __classPrivateFieldIn(_classThis, obj), set: (obj, value) => { __classPrivateFieldSet(obj, _classThis, value, "a", _C_x_set); } } }, null, _staticExtraInitializers); + __esDecorate(_classThis, _static_private_z_descriptor = { get: __setFunctionName(function () { return __classPrivateFieldGet(_classThis, _classThis, "f", _C_z_accessor_storage); }, "#z", "get"), set: __setFunctionName(function (value) { __classPrivateFieldSet(_classThis, _classThis, value, "f", _C_z_accessor_storage); }, "#z", "set") }, _static_private_z_decorators, { kind: "accessor", name: "#z", static: true, private: true, access: { has: obj => __classPrivateFieldIn(_classThis, obj), get: obj => __classPrivateFieldGet(obj, _classThis, "a", _C_z_get), set: (obj, value) => { __classPrivateFieldSet(obj, _classThis, value, "a", _C_z_set); } } }, _static_private_z_initializers, _staticExtraInitializers); __esDecorate(_classThis, null, _method_decorators, { kind: "method", name: "method", static: false, private: false, access: { has: obj => "method" in obj, get: obj => obj.method } }, null, _instanceExtraInitializers); __esDecorate(_classThis, null, _get_x_decorators, { kind: "getter", name: "x", static: false, private: false, access: { has: obj => "x" in obj, get: obj => obj.x } }, null, _instanceExtraInitializers); __esDecorate(_classThis, null, _set_x_decorators, { kind: "setter", name: "x", static: false, private: false, access: { has: obj => "x" in obj, set: (obj, value) => { obj.x = value; } } }, null, _instanceExtraInitializers); __esDecorate(_classThis, null, _z_decorators, { kind: "accessor", name: "z", static: false, private: false, access: { has: obj => "z" in obj, get: obj => obj.z, set: (obj, value) => { obj.z = value; } } }, _z_initializers, _instanceExtraInitializers); - __esDecorate(null, null, _static_private_y_decorators, { kind: "field", name: "#y", static: true, private: true, access: { has: obj => __classPrivateFieldIn(_classThis, obj), get: obj => __classPrivateFieldGet(obj, _classThis, "f", _y), set: (obj, value) => { __classPrivateFieldSet(obj, _classThis, value, "f", _y); } } }, _static_private_y_initializers, _staticExtraInitializers); + __esDecorate(null, null, _static_private_y_decorators, { kind: "field", name: "#y", static: true, private: true, access: { has: obj => __classPrivateFieldIn(_classThis, obj), get: obj => __classPrivateFieldGet(obj, _classThis, "f", _C_y), set: (obj, value) => { __classPrivateFieldSet(obj, _classThis, value, "f", _C_y); } } }, _static_private_y_initializers, _staticExtraInitializers); __esDecorate(null, null, _y_decorators, { kind: "field", name: "y", static: false, private: false, access: { has: obj => "y" in obj, get: obj => obj.y, set: (obj, value) => { obj.y = value; } } }, _y_initializers, _instanceExtraInitializers); __esDecorate(null, _classDescriptor = { value: _classThis }, _classDecorators, { kind: "class", name: _classThis.name }, null, _classExtraInitializers); C = _classThis = _classDescriptor.value; __runInitializers(_classThis, _staticExtraInitializers); })(); /*28*/ - _y = { value: __runInitializers(_classThis, _static_private_y_initializers, 1) }; - _z_accessor_storage = { value: __runInitializers(_classThis, _static_private_z_initializers, 1) }; + _C_y = { value: __runInitializers(_classThis, _static_private_y_initializers, 1) }; + _C_z_accessor_storage = { value: __runInitializers(_classThis, _static_private_z_initializers, 1) }; (() => { __runInitializers(_classThis, _classExtraInitializers); })(); @@ -208,7 +208,7 @@ let C = (() => { Object.defineProperty(exports, "__esModule", { value: true }); exports.D = void 0; /*34*/ -let D = exports.D = (() => { +let D = (() => { let _classDecorators = [dec, dec]; let _classDescriptor; let _classExtraInitializers = []; @@ -223,27 +223,29 @@ let D = exports.D = (() => { })(); return D = _classThis; })(); -exports.default = (() => { - let _classDecorators_1 = [dec, dec]; - let _classDescriptor_1; - let _classExtraInitializers_1 = []; - let _classThis_1; - var E = _classThis_1 = class { +exports.D = D; +let E = (() => { + let _classDecorators = [dec, dec]; + let _classDescriptor; + let _classExtraInitializers = []; + let _classThis; + var E = _classThis = class { }; - __setFunctionName(_classThis_1, "E"); + __setFunctionName(_classThis, "E"); (() => { - __esDecorate(null, _classDescriptor_1 = { value: _classThis_1 }, _classDecorators_1, { kind: "class", name: _classThis_1.name }, null, _classExtraInitializers_1); - E = _classThis_1 = _classDescriptor_1.value; - __runInitializers(_classThis_1, _classExtraInitializers_1); + __esDecorate(null, _classDescriptor = { value: _classThis }, _classDecorators, { kind: "class", name: _classThis.name }, null, _classExtraInitializers); + E = _classThis = _classDescriptor.value; + __runInitializers(_classThis, _classExtraInitializers); })(); - return E = _classThis_1; + return E = _classThis; })(); +exports.default = E; //// [file3.js] "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.F = void 0; /*40*/ -let F = exports.F = (() => { +let F = (() => { let _classDecorators = [dec, dec]; let _classDescriptor; let _classExtraInitializers = []; @@ -258,18 +260,20 @@ let F = exports.F = (() => { })(); return F = _classThis; })(); -exports.default = (() => { - let _classDecorators_1 = [dec, dec]; - let _classDescriptor_1; - let _classExtraInitializers_1 = []; - let _classThis_1; - var G = _classThis_1 = class { +exports.F = F; +let G = (() => { + let _classDecorators = [dec, dec]; + let _classDescriptor; + let _classExtraInitializers = []; + let _classThis; + var G = _classThis = class { }; - __setFunctionName(_classThis_1, "G"); + __setFunctionName(_classThis, "G"); (() => { - __esDecorate(null, _classDescriptor_1 = { value: _classThis_1 }, _classDecorators_1, { kind: "class", name: _classThis_1.name }, null, _classExtraInitializers_1); - G = _classThis_1 = _classDescriptor_1.value; - __runInitializers(_classThis_1, _classExtraInitializers_1); + __esDecorate(null, _classDescriptor = { value: _classThis }, _classDecorators, { kind: "class", name: _classThis.name }, null, _classExtraInitializers); + G = _classThis = _classDescriptor.value; + __runInitializers(_classThis, _classExtraInitializers); })(); - return G = _classThis_1; + return G = _classThis; })(); +exports.default = G; diff --git a/tests/baselines/reference/esDecorators-classDeclaration-commentPreservation(module=commonjs,target=es2022).js b/tests/baselines/reference/esDecorators-classDeclaration-commentPreservation(module=commonjs,target=es2022).js index 812dcb28249c2..3d1ef041d6996 100644 --- a/tests/baselines/reference/esDecorators-classDeclaration-commentPreservation(module=commonjs,target=es2022).js +++ b/tests/baselines/reference/esDecorators-classDeclaration-commentPreservation(module=commonjs,target=es2022).js @@ -122,7 +122,7 @@ class G { //// [file1.js] /*1*/ let C = (() => { - var _method_get, _x_get, _x_set, _y, _z_accessor_storage, _z_get, _z_set; + var _C_method_get, _C_x_get, _C_x_set, _C_y, _C_z_accessor_storage, _C_z_get, _C_z_set; let _classDecorators = [dec, dec]; let _classDescriptor; let _classExtraInitializers = []; @@ -148,8 +148,9 @@ let C = (() => { let _z_decorators; let _z_initializers = []; var C = class { + static { _classThis = this; } static { __setFunctionName(this, "C"); } - static { _method_get = function _method_get() { return _static_private_method_descriptor.value; }, _x_get = function _x_get() { return _static_private_get_x_descriptor.get.call(this); }, _x_set = function _x_set(value) { return _static_private_set_x_descriptor.set.call(this, value); }, _z_get = function _z_get() { return _static_private_z_descriptor.get.call(this); }, _z_set = function _z_set(value) { return _static_private_z_descriptor.set.call(this, value); }; } + static { _C_method_get = function _C_method_get() { return _static_private_method_descriptor.value; }, _C_x_get = function _C_x_get() { return _static_private_get_x_descriptor.get.call(this); }, _C_x_set = function _C_x_set(value) { return _static_private_set_x_descriptor.set.call(this, value); }, _C_z_get = function _C_z_get() { return _static_private_z_descriptor.get.call(this); }, _C_z_set = function _C_z_set(value) { return _static_private_z_descriptor.set.call(this, value); }; } static { _method_decorators = [dec, dec]; _get_x_decorators = [dec, dec]; @@ -161,17 +162,17 @@ let C = (() => { _static_private_set_x_decorators = [dec, dec]; _static_private_y_decorators = [dec, dec]; _static_private_z_decorators = [dec, dec]; - __esDecorate(this, _static_private_method_descriptor = { value: __setFunctionName(function () { }, "#method") }, _static_private_method_decorators, { kind: "method", name: "#method", static: true, private: true, access: { has: obj => __classPrivateFieldIn(_classThis, obj), get: obj => __classPrivateFieldGet(obj, _classThis, "a", _method_get) } }, null, _staticExtraInitializers); - __esDecorate(this, _static_private_get_x_descriptor = { get: __setFunctionName(function () { return 1; }, "#x", "get") }, _static_private_get_x_decorators, { kind: "getter", name: "#x", static: true, private: true, access: { has: obj => __classPrivateFieldIn(_classThis, obj), get: obj => __classPrivateFieldGet(obj, _classThis, "a", _x_get) } }, null, _staticExtraInitializers); - __esDecorate(this, _static_private_set_x_descriptor = { set: __setFunctionName(function (value) { }, "#x", "set") }, _static_private_set_x_decorators, { kind: "setter", name: "#x", static: true, private: true, access: { has: obj => __classPrivateFieldIn(_classThis, obj), set: (obj, value) => { __classPrivateFieldSet(obj, _classThis, value, "a", _x_set); } } }, null, _staticExtraInitializers); - __esDecorate(this, _static_private_z_descriptor = { get: __setFunctionName(function () { return __classPrivateFieldGet(this, _classThis, "f", _z_accessor_storage); }, "#z", "get"), set: __setFunctionName(function (value) { __classPrivateFieldSet(this, _classThis, value, "f", _z_accessor_storage); }, "#z", "set") }, _static_private_z_decorators, { kind: "accessor", name: "#z", static: true, private: true, access: { has: obj => __classPrivateFieldIn(_classThis, obj), get: obj => __classPrivateFieldGet(obj, _classThis, "a", _z_get), set: (obj, value) => { __classPrivateFieldSet(obj, _classThis, value, "a", _z_set); } } }, _static_private_z_initializers, _staticExtraInitializers); + __esDecorate(this, _static_private_method_descriptor = { value: __setFunctionName(function () { }, "#method") }, _static_private_method_decorators, { kind: "method", name: "#method", static: true, private: true, access: { has: obj => __classPrivateFieldIn(_classThis, obj), get: obj => __classPrivateFieldGet(obj, _classThis, "a", _C_method_get) } }, null, _staticExtraInitializers); + __esDecorate(this, _static_private_get_x_descriptor = { get: __setFunctionName(function () { return 1; }, "#x", "get") }, _static_private_get_x_decorators, { kind: "getter", name: "#x", static: true, private: true, access: { has: obj => __classPrivateFieldIn(_classThis, obj), get: obj => __classPrivateFieldGet(obj, _classThis, "a", _C_x_get) } }, null, _staticExtraInitializers); + __esDecorate(this, _static_private_set_x_descriptor = { set: __setFunctionName(function (value) { }, "#x", "set") }, _static_private_set_x_decorators, { kind: "setter", name: "#x", static: true, private: true, access: { has: obj => __classPrivateFieldIn(_classThis, obj), set: (obj, value) => { __classPrivateFieldSet(obj, _classThis, value, "a", _C_x_set); } } }, null, _staticExtraInitializers); + __esDecorate(this, _static_private_z_descriptor = { get: __setFunctionName(function () { return __classPrivateFieldGet(this, _classThis, "f", _C_z_accessor_storage); }, "#z", "get"), set: __setFunctionName(function (value) { __classPrivateFieldSet(this, _classThis, value, "f", _C_z_accessor_storage); }, "#z", "set") }, _static_private_z_decorators, { kind: "accessor", name: "#z", static: true, private: true, access: { has: obj => __classPrivateFieldIn(_classThis, obj), get: obj => __classPrivateFieldGet(obj, _classThis, "a", _C_z_get), set: (obj, value) => { __classPrivateFieldSet(obj, _classThis, value, "a", _C_z_set); } } }, _static_private_z_initializers, _staticExtraInitializers); __esDecorate(this, null, _method_decorators, { kind: "method", name: "method", static: false, private: false, access: { has: obj => "method" in obj, get: obj => obj.method } }, null, _instanceExtraInitializers); __esDecorate(this, null, _get_x_decorators, { kind: "getter", name: "x", static: false, private: false, access: { has: obj => "x" in obj, get: obj => obj.x } }, null, _instanceExtraInitializers); __esDecorate(this, null, _set_x_decorators, { kind: "setter", name: "x", static: false, private: false, access: { has: obj => "x" in obj, set: (obj, value) => { obj.x = value; } } }, null, _instanceExtraInitializers); __esDecorate(this, null, _z_decorators, { kind: "accessor", name: "z", static: false, private: false, access: { has: obj => "z" in obj, get: obj => obj.z, set: (obj, value) => { obj.z = value; } } }, _z_initializers, _instanceExtraInitializers); - __esDecorate(null, null, _static_private_y_decorators, { kind: "field", name: "#y", static: true, private: true, access: { has: obj => __classPrivateFieldIn(_classThis, obj), get: obj => __classPrivateFieldGet(obj, _classThis, "f", _y), set: (obj, value) => { __classPrivateFieldSet(obj, _classThis, value, "f", _y); } } }, _static_private_y_initializers, _staticExtraInitializers); + __esDecorate(null, null, _static_private_y_decorators, { kind: "field", name: "#y", static: true, private: true, access: { has: obj => __classPrivateFieldIn(_classThis, obj), get: obj => __classPrivateFieldGet(obj, _classThis, "f", _C_y), set: (obj, value) => { __classPrivateFieldSet(obj, _classThis, value, "f", _C_y); } } }, _static_private_y_initializers, _staticExtraInitializers); __esDecorate(null, null, _y_decorators, { kind: "field", name: "y", static: false, private: false, access: { has: obj => "y" in obj, get: obj => obj.y, set: (obj, value) => { obj.y = value; } } }, _y_initializers, _instanceExtraInitializers); - __esDecorate(null, _classDescriptor = { value: this }, _classDecorators, { kind: "class", name: this.name }, null, _classExtraInitializers); + __esDecorate(null, _classDescriptor = { value: _classThis }, _classDecorators, { kind: "class", name: _classThis.name }, null, _classExtraInitializers); C = _classThis = _classDescriptor.value; __runInitializers(_classThis, _staticExtraInitializers); } @@ -189,10 +190,10 @@ let C = (() => { set z(value) { this.#z_accessor_storage = value; } static { /*28*/ - _y = { value: __runInitializers(_classThis, _static_private_y_initializers, 1) }; + _C_y = { value: __runInitializers(_classThis, _static_private_y_initializers, 1) }; } static { - _z_accessor_storage = { value: __runInitializers(_classThis, _static_private_z_initializers, 1) }; + _C_z_accessor_storage = { value: __runInitializers(_classThis, _static_private_z_initializers, 1) }; } static { __runInitializers(_classThis, _classExtraInitializers); @@ -205,64 +206,72 @@ let C = (() => { Object.defineProperty(exports, "__esModule", { value: true }); exports.D = void 0; /*34*/ -let D = exports.D = (() => { +let D = (() => { let _classDecorators = [dec, dec]; let _classDescriptor; let _classExtraInitializers = []; let _classThis; var D = class { + static { _classThis = this; } static { - __esDecorate(null, _classDescriptor = { value: this }, _classDecorators, { kind: "class", name: this.name }, null, _classExtraInitializers); + __esDecorate(null, _classDescriptor = { value: _classThis }, _classDecorators, { kind: "class", name: _classThis.name }, null, _classExtraInitializers); D = _classThis = _classDescriptor.value; __runInitializers(_classThis, _classExtraInitializers); } }; return D = _classThis; })(); -exports.default = (() => { - let _classDecorators_1 = [dec, dec]; - let _classDescriptor_1; - let _classExtraInitializers_1 = []; - let _classThis_1; +exports.D = D; +let E = (() => { + let _classDecorators = [dec, dec]; + let _classDescriptor; + let _classExtraInitializers = []; + let _classThis; var E = class { + static { _classThis = this; } static { - __esDecorate(null, _classDescriptor_1 = { value: this }, _classDecorators_1, { kind: "class", name: this.name }, null, _classExtraInitializers_1); - E = _classThis_1 = _classDescriptor_1.value; - __runInitializers(_classThis_1, _classExtraInitializers_1); + __esDecorate(null, _classDescriptor = { value: _classThis }, _classDecorators, { kind: "class", name: _classThis.name }, null, _classExtraInitializers); + E = _classThis = _classDescriptor.value; + __runInitializers(_classThis, _classExtraInitializers); } }; - return E = _classThis_1; + return E = _classThis; })(); +exports.default = E; //// [file3.js] "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.F = void 0; /*40*/ -let F = exports.F = (() => { +let F = (() => { let _classDecorators = [dec, dec]; let _classDescriptor; let _classExtraInitializers = []; let _classThis; var F = class { + static { _classThis = this; } static { - __esDecorate(null, _classDescriptor = { value: this }, _classDecorators, { kind: "class", name: this.name }, null, _classExtraInitializers); + __esDecorate(null, _classDescriptor = { value: _classThis }, _classDecorators, { kind: "class", name: _classThis.name }, null, _classExtraInitializers); F = _classThis = _classDescriptor.value; __runInitializers(_classThis, _classExtraInitializers); } }; return F = _classThis; })(); -exports.default = (() => { - let _classDecorators_1 = [dec, dec]; - let _classDescriptor_1; - let _classExtraInitializers_1 = []; - let _classThis_1; +exports.F = F; +let G = (() => { + let _classDecorators = [dec, dec]; + let _classDescriptor; + let _classExtraInitializers = []; + let _classThis; var G = class { + static { _classThis = this; } static { - __esDecorate(null, _classDescriptor_1 = { value: this }, _classDecorators_1, { kind: "class", name: this.name }, null, _classExtraInitializers_1); - G = _classThis_1 = _classDescriptor_1.value; - __runInitializers(_classThis_1, _classExtraInitializers_1); + __esDecorate(null, _classDescriptor = { value: _classThis }, _classDecorators, { kind: "class", name: _classThis.name }, null, _classExtraInitializers); + G = _classThis = _classDescriptor.value; + __runInitializers(_classThis, _classExtraInitializers); } }; - return G = _classThis_1; + return G = _classThis; })(); +exports.default = G; diff --git a/tests/baselines/reference/esDecorators-classDeclaration-commentPreservation(module=esnext,target=es2015).js b/tests/baselines/reference/esDecorators-classDeclaration-commentPreservation(module=esnext,target=es2015).js index 98eb2ad7ac31a..7029ea1157cc0 100644 --- a/tests/baselines/reference/esDecorators-classDeclaration-commentPreservation(module=esnext,target=es2015).js +++ b/tests/baselines/reference/esDecorators-classDeclaration-commentPreservation(module=esnext,target=es2015).js @@ -122,7 +122,7 @@ class G { //// [file1.js] /*1*/ let C = (() => { - var _method_get, _x_get, _x_set, _y, _z_accessor_storage, _z_get, _z_set, _z_1_accessor_storage; + var _C_method_get, _C_x_get, _C_x_set, _C_y, _C_z_accessor_storage, _C_z_get, _C_z_set, _C_z_1_accessor_storage; let _classDecorators = [dec, dec]; let _classDescriptor; let _classExtraInitializers = []; @@ -151,7 +151,7 @@ let C = (() => { constructor() { /*13*/ this.y = (__runInitializers(this, _instanceExtraInitializers), __runInitializers(this, _y_initializers, 1)); - _z_1_accessor_storage.set(this, __runInitializers(this, _z_initializers, 1)); + _C_z_1_accessor_storage.set(this, __runInitializers(this, _z_initializers, 1)); } /*4*/ method() { } @@ -160,15 +160,15 @@ let C = (() => { /*10*/ set x(value) { } /*16*/ - get z() { return __classPrivateFieldGet(this, _z_1_accessor_storage, "f"); } - set z(value) { __classPrivateFieldSet(this, _z_1_accessor_storage, value, "f"); } + get z() { return __classPrivateFieldGet(this, _C_z_1_accessor_storage, "f"); } + set z(value) { __classPrivateFieldSet(this, _C_z_1_accessor_storage, value, "f"); } }; - _z_1_accessor_storage = new WeakMap(); - _method_get = function _method_get() { return _static_private_method_descriptor.value; }; - _x_get = function _x_get() { return _static_private_get_x_descriptor.get.call(this); }; - _x_set = function _x_set(value) { return _static_private_set_x_descriptor.set.call(this, value); }; - _z_get = function _z_get() { return _static_private_z_descriptor.get.call(this); }; - _z_set = function _z_set(value) { return _static_private_z_descriptor.set.call(this, value); }; + _C_z_1_accessor_storage = new WeakMap(); + _C_method_get = function _C_method_get() { return _static_private_method_descriptor.value; }; + _C_x_get = function _C_x_get() { return _static_private_get_x_descriptor.get.call(this); }; + _C_x_set = function _C_x_set(value) { return _static_private_set_x_descriptor.set.call(this, value); }; + _C_z_get = function _C_z_get() { return _static_private_z_descriptor.get.call(this); }; + _C_z_set = function _C_z_set(value) { return _static_private_z_descriptor.set.call(this, value); }; __setFunctionName(_classThis, "C"); (() => { _method_decorators = [dec, dec]; @@ -181,23 +181,23 @@ let C = (() => { _static_private_set_x_decorators = [dec, dec]; _static_private_y_decorators = [dec, dec]; _static_private_z_decorators = [dec, dec]; - __esDecorate(_classThis, _static_private_method_descriptor = { value: __setFunctionName(function () { }, "#method") }, _static_private_method_decorators, { kind: "method", name: "#method", static: true, private: true, access: { has: obj => __classPrivateFieldIn(_classThis, obj), get: obj => __classPrivateFieldGet(obj, _classThis, "a", _method_get) } }, null, _staticExtraInitializers); - __esDecorate(_classThis, _static_private_get_x_descriptor = { get: __setFunctionName(function () { return 1; }, "#x", "get") }, _static_private_get_x_decorators, { kind: "getter", name: "#x", static: true, private: true, access: { has: obj => __classPrivateFieldIn(_classThis, obj), get: obj => __classPrivateFieldGet(obj, _classThis, "a", _x_get) } }, null, _staticExtraInitializers); - __esDecorate(_classThis, _static_private_set_x_descriptor = { set: __setFunctionName(function (value) { }, "#x", "set") }, _static_private_set_x_decorators, { kind: "setter", name: "#x", static: true, private: true, access: { has: obj => __classPrivateFieldIn(_classThis, obj), set: (obj, value) => { __classPrivateFieldSet(obj, _classThis, value, "a", _x_set); } } }, null, _staticExtraInitializers); - __esDecorate(_classThis, _static_private_z_descriptor = { get: __setFunctionName(function () { return __classPrivateFieldGet(_classThis, _classThis, "f", _z_accessor_storage); }, "#z", "get"), set: __setFunctionName(function (value) { __classPrivateFieldSet(_classThis, _classThis, value, "f", _z_accessor_storage); }, "#z", "set") }, _static_private_z_decorators, { kind: "accessor", name: "#z", static: true, private: true, access: { has: obj => __classPrivateFieldIn(_classThis, obj), get: obj => __classPrivateFieldGet(obj, _classThis, "a", _z_get), set: (obj, value) => { __classPrivateFieldSet(obj, _classThis, value, "a", _z_set); } } }, _static_private_z_initializers, _staticExtraInitializers); + __esDecorate(_classThis, _static_private_method_descriptor = { value: __setFunctionName(function () { }, "#method") }, _static_private_method_decorators, { kind: "method", name: "#method", static: true, private: true, access: { has: obj => __classPrivateFieldIn(_classThis, obj), get: obj => __classPrivateFieldGet(obj, _classThis, "a", _C_method_get) } }, null, _staticExtraInitializers); + __esDecorate(_classThis, _static_private_get_x_descriptor = { get: __setFunctionName(function () { return 1; }, "#x", "get") }, _static_private_get_x_decorators, { kind: "getter", name: "#x", static: true, private: true, access: { has: obj => __classPrivateFieldIn(_classThis, obj), get: obj => __classPrivateFieldGet(obj, _classThis, "a", _C_x_get) } }, null, _staticExtraInitializers); + __esDecorate(_classThis, _static_private_set_x_descriptor = { set: __setFunctionName(function (value) { }, "#x", "set") }, _static_private_set_x_decorators, { kind: "setter", name: "#x", static: true, private: true, access: { has: obj => __classPrivateFieldIn(_classThis, obj), set: (obj, value) => { __classPrivateFieldSet(obj, _classThis, value, "a", _C_x_set); } } }, null, _staticExtraInitializers); + __esDecorate(_classThis, _static_private_z_descriptor = { get: __setFunctionName(function () { return __classPrivateFieldGet(_classThis, _classThis, "f", _C_z_accessor_storage); }, "#z", "get"), set: __setFunctionName(function (value) { __classPrivateFieldSet(_classThis, _classThis, value, "f", _C_z_accessor_storage); }, "#z", "set") }, _static_private_z_decorators, { kind: "accessor", name: "#z", static: true, private: true, access: { has: obj => __classPrivateFieldIn(_classThis, obj), get: obj => __classPrivateFieldGet(obj, _classThis, "a", _C_z_get), set: (obj, value) => { __classPrivateFieldSet(obj, _classThis, value, "a", _C_z_set); } } }, _static_private_z_initializers, _staticExtraInitializers); __esDecorate(_classThis, null, _method_decorators, { kind: "method", name: "method", static: false, private: false, access: { has: obj => "method" in obj, get: obj => obj.method } }, null, _instanceExtraInitializers); __esDecorate(_classThis, null, _get_x_decorators, { kind: "getter", name: "x", static: false, private: false, access: { has: obj => "x" in obj, get: obj => obj.x } }, null, _instanceExtraInitializers); __esDecorate(_classThis, null, _set_x_decorators, { kind: "setter", name: "x", static: false, private: false, access: { has: obj => "x" in obj, set: (obj, value) => { obj.x = value; } } }, null, _instanceExtraInitializers); __esDecorate(_classThis, null, _z_decorators, { kind: "accessor", name: "z", static: false, private: false, access: { has: obj => "z" in obj, get: obj => obj.z, set: (obj, value) => { obj.z = value; } } }, _z_initializers, _instanceExtraInitializers); - __esDecorate(null, null, _static_private_y_decorators, { kind: "field", name: "#y", static: true, private: true, access: { has: obj => __classPrivateFieldIn(_classThis, obj), get: obj => __classPrivateFieldGet(obj, _classThis, "f", _y), set: (obj, value) => { __classPrivateFieldSet(obj, _classThis, value, "f", _y); } } }, _static_private_y_initializers, _staticExtraInitializers); + __esDecorate(null, null, _static_private_y_decorators, { kind: "field", name: "#y", static: true, private: true, access: { has: obj => __classPrivateFieldIn(_classThis, obj), get: obj => __classPrivateFieldGet(obj, _classThis, "f", _C_y), set: (obj, value) => { __classPrivateFieldSet(obj, _classThis, value, "f", _C_y); } } }, _static_private_y_initializers, _staticExtraInitializers); __esDecorate(null, null, _y_decorators, { kind: "field", name: "y", static: false, private: false, access: { has: obj => "y" in obj, get: obj => obj.y, set: (obj, value) => { obj.y = value; } } }, _y_initializers, _instanceExtraInitializers); __esDecorate(null, _classDescriptor = { value: _classThis }, _classDecorators, { kind: "class", name: _classThis.name }, null, _classExtraInitializers); C = _classThis = _classDescriptor.value; __runInitializers(_classThis, _staticExtraInitializers); })(); /*28*/ - _y = { value: __runInitializers(_classThis, _static_private_y_initializers, 1) }; - _z_accessor_storage = { value: __runInitializers(_classThis, _static_private_z_initializers, 1) }; + _C_y = { value: __runInitializers(_classThis, _static_private_y_initializers, 1) }; + _C_z_accessor_storage = { value: __runInitializers(_classThis, _static_private_z_initializers, 1) }; (() => { __runInitializers(_classThis, _classExtraInitializers); })(); @@ -205,8 +205,7 @@ let C = (() => { })(); //// [file2.js] /*34*/ -/*36*/ -export let D = (() => { +let D = (() => { let _classDecorators = [dec, dec]; let _classDescriptor; let _classExtraInitializers = []; @@ -221,25 +220,27 @@ export let D = (() => { })(); return D = _classThis; })(); -/*37*/ -export default (() => { - let _classDecorators_1 = [dec, dec]; - let _classDescriptor_1; - let _classExtraInitializers_1 = []; - let _classThis_1; - var E = _classThis_1 = class { +export { D }; +let E = (() => { + let _classDecorators = [dec, dec]; + let _classDescriptor; + let _classExtraInitializers = []; + let _classThis; + var E = _classThis = class { }; - __setFunctionName(_classThis_1, "E"); + __setFunctionName(_classThis, "E"); (() => { - __esDecorate(null, _classDescriptor_1 = { value: _classThis_1 }, _classDecorators_1, { kind: "class", name: _classThis_1.name }, null, _classExtraInitializers_1); - E = _classThis_1 = _classDescriptor_1.value; - __runInitializers(_classThis_1, _classExtraInitializers_1); + __esDecorate(null, _classDescriptor = { value: _classThis }, _classDecorators, { kind: "class", name: _classThis.name }, null, _classExtraInitializers); + E = _classThis = _classDescriptor.value; + __runInitializers(_classThis, _classExtraInitializers); })(); - return E = _classThis_1; + return E = _classThis; })(); +/*37*/ +export default E; //// [file3.js] /*40*/ -export let F = (() => { +let F = (() => { let _classDecorators = [dec, dec]; let _classDescriptor; let _classExtraInitializers = []; @@ -254,19 +255,21 @@ export let F = (() => { })(); return F = _classThis; })(); -/*44*/ -export default (() => { - let _classDecorators_1 = [dec, dec]; - let _classDescriptor_1; - let _classExtraInitializers_1 = []; - let _classThis_1; - var G = _classThis_1 = class { +export { F }; +let G = (() => { + let _classDecorators = [dec, dec]; + let _classDescriptor; + let _classExtraInitializers = []; + let _classThis; + var G = _classThis = class { }; - __setFunctionName(_classThis_1, "G"); + __setFunctionName(_classThis, "G"); (() => { - __esDecorate(null, _classDescriptor_1 = { value: _classThis_1 }, _classDecorators_1, { kind: "class", name: _classThis_1.name }, null, _classExtraInitializers_1); - G = _classThis_1 = _classDescriptor_1.value; - __runInitializers(_classThis_1, _classExtraInitializers_1); + __esDecorate(null, _classDescriptor = { value: _classThis }, _classDecorators, { kind: "class", name: _classThis.name }, null, _classExtraInitializers); + G = _classThis = _classDescriptor.value; + __runInitializers(_classThis, _classExtraInitializers); })(); - return G = _classThis_1; + return G = _classThis; })(); +/*44*/ +export default G; diff --git a/tests/baselines/reference/esDecorators-classDeclaration-commentPreservation(module=esnext,target=es2022).js b/tests/baselines/reference/esDecorators-classDeclaration-commentPreservation(module=esnext,target=es2022).js index fb04f31ae345d..cdd455b4f468c 100644 --- a/tests/baselines/reference/esDecorators-classDeclaration-commentPreservation(module=esnext,target=es2022).js +++ b/tests/baselines/reference/esDecorators-classDeclaration-commentPreservation(module=esnext,target=es2022).js @@ -122,7 +122,7 @@ class G { //// [file1.js] /*1*/ let C = (() => { - var _method_get, _x_get, _x_set, _y, _z_accessor_storage, _z_get, _z_set; + var _C_method_get, _C_x_get, _C_x_set, _C_y, _C_z_accessor_storage, _C_z_get, _C_z_set; let _classDecorators = [dec, dec]; let _classDescriptor; let _classExtraInitializers = []; @@ -148,8 +148,9 @@ let C = (() => { let _z_decorators; let _z_initializers = []; var C = class { + static { _classThis = this; } static { __setFunctionName(this, "C"); } - static { _method_get = function _method_get() { return _static_private_method_descriptor.value; }, _x_get = function _x_get() { return _static_private_get_x_descriptor.get.call(this); }, _x_set = function _x_set(value) { return _static_private_set_x_descriptor.set.call(this, value); }, _z_get = function _z_get() { return _static_private_z_descriptor.get.call(this); }, _z_set = function _z_set(value) { return _static_private_z_descriptor.set.call(this, value); }; } + static { _C_method_get = function _C_method_get() { return _static_private_method_descriptor.value; }, _C_x_get = function _C_x_get() { return _static_private_get_x_descriptor.get.call(this); }, _C_x_set = function _C_x_set(value) { return _static_private_set_x_descriptor.set.call(this, value); }, _C_z_get = function _C_z_get() { return _static_private_z_descriptor.get.call(this); }, _C_z_set = function _C_z_set(value) { return _static_private_z_descriptor.set.call(this, value); }; } static { _method_decorators = [dec, dec]; _get_x_decorators = [dec, dec]; @@ -161,17 +162,17 @@ let C = (() => { _static_private_set_x_decorators = [dec, dec]; _static_private_y_decorators = [dec, dec]; _static_private_z_decorators = [dec, dec]; - __esDecorate(this, _static_private_method_descriptor = { value: __setFunctionName(function () { }, "#method") }, _static_private_method_decorators, { kind: "method", name: "#method", static: true, private: true, access: { has: obj => __classPrivateFieldIn(_classThis, obj), get: obj => __classPrivateFieldGet(obj, _classThis, "a", _method_get) } }, null, _staticExtraInitializers); - __esDecorate(this, _static_private_get_x_descriptor = { get: __setFunctionName(function () { return 1; }, "#x", "get") }, _static_private_get_x_decorators, { kind: "getter", name: "#x", static: true, private: true, access: { has: obj => __classPrivateFieldIn(_classThis, obj), get: obj => __classPrivateFieldGet(obj, _classThis, "a", _x_get) } }, null, _staticExtraInitializers); - __esDecorate(this, _static_private_set_x_descriptor = { set: __setFunctionName(function (value) { }, "#x", "set") }, _static_private_set_x_decorators, { kind: "setter", name: "#x", static: true, private: true, access: { has: obj => __classPrivateFieldIn(_classThis, obj), set: (obj, value) => { __classPrivateFieldSet(obj, _classThis, value, "a", _x_set); } } }, null, _staticExtraInitializers); - __esDecorate(this, _static_private_z_descriptor = { get: __setFunctionName(function () { return __classPrivateFieldGet(this, _classThis, "f", _z_accessor_storage); }, "#z", "get"), set: __setFunctionName(function (value) { __classPrivateFieldSet(this, _classThis, value, "f", _z_accessor_storage); }, "#z", "set") }, _static_private_z_decorators, { kind: "accessor", name: "#z", static: true, private: true, access: { has: obj => __classPrivateFieldIn(_classThis, obj), get: obj => __classPrivateFieldGet(obj, _classThis, "a", _z_get), set: (obj, value) => { __classPrivateFieldSet(obj, _classThis, value, "a", _z_set); } } }, _static_private_z_initializers, _staticExtraInitializers); + __esDecorate(this, _static_private_method_descriptor = { value: __setFunctionName(function () { }, "#method") }, _static_private_method_decorators, { kind: "method", name: "#method", static: true, private: true, access: { has: obj => __classPrivateFieldIn(_classThis, obj), get: obj => __classPrivateFieldGet(obj, _classThis, "a", _C_method_get) } }, null, _staticExtraInitializers); + __esDecorate(this, _static_private_get_x_descriptor = { get: __setFunctionName(function () { return 1; }, "#x", "get") }, _static_private_get_x_decorators, { kind: "getter", name: "#x", static: true, private: true, access: { has: obj => __classPrivateFieldIn(_classThis, obj), get: obj => __classPrivateFieldGet(obj, _classThis, "a", _C_x_get) } }, null, _staticExtraInitializers); + __esDecorate(this, _static_private_set_x_descriptor = { set: __setFunctionName(function (value) { }, "#x", "set") }, _static_private_set_x_decorators, { kind: "setter", name: "#x", static: true, private: true, access: { has: obj => __classPrivateFieldIn(_classThis, obj), set: (obj, value) => { __classPrivateFieldSet(obj, _classThis, value, "a", _C_x_set); } } }, null, _staticExtraInitializers); + __esDecorate(this, _static_private_z_descriptor = { get: __setFunctionName(function () { return __classPrivateFieldGet(this, _classThis, "f", _C_z_accessor_storage); }, "#z", "get"), set: __setFunctionName(function (value) { __classPrivateFieldSet(this, _classThis, value, "f", _C_z_accessor_storage); }, "#z", "set") }, _static_private_z_decorators, { kind: "accessor", name: "#z", static: true, private: true, access: { has: obj => __classPrivateFieldIn(_classThis, obj), get: obj => __classPrivateFieldGet(obj, _classThis, "a", _C_z_get), set: (obj, value) => { __classPrivateFieldSet(obj, _classThis, value, "a", _C_z_set); } } }, _static_private_z_initializers, _staticExtraInitializers); __esDecorate(this, null, _method_decorators, { kind: "method", name: "method", static: false, private: false, access: { has: obj => "method" in obj, get: obj => obj.method } }, null, _instanceExtraInitializers); __esDecorate(this, null, _get_x_decorators, { kind: "getter", name: "x", static: false, private: false, access: { has: obj => "x" in obj, get: obj => obj.x } }, null, _instanceExtraInitializers); __esDecorate(this, null, _set_x_decorators, { kind: "setter", name: "x", static: false, private: false, access: { has: obj => "x" in obj, set: (obj, value) => { obj.x = value; } } }, null, _instanceExtraInitializers); __esDecorate(this, null, _z_decorators, { kind: "accessor", name: "z", static: false, private: false, access: { has: obj => "z" in obj, get: obj => obj.z, set: (obj, value) => { obj.z = value; } } }, _z_initializers, _instanceExtraInitializers); - __esDecorate(null, null, _static_private_y_decorators, { kind: "field", name: "#y", static: true, private: true, access: { has: obj => __classPrivateFieldIn(_classThis, obj), get: obj => __classPrivateFieldGet(obj, _classThis, "f", _y), set: (obj, value) => { __classPrivateFieldSet(obj, _classThis, value, "f", _y); } } }, _static_private_y_initializers, _staticExtraInitializers); + __esDecorate(null, null, _static_private_y_decorators, { kind: "field", name: "#y", static: true, private: true, access: { has: obj => __classPrivateFieldIn(_classThis, obj), get: obj => __classPrivateFieldGet(obj, _classThis, "f", _C_y), set: (obj, value) => { __classPrivateFieldSet(obj, _classThis, value, "f", _C_y); } } }, _static_private_y_initializers, _staticExtraInitializers); __esDecorate(null, null, _y_decorators, { kind: "field", name: "y", static: false, private: false, access: { has: obj => "y" in obj, get: obj => obj.y, set: (obj, value) => { obj.y = value; } } }, _y_initializers, _instanceExtraInitializers); - __esDecorate(null, _classDescriptor = { value: this }, _classDecorators, { kind: "class", name: this.name }, null, _classExtraInitializers); + __esDecorate(null, _classDescriptor = { value: _classThis }, _classDecorators, { kind: "class", name: _classThis.name }, null, _classExtraInitializers); C = _classThis = _classDescriptor.value; __runInitializers(_classThis, _staticExtraInitializers); } @@ -189,10 +190,10 @@ let C = (() => { set z(value) { this.#z_accessor_storage = value; } static { /*28*/ - _y = { value: __runInitializers(_classThis, _static_private_y_initializers, 1) }; + _C_y = { value: __runInitializers(_classThis, _static_private_y_initializers, 1) }; } static { - _z_accessor_storage = { value: __runInitializers(_classThis, _static_private_z_initializers, 1) }; + _C_z_accessor_storage = { value: __runInitializers(_classThis, _static_private_z_initializers, 1) }; } static { __runInitializers(_classThis, _classExtraInitializers); @@ -202,64 +203,71 @@ let C = (() => { })(); //// [file2.js] /*34*/ -/*36*/ -export let D = (() => { +let D = (() => { let _classDecorators = [dec, dec]; let _classDescriptor; let _classExtraInitializers = []; let _classThis; var D = class { + static { _classThis = this; } static { - __esDecorate(null, _classDescriptor = { value: this }, _classDecorators, { kind: "class", name: this.name }, null, _classExtraInitializers); + __esDecorate(null, _classDescriptor = { value: _classThis }, _classDecorators, { kind: "class", name: _classThis.name }, null, _classExtraInitializers); D = _classThis = _classDescriptor.value; __runInitializers(_classThis, _classExtraInitializers); } }; return D = _classThis; })(); -/*37*/ -export default (() => { - let _classDecorators_1 = [dec, dec]; - let _classDescriptor_1; - let _classExtraInitializers_1 = []; - let _classThis_1; +export { D }; +let E = (() => { + let _classDecorators = [dec, dec]; + let _classDescriptor; + let _classExtraInitializers = []; + let _classThis; var E = class { + static { _classThis = this; } static { - __esDecorate(null, _classDescriptor_1 = { value: this }, _classDecorators_1, { kind: "class", name: this.name }, null, _classExtraInitializers_1); - E = _classThis_1 = _classDescriptor_1.value; - __runInitializers(_classThis_1, _classExtraInitializers_1); + __esDecorate(null, _classDescriptor = { value: _classThis }, _classDecorators, { kind: "class", name: _classThis.name }, null, _classExtraInitializers); + E = _classThis = _classDescriptor.value; + __runInitializers(_classThis, _classExtraInitializers); } }; - return E = _classThis_1; + return E = _classThis; })(); +/*37*/ +export default E; //// [file3.js] /*40*/ -export let F = (() => { +let F = (() => { let _classDecorators = [dec, dec]; let _classDescriptor; let _classExtraInitializers = []; let _classThis; var F = class { + static { _classThis = this; } static { - __esDecorate(null, _classDescriptor = { value: this }, _classDecorators, { kind: "class", name: this.name }, null, _classExtraInitializers); + __esDecorate(null, _classDescriptor = { value: _classThis }, _classDecorators, { kind: "class", name: _classThis.name }, null, _classExtraInitializers); F = _classThis = _classDescriptor.value; __runInitializers(_classThis, _classExtraInitializers); } }; return F = _classThis; })(); -/*44*/ -export default (() => { - let _classDecorators_1 = [dec, dec]; - let _classDescriptor_1; - let _classExtraInitializers_1 = []; - let _classThis_1; +export { F }; +let G = (() => { + let _classDecorators = [dec, dec]; + let _classDescriptor; + let _classExtraInitializers = []; + let _classThis; var G = class { + static { _classThis = this; } static { - __esDecorate(null, _classDescriptor_1 = { value: this }, _classDecorators_1, { kind: "class", name: this.name }, null, _classExtraInitializers_1); - G = _classThis_1 = _classDescriptor_1.value; - __runInitializers(_classThis_1, _classExtraInitializers_1); + __esDecorate(null, _classDescriptor = { value: _classThis }, _classDecorators, { kind: "class", name: _classThis.name }, null, _classExtraInitializers); + G = _classThis = _classDescriptor.value; + __runInitializers(_classThis, _classExtraInitializers); } }; - return G = _classThis_1; + return G = _classThis; })(); +/*44*/ +export default G; diff --git a/tests/baselines/reference/esDecorators-classDeclaration-commonjs-classNamespaceMerge.js b/tests/baselines/reference/esDecorators-classDeclaration-commonjs-classNamespaceMerge.js index 0d52e9f2854ed..2d666b8699afb 100644 --- a/tests/baselines/reference/esDecorators-classDeclaration-commonjs-classNamespaceMerge.js +++ b/tests/baselines/reference/esDecorators-classDeclaration-commonjs-classNamespaceMerge.js @@ -52,14 +52,15 @@ var __runInitializers = (this && this.__runInitializers) || function (thisArg, i }; Object.defineProperty(exports, "__esModule", { value: true }); exports.Example = void 0; -let Example = exports.Example = (() => { +let Example = (() => { let _classDecorators = [deco]; let _classDescriptor; let _classExtraInitializers = []; let _classThis; var Example = class { + static { _classThis = this; } static { - __esDecorate(null, _classDescriptor = { value: this }, _classDecorators, { kind: "class", name: this.name }, null, _classExtraInitializers); + __esDecorate(null, _classDescriptor = { value: _classThis }, _classDecorators, { kind: "class", name: _classThis.name }, null, _classExtraInitializers); Example = _classThis = _classDescriptor.value; __runInitializers(_classThis, _classExtraInitializers); } @@ -67,6 +68,7 @@ let Example = exports.Example = (() => { }; return Example = _classThis; })(); +exports.Example = Example; (function (Example) { Example.x = 1; })(Example || (exports.Example = Example = {})); diff --git a/tests/baselines/reference/esDecorators-classDeclaration-commonjs.js b/tests/baselines/reference/esDecorators-classDeclaration-commonjs.js index d354b8480487b..aa5eda2192437 100644 --- a/tests/baselines/reference/esDecorators-classDeclaration-commonjs.js +++ b/tests/baselines/reference/esDecorators-classDeclaration-commonjs.js @@ -48,14 +48,15 @@ var __runInitializers = (this && this.__runInitializers) || function (thisArg, i }; Object.defineProperty(exports, "__esModule", { value: true }); exports.Example = void 0; -let Example = exports.Example = (() => { +let Example = (() => { let _classDecorators = [deco]; let _classDescriptor; let _classExtraInitializers = []; let _classThis; var Example = class { + static { _classThis = this; } static { - __esDecorate(null, _classDescriptor = { value: this }, _classDecorators, { kind: "class", name: this.name }, null, _classExtraInitializers); + __esDecorate(null, _classDescriptor = { value: _classThis }, _classDecorators, { kind: "class", name: _classThis.name }, null, _classExtraInitializers); Example = _classThis = _classDescriptor.value; __runInitializers(_classThis, _classExtraInitializers); } @@ -63,4 +64,5 @@ let Example = exports.Example = (() => { }; return Example = _classThis; })(); +exports.Example = Example; Example.foo(); diff --git a/tests/baselines/reference/esDecorators-classDeclaration-fields-staticAccessor(target=es2015).js b/tests/baselines/reference/esDecorators-classDeclaration-fields-staticAccessor(target=es2015).js index a914c0d06dc06..67795dc6b561d 100644 --- a/tests/baselines/reference/esDecorators-classDeclaration-fields-staticAccessor(target=es2015).js +++ b/tests/baselines/reference/esDecorators-classDeclaration-fields-staticAccessor(target=es2015).js @@ -52,21 +52,21 @@ let C = (() => { _a; })(); let D = (() => { - var _field1_accessor_storage; + var _D_field1_accessor_storage; let _classDecorators = [dec]; let _classDescriptor; let _classExtraInitializers = []; let _classThis; var D = _classThis = class { - static get field1() { return __classPrivateFieldGet(this, _classThis, "f", _field1_accessor_storage); } - static set field1(value) { __classPrivateFieldSet(this, _classThis, value, "f", _field1_accessor_storage); } + static get field1() { return __classPrivateFieldGet(this, _classThis, "f", _D_field1_accessor_storage); } + static set field1(value) { __classPrivateFieldSet(this, _classThis, value, "f", _D_field1_accessor_storage); } }; __setFunctionName(_classThis, "D"); (() => { __esDecorate(null, _classDescriptor = { value: _classThis }, _classDecorators, { kind: "class", name: _classThis.name }, null, _classExtraInitializers); D = _classThis = _classDescriptor.value; })(); - _field1_accessor_storage = { value: 1 }; + _D_field1_accessor_storage = { value: 1 }; (() => { _classThis.field1; _classThis.field1 = 1; diff --git a/tests/baselines/reference/esDecorators-classDeclaration-fields-staticAccessor(target=es2022).js b/tests/baselines/reference/esDecorators-classDeclaration-fields-staticAccessor(target=es2022).js index 15e126bf87c56..f0d99a2396c8c 100644 --- a/tests/baselines/reference/esDecorators-classDeclaration-fields-staticAccessor(target=es2022).js +++ b/tests/baselines/reference/esDecorators-classDeclaration-fields-staticAccessor(target=es2022).js @@ -50,22 +50,23 @@ let C = (() => { }; })(); let D = (() => { - var _field1_accessor_storage; + var _D_field1_accessor_storage; let _classDecorators = [dec]; let _classDescriptor; let _classExtraInitializers = []; let _classThis; var D = class { + static { _classThis = this; } static { __setFunctionName(this, "D"); } static { - __esDecorate(null, _classDescriptor = { value: this }, _classDecorators, { kind: "class", name: this.name }, null, _classExtraInitializers); + __esDecorate(null, _classDescriptor = { value: _classThis }, _classDecorators, { kind: "class", name: _classThis.name }, null, _classExtraInitializers); D = _classThis = _classDescriptor.value; } static { - _field1_accessor_storage = { value: 1 }; + _D_field1_accessor_storage = { value: 1 }; } - static get field1() { return __classPrivateFieldGet(this, _classThis, "f", _field1_accessor_storage); } - static set field1(value) { __classPrivateFieldSet(this, _classThis, value, "f", _field1_accessor_storage); } + static get field1() { return __classPrivateFieldGet(this, _classThis, "f", _D_field1_accessor_storage); } + static set field1(value) { __classPrivateFieldSet(this, _classThis, value, "f", _D_field1_accessor_storage); } static { _classThis.field1; _classThis.field1 = 1; diff --git a/tests/baselines/reference/esDecorators-classDeclaration-fields-staticPrivate(target=es2015).js b/tests/baselines/reference/esDecorators-classDeclaration-fields-staticPrivate(target=es2015).js index 70c22ebd6d38d..185fb761bf476 100644 --- a/tests/baselines/reference/esDecorators-classDeclaration-fields-staticPrivate(target=es2015).js +++ b/tests/baselines/reference/esDecorators-classDeclaration-fields-staticPrivate(target=es2015).js @@ -34,7 +34,7 @@ let C = (() => { _a; })(); let D = (() => { - var _field1; + var _D_field1; let _classDecorators = [dec]; let _classDescriptor; let _classExtraInitializers = []; @@ -46,10 +46,10 @@ let D = (() => { __esDecorate(null, _classDescriptor = { value: _classThis }, _classDecorators, { kind: "class", name: _classThis.name }, null, _classExtraInitializers); D = _classThis = _classDescriptor.value; })(); - _field1 = { value: 0 }; + _D_field1 = { value: 0 }; (() => { - __classPrivateFieldGet(_classThis, _classThis, "f", _field1); - __classPrivateFieldSet(_classThis, _classThis, 1, "f", _field1); + __classPrivateFieldGet(_classThis, _classThis, "f", _D_field1); + __classPrivateFieldSet(_classThis, _classThis, 1, "f", _D_field1); })(); (() => { __runInitializers(_classThis, _classExtraInitializers); diff --git a/tests/baselines/reference/esDecorators-classDeclaration-fields-staticPrivate(target=es2022).js b/tests/baselines/reference/esDecorators-classDeclaration-fields-staticPrivate(target=es2022).js index cbb231f1416e5..7aef10a846241 100644 --- a/tests/baselines/reference/esDecorators-classDeclaration-fields-staticPrivate(target=es2022).js +++ b/tests/baselines/reference/esDecorators-classDeclaration-fields-staticPrivate(target=es2022).js @@ -32,23 +32,24 @@ let C = (() => { }; })(); let D = (() => { - var _field1; + var _D_field1; let _classDecorators = [dec]; let _classDescriptor; let _classExtraInitializers = []; let _classThis; var D = class { + static { _classThis = this; } static { __setFunctionName(this, "D"); } static { - __esDecorate(null, _classDescriptor = { value: this }, _classDecorators, { kind: "class", name: this.name }, null, _classExtraInitializers); + __esDecorate(null, _classDescriptor = { value: _classThis }, _classDecorators, { kind: "class", name: _classThis.name }, null, _classExtraInitializers); D = _classThis = _classDescriptor.value; } static { - _field1 = { value: 0 }; + _D_field1 = { value: 0 }; } static { - __classPrivateFieldGet(_classThis, _classThis, "f", _field1); - __classPrivateFieldSet(_classThis, _classThis, 1, "f", _field1); + __classPrivateFieldGet(_classThis, _classThis, "f", _D_field1); + __classPrivateFieldSet(_classThis, _classThis, 1, "f", _D_field1); } static { __runInitializers(_classThis, _classExtraInitializers); diff --git a/tests/baselines/reference/esDecorators-classDeclaration-fields-staticPrivateAccessor(target=es2015).js b/tests/baselines/reference/esDecorators-classDeclaration-fields-staticPrivateAccessor(target=es2015).js index 70faeb7dec516..032b59a41166e 100644 --- a/tests/baselines/reference/esDecorators-classDeclaration-fields-staticPrivateAccessor(target=es2015).js +++ b/tests/baselines/reference/esDecorators-classDeclaration-fields-staticPrivateAccessor(target=es2015).js @@ -33,28 +33,28 @@ let C = (() => { __esDecorate(_a, _static_private_field1_descriptor = { get: __setFunctionName(function () { return __classPrivateFieldGet(_a, _a, "f", _C_field1_accessor_storage); }, "#field1", "get"), set: __setFunctionName(function (value) { __classPrivateFieldSet(_a, _a, value, "f", _C_field1_accessor_storage); }, "#field1", "set") }, _static_private_field1_decorators, { kind: "accessor", name: "#field1", static: true, private: true, access: { has: obj => __classPrivateFieldIn(_a, obj), get: obj => __classPrivateFieldGet(obj, _a, "a", _C_field1_get), set: (obj, value) => { __classPrivateFieldSet(obj, _a, value, "a", _C_field1_set); } } }, _static_private_field1_initializers, _staticExtraInitializers); __runInitializers(_a, _staticExtraInitializers); })(), - _C_field1_accessor_storage = { value: __runInitializers(this, _static_private_field1_initializers, 0) }, + _C_field1_accessor_storage = { value: __runInitializers(_a, _static_private_field1_initializers, 0) }, _a; })(); let D = (() => { - var _field1_get, _field1_set, _field1_accessor_storage; + var _D_field1_get, _D_field1_set, _D_field1_accessor_storage; let _classDecorators = [dec]; let _classDescriptor; let _classExtraInitializers = []; let _classThis; var D = _classThis = class { }; - _field1_get = function _field1_get() { return __classPrivateFieldGet(this, _classThis, "f", _field1_accessor_storage); }; - _field1_set = function _field1_set(value) { __classPrivateFieldSet(this, _classThis, value, "f", _field1_accessor_storage); }; + _D_field1_get = function _D_field1_get() { return __classPrivateFieldGet(this, _classThis, "f", _D_field1_accessor_storage); }; + _D_field1_set = function _D_field1_set(value) { __classPrivateFieldSet(this, _classThis, value, "f", _D_field1_accessor_storage); }; __setFunctionName(_classThis, "D"); (() => { __esDecorate(null, _classDescriptor = { value: _classThis }, _classDecorators, { kind: "class", name: _classThis.name }, null, _classExtraInitializers); D = _classThis = _classDescriptor.value; })(); - _field1_accessor_storage = { value: 0 }; + _D_field1_accessor_storage = { value: 0 }; (() => { - __classPrivateFieldGet(_classThis, _classThis, "a", _field1_get); - __classPrivateFieldSet(_classThis, _classThis, 1, "a", _field1_set); + __classPrivateFieldGet(_classThis, _classThis, "a", _D_field1_get); + __classPrivateFieldSet(_classThis, _classThis, 1, "a", _D_field1_set); })(); (() => { __runInitializers(_classThis, _classExtraInitializers); diff --git a/tests/baselines/reference/esDecorators-classDeclaration-fields-staticPrivateAccessor(target=es2022).js b/tests/baselines/reference/esDecorators-classDeclaration-fields-staticPrivateAccessor(target=es2022).js index 1337c1f57aa28..0fd54651c9a60 100644 --- a/tests/baselines/reference/esDecorators-classDeclaration-fields-staticPrivateAccessor(target=es2022).js +++ b/tests/baselines/reference/esDecorators-classDeclaration-fields-staticPrivateAccessor(target=es2022).js @@ -35,24 +35,25 @@ let C = (() => { }; })(); let D = (() => { - var _field1_get, _field1_set, _field1_accessor_storage; + var _D_field1_get, _D_field1_set, _D_field1_accessor_storage; let _classDecorators = [dec]; let _classDescriptor; let _classExtraInitializers = []; let _classThis; var D = class { + static { _classThis = this; } static { __setFunctionName(this, "D"); } - static { _field1_get = function _field1_get() { return __classPrivateFieldGet(this, _classThis, "f", _field1_accessor_storage); }, _field1_set = function _field1_set(value) { __classPrivateFieldSet(this, _classThis, value, "f", _field1_accessor_storage); }; } + static { _D_field1_get = function _D_field1_get() { return __classPrivateFieldGet(this, _classThis, "f", _D_field1_accessor_storage); }, _D_field1_set = function _D_field1_set(value) { __classPrivateFieldSet(this, _classThis, value, "f", _D_field1_accessor_storage); }; } static { - __esDecorate(null, _classDescriptor = { value: this }, _classDecorators, { kind: "class", name: this.name }, null, _classExtraInitializers); + __esDecorate(null, _classDescriptor = { value: _classThis }, _classDecorators, { kind: "class", name: _classThis.name }, null, _classExtraInitializers); D = _classThis = _classDescriptor.value; } static { - _field1_accessor_storage = { value: 0 }; + _D_field1_accessor_storage = { value: 0 }; } static { - __classPrivateFieldGet(_classThis, _classThis, "a", _field1_get); - __classPrivateFieldSet(_classThis, _classThis, 1, "a", _field1_set); + __classPrivateFieldGet(_classThis, _classThis, "a", _D_field1_get); + __classPrivateFieldSet(_classThis, _classThis, 1, "a", _D_field1_set); } static { __runInitializers(_classThis, _classExtraInitializers); diff --git a/tests/baselines/reference/esDecorators-classDeclaration-methods-nonStatic(target=es5).js b/tests/baselines/reference/esDecorators-classDeclaration-methods-nonStatic(target=es5).js index ee0e92d4500d5..e3e4ce19b10cd 100644 --- a/tests/baselines/reference/esDecorators-classDeclaration-methods-nonStatic(target=es5).js +++ b/tests/baselines/reference/esDecorators-classDeclaration-methods-nonStatic(target=es5).js @@ -13,7 +13,6 @@ class C { //// [esDecorators-classDeclaration-methods-nonStatic.js] -var _this = this; var method3 = "method3"; var C = function () { var _a; diff --git a/tests/baselines/reference/esDecorators-classDeclaration-methods-static(target=es5).js b/tests/baselines/reference/esDecorators-classDeclaration-methods-static(target=es5).js index 301743dd21f7e..e28c8eb995a8e 100644 --- a/tests/baselines/reference/esDecorators-classDeclaration-methods-static(target=es5).js +++ b/tests/baselines/reference/esDecorators-classDeclaration-methods-static(target=es5).js @@ -13,7 +13,6 @@ class C { //// [esDecorators-classDeclaration-methods-static.js] -var _this = this; var method3 = "method3"; var C = function () { var _a; diff --git a/tests/baselines/reference/esDecorators-classDeclaration-methods-staticPrivate(target=es2015).js b/tests/baselines/reference/esDecorators-classDeclaration-methods-staticPrivate(target=es2015).js index 71a531d10ef03..449a96263087e 100644 --- a/tests/baselines/reference/esDecorators-classDeclaration-methods-staticPrivate(target=es2015).js +++ b/tests/baselines/reference/esDecorators-classDeclaration-methods-staticPrivate(target=es2015).js @@ -30,14 +30,14 @@ let C = (() => { _a; })(); let D = (() => { - var _method1; + var _D_method1; let _classDecorators = [dec]; let _classDescriptor; let _classExtraInitializers = []; let _classThis; var D = _classThis = class { }; - _method1 = function _method1() { }; + _D_method1 = function _D_method1() { }; __setFunctionName(_classThis, "D"); (() => { __esDecorate(null, _classDescriptor = { value: _classThis }, _classDecorators, { kind: "class", name: _classThis.name }, null, _classExtraInitializers); diff --git a/tests/baselines/reference/esDecorators-classDeclaration-methods-staticPrivate(target=es2022).js b/tests/baselines/reference/esDecorators-classDeclaration-methods-staticPrivate(target=es2022).js index efc4f2e83a377..d1516b15709b4 100644 --- a/tests/baselines/reference/esDecorators-classDeclaration-methods-staticPrivate(target=es2022).js +++ b/tests/baselines/reference/esDecorators-classDeclaration-methods-staticPrivate(target=es2022).js @@ -28,16 +28,17 @@ let C = (() => { }; })(); let D = (() => { - var _method1; + var _D_method1; let _classDecorators = [dec]; let _classDescriptor; let _classExtraInitializers = []; let _classThis; var D = class { + static { _classThis = this; } static { __setFunctionName(this, "D"); } - static { _method1 = function _method1() { }; } + static { _D_method1 = function _D_method1() { }; } static { - __esDecorate(null, _classDescriptor = { value: this }, _classDecorators, { kind: "class", name: this.name }, null, _classExtraInitializers); + __esDecorate(null, _classDescriptor = { value: _classThis }, _classDecorators, { kind: "class", name: _classThis.name }, null, _classExtraInitializers); D = _classThis = _classDescriptor.value; __runInitializers(_classThis, _classExtraInitializers); } diff --git a/tests/baselines/reference/esDecorators-classDeclaration-missingEmitHelpers-classDecorator.1.js b/tests/baselines/reference/esDecorators-classDeclaration-missingEmitHelpers-classDecorator.1.js index d5480454cf474..bffbb5a888ea8 100644 --- a/tests/baselines/reference/esDecorators-classDeclaration-missingEmitHelpers-classDecorator.1.js +++ b/tests/baselines/reference/esDecorators-classDeclaration-missingEmitHelpers-classDecorator.1.js @@ -23,8 +23,9 @@ let C = (() => { let _classExtraInitializers = []; let _classThis; var C = class { + static { _classThis = this; } static { - tslib_1.__esDecorate(null, _classDescriptor = { value: this }, _classDecorators, { kind: "class", name: this.name }, null, _classExtraInitializers); + tslib_1.__esDecorate(null, _classDescriptor = { value: _classThis }, _classDecorators, { kind: "class", name: _classThis.name }, null, _classExtraInitializers); C = _classThis = _classDescriptor.value; tslib_1.__runInitializers(_classThis, _classExtraInitializers); } diff --git a/tests/baselines/reference/esDecorators-classDeclaration-missingEmitHelpers-classDecorator.2.js b/tests/baselines/reference/esDecorators-classDeclaration-missingEmitHelpers-classDecorator.2.js index c39b9a4c0a89d..cc5d12ea36666 100644 --- a/tests/baselines/reference/esDecorators-classDeclaration-missingEmitHelpers-classDecorator.2.js +++ b/tests/baselines/reference/esDecorators-classDeclaration-missingEmitHelpers-classDecorator.2.js @@ -22,9 +22,10 @@ exports.default = (() => { let _classExtraInitializers = []; let _classThis; var default_1 = class { + static { _classThis = this; } + static { tslib_1.__setFunctionName(_classThis, "default"); } static { - tslib_1.__setFunctionName(this, "default"); - tslib_1.__esDecorate(null, _classDescriptor = { value: this }, _classDecorators, { kind: "class", name: this.name }, null, _classExtraInitializers); + tslib_1.__esDecorate(null, _classDescriptor = { value: _classThis }, _classDecorators, { kind: "class", name: _classThis.name }, null, _classExtraInitializers); default_1 = _classThis = _classDescriptor.value; tslib_1.__runInitializers(_classThis, _classExtraInitializers); } diff --git a/tests/baselines/reference/esDecorators-classDeclaration-missingEmitHelpers-classDecorator.3.js b/tests/baselines/reference/esDecorators-classDeclaration-missingEmitHelpers-classDecorator.3.js index 75f96af51fcdc..abbd3d0ab96e2 100644 --- a/tests/baselines/reference/esDecorators-classDeclaration-missingEmitHelpers-classDecorator.3.js +++ b/tests/baselines/reference/esDecorators-classDeclaration-missingEmitHelpers-classDecorator.3.js @@ -20,16 +20,17 @@ Object.defineProperty(exports, "__esModule", { value: true }); const tslib_1 = require("tslib"); // needs: __esDecorate, __runInitializers, __setFunctionName let C = (() => { - var _foo; + var _C_foo; let _classDecorators = [dec]; let _classDescriptor; let _classExtraInitializers = []; let _classThis; var C = class { + static { _classThis = this; } static { tslib_1.__setFunctionName(this, "C"); } - static { _foo = function _foo() { }; } + static { _C_foo = function _C_foo() { }; } static { - tslib_1.__esDecorate(null, _classDescriptor = { value: this }, _classDecorators, { kind: "class", name: this.name }, null, _classExtraInitializers); + tslib_1.__esDecorate(null, _classDescriptor = { value: _classThis }, _classDecorators, { kind: "class", name: _classThis.name }, null, _classExtraInitializers); C = _classThis = _classDescriptor.value; tslib_1.__runInitializers(_classThis, _classExtraInitializers); } diff --git a/tests/baselines/reference/esDecorators-classDeclaration-multipleDecorators(target=es2022).js b/tests/baselines/reference/esDecorators-classDeclaration-multipleDecorators(target=es2022).js index 7ee615b20675d..a1e83f6d1108f 100644 --- a/tests/baselines/reference/esDecorators-classDeclaration-multipleDecorators(target=es2022).js +++ b/tests/baselines/reference/esDecorators-classDeclaration-multipleDecorators(target=es2022).js @@ -16,8 +16,9 @@ let C = (() => { let _classExtraInitializers = []; let _classThis; var C = class { + static { _classThis = this; } static { - __esDecorate(null, _classDescriptor = { value: this }, _classDecorators, { kind: "class", name: this.name }, null, _classExtraInitializers); + __esDecorate(null, _classDescriptor = { value: _classThis }, _classDecorators, { kind: "class", name: _classThis.name }, null, _classExtraInitializers); C = _classThis = _classDescriptor.value; __runInitializers(_classThis, _classExtraInitializers); } diff --git a/tests/baselines/reference/esDecorators-classDeclaration-multipleDecorators(target=es5).js b/tests/baselines/reference/esDecorators-classDeclaration-multipleDecorators(target=es5).js index 83e5ce8484396..54bf2f0b129a0 100644 --- a/tests/baselines/reference/esDecorators-classDeclaration-multipleDecorators(target=es5).js +++ b/tests/baselines/reference/esDecorators-classDeclaration-multipleDecorators(target=es5).js @@ -10,7 +10,6 @@ class C { //// [esDecorators-classDeclaration-multipleDecorators.js] -var _this = this; var C = function () { var _classDecorators = [dec1, dec2]; var _classDescriptor; diff --git a/tests/baselines/reference/esDecorators-classDeclaration-outerThisReference(target=es2015).js b/tests/baselines/reference/esDecorators-classDeclaration-outerThisReference(target=es2015).js index 4f67275e1af28..3b3d0e404bdf3 100644 --- a/tests/baselines/reference/esDecorators-classDeclaration-outerThisReference(target=es2015).js +++ b/tests/baselines/reference/esDecorators-classDeclaration-outerThisReference(target=es2015).js @@ -67,17 +67,17 @@ let A = (() => { // property names. let B = (() => { var _a, _b; - let _classDecorators_1 = [dec(this)]; - let _classDescriptor_1; - let _classExtraInitializers_1 = []; - let _classThis_1; - let _instanceExtraInitializers_1 = []; + let _classDecorators = [dec(this)]; + let _classDescriptor; + let _classExtraInitializers = []; + let _classThis; + let _instanceExtraInitializers = []; let _b_decorators; let _b_initializers = []; - var B = _classThis_1 = class { + var B = _classThis = class { constructor() { // @ts-ignore - this[_a] = (__runInitializers(this, _instanceExtraInitializers_1), 1); + this[_a] = (__runInitializers(this, _instanceExtraInitializers), 1); this.b = __runInitializers(this, _b_initializers, 2); // @ts-ignore this[_b] = 3; @@ -85,41 +85,41 @@ let B = (() => { }; _a = f(this); _b = (_b_decorators = [dec(this)], f(this)); - __setFunctionName(_classThis_1, "B"); + __setFunctionName(_classThis, "B"); (() => { - __esDecorate(null, null, _b_decorators, { kind: "field", name: "b", static: false, private: false, access: { has: obj => "b" in obj, get: obj => obj.b, set: (obj, value) => { obj.b = value; } } }, _b_initializers, _instanceExtraInitializers_1); - __esDecorate(null, _classDescriptor_1 = { value: _classThis_1 }, _classDecorators_1, { kind: "class", name: _classThis_1.name }, null, _classExtraInitializers_1); - B = _classThis_1 = _classDescriptor_1.value; - __runInitializers(_classThis_1, _classExtraInitializers_1); + __esDecorate(null, null, _b_decorators, { kind: "field", name: "b", static: false, private: false, access: { has: obj => "b" in obj, get: obj => obj.b, set: (obj, value) => { obj.b = value; } } }, _b_initializers, _instanceExtraInitializers); + __esDecorate(null, _classDescriptor = { value: _classThis }, _classDecorators, { kind: "class", name: _classThis.name }, null, _classExtraInitializers); + B = _classThis = _classDescriptor.value; + __runInitializers(_classThis, _classExtraInitializers); })(); - return B = _classThis_1; + return B = _classThis; })(); // The `this` transformation should ensure that decorators inside the class body have privileged access to // private names. let C = (() => { - var _a; + var _C_a; let _outerThis_1 = this; - let _classDecorators_2 = [dec(this)]; - let _classDescriptor_2; - let _classExtraInitializers_2 = []; - let _classThis_2; - let _instanceExtraInitializers_2 = []; + let _classDecorators = [dec(this)]; + let _classDescriptor; + let _classExtraInitializers = []; + let _classThis; + let _instanceExtraInitializers = []; let _b_decorators; let _b_initializers = []; - var C = _classThis_2 = class { + var C = _classThis = class { constructor() { - _a.set(this, (__runInitializers(this, _instanceExtraInitializers_2), 1)); + _C_a.set(this, (__runInitializers(this, _instanceExtraInitializers), 1)); this.b = __runInitializers(this, _b_initializers, 2); } }; - _a = new WeakMap(); - __setFunctionName(_classThis_2, "C"); + _C_a = new WeakMap(); + __setFunctionName(_classThis, "C"); (() => { - _b_decorators = [dec(_outerThis_1, (x) => __classPrivateFieldGet(x, _a, "f"))]; - __esDecorate(null, null, _b_decorators, { kind: "field", name: "b", static: false, private: false, access: { has: obj => "b" in obj, get: obj => obj.b, set: (obj, value) => { obj.b = value; } } }, _b_initializers, _instanceExtraInitializers_2); - __esDecorate(null, _classDescriptor_2 = { value: _classThis_2 }, _classDecorators_2, { kind: "class", name: _classThis_2.name }, null, _classExtraInitializers_2); - C = _classThis_2 = _classDescriptor_2.value; - __runInitializers(_classThis_2, _classExtraInitializers_2); + _b_decorators = [dec(_outerThis_1, (x) => __classPrivateFieldGet(x, _C_a, "f"))]; + __esDecorate(null, null, _b_decorators, { kind: "field", name: "b", static: false, private: false, access: { has: obj => "b" in obj, get: obj => obj.b, set: (obj, value) => { obj.b = value; } } }, _b_initializers, _instanceExtraInitializers); + __esDecorate(null, _classDescriptor = { value: _classThis }, _classDecorators, { kind: "class", name: _classThis.name }, null, _classExtraInitializers); + C = _classThis = _classDescriptor.value; + __runInitializers(_classThis, _classExtraInitializers); })(); - return C = _classThis_2; + return C = _classThis; })(); diff --git a/tests/baselines/reference/esDecorators-classDeclaration-outerThisReference(target=es2021).js b/tests/baselines/reference/esDecorators-classDeclaration-outerThisReference(target=es2021).js index 4f67275e1af28..3b3d0e404bdf3 100644 --- a/tests/baselines/reference/esDecorators-classDeclaration-outerThisReference(target=es2021).js +++ b/tests/baselines/reference/esDecorators-classDeclaration-outerThisReference(target=es2021).js @@ -67,17 +67,17 @@ let A = (() => { // property names. let B = (() => { var _a, _b; - let _classDecorators_1 = [dec(this)]; - let _classDescriptor_1; - let _classExtraInitializers_1 = []; - let _classThis_1; - let _instanceExtraInitializers_1 = []; + let _classDecorators = [dec(this)]; + let _classDescriptor; + let _classExtraInitializers = []; + let _classThis; + let _instanceExtraInitializers = []; let _b_decorators; let _b_initializers = []; - var B = _classThis_1 = class { + var B = _classThis = class { constructor() { // @ts-ignore - this[_a] = (__runInitializers(this, _instanceExtraInitializers_1), 1); + this[_a] = (__runInitializers(this, _instanceExtraInitializers), 1); this.b = __runInitializers(this, _b_initializers, 2); // @ts-ignore this[_b] = 3; @@ -85,41 +85,41 @@ let B = (() => { }; _a = f(this); _b = (_b_decorators = [dec(this)], f(this)); - __setFunctionName(_classThis_1, "B"); + __setFunctionName(_classThis, "B"); (() => { - __esDecorate(null, null, _b_decorators, { kind: "field", name: "b", static: false, private: false, access: { has: obj => "b" in obj, get: obj => obj.b, set: (obj, value) => { obj.b = value; } } }, _b_initializers, _instanceExtraInitializers_1); - __esDecorate(null, _classDescriptor_1 = { value: _classThis_1 }, _classDecorators_1, { kind: "class", name: _classThis_1.name }, null, _classExtraInitializers_1); - B = _classThis_1 = _classDescriptor_1.value; - __runInitializers(_classThis_1, _classExtraInitializers_1); + __esDecorate(null, null, _b_decorators, { kind: "field", name: "b", static: false, private: false, access: { has: obj => "b" in obj, get: obj => obj.b, set: (obj, value) => { obj.b = value; } } }, _b_initializers, _instanceExtraInitializers); + __esDecorate(null, _classDescriptor = { value: _classThis }, _classDecorators, { kind: "class", name: _classThis.name }, null, _classExtraInitializers); + B = _classThis = _classDescriptor.value; + __runInitializers(_classThis, _classExtraInitializers); })(); - return B = _classThis_1; + return B = _classThis; })(); // The `this` transformation should ensure that decorators inside the class body have privileged access to // private names. let C = (() => { - var _a; + var _C_a; let _outerThis_1 = this; - let _classDecorators_2 = [dec(this)]; - let _classDescriptor_2; - let _classExtraInitializers_2 = []; - let _classThis_2; - let _instanceExtraInitializers_2 = []; + let _classDecorators = [dec(this)]; + let _classDescriptor; + let _classExtraInitializers = []; + let _classThis; + let _instanceExtraInitializers = []; let _b_decorators; let _b_initializers = []; - var C = _classThis_2 = class { + var C = _classThis = class { constructor() { - _a.set(this, (__runInitializers(this, _instanceExtraInitializers_2), 1)); + _C_a.set(this, (__runInitializers(this, _instanceExtraInitializers), 1)); this.b = __runInitializers(this, _b_initializers, 2); } }; - _a = new WeakMap(); - __setFunctionName(_classThis_2, "C"); + _C_a = new WeakMap(); + __setFunctionName(_classThis, "C"); (() => { - _b_decorators = [dec(_outerThis_1, (x) => __classPrivateFieldGet(x, _a, "f"))]; - __esDecorate(null, null, _b_decorators, { kind: "field", name: "b", static: false, private: false, access: { has: obj => "b" in obj, get: obj => obj.b, set: (obj, value) => { obj.b = value; } } }, _b_initializers, _instanceExtraInitializers_2); - __esDecorate(null, _classDescriptor_2 = { value: _classThis_2 }, _classDecorators_2, { kind: "class", name: _classThis_2.name }, null, _classExtraInitializers_2); - C = _classThis_2 = _classDescriptor_2.value; - __runInitializers(_classThis_2, _classExtraInitializers_2); + _b_decorators = [dec(_outerThis_1, (x) => __classPrivateFieldGet(x, _C_a, "f"))]; + __esDecorate(null, null, _b_decorators, { kind: "field", name: "b", static: false, private: false, access: { has: obj => "b" in obj, get: obj => obj.b, set: (obj, value) => { obj.b = value; } } }, _b_initializers, _instanceExtraInitializers); + __esDecorate(null, _classDescriptor = { value: _classThis }, _classDecorators, { kind: "class", name: _classThis.name }, null, _classExtraInitializers); + C = _classThis = _classDescriptor.value; + __runInitializers(_classThis, _classExtraInitializers); })(); - return C = _classThis_2; + return C = _classThis; })(); diff --git a/tests/baselines/reference/esDecorators-classDeclaration-outerThisReference(target=es2022).js b/tests/baselines/reference/esDecorators-classDeclaration-outerThisReference(target=es2022).js index e23eb5b111f45..259bf471f945d 100644 --- a/tests/baselines/reference/esDecorators-classDeclaration-outerThisReference(target=es2022).js +++ b/tests/baselines/reference/esDecorators-classDeclaration-outerThisReference(target=es2022).js @@ -49,10 +49,11 @@ let A = (() => { let _b_decorators; let _b_initializers = []; var A = class { + static { _classThis = this; } static { _b_decorators = [dec(_outerThis)]; __esDecorate(null, null, _b_decorators, { kind: "field", name: "b", static: false, private: false, access: { has: obj => "b" in obj, get: obj => obj.b, set: (obj, value) => { obj.b = value; } } }, _b_initializers, _instanceExtraInitializers); - __esDecorate(null, _classDescriptor = { value: this }, _classDecorators, { kind: "class", name: this.name }, null, _classExtraInitializers); + __esDecorate(null, _classDescriptor = { value: _classThis }, _classDecorators, { kind: "class", name: _classThis.name }, null, _classExtraInitializers); A = _classThis = _classDescriptor.value; __runInitializers(_classThis, _classExtraInitializers); } @@ -63,49 +64,51 @@ let A = (() => { // `this` should point to the outer `this`, and maintain the correct evaluation order with respect to computed // property names. let B = (() => { - let _classDecorators_1 = [dec(this)]; - let _classDescriptor_1; - let _classExtraInitializers_1 = []; - let _classThis_1; - let _instanceExtraInitializers_1 = []; + let _classDecorators = [dec(this)]; + let _classDescriptor; + let _classExtraInitializers = []; + let _classThis; + let _instanceExtraInitializers = []; let _b_decorators; let _b_initializers = []; var B = class { + static { _classThis = this; } static { - __esDecorate(null, null, _b_decorators, { kind: "field", name: "b", static: false, private: false, access: { has: obj => "b" in obj, get: obj => obj.b, set: (obj, value) => { obj.b = value; } } }, _b_initializers, _instanceExtraInitializers_1); - __esDecorate(null, _classDescriptor_1 = { value: this }, _classDecorators_1, { kind: "class", name: this.name }, null, _classExtraInitializers_1); - B = _classThis_1 = _classDescriptor_1.value; - __runInitializers(_classThis_1, _classExtraInitializers_1); + __esDecorate(null, null, _b_decorators, { kind: "field", name: "b", static: false, private: false, access: { has: obj => "b" in obj, get: obj => obj.b, set: (obj, value) => { obj.b = value; } } }, _b_initializers, _instanceExtraInitializers); + __esDecorate(null, _classDescriptor = { value: _classThis }, _classDecorators, { kind: "class", name: _classThis.name }, null, _classExtraInitializers); + B = _classThis = _classDescriptor.value; + __runInitializers(_classThis, _classExtraInitializers); } // @ts-ignore - [f(this)] = (__runInitializers(this, _instanceExtraInitializers_1), 1); + [f(this)] = (__runInitializers(this, _instanceExtraInitializers), 1); b = __runInitializers(this, _b_initializers, 2); // @ts-ignore [(_b_decorators = [dec(this)], f(this))] = 3; }; - return B = _classThis_1; + return B = _classThis; })(); // The `this` transformation should ensure that decorators inside the class body have privileged access to // private names. let C = (() => { let _outerThis_1 = this; - let _classDecorators_2 = [dec(this)]; - let _classDescriptor_2; - let _classExtraInitializers_2 = []; - let _classThis_2; - let _instanceExtraInitializers_2 = []; + let _classDecorators = [dec(this)]; + let _classDescriptor; + let _classExtraInitializers = []; + let _classThis; + let _instanceExtraInitializers = []; let _b_decorators; let _b_initializers = []; var C = class { + static { _classThis = this; } static { _b_decorators = [dec(_outerThis_1, (x) => x.#a)]; - __esDecorate(null, null, _b_decorators, { kind: "field", name: "b", static: false, private: false, access: { has: obj => "b" in obj, get: obj => obj.b, set: (obj, value) => { obj.b = value; } } }, _b_initializers, _instanceExtraInitializers_2); - __esDecorate(null, _classDescriptor_2 = { value: this }, _classDecorators_2, { kind: "class", name: this.name }, null, _classExtraInitializers_2); - C = _classThis_2 = _classDescriptor_2.value; - __runInitializers(_classThis_2, _classExtraInitializers_2); + __esDecorate(null, null, _b_decorators, { kind: "field", name: "b", static: false, private: false, access: { has: obj => "b" in obj, get: obj => obj.b, set: (obj, value) => { obj.b = value; } } }, _b_initializers, _instanceExtraInitializers); + __esDecorate(null, _classDescriptor = { value: _classThis }, _classDecorators, { kind: "class", name: _classThis.name }, null, _classExtraInitializers); + C = _classThis = _classDescriptor.value; + __runInitializers(_classThis, _classExtraInitializers); } - #a = (__runInitializers(this, _instanceExtraInitializers_2), 1); + #a = (__runInitializers(this, _instanceExtraInitializers), 1); b = __runInitializers(this, _b_initializers, 2); }; - return C = _classThis_2; + return C = _classThis; })(); diff --git a/tests/baselines/reference/esDecorators-classDeclaration-parameterProperties(target=es5,usedefineforclassfields=false).js b/tests/baselines/reference/esDecorators-classDeclaration-parameterProperties(target=es5,usedefineforclassfields=false).js index b00b1ac7f0671..f7505a503c5e0 100644 --- a/tests/baselines/reference/esDecorators-classDeclaration-parameterProperties(target=es5,usedefineforclassfields=false).js +++ b/tests/baselines/reference/esDecorators-classDeclaration-parameterProperties(target=es5,usedefineforclassfields=false).js @@ -12,7 +12,6 @@ class C { //// [esDecorators-classDeclaration-parameterProperties.js] -var _this = this; var C = function () { var _a; var _instanceExtraInitializers = []; diff --git a/tests/baselines/reference/esDecorators-classDeclaration-parameterProperties(target=es5,usedefineforclassfields=true).js b/tests/baselines/reference/esDecorators-classDeclaration-parameterProperties(target=es5,usedefineforclassfields=true).js index a798a3d247644..b352efced46b0 100644 --- a/tests/baselines/reference/esDecorators-classDeclaration-parameterProperties(target=es5,usedefineforclassfields=true).js +++ b/tests/baselines/reference/esDecorators-classDeclaration-parameterProperties(target=es5,usedefineforclassfields=true).js @@ -12,7 +12,6 @@ class C { //// [esDecorators-classDeclaration-parameterProperties.js] -var _this = this; var C = function () { var _a; var _instanceExtraInitializers = []; diff --git a/tests/baselines/reference/esDecorators-classDeclaration-setFunctionName(target=es2015).js b/tests/baselines/reference/esDecorators-classDeclaration-setFunctionName(target=es2015).js index 7702afec3b08f..93e137a736452 100644 --- a/tests/baselines/reference/esDecorators-classDeclaration-setFunctionName(target=es2015).js +++ b/tests/baselines/reference/esDecorators-classDeclaration-setFunctionName(target=es2015).js @@ -41,7 +41,7 @@ let C = (() => { })(); export {}; //// [b.js] -export let C = (() => { +let C = (() => { let _classDecorators = [dec]; let _classDescriptor; let _classExtraInitializers = []; @@ -56,6 +56,7 @@ export let C = (() => { })(); return C = _classThis; })(); +export { C }; //// [c.js] export default (() => { let _classDecorators = [dec]; @@ -64,8 +65,8 @@ export default (() => { let _classThis; var default_1 = _classThis = class { }; + __setFunctionName(_classThis, "default"); (() => { - __setFunctionName(_classThis, "default"); __esDecorate(null, _classDescriptor = { value: _classThis }, _classDecorators, { kind: "class", name: _classThis.name }, null, _classExtraInitializers); default_1 = _classThis = _classDescriptor.value; __runInitializers(_classThis, _classExtraInitializers); diff --git a/tests/baselines/reference/esDecorators-classDeclaration-setFunctionName(target=es2022).js b/tests/baselines/reference/esDecorators-classDeclaration-setFunctionName(target=es2022).js index 09eac0a5b6171..aa2e4099d69aa 100644 --- a/tests/baselines/reference/esDecorators-classDeclaration-setFunctionName(target=es2022).js +++ b/tests/baselines/reference/esDecorators-classDeclaration-setFunctionName(target=es2022).js @@ -30,8 +30,9 @@ let C = (() => { let _classExtraInitializers = []; let _classThis; var C = class { + static { _classThis = this; } static { - __esDecorate(null, _classDescriptor = { value: this }, _classDecorators, { kind: "class", name: this.name }, null, _classExtraInitializers); + __esDecorate(null, _classDescriptor = { value: _classThis }, _classDecorators, { kind: "class", name: _classThis.name }, null, _classExtraInitializers); C = _classThis = _classDescriptor.value; __runInitializers(_classThis, _classExtraInitializers); } @@ -40,20 +41,22 @@ let C = (() => { })(); export {}; //// [b.js] -export let C = (() => { +let C = (() => { let _classDecorators = [dec]; let _classDescriptor; let _classExtraInitializers = []; let _classThis; var C = class { + static { _classThis = this; } static { - __esDecorate(null, _classDescriptor = { value: this }, _classDecorators, { kind: "class", name: this.name }, null, _classExtraInitializers); + __esDecorate(null, _classDescriptor = { value: _classThis }, _classDecorators, { kind: "class", name: _classThis.name }, null, _classExtraInitializers); C = _classThis = _classDescriptor.value; __runInitializers(_classThis, _classExtraInitializers); } }; return C = _classThis; })(); +export { C }; //// [c.js] export default (() => { let _classDecorators = [dec]; @@ -61,9 +64,10 @@ export default (() => { let _classExtraInitializers = []; let _classThis; var default_1 = class { + static { _classThis = this; } + static { __setFunctionName(_classThis, "default"); } static { - __setFunctionName(this, "default"); - __esDecorate(null, _classDescriptor = { value: this }, _classDecorators, { kind: "class", name: this.name }, null, _classExtraInitializers); + __esDecorate(null, _classDescriptor = { value: _classThis }, _classDecorators, { kind: "class", name: _classThis.name }, null, _classExtraInitializers); default_1 = _classThis = _classDescriptor.value; __runInitializers(_classThis, _classExtraInitializers); } diff --git a/tests/baselines/reference/esDecorators-classDeclaration-setFunctionName(target=es5).js b/tests/baselines/reference/esDecorators-classDeclaration-setFunctionName(target=es5).js index b574caffd3bbf..a0ef79023b0a7 100644 --- a/tests/baselines/reference/esDecorators-classDeclaration-setFunctionName(target=es5).js +++ b/tests/baselines/reference/esDecorators-classDeclaration-setFunctionName(target=es5).js @@ -25,7 +25,6 @@ declare let dec: any; //// [a.js] "use strict"; -var _this = this; Object.defineProperty(exports, "__esModule", { value: true }); var C = function () { var _classDecorators = [dec]; @@ -47,10 +46,9 @@ var C = function () { }(); //// [b.js] "use strict"; -var _this = this; Object.defineProperty(exports, "__esModule", { value: true }); exports.C = void 0; -var C = exports.C = function () { +var C = function () { var _classDecorators = [dec]; var _classDescriptor; var _classExtraInitializers = []; @@ -68,9 +66,9 @@ var C = exports.C = function () { })(); return C = _classThis; }(); +exports.C = C; //// [c.js] "use strict"; -var _this = this; Object.defineProperty(exports, "__esModule", { value: true }); var default_1 = function () { var _classDecorators = [dec]; @@ -82,8 +80,8 @@ var default_1 = function () { } return default_1; }()); + __setFunctionName(_classThis, "default"); (function () { - __setFunctionName(_classThis, "default_1"); __esDecorate(null, _classDescriptor = { value: _classThis }, _classDecorators, { kind: "class", name: _classThis.name }, null, _classExtraInitializers); default_1 = _classThis = _classDescriptor.value; __runInitializers(_classThis, _classExtraInitializers); diff --git a/tests/baselines/reference/esDecorators-classDeclaration-simpleTransformation(target=es2022).js b/tests/baselines/reference/esDecorators-classDeclaration-simpleTransformation(target=es2022).js index f6d99dc429d73..8396a58f6b58c 100644 --- a/tests/baselines/reference/esDecorators-classDeclaration-simpleTransformation(target=es2022).js +++ b/tests/baselines/reference/esDecorators-classDeclaration-simpleTransformation(target=es2022).js @@ -15,8 +15,9 @@ let C = (() => { let _classExtraInitializers = []; let _classThis; var C = class { + static { _classThis = this; } static { - __esDecorate(null, _classDescriptor = { value: this }, _classDecorators, { kind: "class", name: this.name }, null, _classExtraInitializers); + __esDecorate(null, _classDescriptor = { value: _classThis }, _classDecorators, { kind: "class", name: _classThis.name }, null, _classExtraInitializers); C = _classThis = _classDescriptor.value; __runInitializers(_classThis, _classExtraInitializers); } diff --git a/tests/baselines/reference/esDecorators-classDeclaration-simpleTransformation(target=es5).js b/tests/baselines/reference/esDecorators-classDeclaration-simpleTransformation(target=es5).js index 6567b6fcdf2a1..89d9fea826f65 100644 --- a/tests/baselines/reference/esDecorators-classDeclaration-simpleTransformation(target=es5).js +++ b/tests/baselines/reference/esDecorators-classDeclaration-simpleTransformation(target=es5).js @@ -9,7 +9,6 @@ class C { //// [esDecorators-classDeclaration-simpleTransformation.js] -var _this = this; var C = function () { var _classDecorators = [dec]; var _classDescriptor; diff --git a/tests/baselines/reference/esDecorators-classDeclaration-sourceMap(target=es2015).js b/tests/baselines/reference/esDecorators-classDeclaration-sourceMap(target=es2015).js index d85f8dacc5cf9..c3cc0da4121c8 100644 --- a/tests/baselines/reference/esDecorators-classDeclaration-sourceMap(target=es2015).js +++ b/tests/baselines/reference/esDecorators-classDeclaration-sourceMap(target=es2015).js @@ -103,7 +103,7 @@ var __classPrivateFieldIn = (this && this.__classPrivateFieldIn) || function(sta return typeof state === "function" ? receiver === state : state.has(receiver); }; let C = (() => { - var _method_get, _x_get, _x_set, _y, _z_accessor_storage, _z_get, _z_set, _z_1_accessor_storage; + var _C_method_get, _C_x_get, _C_x_set, _C_y, _C_z_accessor_storage, _C_z_get, _C_z_set, _C_z_1_accessor_storage; let _classDecorators = [dec, dec]; let _classDescriptor; let _classExtraInitializers = []; @@ -131,20 +131,20 @@ let C = (() => { var C = _classThis = class { constructor() { this.y = (__runInitializers(this, _instanceExtraInitializers), __runInitializers(this, _y_initializers, 1)); - _z_1_accessor_storage.set(this, __runInitializers(this, _z_initializers, 1)); + _C_z_1_accessor_storage.set(this, __runInitializers(this, _z_initializers, 1)); } method() { } get x() { return 1; } set x(value) { } - get z() { return __classPrivateFieldGet(this, _z_1_accessor_storage, "f"); } - set z(value) { __classPrivateFieldSet(this, _z_1_accessor_storage, value, "f"); } + get z() { return __classPrivateFieldGet(this, _C_z_1_accessor_storage, "f"); } + set z(value) { __classPrivateFieldSet(this, _C_z_1_accessor_storage, value, "f"); } }; - _z_1_accessor_storage = new WeakMap(); - _method_get = function _method_get() { return _static_private_method_descriptor.value; }; - _x_get = function _x_get() { return _static_private_get_x_descriptor.get.call(this); }; - _x_set = function _x_set(value) { return _static_private_set_x_descriptor.set.call(this, value); }; - _z_get = function _z_get() { return _static_private_z_descriptor.get.call(this); }; - _z_set = function _z_set(value) { return _static_private_z_descriptor.set.call(this, value); }; + _C_z_1_accessor_storage = new WeakMap(); + _C_method_get = function _C_method_get() { return _static_private_method_descriptor.value; }; + _C_x_get = function _C_x_get() { return _static_private_get_x_descriptor.get.call(this); }; + _C_x_set = function _C_x_set(value) { return _static_private_set_x_descriptor.set.call(this, value); }; + _C_z_get = function _C_z_get() { return _static_private_z_descriptor.get.call(this); }; + _C_z_set = function _C_z_set(value) { return _static_private_z_descriptor.set.call(this, value); }; __setFunctionName(_classThis, "C"); (() => { _method_decorators = [dec, dec]; @@ -157,22 +157,22 @@ let C = (() => { _static_private_set_x_decorators = [dec, dec]; _static_private_y_decorators = [dec, dec]; _static_private_z_decorators = [dec, dec]; - __esDecorate(_classThis, _static_private_method_descriptor = { value: __setFunctionName(function () { }, "#method") }, _static_private_method_decorators, { kind: "method", name: "#method", static: true, private: true, access: { has: obj => __classPrivateFieldIn(_classThis, obj), get: obj => __classPrivateFieldGet(obj, _classThis, "a", _method_get) } }, null, _staticExtraInitializers); - __esDecorate(_classThis, _static_private_get_x_descriptor = { get: __setFunctionName(function () { return 1; }, "#x", "get") }, _static_private_get_x_decorators, { kind: "getter", name: "#x", static: true, private: true, access: { has: obj => __classPrivateFieldIn(_classThis, obj), get: obj => __classPrivateFieldGet(obj, _classThis, "a", _x_get) } }, null, _staticExtraInitializers); - __esDecorate(_classThis, _static_private_set_x_descriptor = { set: __setFunctionName(function (value) { }, "#x", "set") }, _static_private_set_x_decorators, { kind: "setter", name: "#x", static: true, private: true, access: { has: obj => __classPrivateFieldIn(_classThis, obj), set: (obj, value) => { __classPrivateFieldSet(obj, _classThis, value, "a", _x_set); } } }, null, _staticExtraInitializers); - __esDecorate(_classThis, _static_private_z_descriptor = { get: __setFunctionName(function () { return __classPrivateFieldGet(_classThis, _classThis, "f", _z_accessor_storage); }, "#z", "get"), set: __setFunctionName(function (value) { __classPrivateFieldSet(_classThis, _classThis, value, "f", _z_accessor_storage); }, "#z", "set") }, _static_private_z_decorators, { kind: "accessor", name: "#z", static: true, private: true, access: { has: obj => __classPrivateFieldIn(_classThis, obj), get: obj => __classPrivateFieldGet(obj, _classThis, "a", _z_get), set: (obj, value) => { __classPrivateFieldSet(obj, _classThis, value, "a", _z_set); } } }, _static_private_z_initializers, _staticExtraInitializers); + __esDecorate(_classThis, _static_private_method_descriptor = { value: __setFunctionName(function () { }, "#method") }, _static_private_method_decorators, { kind: "method", name: "#method", static: true, private: true, access: { has: obj => __classPrivateFieldIn(_classThis, obj), get: obj => __classPrivateFieldGet(obj, _classThis, "a", _C_method_get) } }, null, _staticExtraInitializers); + __esDecorate(_classThis, _static_private_get_x_descriptor = { get: __setFunctionName(function () { return 1; }, "#x", "get") }, _static_private_get_x_decorators, { kind: "getter", name: "#x", static: true, private: true, access: { has: obj => __classPrivateFieldIn(_classThis, obj), get: obj => __classPrivateFieldGet(obj, _classThis, "a", _C_x_get) } }, null, _staticExtraInitializers); + __esDecorate(_classThis, _static_private_set_x_descriptor = { set: __setFunctionName(function (value) { }, "#x", "set") }, _static_private_set_x_decorators, { kind: "setter", name: "#x", static: true, private: true, access: { has: obj => __classPrivateFieldIn(_classThis, obj), set: (obj, value) => { __classPrivateFieldSet(obj, _classThis, value, "a", _C_x_set); } } }, null, _staticExtraInitializers); + __esDecorate(_classThis, _static_private_z_descriptor = { get: __setFunctionName(function () { return __classPrivateFieldGet(_classThis, _classThis, "f", _C_z_accessor_storage); }, "#z", "get"), set: __setFunctionName(function (value) { __classPrivateFieldSet(_classThis, _classThis, value, "f", _C_z_accessor_storage); }, "#z", "set") }, _static_private_z_decorators, { kind: "accessor", name: "#z", static: true, private: true, access: { has: obj => __classPrivateFieldIn(_classThis, obj), get: obj => __classPrivateFieldGet(obj, _classThis, "a", _C_z_get), set: (obj, value) => { __classPrivateFieldSet(obj, _classThis, value, "a", _C_z_set); } } }, _static_private_z_initializers, _staticExtraInitializers); __esDecorate(_classThis, null, _method_decorators, { kind: "method", name: "method", static: false, private: false, access: { has: obj => "method" in obj, get: obj => obj.method } }, null, _instanceExtraInitializers); __esDecorate(_classThis, null, _get_x_decorators, { kind: "getter", name: "x", static: false, private: false, access: { has: obj => "x" in obj, get: obj => obj.x } }, null, _instanceExtraInitializers); __esDecorate(_classThis, null, _set_x_decorators, { kind: "setter", name: "x", static: false, private: false, access: { has: obj => "x" in obj, set: (obj, value) => { obj.x = value; } } }, null, _instanceExtraInitializers); __esDecorate(_classThis, null, _z_decorators, { kind: "accessor", name: "z", static: false, private: false, access: { has: obj => "z" in obj, get: obj => obj.z, set: (obj, value) => { obj.z = value; } } }, _z_initializers, _instanceExtraInitializers); - __esDecorate(null, null, _static_private_y_decorators, { kind: "field", name: "#y", static: true, private: true, access: { has: obj => __classPrivateFieldIn(_classThis, obj), get: obj => __classPrivateFieldGet(obj, _classThis, "f", _y), set: (obj, value) => { __classPrivateFieldSet(obj, _classThis, value, "f", _y); } } }, _static_private_y_initializers, _staticExtraInitializers); + __esDecorate(null, null, _static_private_y_decorators, { kind: "field", name: "#y", static: true, private: true, access: { has: obj => __classPrivateFieldIn(_classThis, obj), get: obj => __classPrivateFieldGet(obj, _classThis, "f", _C_y), set: (obj, value) => { __classPrivateFieldSet(obj, _classThis, value, "f", _C_y); } } }, _static_private_y_initializers, _staticExtraInitializers); __esDecorate(null, null, _y_decorators, { kind: "field", name: "y", static: false, private: false, access: { has: obj => "y" in obj, get: obj => obj.y, set: (obj, value) => { obj.y = value; } } }, _y_initializers, _instanceExtraInitializers); __esDecorate(null, _classDescriptor = { value: _classThis }, _classDecorators, { kind: "class", name: _classThis.name }, null, _classExtraInitializers); C = _classThis = _classDescriptor.value; __runInitializers(_classThis, _staticExtraInitializers); })(); - _y = { value: __runInitializers(_classThis, _static_private_y_initializers, 1) }; - _z_accessor_storage = { value: __runInitializers(_classThis, _static_private_z_initializers, 1) }; + _C_y = { value: __runInitializers(_classThis, _static_private_y_initializers, 1) }; + _C_z_accessor_storage = { value: __runInitializers(_classThis, _static_private_z_initializers, 1) }; (() => { __runInitializers(_classThis, _classExtraInitializers); })(); diff --git a/tests/baselines/reference/esDecorators-classDeclaration-sourceMap(target=es2015).js.map b/tests/baselines/reference/esDecorators-classDeclaration-sourceMap(target=es2015).js.map index 25a35851e66e1..095f55e5a6d25 100644 --- a/tests/baselines/reference/esDecorators-classDeclaration-sourceMap(target=es2015).js.map +++ b/tests/baselines/reference/esDecorators-classDeclaration-sourceMap(target=es2015).js.map @@ -1,6 +1,6 @@ //// [esDecorators-classDeclaration-sourceMap.js.map] -{"version":3,"file":"esDecorators-classDeclaration-sourceMap.js","sourceRoot":"","sources":["esDecorators-classDeclaration-sourceMap.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;IAIM,CAAC;;4BAFN,GAAG,EACH,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;YAgBA,MAAC,kGAAG,CAAC,GAAC;YAIG,yEAAI,CAAC,GAAC;QAqBnB,CAAC;QArCG,MAAM,KAAI,CAAC;QAIX,IAAI,CAAC,KAAK,OAAO,CAAC,CAAC,CAAC,CAAC;QAIrB,IAAI,CAAC,CAAC,KAAa,IAAI,CAAC;QAQxB,IAAS,CAAC,uEAAK;QAAf,IAAS,CAAC,4EAAK;;;;;;;;;;8BAlBd,GAAG,EACH,GAAG;6BAGH,GAAG,EACH,GAAG;6BAGH,GAAG,EACH,GAAG;yBAGH,GAAG,EACH,GAAG;yBAGH,GAAG,EACH,GAAG;6CAGH,GAAG,EACH,GAAG;4CAGH,GAAG,EACH,GAAG;4CAGH,GAAG,EACH,GAAG;wCAGH,GAAG,EACH,GAAG;wCAGH,GAAG,EACH,GAAG;QAfJ,+DAAA,yBAAA,cAAkB,CAAC,YAAA,gRAAA;QAInB,8DAAA,uBAAA,cAAkB,OAAO,CAAC,CAAC,CAAC,CAAC,cAAA,qQAAA;QAI7B,8DAAA,uBAAA,UAAc,KAAa,IAAI,CAAC,cAAA,0RAAA;QAQhC,0DAAA,uBAAA,gGAAuB,cAAA,EAAvB,uBAAA,qGAAuB,cAAA,oXAAA;QApCvB,2KAAA,MAAM,wCAAK;QAIX,gKAAI,CAAC,wCAAgB;QAIrB,2KAAI,CAAC,mDAAmB;QAQxB,8JAAS,CAAC,6BAAD,CAAC,8DAAK;QAgBf,8XAAc;QApBd,qJAAA,CAAC,6BAAD,CAAC,8DAAK;QAfV,wJAwCC;;QAxCK,wDAAC;;IAmCI,4EAAK,CAAC,GAAJ,CAAK;IAIE,6FAAK,CAAC,GAAJ,CAAK;;QAvCrB,uDAAC"} -//// https://sokra.github.io/source-map-visualization#base64,dmFyIF9fZXNEZWNvcmF0ZSA9ICh0aGlzICYmIHRoaXMuX19lc0RlY29yYXRlKSB8fCBmdW5jdGlvbiAoY3RvciwgZGVzY3JpcHRvckluLCBkZWNvcmF0b3JzLCBjb250ZXh0SW4sIGluaXRpYWxpemVycywgZXh0cmFJbml0aWFsaXplcnMpIHsNCiAgICBmdW5jdGlvbiBhY2NlcHQoZikgeyBpZiAoZiAhPT0gdm9pZCAwICYmIHR5cGVvZiBmICE9PSAiZnVuY3Rpb24iKSB0aHJvdyBuZXcgVHlwZUVycm9yKCJGdW5jdGlvbiBleHBlY3RlZCIpOyByZXR1cm4gZjsgfQ0KICAgIHZhciBraW5kID0gY29udGV4dEluLmtpbmQsIGtleSA9IGtpbmQgPT09ICJnZXR0ZXIiID8gImdldCIgOiBraW5kID09PSAic2V0dGVyIiA/ICJzZXQiIDogInZhbHVlIjsNCiAgICB2YXIgdGFyZ2V0ID0gIWRlc2NyaXB0b3JJbiAmJiBjdG9yID8gY29udGV4dEluWyJzdGF0aWMiXSA/IGN0b3IgOiBjdG9yLnByb3RvdHlwZSA6IG51bGw7DQogICAgdmFyIGRlc2NyaXB0b3IgPSBkZXNjcmlwdG9ySW4gfHwgKHRhcmdldCA/IE9iamVjdC5nZXRPd25Qcm9wZXJ0eURlc2NyaXB0b3IodGFyZ2V0LCBjb250ZXh0SW4ubmFtZSkgOiB7fSk7DQogICAgdmFyIF8sIGRvbmUgPSBmYWxzZTsNCiAgICBmb3IgKHZhciBpID0gZGVjb3JhdG9ycy5sZW5ndGggLSAxOyBpID49IDA7IGktLSkgew0KICAgICAgICB2YXIgY29udGV4dCA9IHt9Ow0KICAgICAgICBmb3IgKHZhciBwIGluIGNvbnRleHRJbikgY29udGV4dFtwXSA9IHAgPT09ICJhY2Nlc3MiID8ge30gOiBjb250ZXh0SW5bcF07DQogICAgICAgIGZvciAodmFyIHAgaW4gY29udGV4dEluLmFjY2VzcykgY29udGV4dC5hY2Nlc3NbcF0gPSBjb250ZXh0SW4uYWNjZXNzW3BdOw0KICAgICAgICBjb250ZXh0LmFkZEluaXRpYWxpemVyID0gZnVuY3Rpb24gKGYpIHsgaWYgKGRvbmUpIHRocm93IG5ldyBUeXBlRXJyb3IoIkNhbm5vdCBhZGQgaW5pdGlhbGl6ZXJzIGFmdGVyIGRlY29yYXRpb24gaGFzIGNvbXBsZXRlZCIpOyBleHRyYUluaXRpYWxpemVycy5wdXNoKGFjY2VwdChmIHx8IG51bGwpKTsgfTsNCiAgICAgICAgdmFyIHJlc3VsdCA9ICgwLCBkZWNvcmF0b3JzW2ldKShraW5kID09PSAiYWNjZXNzb3IiID8geyBnZXQ6IGRlc2NyaXB0b3IuZ2V0LCBzZXQ6IGRlc2NyaXB0b3Iuc2V0IH0gOiBkZXNjcmlwdG9yW2tleV0sIGNvbnRleHQpOw0KICAgICAgICBpZiAoa2luZCA9PT0gImFjY2Vzc29yIikgew0KICAgICAgICAgICAgaWYgKHJlc3VsdCA9PT0gdm9pZCAwKSBjb250aW51ZTsNCiAgICAgICAgICAgIGlmIChyZXN1bHQgPT09IG51bGwgfHwgdHlwZW9mIHJlc3VsdCAhPT0gIm9iamVjdCIpIHRocm93IG5ldyBUeXBlRXJyb3IoIk9iamVjdCBleHBlY3RlZCIpOw0KICAgICAgICAgICAgaWYgKF8gPSBhY2NlcHQocmVzdWx0LmdldCkpIGRlc2NyaXB0b3IuZ2V0ID0gXzsNCiAgICAgICAgICAgIGlmIChfID0gYWNjZXB0KHJlc3VsdC5zZXQpKSBkZXNjcmlwdG9yLnNldCA9IF87DQogICAgICAgICAgICBpZiAoXyA9IGFjY2VwdChyZXN1bHQuaW5pdCkpIGluaXRpYWxpemVycy51bnNoaWZ0KF8pOw0KICAgICAgICB9DQogICAgICAgIGVsc2UgaWYgKF8gPSBhY2NlcHQocmVzdWx0KSkgew0KICAgICAgICAgICAgaWYgKGtpbmQgPT09ICJmaWVsZCIpIGluaXRpYWxpemVycy51bnNoaWZ0KF8pOw0KICAgICAgICAgICAgZWxzZSBkZXNjcmlwdG9yW2tleV0gPSBfOw0KICAgICAgICB9DQogICAgfQ0KICAgIGlmICh0YXJnZXQpIE9iamVjdC5kZWZpbmVQcm9wZXJ0eSh0YXJnZXQsIGNvbnRleHRJbi5uYW1lLCBkZXNjcmlwdG9yKTsNCiAgICBkb25lID0gdHJ1ZTsNCn07DQp2YXIgX19ydW5Jbml0aWFsaXplcnMgPSAodGhpcyAmJiB0aGlzLl9fcnVuSW5pdGlhbGl6ZXJzKSB8fCBmdW5jdGlvbiAodGhpc0FyZywgaW5pdGlhbGl6ZXJzLCB2YWx1ZSkgew0KICAgIHZhciB1c2VWYWx1ZSA9IGFyZ3VtZW50cy5sZW5ndGggPiAyOw0KICAgIGZvciAodmFyIGkgPSAwOyBpIDwgaW5pdGlhbGl6ZXJzLmxlbmd0aDsgaSsrKSB7DQogICAgICAgIHZhbHVlID0gdXNlVmFsdWUgPyBpbml0aWFsaXplcnNbaV0uY2FsbCh0aGlzQXJnLCB2YWx1ZSkgOiBpbml0aWFsaXplcnNbaV0uY2FsbCh0aGlzQXJnKTsNCiAgICB9DQogICAgcmV0dXJuIHVzZVZhbHVlID8gdmFsdWUgOiB2b2lkIDA7DQp9Ow0KdmFyIF9fc2V0RnVuY3Rpb25OYW1lID0gKHRoaXMgJiYgdGhpcy5fX3NldEZ1bmN0aW9uTmFtZSkgfHwgZnVuY3Rpb24gKGYsIG5hbWUsIHByZWZpeCkgew0KICAgIGlmICh0eXBlb2YgbmFtZSA9PT0gInN5bWJvbCIpIG5hbWUgPSBuYW1lLmRlc2NyaXB0aW9uID8gIlsiLmNvbmNhdChuYW1lLmRlc2NyaXB0aW9uLCAiXSIpIDogIiI7DQogICAgcmV0dXJuIE9iamVjdC5kZWZpbmVQcm9wZXJ0eShmLCAibmFtZSIsIHsgY29uZmlndXJhYmxlOiB0cnVlLCB2YWx1ZTogcHJlZml4ID8gIiIuY29uY2F0KHByZWZpeCwgIiAiLCBuYW1lKSA6IG5hbWUgfSk7DQp9Ow0KdmFyIF9fY2xhc3NQcml2YXRlRmllbGRHZXQgPSAodGhpcyAmJiB0aGlzLl9fY2xhc3NQcml2YXRlRmllbGRHZXQpIHx8IGZ1bmN0aW9uIChyZWNlaXZlciwgc3RhdGUsIGtpbmQsIGYpIHsNCiAgICBpZiAoa2luZCA9PT0gImEiICYmICFmKSB0aHJvdyBuZXcgVHlwZUVycm9yKCJQcml2YXRlIGFjY2Vzc29yIHdhcyBkZWZpbmVkIHdpdGhvdXQgYSBnZXR0ZXIiKTsNCiAgICBpZiAodHlwZW9mIHN0YXRlID09PSAiZnVuY3Rpb24iID8gcmVjZWl2ZXIgIT09IHN0YXRlIHx8ICFmIDogIXN0YXRlLmhhcyhyZWNlaXZlcikpIHRocm93IG5ldyBUeXBlRXJyb3IoIkNhbm5vdCByZWFkIHByaXZhdGUgbWVtYmVyIGZyb20gYW4gb2JqZWN0IHdob3NlIGNsYXNzIGRpZCBub3QgZGVjbGFyZSBpdCIpOw0KICAgIHJldHVybiBraW5kID09PSAibSIgPyBmIDoga2luZCA9PT0gImEiID8gZi5jYWxsKHJlY2VpdmVyKSA6IGYgPyBmLnZhbHVlIDogc3RhdGUuZ2V0KHJlY2VpdmVyKTsNCn07DQp2YXIgX19jbGFzc1ByaXZhdGVGaWVsZFNldCA9ICh0aGlzICYmIHRoaXMuX19jbGFzc1ByaXZhdGVGaWVsZFNldCkgfHwgZnVuY3Rpb24gKHJlY2VpdmVyLCBzdGF0ZSwgdmFsdWUsIGtpbmQsIGYpIHsNCiAgICBpZiAoa2luZCA9PT0gIm0iKSB0aHJvdyBuZXcgVHlwZUVycm9yKCJQcml2YXRlIG1ldGhvZCBpcyBub3Qgd3JpdGFibGUiKTsNCiAgICBpZiAoa2luZCA9PT0gImEiICYmICFmKSB0aHJvdyBuZXcgVHlwZUVycm9yKCJQcml2YXRlIGFjY2Vzc29yIHdhcyBkZWZpbmVkIHdpdGhvdXQgYSBzZXR0ZXIiKTsNCiAgICBpZiAodHlwZW9mIHN0YXRlID09PSAiZnVuY3Rpb24iID8gcmVjZWl2ZXIgIT09IHN0YXRlIHx8ICFmIDogIXN0YXRlLmhhcyhyZWNlaXZlcikpIHRocm93IG5ldyBUeXBlRXJyb3IoIkNhbm5vdCB3cml0ZSBwcml2YXRlIG1lbWJlciB0byBhbiBvYmplY3Qgd2hvc2UgY2xhc3MgZGlkIG5vdCBkZWNsYXJlIGl0Iik7DQogICAgcmV0dXJuIChraW5kID09PSAiYSIgPyBmLmNhbGwocmVjZWl2ZXIsIHZhbHVlKSA6IGYgPyBmLnZhbHVlID0gdmFsdWUgOiBzdGF0ZS5zZXQocmVjZWl2ZXIsIHZhbHVlKSksIHZhbHVlOw0KfTsNCnZhciBfX2NsYXNzUHJpdmF0ZUZpZWxkSW4gPSAodGhpcyAmJiB0aGlzLl9fY2xhc3NQcml2YXRlRmllbGRJbikgfHwgZnVuY3Rpb24oc3RhdGUsIHJlY2VpdmVyKSB7DQogICAgaWYgKHJlY2VpdmVyID09PSBudWxsIHx8ICh0eXBlb2YgcmVjZWl2ZXIgIT09ICJvYmplY3QiICYmIHR5cGVvZiByZWNlaXZlciAhPT0gImZ1bmN0aW9uIikpIHRocm93IG5ldyBUeXBlRXJyb3IoIkNhbm5vdCB1c2UgJ2luJyBvcGVyYXRvciBvbiBub24tb2JqZWN0Iik7DQogICAgcmV0dXJuIHR5cGVvZiBzdGF0ZSA9PT0gImZ1bmN0aW9uIiA/IHJlY2VpdmVyID09PSBzdGF0ZSA6IHN0YXRlLmhhcyhyZWNlaXZlcik7DQp9Ow0KbGV0IEMgPSAoKCkgPT4gew0KICAgIHZhciBfbWV0aG9kX2dldCwgX3hfZ2V0LCBfeF9zZXQsIF95LCBfel9hY2Nlc3Nvcl9zdG9yYWdlLCBfel9nZXQsIF96X3NldCwgX3pfMV9hY2Nlc3Nvcl9zdG9yYWdlOw0KICAgIGxldCBfY2xhc3NEZWNvcmF0b3JzID0gW2RlYywgZGVjXTsNCiAgICBsZXQgX2NsYXNzRGVzY3JpcHRvcjsNCiAgICBsZXQgX2NsYXNzRXh0cmFJbml0aWFsaXplcnMgPSBbXTsNCiAgICBsZXQgX2NsYXNzVGhpczsNCiAgICBsZXQgX3N0YXRpY0V4dHJhSW5pdGlhbGl6ZXJzID0gW107DQogICAgbGV0IF9pbnN0YW5jZUV4dHJhSW5pdGlhbGl6ZXJzID0gW107DQogICAgbGV0IF9zdGF0aWNfcHJpdmF0ZV9tZXRob2RfZGVjb3JhdG9yczsNCiAgICBsZXQgX3N0YXRpY19wcml2YXRlX21ldGhvZF9kZXNjcmlwdG9yOw0KICAgIGxldCBfc3RhdGljX3ByaXZhdGVfZ2V0X3hfZGVjb3JhdG9yczsNCiAgICBsZXQgX3N0YXRpY19wcml2YXRlX2dldF94X2Rlc2NyaXB0b3I7DQogICAgbGV0IF9zdGF0aWNfcHJpdmF0ZV9zZXRfeF9kZWNvcmF0b3JzOw0KICAgIGxldCBfc3RhdGljX3ByaXZhdGVfc2V0X3hfZGVzY3JpcHRvcjsNCiAgICBsZXQgX3N0YXRpY19wcml2YXRlX3lfZGVjb3JhdG9yczsNCiAgICBsZXQgX3N0YXRpY19wcml2YXRlX3lfaW5pdGlhbGl6ZXJzID0gW107DQogICAgbGV0IF9zdGF0aWNfcHJpdmF0ZV96X2RlY29yYXRvcnM7DQogICAgbGV0IF9zdGF0aWNfcHJpdmF0ZV96X2luaXRpYWxpemVycyA9IFtdOw0KICAgIGxldCBfc3RhdGljX3ByaXZhdGVfel9kZXNjcmlwdG9yOw0KICAgIGxldCBfbWV0aG9kX2RlY29yYXRvcnM7DQogICAgbGV0IF9nZXRfeF9kZWNvcmF0b3JzOw0KICAgIGxldCBfc2V0X3hfZGVjb3JhdG9yczsNCiAgICBsZXQgX3lfZGVjb3JhdG9yczsNCiAgICBsZXQgX3lfaW5pdGlhbGl6ZXJzID0gW107DQogICAgbGV0IF96X2RlY29yYXRvcnM7DQogICAgbGV0IF96X2luaXRpYWxpemVycyA9IFtdOw0KICAgIHZhciBDID0gX2NsYXNzVGhpcyA9IGNsYXNzIHsNCiAgICAgICAgY29uc3RydWN0b3IoKSB7DQogICAgICAgICAgICB0aGlzLnkgPSAoX19ydW5Jbml0aWFsaXplcnModGhpcywgX2luc3RhbmNlRXh0cmFJbml0aWFsaXplcnMpLCBfX3J1bkluaXRpYWxpemVycyh0aGlzLCBfeV9pbml0aWFsaXplcnMsIDEpKTsNCiAgICAgICAgICAgIF96XzFfYWNjZXNzb3Jfc3RvcmFnZS5zZXQodGhpcywgX19ydW5Jbml0aWFsaXplcnModGhpcywgX3pfaW5pdGlhbGl6ZXJzLCAxKSk7DQogICAgICAgIH0NCiAgICAgICAgbWV0aG9kKCkgeyB9DQogICAgICAgIGdldCB4KCkgeyByZXR1cm4gMTsgfQ0KICAgICAgICBzZXQgeCh2YWx1ZSkgeyB9DQogICAgICAgIGdldCB6KCkgeyByZXR1cm4gX19jbGFzc1ByaXZhdGVGaWVsZEdldCh0aGlzLCBfel8xX2FjY2Vzc29yX3N0b3JhZ2UsICJmIik7IH0NCiAgICAgICAgc2V0IHoodmFsdWUpIHsgX19jbGFzc1ByaXZhdGVGaWVsZFNldCh0aGlzLCBfel8xX2FjY2Vzc29yX3N0b3JhZ2UsIHZhbHVlLCAiZiIpOyB9DQogICAgfTsNCiAgICBfel8xX2FjY2Vzc29yX3N0b3JhZ2UgPSBuZXcgV2Vha01hcCgpOw0KICAgIF9tZXRob2RfZ2V0ID0gZnVuY3Rpb24gX21ldGhvZF9nZXQoKSB7IHJldHVybiBfc3RhdGljX3ByaXZhdGVfbWV0aG9kX2Rlc2NyaXB0b3IudmFsdWU7IH07DQogICAgX3hfZ2V0ID0gZnVuY3Rpb24gX3hfZ2V0KCkgeyByZXR1cm4gX3N0YXRpY19wcml2YXRlX2dldF94X2Rlc2NyaXB0b3IuZ2V0LmNhbGwodGhpcyk7IH07DQogICAgX3hfc2V0ID0gZnVuY3Rpb24gX3hfc2V0KHZhbHVlKSB7IHJldHVybiBfc3RhdGljX3ByaXZhdGVfc2V0X3hfZGVzY3JpcHRvci5zZXQuY2FsbCh0aGlzLCB2YWx1ZSk7IH07DQogICAgX3pfZ2V0ID0gZnVuY3Rpb24gX3pfZ2V0KCkgeyByZXR1cm4gX3N0YXRpY19wcml2YXRlX3pfZGVzY3JpcHRvci5nZXQuY2FsbCh0aGlzKTsgfTsNCiAgICBfel9zZXQgPSBmdW5jdGlvbiBfel9zZXQodmFsdWUpIHsgcmV0dXJuIF9zdGF0aWNfcHJpdmF0ZV96X2Rlc2NyaXB0b3Iuc2V0LmNhbGwodGhpcywgdmFsdWUpOyB9Ow0KICAgIF9fc2V0RnVuY3Rpb25OYW1lKF9jbGFzc1RoaXMsICJDIik7DQogICAgKCgpID0+IHsNCiAgICAgICAgX21ldGhvZF9kZWNvcmF0b3JzID0gW2RlYywgZGVjXTsNCiAgICAgICAgX2dldF94X2RlY29yYXRvcnMgPSBbZGVjLCBkZWNdOw0KICAgICAgICBfc2V0X3hfZGVjb3JhdG9ycyA9IFtkZWMsIGRlY107DQogICAgICAgIF95X2RlY29yYXRvcnMgPSBbZGVjLCBkZWNdOw0KICAgICAgICBfel9kZWNvcmF0b3JzID0gW2RlYywgZGVjXTsNCiAgICAgICAgX3N0YXRpY19wcml2YXRlX21ldGhvZF9kZWNvcmF0b3JzID0gW2RlYywgZGVjXTsNCiAgICAgICAgX3N0YXRpY19wcml2YXRlX2dldF94X2RlY29yYXRvcnMgPSBbZGVjLCBkZWNdOw0KICAgICAgICBfc3RhdGljX3ByaXZhdGVfc2V0X3hfZGVjb3JhdG9ycyA9IFtkZWMsIGRlY107DQogICAgICAgIF9zdGF0aWNfcHJpdmF0ZV95X2RlY29yYXRvcnMgPSBbZGVjLCBkZWNdOw0KICAgICAgICBfc3RhdGljX3ByaXZhdGVfel9kZWNvcmF0b3JzID0gW2RlYywgZGVjXTsNCiAgICAgICAgX19lc0RlY29yYXRlKF9jbGFzc1RoaXMsIF9zdGF0aWNfcHJpdmF0ZV9tZXRob2RfZGVzY3JpcHRvciA9IHsgdmFsdWU6IF9fc2V0RnVuY3Rpb25OYW1lKGZ1bmN0aW9uICgpIHsgfSwgIiNtZXRob2QiKSB9LCBfc3RhdGljX3ByaXZhdGVfbWV0aG9kX2RlY29yYXRvcnMsIHsga2luZDogIm1ldGhvZCIsIG5hbWU6ICIjbWV0aG9kIiwgc3RhdGljOiB0cnVlLCBwcml2YXRlOiB0cnVlLCBhY2Nlc3M6IHsgaGFzOiBvYmogPT4gX19jbGFzc1ByaXZhdGVGaWVsZEluKF9jbGFzc1RoaXMsIG9iaiksIGdldDogb2JqID0+IF9fY2xhc3NQcml2YXRlRmllbGRHZXQob2JqLCBfY2xhc3NUaGlzLCAiYSIsIF9tZXRob2RfZ2V0KSB9IH0sIG51bGwsIF9zdGF0aWNFeHRyYUluaXRpYWxpemVycyk7DQogICAgICAgIF9fZXNEZWNvcmF0ZShfY2xhc3NUaGlzLCBfc3RhdGljX3ByaXZhdGVfZ2V0X3hfZGVzY3JpcHRvciA9IHsgZ2V0OiBfX3NldEZ1bmN0aW9uTmFtZShmdW5jdGlvbiAoKSB7IHJldHVybiAxOyB9LCAiI3giLCAiZ2V0IikgfSwgX3N0YXRpY19wcml2YXRlX2dldF94X2RlY29yYXRvcnMsIHsga2luZDogImdldHRlciIsIG5hbWU6ICIjeCIsIHN0YXRpYzogdHJ1ZSwgcHJpdmF0ZTogdHJ1ZSwgYWNjZXNzOiB7IGhhczogb2JqID0+IF9fY2xhc3NQcml2YXRlRmllbGRJbihfY2xhc3NUaGlzLCBvYmopLCBnZXQ6IG9iaiA9PiBfX2NsYXNzUHJpdmF0ZUZpZWxkR2V0KG9iaiwgX2NsYXNzVGhpcywgImEiLCBfeF9nZXQpIH0gfSwgbnVsbCwgX3N0YXRpY0V4dHJhSW5pdGlhbGl6ZXJzKTsNCiAgICAgICAgX19lc0RlY29yYXRlKF9jbGFzc1RoaXMsIF9zdGF0aWNfcHJpdmF0ZV9zZXRfeF9kZXNjcmlwdG9yID0geyBzZXQ6IF9fc2V0RnVuY3Rpb25OYW1lKGZ1bmN0aW9uICh2YWx1ZSkgeyB9LCAiI3giLCAic2V0IikgfSwgX3N0YXRpY19wcml2YXRlX3NldF94X2RlY29yYXRvcnMsIHsga2luZDogInNldHRlciIsIG5hbWU6ICIjeCIsIHN0YXRpYzogdHJ1ZSwgcHJpdmF0ZTogdHJ1ZSwgYWNjZXNzOiB7IGhhczogb2JqID0+IF9fY2xhc3NQcml2YXRlRmllbGRJbihfY2xhc3NUaGlzLCBvYmopLCBzZXQ6IChvYmosIHZhbHVlKSA9PiB7IF9fY2xhc3NQcml2YXRlRmllbGRTZXQob2JqLCBfY2xhc3NUaGlzLCB2YWx1ZSwgImEiLCBfeF9zZXQpOyB9IH0gfSwgbnVsbCwgX3N0YXRpY0V4dHJhSW5pdGlhbGl6ZXJzKTsNCiAgICAgICAgX19lc0RlY29yYXRlKF9jbGFzc1RoaXMsIF9zdGF0aWNfcHJpdmF0ZV96X2Rlc2NyaXB0b3IgPSB7IGdldDogX19zZXRGdW5jdGlvbk5hbWUoZnVuY3Rpb24gKCkgeyByZXR1cm4gX19jbGFzc1ByaXZhdGVGaWVsZEdldChfY2xhc3NUaGlzLCBfY2xhc3NUaGlzLCAiZiIsIF96X2FjY2Vzc29yX3N0b3JhZ2UpOyB9LCAiI3oiLCAiZ2V0IiksIHNldDogX19zZXRGdW5jdGlvbk5hbWUoZnVuY3Rpb24gKHZhbHVlKSB7IF9fY2xhc3NQcml2YXRlRmllbGRTZXQoX2NsYXNzVGhpcywgX2NsYXNzVGhpcywgdmFsdWUsICJmIiwgX3pfYWNjZXNzb3Jfc3RvcmFnZSk7IH0sICIjeiIsICJzZXQiKSB9LCBfc3RhdGljX3ByaXZhdGVfel9kZWNvcmF0b3JzLCB7IGtpbmQ6ICJhY2Nlc3NvciIsIG5hbWU6ICIjeiIsIHN0YXRpYzogdHJ1ZSwgcHJpdmF0ZTogdHJ1ZSwgYWNjZXNzOiB7IGhhczogb2JqID0+IF9fY2xhc3NQcml2YXRlRmllbGRJbihfY2xhc3NUaGlzLCBvYmopLCBnZXQ6IG9iaiA9PiBfX2NsYXNzUHJpdmF0ZUZpZWxkR2V0KG9iaiwgX2NsYXNzVGhpcywgImEiLCBfel9nZXQpLCBzZXQ6IChvYmosIHZhbHVlKSA9PiB7IF9fY2xhc3NQcml2YXRlRmllbGRTZXQob2JqLCBfY2xhc3NUaGlzLCB2YWx1ZSwgImEiLCBfel9zZXQpOyB9IH0gfSwgX3N0YXRpY19wcml2YXRlX3pfaW5pdGlhbGl6ZXJzLCBfc3RhdGljRXh0cmFJbml0aWFsaXplcnMpOw0KICAgICAgICBfX2VzRGVjb3JhdGUoX2NsYXNzVGhpcywgbnVsbCwgX21ldGhvZF9kZWNvcmF0b3JzLCB7IGtpbmQ6ICJtZXRob2QiLCBuYW1lOiAibWV0aG9kIiwgc3RhdGljOiBmYWxzZSwgcHJpdmF0ZTogZmFsc2UsIGFjY2VzczogeyBoYXM6IG9iaiA9PiAibWV0aG9kIiBpbiBvYmosIGdldDogb2JqID0+IG9iai5tZXRob2QgfSB9LCBudWxsLCBfaW5zdGFuY2VFeHRyYUluaXRpYWxpemVycyk7DQogICAgICAgIF9fZXNEZWNvcmF0ZShfY2xhc3NUaGlzLCBudWxsLCBfZ2V0X3hfZGVjb3JhdG9ycywgeyBraW5kOiAiZ2V0dGVyIiwgbmFtZTogIngiLCBzdGF0aWM6IGZhbHNlLCBwcml2YXRlOiBmYWxzZSwgYWNjZXNzOiB7IGhhczogb2JqID0+ICJ4IiBpbiBvYmosIGdldDogb2JqID0+IG9iai54IH0gfSwgbnVsbCwgX2luc3RhbmNlRXh0cmFJbml0aWFsaXplcnMpOw0KICAgICAgICBfX2VzRGVjb3JhdGUoX2NsYXNzVGhpcywgbnVsbCwgX3NldF94X2RlY29yYXRvcnMsIHsga2luZDogInNldHRlciIsIG5hbWU6ICJ4Iiwgc3RhdGljOiBmYWxzZSwgcHJpdmF0ZTogZmFsc2UsIGFjY2VzczogeyBoYXM6IG9iaiA9PiAieCIgaW4gb2JqLCBzZXQ6IChvYmosIHZhbHVlKSA9PiB7IG9iai54ID0gdmFsdWU7IH0gfSB9LCBudWxsLCBfaW5zdGFuY2VFeHRyYUluaXRpYWxpemVycyk7DQogICAgICAgIF9fZXNEZWNvcmF0ZShfY2xhc3NUaGlzLCBudWxsLCBfel9kZWNvcmF0b3JzLCB7IGtpbmQ6ICJhY2Nlc3NvciIsIG5hbWU6ICJ6Iiwgc3RhdGljOiBmYWxzZSwgcHJpdmF0ZTogZmFsc2UsIGFjY2VzczogeyBoYXM6IG9iaiA9PiAieiIgaW4gb2JqLCBnZXQ6IG9iaiA9PiBvYmoueiwgc2V0OiAob2JqLCB2YWx1ZSkgPT4geyBvYmoueiA9IHZhbHVlOyB9IH0gfSwgX3pfaW5pdGlhbGl6ZXJzLCBfaW5zdGFuY2VFeHRyYUluaXRpYWxpemVycyk7DQogICAgICAgIF9fZXNEZWNvcmF0ZShudWxsLCBudWxsLCBfc3RhdGljX3ByaXZhdGVfeV9kZWNvcmF0b3JzLCB7IGtpbmQ6ICJmaWVsZCIsIG5hbWU6ICIjeSIsIHN0YXRpYzogdHJ1ZSwgcHJpdmF0ZTogdHJ1ZSwgYWNjZXNzOiB7IGhhczogb2JqID0+IF9fY2xhc3NQcml2YXRlRmllbGRJbihfY2xhc3NUaGlzLCBvYmopLCBnZXQ6IG9iaiA9PiBfX2NsYXNzUHJpdmF0ZUZpZWxkR2V0KG9iaiwgX2NsYXNzVGhpcywgImYiLCBfeSksIHNldDogKG9iaiwgdmFsdWUpID0+IHsgX19jbGFzc1ByaXZhdGVGaWVsZFNldChvYmosIF9jbGFzc1RoaXMsIHZhbHVlLCAiZiIsIF95KTsgfSB9IH0sIF9zdGF0aWNfcHJpdmF0ZV95X2luaXRpYWxpemVycywgX3N0YXRpY0V4dHJhSW5pdGlhbGl6ZXJzKTsNCiAgICAgICAgX19lc0RlY29yYXRlKG51bGwsIG51bGwsIF95X2RlY29yYXRvcnMsIHsga2luZDogImZpZWxkIiwgbmFtZTogInkiLCBzdGF0aWM6IGZhbHNlLCBwcml2YXRlOiBmYWxzZSwgYWNjZXNzOiB7IGhhczogb2JqID0+ICJ5IiBpbiBvYmosIGdldDogb2JqID0+IG9iai55LCBzZXQ6IChvYmosIHZhbHVlKSA9PiB7IG9iai55ID0gdmFsdWU7IH0gfSB9LCBfeV9pbml0aWFsaXplcnMsIF9pbnN0YW5jZUV4dHJhSW5pdGlhbGl6ZXJzKTsNCiAgICAgICAgX19lc0RlY29yYXRlKG51bGwsIF9jbGFzc0Rlc2NyaXB0b3IgPSB7IHZhbHVlOiBfY2xhc3NUaGlzIH0sIF9jbGFzc0RlY29yYXRvcnMsIHsga2luZDogImNsYXNzIiwgbmFtZTogX2NsYXNzVGhpcy5uYW1lIH0sIG51bGwsIF9jbGFzc0V4dHJhSW5pdGlhbGl6ZXJzKTsNCiAgICAgICAgQyA9IF9jbGFzc1RoaXMgPSBfY2xhc3NEZXNjcmlwdG9yLnZhbHVlOw0KICAgICAgICBfX3J1bkluaXRpYWxpemVycyhfY2xhc3NUaGlzLCBfc3RhdGljRXh0cmFJbml0aWFsaXplcnMpOw0KICAgIH0pKCk7DQogICAgX3kgPSB7IHZhbHVlOiBfX3J1bkluaXRpYWxpemVycyhfY2xhc3NUaGlzLCBfc3RhdGljX3ByaXZhdGVfeV9pbml0aWFsaXplcnMsIDEpIH07DQogICAgX3pfYWNjZXNzb3Jfc3RvcmFnZSA9IHsgdmFsdWU6IF9fcnVuSW5pdGlhbGl6ZXJzKF9jbGFzc1RoaXMsIF9zdGF0aWNfcHJpdmF0ZV96X2luaXRpYWxpemVycywgMSkgfTsNCiAgICAoKCkgPT4gew0KICAgICAgICBfX3J1bkluaXRpYWxpemVycyhfY2xhc3NUaGlzLCBfY2xhc3NFeHRyYUluaXRpYWxpemVycyk7DQogICAgfSkoKTsNCiAgICByZXR1cm4gQyA9IF9jbGFzc1RoaXM7DQp9KSgpOw0KLy8jIHNvdXJjZU1hcHBpbmdVUkw9ZXNEZWNvcmF0b3JzLWNsYXNzRGVjbGFyYXRpb24tc291cmNlTWFwLmpzLm1hcA==,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiZXNEZWNvcmF0b3JzLWNsYXNzRGVjbGFyYXRpb24tc291cmNlTWFwLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiZXNEZWNvcmF0b3JzLWNsYXNzRGVjbGFyYXRpb24tc291cmNlTWFwLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7O0lBSU0sQ0FBQzs7NEJBRk4sR0FBRyxFQUNILEdBQUc7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7O1lBZ0JBLE1BQUMsa0dBQUcsQ0FBQyxHQUFDO1lBSUcseUVBQUksQ0FBQyxHQUFDO1FBcUJuQixDQUFDO1FBckNHLE1BQU0sS0FBSSxDQUFDO1FBSVgsSUFBSSxDQUFDLEtBQUssT0FBTyxDQUFDLENBQUMsQ0FBQyxDQUFDO1FBSXJCLElBQUksQ0FBQyxDQUFDLEtBQWEsSUFBSSxDQUFDO1FBUXhCLElBQVMsQ0FBQyx1RUFBSztRQUFmLElBQVMsQ0FBQyw0RUFBSzs7Ozs7Ozs7Ozs4QkFsQmQsR0FBRyxFQUNILEdBQUc7NkJBR0gsR0FBRyxFQUNILEdBQUc7NkJBR0gsR0FBRyxFQUNILEdBQUc7eUJBR0gsR0FBRyxFQUNILEdBQUc7eUJBR0gsR0FBRyxFQUNILEdBQUc7NkNBR0gsR0FBRyxFQUNILEdBQUc7NENBR0gsR0FBRyxFQUNILEdBQUc7NENBR0gsR0FBRyxFQUNILEdBQUc7d0NBR0gsR0FBRyxFQUNILEdBQUc7d0NBR0gsR0FBRyxFQUNILEdBQUc7UUFmSiwrREFBQSx5QkFBQSxjQUFrQixDQUFDLFlBQUEsZ1JBQUE7UUFJbkIsOERBQUEsdUJBQUEsY0FBa0IsT0FBTyxDQUFDLENBQUMsQ0FBQyxDQUFDLGNBQUEscVFBQUE7UUFJN0IsOERBQUEsdUJBQUEsVUFBYyxLQUFhLElBQUksQ0FBQyxjQUFBLDBSQUFBO1FBUWhDLDBEQUFBLHVCQUFBLGdHQUF1QixjQUFBLEVBQXZCLHVCQUFBLHFHQUF1QixjQUFBLG9YQUFBO1FBcEN2QiwyS0FBQSxNQUFNLHdDQUFLO1FBSVgsZ0tBQUksQ0FBQyx3Q0FBZ0I7UUFJckIsMktBQUksQ0FBQyxtREFBbUI7UUFReEIsOEpBQVMsQ0FBQyw2QkFBRCxDQUFDLDhEQUFLO1FBZ0JmLDhYQUFjO1FBcEJkLHFKQUFBLENBQUMsNkJBQUQsQ0FBQyw4REFBSztRQWZWLHdKQXdDQzs7UUF4Q0ssd0RBQUM7O0lBbUNJLDRFQUFLLENBQUMsR0FBSixDQUFLO0lBSUUsNkZBQUssQ0FBQyxHQUFKLENBQUs7O1FBdkNyQix1REFBQyJ9,ZGVjbGFyZSB2YXIgZGVjOiBhbnk7CgpAZGVjCkBkZWMKY2xhc3MgQyB7CiAgICBAZGVjCiAgICBAZGVjCiAgICBtZXRob2QoKSB7fQoKICAgIEBkZWMKICAgIEBkZWMKICAgIGdldCB4KCkgeyByZXR1cm4gMTsgfQoKICAgIEBkZWMKICAgIEBkZWMKICAgIHNldCB4KHZhbHVlOiBudW1iZXIpIHsgfQoKICAgIEBkZWMKICAgIEBkZWMKICAgIHkgPSAxOwoKICAgIEBkZWMKICAgIEBkZWMKICAgIGFjY2Vzc29yIHogPSAxOwoKICAgIEBkZWMKICAgIEBkZWMKICAgIHN0YXRpYyAjbWV0aG9kKCkge30KCiAgICBAZGVjCiAgICBAZGVjCiAgICBzdGF0aWMgZ2V0ICN4KCkgeyByZXR1cm4gMTsgfQoKICAgIEBkZWMKICAgIEBkZWMKICAgIHN0YXRpYyBzZXQgI3godmFsdWU6IG51bWJlcikgeyB9CgogICAgQGRlYwogICAgQGRlYwogICAgc3RhdGljICN5ID0gMTsKCiAgICBAZGVjCiAgICBAZGVjCiAgICBzdGF0aWMgYWNjZXNzb3IgI3ogPSAxOwp9Cg== +{"version":3,"file":"esDecorators-classDeclaration-sourceMap.js","sourceRoot":"","sources":["esDecorators-classDeclaration-sourceMap.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;IAIM,CAAC;;4BAFN,GAAG,EACH,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;YAgBA,MAAC,kGAAG,CAAC,GAAC;YAIG,2EAAI,CAAC,GAAC;QAqBnB,CAAC;QArCG,MAAM,KAAI,CAAC;QAIX,IAAI,CAAC,KAAK,OAAO,CAAC,CAAC,CAAC,CAAC;QAIrB,IAAI,CAAC,CAAC,KAAa,IAAI,CAAC;QAQxB,IAAS,CAAC,yEAAK;QAAf,IAAS,CAAC,8EAAK;;;;;;;;;;8BAlBd,GAAG,EACH,GAAG;6BAGH,GAAG,EACH,GAAG;6BAGH,GAAG,EACH,GAAG;yBAGH,GAAG,EACH,GAAG;yBAGH,GAAG,EACH,GAAG;6CAGH,GAAG,EACH,GAAG;4CAGH,GAAG,EACH,GAAG;4CAGH,GAAG,EACH,GAAG;wCAGH,GAAG,EACH,GAAG;wCAGH,GAAG,EACH,GAAG;QAfJ,+DAAA,yBAAA,cAAkB,CAAC,YAAA,kRAAA;QAInB,8DAAA,uBAAA,cAAkB,OAAO,CAAC,CAAC,CAAC,CAAC,cAAA,uQAAA;QAI7B,8DAAA,uBAAA,UAAc,KAAa,IAAI,CAAC,cAAA,4RAAA;QAQhC,0DAAA,uBAAA,kGAAuB,cAAA,EAAvB,uBAAA,uGAAuB,cAAA,wXAAA;QApCvB,2KAAA,MAAM,wCAAK;QAIX,gKAAI,CAAC,wCAAgB;QAIrB,2KAAI,CAAC,mDAAmB;QAQxB,8JAAS,CAAC,6BAAD,CAAC,8DAAK;QAgBf,kYAAc;QApBd,qJAAA,CAAC,6BAAD,CAAC,8DAAK;QAfV,wJAwCC;;QAxCK,wDAAC;;IAmCI,8EAAK,CAAC,GAAJ,CAAK;IAIE,+FAAK,CAAC,GAAJ,CAAK;;QAvCrB,uDAAC"} +//// https://sokra.github.io/source-map-visualization#base64,dmFyIF9fZXNEZWNvcmF0ZSA9ICh0aGlzICYmIHRoaXMuX19lc0RlY29yYXRlKSB8fCBmdW5jdGlvbiAoY3RvciwgZGVzY3JpcHRvckluLCBkZWNvcmF0b3JzLCBjb250ZXh0SW4sIGluaXRpYWxpemVycywgZXh0cmFJbml0aWFsaXplcnMpIHsNCiAgICBmdW5jdGlvbiBhY2NlcHQoZikgeyBpZiAoZiAhPT0gdm9pZCAwICYmIHR5cGVvZiBmICE9PSAiZnVuY3Rpb24iKSB0aHJvdyBuZXcgVHlwZUVycm9yKCJGdW5jdGlvbiBleHBlY3RlZCIpOyByZXR1cm4gZjsgfQ0KICAgIHZhciBraW5kID0gY29udGV4dEluLmtpbmQsIGtleSA9IGtpbmQgPT09ICJnZXR0ZXIiID8gImdldCIgOiBraW5kID09PSAic2V0dGVyIiA/ICJzZXQiIDogInZhbHVlIjsNCiAgICB2YXIgdGFyZ2V0ID0gIWRlc2NyaXB0b3JJbiAmJiBjdG9yID8gY29udGV4dEluWyJzdGF0aWMiXSA/IGN0b3IgOiBjdG9yLnByb3RvdHlwZSA6IG51bGw7DQogICAgdmFyIGRlc2NyaXB0b3IgPSBkZXNjcmlwdG9ySW4gfHwgKHRhcmdldCA/IE9iamVjdC5nZXRPd25Qcm9wZXJ0eURlc2NyaXB0b3IodGFyZ2V0LCBjb250ZXh0SW4ubmFtZSkgOiB7fSk7DQogICAgdmFyIF8sIGRvbmUgPSBmYWxzZTsNCiAgICBmb3IgKHZhciBpID0gZGVjb3JhdG9ycy5sZW5ndGggLSAxOyBpID49IDA7IGktLSkgew0KICAgICAgICB2YXIgY29udGV4dCA9IHt9Ow0KICAgICAgICBmb3IgKHZhciBwIGluIGNvbnRleHRJbikgY29udGV4dFtwXSA9IHAgPT09ICJhY2Nlc3MiID8ge30gOiBjb250ZXh0SW5bcF07DQogICAgICAgIGZvciAodmFyIHAgaW4gY29udGV4dEluLmFjY2VzcykgY29udGV4dC5hY2Nlc3NbcF0gPSBjb250ZXh0SW4uYWNjZXNzW3BdOw0KICAgICAgICBjb250ZXh0LmFkZEluaXRpYWxpemVyID0gZnVuY3Rpb24gKGYpIHsgaWYgKGRvbmUpIHRocm93IG5ldyBUeXBlRXJyb3IoIkNhbm5vdCBhZGQgaW5pdGlhbGl6ZXJzIGFmdGVyIGRlY29yYXRpb24gaGFzIGNvbXBsZXRlZCIpOyBleHRyYUluaXRpYWxpemVycy5wdXNoKGFjY2VwdChmIHx8IG51bGwpKTsgfTsNCiAgICAgICAgdmFyIHJlc3VsdCA9ICgwLCBkZWNvcmF0b3JzW2ldKShraW5kID09PSAiYWNjZXNzb3IiID8geyBnZXQ6IGRlc2NyaXB0b3IuZ2V0LCBzZXQ6IGRlc2NyaXB0b3Iuc2V0IH0gOiBkZXNjcmlwdG9yW2tleV0sIGNvbnRleHQpOw0KICAgICAgICBpZiAoa2luZCA9PT0gImFjY2Vzc29yIikgew0KICAgICAgICAgICAgaWYgKHJlc3VsdCA9PT0gdm9pZCAwKSBjb250aW51ZTsNCiAgICAgICAgICAgIGlmIChyZXN1bHQgPT09IG51bGwgfHwgdHlwZW9mIHJlc3VsdCAhPT0gIm9iamVjdCIpIHRocm93IG5ldyBUeXBlRXJyb3IoIk9iamVjdCBleHBlY3RlZCIpOw0KICAgICAgICAgICAgaWYgKF8gPSBhY2NlcHQocmVzdWx0LmdldCkpIGRlc2NyaXB0b3IuZ2V0ID0gXzsNCiAgICAgICAgICAgIGlmIChfID0gYWNjZXB0KHJlc3VsdC5zZXQpKSBkZXNjcmlwdG9yLnNldCA9IF87DQogICAgICAgICAgICBpZiAoXyA9IGFjY2VwdChyZXN1bHQuaW5pdCkpIGluaXRpYWxpemVycy51bnNoaWZ0KF8pOw0KICAgICAgICB9DQogICAgICAgIGVsc2UgaWYgKF8gPSBhY2NlcHQocmVzdWx0KSkgew0KICAgICAgICAgICAgaWYgKGtpbmQgPT09ICJmaWVsZCIpIGluaXRpYWxpemVycy51bnNoaWZ0KF8pOw0KICAgICAgICAgICAgZWxzZSBkZXNjcmlwdG9yW2tleV0gPSBfOw0KICAgICAgICB9DQogICAgfQ0KICAgIGlmICh0YXJnZXQpIE9iamVjdC5kZWZpbmVQcm9wZXJ0eSh0YXJnZXQsIGNvbnRleHRJbi5uYW1lLCBkZXNjcmlwdG9yKTsNCiAgICBkb25lID0gdHJ1ZTsNCn07DQp2YXIgX19ydW5Jbml0aWFsaXplcnMgPSAodGhpcyAmJiB0aGlzLl9fcnVuSW5pdGlhbGl6ZXJzKSB8fCBmdW5jdGlvbiAodGhpc0FyZywgaW5pdGlhbGl6ZXJzLCB2YWx1ZSkgew0KICAgIHZhciB1c2VWYWx1ZSA9IGFyZ3VtZW50cy5sZW5ndGggPiAyOw0KICAgIGZvciAodmFyIGkgPSAwOyBpIDwgaW5pdGlhbGl6ZXJzLmxlbmd0aDsgaSsrKSB7DQogICAgICAgIHZhbHVlID0gdXNlVmFsdWUgPyBpbml0aWFsaXplcnNbaV0uY2FsbCh0aGlzQXJnLCB2YWx1ZSkgOiBpbml0aWFsaXplcnNbaV0uY2FsbCh0aGlzQXJnKTsNCiAgICB9DQogICAgcmV0dXJuIHVzZVZhbHVlID8gdmFsdWUgOiB2b2lkIDA7DQp9Ow0KdmFyIF9fc2V0RnVuY3Rpb25OYW1lID0gKHRoaXMgJiYgdGhpcy5fX3NldEZ1bmN0aW9uTmFtZSkgfHwgZnVuY3Rpb24gKGYsIG5hbWUsIHByZWZpeCkgew0KICAgIGlmICh0eXBlb2YgbmFtZSA9PT0gInN5bWJvbCIpIG5hbWUgPSBuYW1lLmRlc2NyaXB0aW9uID8gIlsiLmNvbmNhdChuYW1lLmRlc2NyaXB0aW9uLCAiXSIpIDogIiI7DQogICAgcmV0dXJuIE9iamVjdC5kZWZpbmVQcm9wZXJ0eShmLCAibmFtZSIsIHsgY29uZmlndXJhYmxlOiB0cnVlLCB2YWx1ZTogcHJlZml4ID8gIiIuY29uY2F0KHByZWZpeCwgIiAiLCBuYW1lKSA6IG5hbWUgfSk7DQp9Ow0KdmFyIF9fY2xhc3NQcml2YXRlRmllbGRHZXQgPSAodGhpcyAmJiB0aGlzLl9fY2xhc3NQcml2YXRlRmllbGRHZXQpIHx8IGZ1bmN0aW9uIChyZWNlaXZlciwgc3RhdGUsIGtpbmQsIGYpIHsNCiAgICBpZiAoa2luZCA9PT0gImEiICYmICFmKSB0aHJvdyBuZXcgVHlwZUVycm9yKCJQcml2YXRlIGFjY2Vzc29yIHdhcyBkZWZpbmVkIHdpdGhvdXQgYSBnZXR0ZXIiKTsNCiAgICBpZiAodHlwZW9mIHN0YXRlID09PSAiZnVuY3Rpb24iID8gcmVjZWl2ZXIgIT09IHN0YXRlIHx8ICFmIDogIXN0YXRlLmhhcyhyZWNlaXZlcikpIHRocm93IG5ldyBUeXBlRXJyb3IoIkNhbm5vdCByZWFkIHByaXZhdGUgbWVtYmVyIGZyb20gYW4gb2JqZWN0IHdob3NlIGNsYXNzIGRpZCBub3QgZGVjbGFyZSBpdCIpOw0KICAgIHJldHVybiBraW5kID09PSAibSIgPyBmIDoga2luZCA9PT0gImEiID8gZi5jYWxsKHJlY2VpdmVyKSA6IGYgPyBmLnZhbHVlIDogc3RhdGUuZ2V0KHJlY2VpdmVyKTsNCn07DQp2YXIgX19jbGFzc1ByaXZhdGVGaWVsZFNldCA9ICh0aGlzICYmIHRoaXMuX19jbGFzc1ByaXZhdGVGaWVsZFNldCkgfHwgZnVuY3Rpb24gKHJlY2VpdmVyLCBzdGF0ZSwgdmFsdWUsIGtpbmQsIGYpIHsNCiAgICBpZiAoa2luZCA9PT0gIm0iKSB0aHJvdyBuZXcgVHlwZUVycm9yKCJQcml2YXRlIG1ldGhvZCBpcyBub3Qgd3JpdGFibGUiKTsNCiAgICBpZiAoa2luZCA9PT0gImEiICYmICFmKSB0aHJvdyBuZXcgVHlwZUVycm9yKCJQcml2YXRlIGFjY2Vzc29yIHdhcyBkZWZpbmVkIHdpdGhvdXQgYSBzZXR0ZXIiKTsNCiAgICBpZiAodHlwZW9mIHN0YXRlID09PSAiZnVuY3Rpb24iID8gcmVjZWl2ZXIgIT09IHN0YXRlIHx8ICFmIDogIXN0YXRlLmhhcyhyZWNlaXZlcikpIHRocm93IG5ldyBUeXBlRXJyb3IoIkNhbm5vdCB3cml0ZSBwcml2YXRlIG1lbWJlciB0byBhbiBvYmplY3Qgd2hvc2UgY2xhc3MgZGlkIG5vdCBkZWNsYXJlIGl0Iik7DQogICAgcmV0dXJuIChraW5kID09PSAiYSIgPyBmLmNhbGwocmVjZWl2ZXIsIHZhbHVlKSA6IGYgPyBmLnZhbHVlID0gdmFsdWUgOiBzdGF0ZS5zZXQocmVjZWl2ZXIsIHZhbHVlKSksIHZhbHVlOw0KfTsNCnZhciBfX2NsYXNzUHJpdmF0ZUZpZWxkSW4gPSAodGhpcyAmJiB0aGlzLl9fY2xhc3NQcml2YXRlRmllbGRJbikgfHwgZnVuY3Rpb24oc3RhdGUsIHJlY2VpdmVyKSB7DQogICAgaWYgKHJlY2VpdmVyID09PSBudWxsIHx8ICh0eXBlb2YgcmVjZWl2ZXIgIT09ICJvYmplY3QiICYmIHR5cGVvZiByZWNlaXZlciAhPT0gImZ1bmN0aW9uIikpIHRocm93IG5ldyBUeXBlRXJyb3IoIkNhbm5vdCB1c2UgJ2luJyBvcGVyYXRvciBvbiBub24tb2JqZWN0Iik7DQogICAgcmV0dXJuIHR5cGVvZiBzdGF0ZSA9PT0gImZ1bmN0aW9uIiA/IHJlY2VpdmVyID09PSBzdGF0ZSA6IHN0YXRlLmhhcyhyZWNlaXZlcik7DQp9Ow0KbGV0IEMgPSAoKCkgPT4gew0KICAgIHZhciBfQ19tZXRob2RfZ2V0LCBfQ194X2dldCwgX0NfeF9zZXQsIF9DX3ksIF9DX3pfYWNjZXNzb3Jfc3RvcmFnZSwgX0Nfel9nZXQsIF9DX3pfc2V0LCBfQ196XzFfYWNjZXNzb3Jfc3RvcmFnZTsNCiAgICBsZXQgX2NsYXNzRGVjb3JhdG9ycyA9IFtkZWMsIGRlY107DQogICAgbGV0IF9jbGFzc0Rlc2NyaXB0b3I7DQogICAgbGV0IF9jbGFzc0V4dHJhSW5pdGlhbGl6ZXJzID0gW107DQogICAgbGV0IF9jbGFzc1RoaXM7DQogICAgbGV0IF9zdGF0aWNFeHRyYUluaXRpYWxpemVycyA9IFtdOw0KICAgIGxldCBfaW5zdGFuY2VFeHRyYUluaXRpYWxpemVycyA9IFtdOw0KICAgIGxldCBfc3RhdGljX3ByaXZhdGVfbWV0aG9kX2RlY29yYXRvcnM7DQogICAgbGV0IF9zdGF0aWNfcHJpdmF0ZV9tZXRob2RfZGVzY3JpcHRvcjsNCiAgICBsZXQgX3N0YXRpY19wcml2YXRlX2dldF94X2RlY29yYXRvcnM7DQogICAgbGV0IF9zdGF0aWNfcHJpdmF0ZV9nZXRfeF9kZXNjcmlwdG9yOw0KICAgIGxldCBfc3RhdGljX3ByaXZhdGVfc2V0X3hfZGVjb3JhdG9yczsNCiAgICBsZXQgX3N0YXRpY19wcml2YXRlX3NldF94X2Rlc2NyaXB0b3I7DQogICAgbGV0IF9zdGF0aWNfcHJpdmF0ZV95X2RlY29yYXRvcnM7DQogICAgbGV0IF9zdGF0aWNfcHJpdmF0ZV95X2luaXRpYWxpemVycyA9IFtdOw0KICAgIGxldCBfc3RhdGljX3ByaXZhdGVfel9kZWNvcmF0b3JzOw0KICAgIGxldCBfc3RhdGljX3ByaXZhdGVfel9pbml0aWFsaXplcnMgPSBbXTsNCiAgICBsZXQgX3N0YXRpY19wcml2YXRlX3pfZGVzY3JpcHRvcjsNCiAgICBsZXQgX21ldGhvZF9kZWNvcmF0b3JzOw0KICAgIGxldCBfZ2V0X3hfZGVjb3JhdG9yczsNCiAgICBsZXQgX3NldF94X2RlY29yYXRvcnM7DQogICAgbGV0IF95X2RlY29yYXRvcnM7DQogICAgbGV0IF95X2luaXRpYWxpemVycyA9IFtdOw0KICAgIGxldCBfel9kZWNvcmF0b3JzOw0KICAgIGxldCBfel9pbml0aWFsaXplcnMgPSBbXTsNCiAgICB2YXIgQyA9IF9jbGFzc1RoaXMgPSBjbGFzcyB7DQogICAgICAgIGNvbnN0cnVjdG9yKCkgew0KICAgICAgICAgICAgdGhpcy55ID0gKF9fcnVuSW5pdGlhbGl6ZXJzKHRoaXMsIF9pbnN0YW5jZUV4dHJhSW5pdGlhbGl6ZXJzKSwgX19ydW5Jbml0aWFsaXplcnModGhpcywgX3lfaW5pdGlhbGl6ZXJzLCAxKSk7DQogICAgICAgICAgICBfQ196XzFfYWNjZXNzb3Jfc3RvcmFnZS5zZXQodGhpcywgX19ydW5Jbml0aWFsaXplcnModGhpcywgX3pfaW5pdGlhbGl6ZXJzLCAxKSk7DQogICAgICAgIH0NCiAgICAgICAgbWV0aG9kKCkgeyB9DQogICAgICAgIGdldCB4KCkgeyByZXR1cm4gMTsgfQ0KICAgICAgICBzZXQgeCh2YWx1ZSkgeyB9DQogICAgICAgIGdldCB6KCkgeyByZXR1cm4gX19jbGFzc1ByaXZhdGVGaWVsZEdldCh0aGlzLCBfQ196XzFfYWNjZXNzb3Jfc3RvcmFnZSwgImYiKTsgfQ0KICAgICAgICBzZXQgeih2YWx1ZSkgeyBfX2NsYXNzUHJpdmF0ZUZpZWxkU2V0KHRoaXMsIF9DX3pfMV9hY2Nlc3Nvcl9zdG9yYWdlLCB2YWx1ZSwgImYiKTsgfQ0KICAgIH07DQogICAgX0Nfel8xX2FjY2Vzc29yX3N0b3JhZ2UgPSBuZXcgV2Vha01hcCgpOw0KICAgIF9DX21ldGhvZF9nZXQgPSBmdW5jdGlvbiBfQ19tZXRob2RfZ2V0KCkgeyByZXR1cm4gX3N0YXRpY19wcml2YXRlX21ldGhvZF9kZXNjcmlwdG9yLnZhbHVlOyB9Ow0KICAgIF9DX3hfZ2V0ID0gZnVuY3Rpb24gX0NfeF9nZXQoKSB7IHJldHVybiBfc3RhdGljX3ByaXZhdGVfZ2V0X3hfZGVzY3JpcHRvci5nZXQuY2FsbCh0aGlzKTsgfTsNCiAgICBfQ194X3NldCA9IGZ1bmN0aW9uIF9DX3hfc2V0KHZhbHVlKSB7IHJldHVybiBfc3RhdGljX3ByaXZhdGVfc2V0X3hfZGVzY3JpcHRvci5zZXQuY2FsbCh0aGlzLCB2YWx1ZSk7IH07DQogICAgX0Nfel9nZXQgPSBmdW5jdGlvbiBfQ196X2dldCgpIHsgcmV0dXJuIF9zdGF0aWNfcHJpdmF0ZV96X2Rlc2NyaXB0b3IuZ2V0LmNhbGwodGhpcyk7IH07DQogICAgX0Nfel9zZXQgPSBmdW5jdGlvbiBfQ196X3NldCh2YWx1ZSkgeyByZXR1cm4gX3N0YXRpY19wcml2YXRlX3pfZGVzY3JpcHRvci5zZXQuY2FsbCh0aGlzLCB2YWx1ZSk7IH07DQogICAgX19zZXRGdW5jdGlvbk5hbWUoX2NsYXNzVGhpcywgIkMiKTsNCiAgICAoKCkgPT4gew0KICAgICAgICBfbWV0aG9kX2RlY29yYXRvcnMgPSBbZGVjLCBkZWNdOw0KICAgICAgICBfZ2V0X3hfZGVjb3JhdG9ycyA9IFtkZWMsIGRlY107DQogICAgICAgIF9zZXRfeF9kZWNvcmF0b3JzID0gW2RlYywgZGVjXTsNCiAgICAgICAgX3lfZGVjb3JhdG9ycyA9IFtkZWMsIGRlY107DQogICAgICAgIF96X2RlY29yYXRvcnMgPSBbZGVjLCBkZWNdOw0KICAgICAgICBfc3RhdGljX3ByaXZhdGVfbWV0aG9kX2RlY29yYXRvcnMgPSBbZGVjLCBkZWNdOw0KICAgICAgICBfc3RhdGljX3ByaXZhdGVfZ2V0X3hfZGVjb3JhdG9ycyA9IFtkZWMsIGRlY107DQogICAgICAgIF9zdGF0aWNfcHJpdmF0ZV9zZXRfeF9kZWNvcmF0b3JzID0gW2RlYywgZGVjXTsNCiAgICAgICAgX3N0YXRpY19wcml2YXRlX3lfZGVjb3JhdG9ycyA9IFtkZWMsIGRlY107DQogICAgICAgIF9zdGF0aWNfcHJpdmF0ZV96X2RlY29yYXRvcnMgPSBbZGVjLCBkZWNdOw0KICAgICAgICBfX2VzRGVjb3JhdGUoX2NsYXNzVGhpcywgX3N0YXRpY19wcml2YXRlX21ldGhvZF9kZXNjcmlwdG9yID0geyB2YWx1ZTogX19zZXRGdW5jdGlvbk5hbWUoZnVuY3Rpb24gKCkgeyB9LCAiI21ldGhvZCIpIH0sIF9zdGF0aWNfcHJpdmF0ZV9tZXRob2RfZGVjb3JhdG9ycywgeyBraW5kOiAibWV0aG9kIiwgbmFtZTogIiNtZXRob2QiLCBzdGF0aWM6IHRydWUsIHByaXZhdGU6IHRydWUsIGFjY2VzczogeyBoYXM6IG9iaiA9PiBfX2NsYXNzUHJpdmF0ZUZpZWxkSW4oX2NsYXNzVGhpcywgb2JqKSwgZ2V0OiBvYmogPT4gX19jbGFzc1ByaXZhdGVGaWVsZEdldChvYmosIF9jbGFzc1RoaXMsICJhIiwgX0NfbWV0aG9kX2dldCkgfSB9LCBudWxsLCBfc3RhdGljRXh0cmFJbml0aWFsaXplcnMpOw0KICAgICAgICBfX2VzRGVjb3JhdGUoX2NsYXNzVGhpcywgX3N0YXRpY19wcml2YXRlX2dldF94X2Rlc2NyaXB0b3IgPSB7IGdldDogX19zZXRGdW5jdGlvbk5hbWUoZnVuY3Rpb24gKCkgeyByZXR1cm4gMTsgfSwgIiN4IiwgImdldCIpIH0sIF9zdGF0aWNfcHJpdmF0ZV9nZXRfeF9kZWNvcmF0b3JzLCB7IGtpbmQ6ICJnZXR0ZXIiLCBuYW1lOiAiI3giLCBzdGF0aWM6IHRydWUsIHByaXZhdGU6IHRydWUsIGFjY2VzczogeyBoYXM6IG9iaiA9PiBfX2NsYXNzUHJpdmF0ZUZpZWxkSW4oX2NsYXNzVGhpcywgb2JqKSwgZ2V0OiBvYmogPT4gX19jbGFzc1ByaXZhdGVGaWVsZEdldChvYmosIF9jbGFzc1RoaXMsICJhIiwgX0NfeF9nZXQpIH0gfSwgbnVsbCwgX3N0YXRpY0V4dHJhSW5pdGlhbGl6ZXJzKTsNCiAgICAgICAgX19lc0RlY29yYXRlKF9jbGFzc1RoaXMsIF9zdGF0aWNfcHJpdmF0ZV9zZXRfeF9kZXNjcmlwdG9yID0geyBzZXQ6IF9fc2V0RnVuY3Rpb25OYW1lKGZ1bmN0aW9uICh2YWx1ZSkgeyB9LCAiI3giLCAic2V0IikgfSwgX3N0YXRpY19wcml2YXRlX3NldF94X2RlY29yYXRvcnMsIHsga2luZDogInNldHRlciIsIG5hbWU6ICIjeCIsIHN0YXRpYzogdHJ1ZSwgcHJpdmF0ZTogdHJ1ZSwgYWNjZXNzOiB7IGhhczogb2JqID0+IF9fY2xhc3NQcml2YXRlRmllbGRJbihfY2xhc3NUaGlzLCBvYmopLCBzZXQ6IChvYmosIHZhbHVlKSA9PiB7IF9fY2xhc3NQcml2YXRlRmllbGRTZXQob2JqLCBfY2xhc3NUaGlzLCB2YWx1ZSwgImEiLCBfQ194X3NldCk7IH0gfSB9LCBudWxsLCBfc3RhdGljRXh0cmFJbml0aWFsaXplcnMpOw0KICAgICAgICBfX2VzRGVjb3JhdGUoX2NsYXNzVGhpcywgX3N0YXRpY19wcml2YXRlX3pfZGVzY3JpcHRvciA9IHsgZ2V0OiBfX3NldEZ1bmN0aW9uTmFtZShmdW5jdGlvbiAoKSB7IHJldHVybiBfX2NsYXNzUHJpdmF0ZUZpZWxkR2V0KF9jbGFzc1RoaXMsIF9jbGFzc1RoaXMsICJmIiwgX0Nfel9hY2Nlc3Nvcl9zdG9yYWdlKTsgfSwgIiN6IiwgImdldCIpLCBzZXQ6IF9fc2V0RnVuY3Rpb25OYW1lKGZ1bmN0aW9uICh2YWx1ZSkgeyBfX2NsYXNzUHJpdmF0ZUZpZWxkU2V0KF9jbGFzc1RoaXMsIF9jbGFzc1RoaXMsIHZhbHVlLCAiZiIsIF9DX3pfYWNjZXNzb3Jfc3RvcmFnZSk7IH0sICIjeiIsICJzZXQiKSB9LCBfc3RhdGljX3ByaXZhdGVfel9kZWNvcmF0b3JzLCB7IGtpbmQ6ICJhY2Nlc3NvciIsIG5hbWU6ICIjeiIsIHN0YXRpYzogdHJ1ZSwgcHJpdmF0ZTogdHJ1ZSwgYWNjZXNzOiB7IGhhczogb2JqID0+IF9fY2xhc3NQcml2YXRlRmllbGRJbihfY2xhc3NUaGlzLCBvYmopLCBnZXQ6IG9iaiA9PiBfX2NsYXNzUHJpdmF0ZUZpZWxkR2V0KG9iaiwgX2NsYXNzVGhpcywgImEiLCBfQ196X2dldCksIHNldDogKG9iaiwgdmFsdWUpID0+IHsgX19jbGFzc1ByaXZhdGVGaWVsZFNldChvYmosIF9jbGFzc1RoaXMsIHZhbHVlLCAiYSIsIF9DX3pfc2V0KTsgfSB9IH0sIF9zdGF0aWNfcHJpdmF0ZV96X2luaXRpYWxpemVycywgX3N0YXRpY0V4dHJhSW5pdGlhbGl6ZXJzKTsNCiAgICAgICAgX19lc0RlY29yYXRlKF9jbGFzc1RoaXMsIG51bGwsIF9tZXRob2RfZGVjb3JhdG9ycywgeyBraW5kOiAibWV0aG9kIiwgbmFtZTogIm1ldGhvZCIsIHN0YXRpYzogZmFsc2UsIHByaXZhdGU6IGZhbHNlLCBhY2Nlc3M6IHsgaGFzOiBvYmogPT4gIm1ldGhvZCIgaW4gb2JqLCBnZXQ6IG9iaiA9PiBvYmoubWV0aG9kIH0gfSwgbnVsbCwgX2luc3RhbmNlRXh0cmFJbml0aWFsaXplcnMpOw0KICAgICAgICBfX2VzRGVjb3JhdGUoX2NsYXNzVGhpcywgbnVsbCwgX2dldF94X2RlY29yYXRvcnMsIHsga2luZDogImdldHRlciIsIG5hbWU6ICJ4Iiwgc3RhdGljOiBmYWxzZSwgcHJpdmF0ZTogZmFsc2UsIGFjY2VzczogeyBoYXM6IG9iaiA9PiAieCIgaW4gb2JqLCBnZXQ6IG9iaiA9PiBvYmoueCB9IH0sIG51bGwsIF9pbnN0YW5jZUV4dHJhSW5pdGlhbGl6ZXJzKTsNCiAgICAgICAgX19lc0RlY29yYXRlKF9jbGFzc1RoaXMsIG51bGwsIF9zZXRfeF9kZWNvcmF0b3JzLCB7IGtpbmQ6ICJzZXR0ZXIiLCBuYW1lOiAieCIsIHN0YXRpYzogZmFsc2UsIHByaXZhdGU6IGZhbHNlLCBhY2Nlc3M6IHsgaGFzOiBvYmogPT4gIngiIGluIG9iaiwgc2V0OiAob2JqLCB2YWx1ZSkgPT4geyBvYmoueCA9IHZhbHVlOyB9IH0gfSwgbnVsbCwgX2luc3RhbmNlRXh0cmFJbml0aWFsaXplcnMpOw0KICAgICAgICBfX2VzRGVjb3JhdGUoX2NsYXNzVGhpcywgbnVsbCwgX3pfZGVjb3JhdG9ycywgeyBraW5kOiAiYWNjZXNzb3IiLCBuYW1lOiAieiIsIHN0YXRpYzogZmFsc2UsIHByaXZhdGU6IGZhbHNlLCBhY2Nlc3M6IHsgaGFzOiBvYmogPT4gInoiIGluIG9iaiwgZ2V0OiBvYmogPT4gb2JqLnosIHNldDogKG9iaiwgdmFsdWUpID0+IHsgb2JqLnogPSB2YWx1ZTsgfSB9IH0sIF96X2luaXRpYWxpemVycywgX2luc3RhbmNlRXh0cmFJbml0aWFsaXplcnMpOw0KICAgICAgICBfX2VzRGVjb3JhdGUobnVsbCwgbnVsbCwgX3N0YXRpY19wcml2YXRlX3lfZGVjb3JhdG9ycywgeyBraW5kOiAiZmllbGQiLCBuYW1lOiAiI3kiLCBzdGF0aWM6IHRydWUsIHByaXZhdGU6IHRydWUsIGFjY2VzczogeyBoYXM6IG9iaiA9PiBfX2NsYXNzUHJpdmF0ZUZpZWxkSW4oX2NsYXNzVGhpcywgb2JqKSwgZ2V0OiBvYmogPT4gX19jbGFzc1ByaXZhdGVGaWVsZEdldChvYmosIF9jbGFzc1RoaXMsICJmIiwgX0NfeSksIHNldDogKG9iaiwgdmFsdWUpID0+IHsgX19jbGFzc1ByaXZhdGVGaWVsZFNldChvYmosIF9jbGFzc1RoaXMsIHZhbHVlLCAiZiIsIF9DX3kpOyB9IH0gfSwgX3N0YXRpY19wcml2YXRlX3lfaW5pdGlhbGl6ZXJzLCBfc3RhdGljRXh0cmFJbml0aWFsaXplcnMpOw0KICAgICAgICBfX2VzRGVjb3JhdGUobnVsbCwgbnVsbCwgX3lfZGVjb3JhdG9ycywgeyBraW5kOiAiZmllbGQiLCBuYW1lOiAieSIsIHN0YXRpYzogZmFsc2UsIHByaXZhdGU6IGZhbHNlLCBhY2Nlc3M6IHsgaGFzOiBvYmogPT4gInkiIGluIG9iaiwgZ2V0OiBvYmogPT4gb2JqLnksIHNldDogKG9iaiwgdmFsdWUpID0+IHsgb2JqLnkgPSB2YWx1ZTsgfSB9IH0sIF95X2luaXRpYWxpemVycywgX2luc3RhbmNlRXh0cmFJbml0aWFsaXplcnMpOw0KICAgICAgICBfX2VzRGVjb3JhdGUobnVsbCwgX2NsYXNzRGVzY3JpcHRvciA9IHsgdmFsdWU6IF9jbGFzc1RoaXMgfSwgX2NsYXNzRGVjb3JhdG9ycywgeyBraW5kOiAiY2xhc3MiLCBuYW1lOiBfY2xhc3NUaGlzLm5hbWUgfSwgbnVsbCwgX2NsYXNzRXh0cmFJbml0aWFsaXplcnMpOw0KICAgICAgICBDID0gX2NsYXNzVGhpcyA9IF9jbGFzc0Rlc2NyaXB0b3IudmFsdWU7DQogICAgICAgIF9fcnVuSW5pdGlhbGl6ZXJzKF9jbGFzc1RoaXMsIF9zdGF0aWNFeHRyYUluaXRpYWxpemVycyk7DQogICAgfSkoKTsNCiAgICBfQ195ID0geyB2YWx1ZTogX19ydW5Jbml0aWFsaXplcnMoX2NsYXNzVGhpcywgX3N0YXRpY19wcml2YXRlX3lfaW5pdGlhbGl6ZXJzLCAxKSB9Ow0KICAgIF9DX3pfYWNjZXNzb3Jfc3RvcmFnZSA9IHsgdmFsdWU6IF9fcnVuSW5pdGlhbGl6ZXJzKF9jbGFzc1RoaXMsIF9zdGF0aWNfcHJpdmF0ZV96X2luaXRpYWxpemVycywgMSkgfTsNCiAgICAoKCkgPT4gew0KICAgICAgICBfX3J1bkluaXRpYWxpemVycyhfY2xhc3NUaGlzLCBfY2xhc3NFeHRyYUluaXRpYWxpemVycyk7DQogICAgfSkoKTsNCiAgICByZXR1cm4gQyA9IF9jbGFzc1RoaXM7DQp9KSgpOw0KLy8jIHNvdXJjZU1hcHBpbmdVUkw9ZXNEZWNvcmF0b3JzLWNsYXNzRGVjbGFyYXRpb24tc291cmNlTWFwLmpzLm1hcA==,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiZXNEZWNvcmF0b3JzLWNsYXNzRGVjbGFyYXRpb24tc291cmNlTWFwLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiZXNEZWNvcmF0b3JzLWNsYXNzRGVjbGFyYXRpb24tc291cmNlTWFwLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7O0lBSU0sQ0FBQzs7NEJBRk4sR0FBRyxFQUNILEdBQUc7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7O1lBZ0JBLE1BQUMsa0dBQUcsQ0FBQyxHQUFDO1lBSUcsMkVBQUksQ0FBQyxHQUFDO1FBcUJuQixDQUFDO1FBckNHLE1BQU0sS0FBSSxDQUFDO1FBSVgsSUFBSSxDQUFDLEtBQUssT0FBTyxDQUFDLENBQUMsQ0FBQyxDQUFDO1FBSXJCLElBQUksQ0FBQyxDQUFDLEtBQWEsSUFBSSxDQUFDO1FBUXhCLElBQVMsQ0FBQyx5RUFBSztRQUFmLElBQVMsQ0FBQyw4RUFBSzs7Ozs7Ozs7Ozs4QkFsQmQsR0FBRyxFQUNILEdBQUc7NkJBR0gsR0FBRyxFQUNILEdBQUc7NkJBR0gsR0FBRyxFQUNILEdBQUc7eUJBR0gsR0FBRyxFQUNILEdBQUc7eUJBR0gsR0FBRyxFQUNILEdBQUc7NkNBR0gsR0FBRyxFQUNILEdBQUc7NENBR0gsR0FBRyxFQUNILEdBQUc7NENBR0gsR0FBRyxFQUNILEdBQUc7d0NBR0gsR0FBRyxFQUNILEdBQUc7d0NBR0gsR0FBRyxFQUNILEdBQUc7UUFmSiwrREFBQSx5QkFBQSxjQUFrQixDQUFDLFlBQUEsa1JBQUE7UUFJbkIsOERBQUEsdUJBQUEsY0FBa0IsT0FBTyxDQUFDLENBQUMsQ0FBQyxDQUFDLGNBQUEsdVFBQUE7UUFJN0IsOERBQUEsdUJBQUEsVUFBYyxLQUFhLElBQUksQ0FBQyxjQUFBLDRSQUFBO1FBUWhDLDBEQUFBLHVCQUFBLGtHQUF1QixjQUFBLEVBQXZCLHVCQUFBLHVHQUF1QixjQUFBLHdYQUFBO1FBcEN2QiwyS0FBQSxNQUFNLHdDQUFLO1FBSVgsZ0tBQUksQ0FBQyx3Q0FBZ0I7UUFJckIsMktBQUksQ0FBQyxtREFBbUI7UUFReEIsOEpBQVMsQ0FBQyw2QkFBRCxDQUFDLDhEQUFLO1FBZ0JmLGtZQUFjO1FBcEJkLHFKQUFBLENBQUMsNkJBQUQsQ0FBQyw4REFBSztRQWZWLHdKQXdDQzs7UUF4Q0ssd0RBQUM7O0lBbUNJLDhFQUFLLENBQUMsR0FBSixDQUFLO0lBSUUsK0ZBQUssQ0FBQyxHQUFKLENBQUs7O1FBdkNyQix1REFBQyJ9,ZGVjbGFyZSB2YXIgZGVjOiBhbnk7CgpAZGVjCkBkZWMKY2xhc3MgQyB7CiAgICBAZGVjCiAgICBAZGVjCiAgICBtZXRob2QoKSB7fQoKICAgIEBkZWMKICAgIEBkZWMKICAgIGdldCB4KCkgeyByZXR1cm4gMTsgfQoKICAgIEBkZWMKICAgIEBkZWMKICAgIHNldCB4KHZhbHVlOiBudW1iZXIpIHsgfQoKICAgIEBkZWMKICAgIEBkZWMKICAgIHkgPSAxOwoKICAgIEBkZWMKICAgIEBkZWMKICAgIGFjY2Vzc29yIHogPSAxOwoKICAgIEBkZWMKICAgIEBkZWMKICAgIHN0YXRpYyAjbWV0aG9kKCkge30KCiAgICBAZGVjCiAgICBAZGVjCiAgICBzdGF0aWMgZ2V0ICN4KCkgeyByZXR1cm4gMTsgfQoKICAgIEBkZWMKICAgIEBkZWMKICAgIHN0YXRpYyBzZXQgI3godmFsdWU6IG51bWJlcikgeyB9CgogICAgQGRlYwogICAgQGRlYwogICAgc3RhdGljICN5ID0gMTsKCiAgICBAZGVjCiAgICBAZGVjCiAgICBzdGF0aWMgYWNjZXNzb3IgI3ogPSAxOwp9Cg== //// [esDecorators-classDeclaration-sourceMap.d.ts.map] {"version":3,"file":"esDecorators-classDeclaration-sourceMap.d.ts","sourceRoot":"","sources":["esDecorators-classDeclaration-sourceMap.ts"],"names":[],"mappings":"AAAA,OAAO,CAAC,IAAI,GAAG,EAAE,GAAG,CAAC;AAErB,cAEM,CAAC;;IAGH,MAAM;IAEN,IAEI,CAAC,IAIQ,MAAM,CAJE;IAErB,IAEI,CAAC,CAAC,KAAK,EAAE,MAAM,EAAK;IAIxB,CAAC,SAAK;IAIN,QAAQ,CAAC,CAAC,SAAK;CAqBlB"} diff --git a/tests/baselines/reference/esDecorators-classDeclaration-sourceMap(target=es2015).sourcemap.txt b/tests/baselines/reference/esDecorators-classDeclaration-sourceMap(target=es2015).sourcemap.txt index 8598ca0a5dc6d..18c71aa823d8a 100644 --- a/tests/baselines/reference/esDecorators-classDeclaration-sourceMap(target=es2015).sourcemap.txt +++ b/tests/baselines/reference/esDecorators-classDeclaration-sourceMap(target=es2015).sourcemap.txt @@ -64,7 +64,7 @@ sourceFile:esDecorators-classDeclaration-sourceMap.ts >>>let C = (() => { 1 >^^^^ 2 > ^ -3 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> +3 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> 1 >declare var dec: any; > >@dec @@ -74,7 +74,7 @@ sourceFile:esDecorators-classDeclaration-sourceMap.ts 1 >Emitted(54, 5) Source(5, 7) + SourceIndex(0) 2 >Emitted(54, 6) Source(5, 8) + SourceIndex(0) --- ->>> var _method_get, _x_get, _x_set, _y, _z_accessor_storage, _z_get, _z_set, _z_1_accessor_storage; +>>> var _C_method_get, _C_x_get, _C_x_set, _C_y, _C_z_accessor_storage, _C_z_get, _C_z_set, _C_z_1_accessor_storage; >>> let _classDecorators = [dec, dec]; 1->^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 2 > ^^^ @@ -148,23 +148,23 @@ sourceFile:esDecorators-classDeclaration-sourceMap.ts 4 >Emitted(82, 118) Source(20, 10) + SourceIndex(0) 5 >Emitted(82, 121) Source(20, 11) + SourceIndex(0) --- ->>> _z_1_accessor_storage.set(this, __runInitializers(this, _z_initializers, 1)); +>>> _C_z_1_accessor_storage.set(this, __runInitializers(this, _z_initializers, 1)); 1 >^^^^^^^^^^^^ -2 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -3 > ^ -4 > ^^^ +2 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +3 > ^ +4 > ^^^ 1 > > > @dec > @dec > accessor 2 > z = -3 > 1 -4 > ; +3 > 1 +4 > ; 1 >Emitted(83, 13) Source(24, 14) + SourceIndex(0) -2 >Emitted(83, 86) Source(24, 18) + SourceIndex(0) -3 >Emitted(83, 87) Source(24, 19) + SourceIndex(0) -4 >Emitted(83, 90) Source(24, 20) + SourceIndex(0) +2 >Emitted(83, 88) Source(24, 18) + SourceIndex(0) +3 >Emitted(83, 89) Source(24, 19) + SourceIndex(0) +4 >Emitted(83, 92) Source(24, 20) + SourceIndex(0) --- >>> } 1 >^^^^^^^^ @@ -252,7 +252,7 @@ sourceFile:esDecorators-classDeclaration-sourceMap.ts 5 > ^^^^^ 6 > ^^^^ 7 > ^ -8 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> +8 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> 1 > > > @dec @@ -272,12 +272,12 @@ sourceFile:esDecorators-classDeclaration-sourceMap.ts 6 >Emitted(87, 24) Source(16, 28) + SourceIndex(0) 7 >Emitted(87, 25) Source(16, 29) + SourceIndex(0) --- ->>> get z() { return __classPrivateFieldGet(this, _z_1_accessor_storage, "f"); } +>>> get z() { return __classPrivateFieldGet(this, _C_z_1_accessor_storage, "f"); } 1->^^^^^^^^ 2 > ^^^^ 3 > ^ -4 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -5 > ^^^^^^-> +4 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +5 > ^^^^^^-> 1-> > > @dec @@ -293,13 +293,13 @@ sourceFile:esDecorators-classDeclaration-sourceMap.ts 1->Emitted(88, 9) Source(24, 5) + SourceIndex(0) 2 >Emitted(88, 13) Source(24, 14) + SourceIndex(0) 3 >Emitted(88, 14) Source(24, 15) + SourceIndex(0) -4 >Emitted(88, 85) Source(24, 20) + SourceIndex(0) +4 >Emitted(88, 87) Source(24, 20) + SourceIndex(0) --- ->>> set z(value) { __classPrivateFieldSet(this, _z_1_accessor_storage, value, "f"); } +>>> set z(value) { __classPrivateFieldSet(this, _C_z_1_accessor_storage, value, "f"); } 1->^^^^^^^^ 2 > ^^^^ 3 > ^ -4 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +4 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 1-> 2 > accessor 3 > z @@ -307,15 +307,15 @@ sourceFile:esDecorators-classDeclaration-sourceMap.ts 1->Emitted(89, 9) Source(24, 5) + SourceIndex(0) 2 >Emitted(89, 13) Source(24, 14) + SourceIndex(0) 3 >Emitted(89, 14) Source(24, 15) + SourceIndex(0) -4 >Emitted(89, 90) Source(24, 20) + SourceIndex(0) +4 >Emitted(89, 92) Source(24, 20) + SourceIndex(0) --- >>> }; ->>> _z_1_accessor_storage = new WeakMap(); ->>> _method_get = function _method_get() { return _static_private_method_descriptor.value; }; ->>> _x_get = function _x_get() { return _static_private_get_x_descriptor.get.call(this); }; ->>> _x_set = function _x_set(value) { return _static_private_set_x_descriptor.set.call(this, value); }; ->>> _z_get = function _z_get() { return _static_private_z_descriptor.get.call(this); }; ->>> _z_set = function _z_set(value) { return _static_private_z_descriptor.set.call(this, value); }; +>>> _C_z_1_accessor_storage = new WeakMap(); +>>> _C_method_get = function _C_method_get() { return _static_private_method_descriptor.value; }; +>>> _C_x_get = function _C_x_get() { return _static_private_get_x_descriptor.get.call(this); }; +>>> _C_x_set = function _C_x_set(value) { return _static_private_set_x_descriptor.set.call(this, value); }; +>>> _C_z_get = function _C_z_get() { return _static_private_z_descriptor.get.call(this); }; +>>> _C_z_set = function _C_z_set(value) { return _static_private_z_descriptor.set.call(this, value); }; >>> __setFunctionName(_classThis, "C"); >>> (() => { >>> _method_decorators = [dec, dec]; @@ -489,7 +489,7 @@ sourceFile:esDecorators-classDeclaration-sourceMap.ts 2 > ^^^ 3 > ^^ 4 > ^^^ -5 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> +5 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> 1-> > static #y = 1; > @@ -503,14 +503,14 @@ sourceFile:esDecorators-classDeclaration-sourceMap.ts 3 >Emitted(108, 46) Source(43, 6) + SourceIndex(0) 4 >Emitted(108, 49) Source(43, 9) + SourceIndex(0) --- ->>> __esDecorate(_classThis, _static_private_method_descriptor = { value: __setFunctionName(function () { }, "#method") }, _static_private_method_decorators, { kind: "method", name: "#method", static: true, private: true, access: { has: obj => __classPrivateFieldIn(_classThis, obj), get: obj => __classPrivateFieldGet(obj, _classThis, "a", _method_get) } }, null, _staticExtraInitializers); +>>> __esDecorate(_classThis, _static_private_method_descriptor = { value: __setFunctionName(function () { }, "#method") }, _static_private_method_decorators, { kind: "method", name: "#method", static: true, private: true, access: { has: obj => __classPrivateFieldIn(_classThis, obj), get: obj => __classPrivateFieldGet(obj, _classThis, "a", _C_method_get) } }, null, _staticExtraInitializers); 1->^^^^^^^^ 2 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 3 > ^^^^^^^^^^^^^^^^^^^^^^^^^ 4 > ^^^^^^^^^^^^^^ 5 > ^ 6 > ^^^^^^^^^^^^ -7 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +7 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 1-> 2 > 3 > @@ -524,9 +524,9 @@ sourceFile:esDecorators-classDeclaration-sourceMap.ts 4 >Emitted(109, 111) Source(28, 23) + SourceIndex(0) 5 >Emitted(109, 112) Source(28, 24) + SourceIndex(0) 6 >Emitted(109, 124) Source(28, 24) + SourceIndex(0) -7 >Emitted(109, 396) Source(28, 24) + SourceIndex(0) +7 >Emitted(109, 398) Source(28, 24) + SourceIndex(0) --- ->>> __esDecorate(_classThis, _static_private_get_x_descriptor = { get: __setFunctionName(function () { return 1; }, "#x", "get") }, _static_private_get_x_decorators, { kind: "getter", name: "#x", static: true, private: true, access: { has: obj => __classPrivateFieldIn(_classThis, obj), get: obj => __classPrivateFieldGet(obj, _classThis, "a", _x_get) } }, null, _staticExtraInitializers); +>>> __esDecorate(_classThis, _static_private_get_x_descriptor = { get: __setFunctionName(function () { return 1; }, "#x", "get") }, _static_private_get_x_decorators, { kind: "getter", name: "#x", static: true, private: true, access: { has: obj => __classPrivateFieldIn(_classThis, obj), get: obj => __classPrivateFieldGet(obj, _classThis, "a", _C_x_get) } }, null, _staticExtraInitializers); 1 >^^^^^^^^ 2 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 3 > ^^^^^^^^^^^^^^^^^^^^^^^ @@ -537,8 +537,8 @@ sourceFile:esDecorators-classDeclaration-sourceMap.ts 8 > ^ 9 > ^ 10> ^^^^^^^^^^^^^^ -11> ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -12> ^^^^^^^^^^^^^^^^^-> +11> ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +12> ^^^^^^^^^^^^^^^^^-> 1 > > > @dec @@ -564,9 +564,9 @@ sourceFile:esDecorators-classDeclaration-sourceMap.ts 8 >Emitted(110, 118) Source(32, 33) + SourceIndex(0) 9 >Emitted(110, 119) Source(32, 34) + SourceIndex(0) 10>Emitted(110, 133) Source(32, 34) + SourceIndex(0) -11>Emitted(110, 394) Source(32, 34) + SourceIndex(0) +11>Emitted(110, 396) Source(32, 34) + SourceIndex(0) --- ->>> __esDecorate(_classThis, _static_private_set_x_descriptor = { set: __setFunctionName(function (value) { }, "#x", "set") }, _static_private_set_x_decorators, { kind: "setter", name: "#x", static: true, private: true, access: { has: obj => __classPrivateFieldIn(_classThis, obj), set: (obj, value) => { __classPrivateFieldSet(obj, _classThis, value, "a", _x_set); } } }, null, _staticExtraInitializers); +>>> __esDecorate(_classThis, _static_private_set_x_descriptor = { set: __setFunctionName(function (value) { }, "#x", "set") }, _static_private_set_x_decorators, { kind: "setter", name: "#x", static: true, private: true, access: { has: obj => __classPrivateFieldIn(_classThis, obj), set: (obj, value) => { __classPrivateFieldSet(obj, _classThis, value, "a", _C_x_set); } } }, null, _staticExtraInitializers); 1->^^^^^^^^ 2 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 3 > ^^^^^^^^^^^^^^^^^^^^^^^ @@ -575,8 +575,8 @@ sourceFile:esDecorators-classDeclaration-sourceMap.ts 6 > ^^^^ 7 > ^ 8 > ^^^^^^^^^^^^^^ -9 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -10> ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> +9 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +10> ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> 1-> > > @dec @@ -598,19 +598,19 @@ sourceFile:esDecorators-classDeclaration-sourceMap.ts 6 >Emitted(111, 113) Source(36, 36) + SourceIndex(0) 7 >Emitted(111, 114) Source(36, 37) + SourceIndex(0) 8 >Emitted(111, 128) Source(36, 37) + SourceIndex(0) -9 >Emitted(111, 410) Source(36, 37) + SourceIndex(0) +9 >Emitted(111, 412) Source(36, 37) + SourceIndex(0) --- ->>> __esDecorate(_classThis, _static_private_z_descriptor = { get: __setFunctionName(function () { return __classPrivateFieldGet(_classThis, _classThis, "f", _z_accessor_storage); }, "#z", "get"), set: __setFunctionName(function (value) { __classPrivateFieldSet(_classThis, _classThis, value, "f", _z_accessor_storage); }, "#z", "set") }, _static_private_z_decorators, { kind: "accessor", name: "#z", static: true, private: true, access: { has: obj => __classPrivateFieldIn(_classThis, obj), get: obj => __classPrivateFieldGet(obj, _classThis, "a", _z_get), set: (obj, value) => { __classPrivateFieldSet(obj, _classThis, value, "a", _z_set); } } }, _static_private_z_initializers, _staticExtraInitializers); +>>> __esDecorate(_classThis, _static_private_z_descriptor = { get: __setFunctionName(function () { return __classPrivateFieldGet(_classThis, _classThis, "f", _C_z_accessor_storage); }, "#z", "get"), set: __setFunctionName(function (value) { __classPrivateFieldSet(_classThis, _classThis, value, "f", _C_z_accessor_storage); }, "#z", "set") }, _static_private_z_decorators, { kind: "accessor", name: "#z", static: true, private: true, access: { has: obj => __classPrivateFieldIn(_classThis, obj), get: obj => __classPrivateFieldGet(obj, _classThis, "a", _C_z_get), set: (obj, value) => { __classPrivateFieldSet(obj, _classThis, value, "a", _C_z_set); } } }, _static_private_z_initializers, _staticExtraInitializers); 1->^^^^^^^^ 2 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 3 > ^^^^^^^^^^^^^^^^^^^^^^^ -4 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -5 > ^^^^^^^^^^^^^^ -6 > ^^ -7 > ^^^^^^^^^^^^^^^^^^^^^^^ -8 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -9 > ^^^^^^^^^^^^^^ -10> ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +4 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +5 > ^^^^^^^^^^^^^^ +6 > ^^ +7 > ^^^^^^^^^^^^^^^^^^^^^^^ +8 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +9 > ^^^^^^^^^^^^^^ +10> ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 1-> > > @dec @@ -623,22 +623,22 @@ sourceFile:esDecorators-classDeclaration-sourceMap.ts 2 > 3 > 4 > static accessor #z = 1; -5 > -6 > -7 > -8 > static accessor #z = 1; -9 > -10> +5 > +6 > +7 > +8 > static accessor #z = 1; +9 > +10> 1->Emitted(112, 9) Source(44, 5) + SourceIndex(0) 2 >Emitted(112, 67) Source(44, 5) + SourceIndex(0) 3 >Emitted(112, 90) Source(44, 5) + SourceIndex(0) -4 >Emitted(112, 186) Source(44, 28) + SourceIndex(0) -5 >Emitted(112, 200) Source(44, 28) + SourceIndex(0) -6 >Emitted(112, 202) Source(44, 5) + SourceIndex(0) -7 >Emitted(112, 225) Source(44, 5) + SourceIndex(0) -8 >Emitted(112, 326) Source(44, 28) + SourceIndex(0) -9 >Emitted(112, 340) Source(44, 28) + SourceIndex(0) -10>Emitted(112, 712) Source(44, 28) + SourceIndex(0) +4 >Emitted(112, 188) Source(44, 28) + SourceIndex(0) +5 >Emitted(112, 202) Source(44, 28) + SourceIndex(0) +6 >Emitted(112, 204) Source(44, 5) + SourceIndex(0) +7 >Emitted(112, 227) Source(44, 5) + SourceIndex(0) +8 >Emitted(112, 330) Source(44, 28) + SourceIndex(0) +9 >Emitted(112, 344) Source(44, 28) + SourceIndex(0) +10>Emitted(112, 720) Source(44, 28) + SourceIndex(0) --- >>> __esDecorate(_classThis, null, _method_decorators, { kind: "method", name: "method", static: false, private: false, access: { has: obj => "method" in obj, get: obj => obj.method } }, null, _instanceExtraInitializers); 1 >^^^^^^^^ @@ -699,7 +699,7 @@ sourceFile:esDecorators-classDeclaration-sourceMap.ts 4 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 5 > ^ 6 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -7 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> +7 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> 1-> > > @dec @@ -721,9 +721,9 @@ sourceFile:esDecorators-classDeclaration-sourceMap.ts 5 >Emitted(116, 198) Source(24, 15) + SourceIndex(0) 6 >Emitted(116, 260) Source(24, 20) + SourceIndex(0) --- ->>> __esDecorate(null, null, _static_private_y_decorators, { kind: "field", name: "#y", static: true, private: true, access: { has: obj => __classPrivateFieldIn(_classThis, obj), get: obj => __classPrivateFieldGet(obj, _classThis, "f", _y), set: (obj, value) => { __classPrivateFieldSet(obj, _classThis, value, "f", _y); } } }, _static_private_y_initializers, _staticExtraInitializers); +>>> __esDecorate(null, null, _static_private_y_decorators, { kind: "field", name: "#y", static: true, private: true, access: { has: obj => __classPrivateFieldIn(_classThis, obj), get: obj => __classPrivateFieldGet(obj, _classThis, "f", _C_y), set: (obj, value) => { __classPrivateFieldSet(obj, _classThis, value, "f", _C_y); } } }, _static_private_y_initializers, _staticExtraInitializers); 1->^^^^^^^^ -2 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +2 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 1-> > > @dec @@ -743,7 +743,7 @@ sourceFile:esDecorators-classDeclaration-sourceMap.ts > 2 > static #y = 1; 1->Emitted(117, 9) Source(40, 5) + SourceIndex(0) -2 >Emitted(117, 391) Source(40, 19) + SourceIndex(0) +2 >Emitted(117, 395) Source(40, 19) + SourceIndex(0) --- >>> __esDecorate(null, null, _y_decorators, { kind: "field", name: "y", static: false, private: false, access: { has: obj => "y" in obj, get: obj => obj.y, set: (obj, value) => { obj.y = value; } } }, _y_initializers, _instanceExtraInitializers); 1 >^^^^^^^^ @@ -823,13 +823,13 @@ sourceFile:esDecorators-classDeclaration-sourceMap.ts 2 >Emitted(121, 65) Source(5, 8) + SourceIndex(0) --- >>> })(); ->>> _y = { value: __runInitializers(_classThis, _static_private_y_initializers, 1) }; +>>> _C_y = { value: __runInitializers(_classThis, _static_private_y_initializers, 1) }; 1 >^^^^ -2 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -3 > ^ -4 > ^^^ -5 > ^ -6 > ^^^^^^^^^^^^^^^^^^-> +2 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +3 > ^ +4 > ^^^ +5 > ^ +6 > ^^^^^^^^^^^^^^^^^^-> 1 > { > @dec > @dec @@ -867,35 +867,35 @@ sourceFile:esDecorators-classDeclaration-sourceMap.ts > @dec > static 2 > #y = -3 > 1 -4 > -5 > = 1; +3 > 1 +4 > +5 > = 1; 1 >Emitted(123, 5) Source(40, 12) + SourceIndex(0) -2 >Emitted(123, 81) Source(40, 17) + SourceIndex(0) -3 >Emitted(123, 82) Source(40, 18) + SourceIndex(0) -4 >Emitted(123, 85) Source(40, 14) + SourceIndex(0) -5 >Emitted(123, 86) Source(40, 19) + SourceIndex(0) +2 >Emitted(123, 83) Source(40, 17) + SourceIndex(0) +3 >Emitted(123, 84) Source(40, 18) + SourceIndex(0) +4 >Emitted(123, 87) Source(40, 14) + SourceIndex(0) +5 >Emitted(123, 88) Source(40, 19) + SourceIndex(0) --- ->>> _z_accessor_storage = { value: __runInitializers(_classThis, _static_private_z_initializers, 1) }; +>>> _C_z_accessor_storage = { value: __runInitializers(_classThis, _static_private_z_initializers, 1) }; 1->^^^^ -2 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -3 > ^ -4 > ^^^ -5 > ^ +2 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +3 > ^ +4 > ^^^ +5 > ^ 1-> > > @dec > @dec > static accessor 2 > #z = -3 > 1 -4 > -5 > = 1; +3 > 1 +4 > +5 > = 1; 1->Emitted(124, 5) Source(44, 21) + SourceIndex(0) -2 >Emitted(124, 98) Source(44, 26) + SourceIndex(0) -3 >Emitted(124, 99) Source(44, 27) + SourceIndex(0) -4 >Emitted(124, 102) Source(44, 23) + SourceIndex(0) -5 >Emitted(124, 103) Source(44, 28) + SourceIndex(0) +2 >Emitted(124, 100) Source(44, 26) + SourceIndex(0) +3 >Emitted(124, 101) Source(44, 27) + SourceIndex(0) +4 >Emitted(124, 104) Source(44, 23) + SourceIndex(0) +5 >Emitted(124, 105) Source(44, 28) + SourceIndex(0) --- >>> (() => { >>> __runInitializers(_classThis, _classExtraInitializers); diff --git a/tests/baselines/reference/esDecorators-classDeclaration-sourceMap(target=es2022).js b/tests/baselines/reference/esDecorators-classDeclaration-sourceMap(target=es2022).js index 9926b4f5bd491..4f43dcb467dca 100644 --- a/tests/baselines/reference/esDecorators-classDeclaration-sourceMap(target=es2022).js +++ b/tests/baselines/reference/esDecorators-classDeclaration-sourceMap(target=es2022).js @@ -103,7 +103,7 @@ var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function ( return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value; }; let C = (() => { - var _method_get, _x_get, _x_set, _y, _z_accessor_storage, _z_get, _z_set; + var _C_method_get, _C_x_get, _C_x_set, _C_y, _C_z_accessor_storage, _C_z_get, _C_z_set; let _classDecorators = [dec, dec]; let _classDescriptor; let _classExtraInitializers = []; @@ -129,8 +129,9 @@ let C = (() => { let _z_decorators; let _z_initializers = []; var C = class { + static { _classThis = this; } static { __setFunctionName(this, "C"); } - static { _method_get = function _method_get() { return _static_private_method_descriptor.value; }, _x_get = function _x_get() { return _static_private_get_x_descriptor.get.call(this); }, _x_set = function _x_set(value) { return _static_private_set_x_descriptor.set.call(this, value); }, _z_get = function _z_get() { return _static_private_z_descriptor.get.call(this); }, _z_set = function _z_set(value) { return _static_private_z_descriptor.set.call(this, value); }; } + static { _C_method_get = function _C_method_get() { return _static_private_method_descriptor.value; }, _C_x_get = function _C_x_get() { return _static_private_get_x_descriptor.get.call(this); }, _C_x_set = function _C_x_set(value) { return _static_private_set_x_descriptor.set.call(this, value); }, _C_z_get = function _C_z_get() { return _static_private_z_descriptor.get.call(this); }, _C_z_set = function _C_z_set(value) { return _static_private_z_descriptor.set.call(this, value); }; } static { _method_decorators = [dec, dec]; _get_x_decorators = [dec, dec]; @@ -142,17 +143,17 @@ let C = (() => { _static_private_set_x_decorators = [dec, dec]; _static_private_y_decorators = [dec, dec]; _static_private_z_decorators = [dec, dec]; - __esDecorate(this, _static_private_method_descriptor = { value: __setFunctionName(function () { }, "#method") }, _static_private_method_decorators, { kind: "method", name: "#method", static: true, private: true, access: { has: obj => __classPrivateFieldIn(_classThis, obj), get: obj => __classPrivateFieldGet(obj, _classThis, "a", _method_get) } }, null, _staticExtraInitializers); - __esDecorate(this, _static_private_get_x_descriptor = { get: __setFunctionName(function () { return 1; }, "#x", "get") }, _static_private_get_x_decorators, { kind: "getter", name: "#x", static: true, private: true, access: { has: obj => __classPrivateFieldIn(_classThis, obj), get: obj => __classPrivateFieldGet(obj, _classThis, "a", _x_get) } }, null, _staticExtraInitializers); - __esDecorate(this, _static_private_set_x_descriptor = { set: __setFunctionName(function (value) { }, "#x", "set") }, _static_private_set_x_decorators, { kind: "setter", name: "#x", static: true, private: true, access: { has: obj => __classPrivateFieldIn(_classThis, obj), set: (obj, value) => { __classPrivateFieldSet(obj, _classThis, value, "a", _x_set); } } }, null, _staticExtraInitializers); - __esDecorate(this, _static_private_z_descriptor = { get: __setFunctionName(function () { return __classPrivateFieldGet(this, _classThis, "f", _z_accessor_storage); }, "#z", "get"), set: __setFunctionName(function (value) { __classPrivateFieldSet(this, _classThis, value, "f", _z_accessor_storage); }, "#z", "set") }, _static_private_z_decorators, { kind: "accessor", name: "#z", static: true, private: true, access: { has: obj => __classPrivateFieldIn(_classThis, obj), get: obj => __classPrivateFieldGet(obj, _classThis, "a", _z_get), set: (obj, value) => { __classPrivateFieldSet(obj, _classThis, value, "a", _z_set); } } }, _static_private_z_initializers, _staticExtraInitializers); + __esDecorate(this, _static_private_method_descriptor = { value: __setFunctionName(function () { }, "#method") }, _static_private_method_decorators, { kind: "method", name: "#method", static: true, private: true, access: { has: obj => __classPrivateFieldIn(_classThis, obj), get: obj => __classPrivateFieldGet(obj, _classThis, "a", _C_method_get) } }, null, _staticExtraInitializers); + __esDecorate(this, _static_private_get_x_descriptor = { get: __setFunctionName(function () { return 1; }, "#x", "get") }, _static_private_get_x_decorators, { kind: "getter", name: "#x", static: true, private: true, access: { has: obj => __classPrivateFieldIn(_classThis, obj), get: obj => __classPrivateFieldGet(obj, _classThis, "a", _C_x_get) } }, null, _staticExtraInitializers); + __esDecorate(this, _static_private_set_x_descriptor = { set: __setFunctionName(function (value) { }, "#x", "set") }, _static_private_set_x_decorators, { kind: "setter", name: "#x", static: true, private: true, access: { has: obj => __classPrivateFieldIn(_classThis, obj), set: (obj, value) => { __classPrivateFieldSet(obj, _classThis, value, "a", _C_x_set); } } }, null, _staticExtraInitializers); + __esDecorate(this, _static_private_z_descriptor = { get: __setFunctionName(function () { return __classPrivateFieldGet(this, _classThis, "f", _C_z_accessor_storage); }, "#z", "get"), set: __setFunctionName(function (value) { __classPrivateFieldSet(this, _classThis, value, "f", _C_z_accessor_storage); }, "#z", "set") }, _static_private_z_decorators, { kind: "accessor", name: "#z", static: true, private: true, access: { has: obj => __classPrivateFieldIn(_classThis, obj), get: obj => __classPrivateFieldGet(obj, _classThis, "a", _C_z_get), set: (obj, value) => { __classPrivateFieldSet(obj, _classThis, value, "a", _C_z_set); } } }, _static_private_z_initializers, _staticExtraInitializers); __esDecorate(this, null, _method_decorators, { kind: "method", name: "method", static: false, private: false, access: { has: obj => "method" in obj, get: obj => obj.method } }, null, _instanceExtraInitializers); __esDecorate(this, null, _get_x_decorators, { kind: "getter", name: "x", static: false, private: false, access: { has: obj => "x" in obj, get: obj => obj.x } }, null, _instanceExtraInitializers); __esDecorate(this, null, _set_x_decorators, { kind: "setter", name: "x", static: false, private: false, access: { has: obj => "x" in obj, set: (obj, value) => { obj.x = value; } } }, null, _instanceExtraInitializers); __esDecorate(this, null, _z_decorators, { kind: "accessor", name: "z", static: false, private: false, access: { has: obj => "z" in obj, get: obj => obj.z, set: (obj, value) => { obj.z = value; } } }, _z_initializers, _instanceExtraInitializers); - __esDecorate(null, null, _static_private_y_decorators, { kind: "field", name: "#y", static: true, private: true, access: { has: obj => __classPrivateFieldIn(_classThis, obj), get: obj => __classPrivateFieldGet(obj, _classThis, "f", _y), set: (obj, value) => { __classPrivateFieldSet(obj, _classThis, value, "f", _y); } } }, _static_private_y_initializers, _staticExtraInitializers); + __esDecorate(null, null, _static_private_y_decorators, { kind: "field", name: "#y", static: true, private: true, access: { has: obj => __classPrivateFieldIn(_classThis, obj), get: obj => __classPrivateFieldGet(obj, _classThis, "f", _C_y), set: (obj, value) => { __classPrivateFieldSet(obj, _classThis, value, "f", _C_y); } } }, _static_private_y_initializers, _staticExtraInitializers); __esDecorate(null, null, _y_decorators, { kind: "field", name: "y", static: false, private: false, access: { has: obj => "y" in obj, get: obj => obj.y, set: (obj, value) => { obj.y = value; } } }, _y_initializers, _instanceExtraInitializers); - __esDecorate(null, _classDescriptor = { value: this }, _classDecorators, { kind: "class", name: this.name }, null, _classExtraInitializers); + __esDecorate(null, _classDescriptor = { value: _classThis }, _classDecorators, { kind: "class", name: _classThis.name }, null, _classExtraInitializers); C = _classThis = _classDescriptor.value; __runInitializers(_classThis, _staticExtraInitializers); } @@ -164,10 +165,10 @@ let C = (() => { get z() { return this.#z_accessor_storage; } set z(value) { this.#z_accessor_storage = value; } static { - _y = { value: __runInitializers(_classThis, _static_private_y_initializers, 1) }; + _C_y = { value: __runInitializers(_classThis, _static_private_y_initializers, 1) }; } static { - _z_accessor_storage = { value: __runInitializers(_classThis, _static_private_z_initializers, 1) }; + _C_z_accessor_storage = { value: __runInitializers(_classThis, _static_private_z_initializers, 1) }; } static { __runInitializers(_classThis, _classExtraInitializers); diff --git a/tests/baselines/reference/esDecorators-classDeclaration-sourceMap(target=es2022).js.map b/tests/baselines/reference/esDecorators-classDeclaration-sourceMap(target=es2022).js.map index 5752ff8d4310a..d40c64ee833f3 100644 --- a/tests/baselines/reference/esDecorators-classDeclaration-sourceMap(target=es2022).js.map +++ b/tests/baselines/reference/esDecorators-classDeclaration-sourceMap(target=es2022).js.map @@ -1,6 +1,6 @@ //// [esDecorators-classDeclaration-sourceMap.js.map] -{"version":3,"file":"esDecorators-classDeclaration-sourceMap.js","sourceRoot":"","sources":["esDecorators-classDeclaration-sourceMap.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;IAIM,CAAC;;4BAFN,GAAG,EACH,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;kCAEC,GAAG,EACH,GAAG;iCAGH,GAAG,EACH,GAAG;iCAGH,GAAG,EACH,GAAG;6BAGH,GAAG,EACH,GAAG;6BAGH,GAAG,EACH,GAAG;iDAGH,GAAG,EACH,GAAG;gDAGH,GAAG,EACH,GAAG;gDAGH,GAAG,EACH,GAAG;4CAGH,GAAG,EACH,GAAG;4CAGH,GAAG,EACH,GAAG;YAfJ,yDAAA,yBAAA,cAAkB,CAAC,YAAA,gRAAA;YAInB,wDAAA,uBAAA,cAAkB,OAAO,CAAC,CAAC,CAAC,CAAC,cAAA,qQAAA;YAI7B,wDAAA,uBAAA,UAAc,KAAa,IAAI,CAAC,cAAA,0RAAA;YAQhC,oDAAA,uBAAA,0FAAuB,cAAA,EAAvB,uBAAA,+FAAuB,cAAA,oXAAA;YApCvB,qKAAA,MAAM,wCAAK;YAIX,0JAAI,CAAC,wCAAgB;YAIrB,qKAAI,CAAC,mDAAmB;YAQxB,wJAAS,CAAC,6BAAD,CAAC,8DAAK;YAgBf,8XAAc;YApBd,qJAAA,CAAC,6BAAD,CAAC,8DAAK;YAfV,4IAwCC;;YAxCK,wDAAC;;QAGH,MAAM,KAAI,CAAC;QAIX,IAAI,CAAC,KAAK,OAAO,CAAC,CAAC,CAAC,CAAC;QAIrB,IAAI,CAAC,CAAC,KAAa,IAAI,CAAC;QAIxB,CAAC,kGAAG,CAAC,GAAC;QAIN,+DAAa,CAAC,EAAC;QAAf,IAAS,CAAC,uCAAK;QAAf,IAAS,CAAC,6CAAK;;YAgBR,4EAAK,CAAC,GAAJ,CAAK;;;YAIE,6FAAK,CAAC,GAAJ,CAAK;;;YAvCrB,uDAAC"} -//// https://sokra.github.io/source-map-visualization#base64,dmFyIF9fZXNEZWNvcmF0ZSA9ICh0aGlzICYmIHRoaXMuX19lc0RlY29yYXRlKSB8fCBmdW5jdGlvbiAoY3RvciwgZGVzY3JpcHRvckluLCBkZWNvcmF0b3JzLCBjb250ZXh0SW4sIGluaXRpYWxpemVycywgZXh0cmFJbml0aWFsaXplcnMpIHsNCiAgICBmdW5jdGlvbiBhY2NlcHQoZikgeyBpZiAoZiAhPT0gdm9pZCAwICYmIHR5cGVvZiBmICE9PSAiZnVuY3Rpb24iKSB0aHJvdyBuZXcgVHlwZUVycm9yKCJGdW5jdGlvbiBleHBlY3RlZCIpOyByZXR1cm4gZjsgfQ0KICAgIHZhciBraW5kID0gY29udGV4dEluLmtpbmQsIGtleSA9IGtpbmQgPT09ICJnZXR0ZXIiID8gImdldCIgOiBraW5kID09PSAic2V0dGVyIiA/ICJzZXQiIDogInZhbHVlIjsNCiAgICB2YXIgdGFyZ2V0ID0gIWRlc2NyaXB0b3JJbiAmJiBjdG9yID8gY29udGV4dEluWyJzdGF0aWMiXSA/IGN0b3IgOiBjdG9yLnByb3RvdHlwZSA6IG51bGw7DQogICAgdmFyIGRlc2NyaXB0b3IgPSBkZXNjcmlwdG9ySW4gfHwgKHRhcmdldCA/IE9iamVjdC5nZXRPd25Qcm9wZXJ0eURlc2NyaXB0b3IodGFyZ2V0LCBjb250ZXh0SW4ubmFtZSkgOiB7fSk7DQogICAgdmFyIF8sIGRvbmUgPSBmYWxzZTsNCiAgICBmb3IgKHZhciBpID0gZGVjb3JhdG9ycy5sZW5ndGggLSAxOyBpID49IDA7IGktLSkgew0KICAgICAgICB2YXIgY29udGV4dCA9IHt9Ow0KICAgICAgICBmb3IgKHZhciBwIGluIGNvbnRleHRJbikgY29udGV4dFtwXSA9IHAgPT09ICJhY2Nlc3MiID8ge30gOiBjb250ZXh0SW5bcF07DQogICAgICAgIGZvciAodmFyIHAgaW4gY29udGV4dEluLmFjY2VzcykgY29udGV4dC5hY2Nlc3NbcF0gPSBjb250ZXh0SW4uYWNjZXNzW3BdOw0KICAgICAgICBjb250ZXh0LmFkZEluaXRpYWxpemVyID0gZnVuY3Rpb24gKGYpIHsgaWYgKGRvbmUpIHRocm93IG5ldyBUeXBlRXJyb3IoIkNhbm5vdCBhZGQgaW5pdGlhbGl6ZXJzIGFmdGVyIGRlY29yYXRpb24gaGFzIGNvbXBsZXRlZCIpOyBleHRyYUluaXRpYWxpemVycy5wdXNoKGFjY2VwdChmIHx8IG51bGwpKTsgfTsNCiAgICAgICAgdmFyIHJlc3VsdCA9ICgwLCBkZWNvcmF0b3JzW2ldKShraW5kID09PSAiYWNjZXNzb3IiID8geyBnZXQ6IGRlc2NyaXB0b3IuZ2V0LCBzZXQ6IGRlc2NyaXB0b3Iuc2V0IH0gOiBkZXNjcmlwdG9yW2tleV0sIGNvbnRleHQpOw0KICAgICAgICBpZiAoa2luZCA9PT0gImFjY2Vzc29yIikgew0KICAgICAgICAgICAgaWYgKHJlc3VsdCA9PT0gdm9pZCAwKSBjb250aW51ZTsNCiAgICAgICAgICAgIGlmIChyZXN1bHQgPT09IG51bGwgfHwgdHlwZW9mIHJlc3VsdCAhPT0gIm9iamVjdCIpIHRocm93IG5ldyBUeXBlRXJyb3IoIk9iamVjdCBleHBlY3RlZCIpOw0KICAgICAgICAgICAgaWYgKF8gPSBhY2NlcHQocmVzdWx0LmdldCkpIGRlc2NyaXB0b3IuZ2V0ID0gXzsNCiAgICAgICAgICAgIGlmIChfID0gYWNjZXB0KHJlc3VsdC5zZXQpKSBkZXNjcmlwdG9yLnNldCA9IF87DQogICAgICAgICAgICBpZiAoXyA9IGFjY2VwdChyZXN1bHQuaW5pdCkpIGluaXRpYWxpemVycy51bnNoaWZ0KF8pOw0KICAgICAgICB9DQogICAgICAgIGVsc2UgaWYgKF8gPSBhY2NlcHQocmVzdWx0KSkgew0KICAgICAgICAgICAgaWYgKGtpbmQgPT09ICJmaWVsZCIpIGluaXRpYWxpemVycy51bnNoaWZ0KF8pOw0KICAgICAgICAgICAgZWxzZSBkZXNjcmlwdG9yW2tleV0gPSBfOw0KICAgICAgICB9DQogICAgfQ0KICAgIGlmICh0YXJnZXQpIE9iamVjdC5kZWZpbmVQcm9wZXJ0eSh0YXJnZXQsIGNvbnRleHRJbi5uYW1lLCBkZXNjcmlwdG9yKTsNCiAgICBkb25lID0gdHJ1ZTsNCn07DQp2YXIgX19ydW5Jbml0aWFsaXplcnMgPSAodGhpcyAmJiB0aGlzLl9fcnVuSW5pdGlhbGl6ZXJzKSB8fCBmdW5jdGlvbiAodGhpc0FyZywgaW5pdGlhbGl6ZXJzLCB2YWx1ZSkgew0KICAgIHZhciB1c2VWYWx1ZSA9IGFyZ3VtZW50cy5sZW5ndGggPiAyOw0KICAgIGZvciAodmFyIGkgPSAwOyBpIDwgaW5pdGlhbGl6ZXJzLmxlbmd0aDsgaSsrKSB7DQogICAgICAgIHZhbHVlID0gdXNlVmFsdWUgPyBpbml0aWFsaXplcnNbaV0uY2FsbCh0aGlzQXJnLCB2YWx1ZSkgOiBpbml0aWFsaXplcnNbaV0uY2FsbCh0aGlzQXJnKTsNCiAgICB9DQogICAgcmV0dXJuIHVzZVZhbHVlID8gdmFsdWUgOiB2b2lkIDA7DQp9Ow0KdmFyIF9fc2V0RnVuY3Rpb25OYW1lID0gKHRoaXMgJiYgdGhpcy5fX3NldEZ1bmN0aW9uTmFtZSkgfHwgZnVuY3Rpb24gKGYsIG5hbWUsIHByZWZpeCkgew0KICAgIGlmICh0eXBlb2YgbmFtZSA9PT0gInN5bWJvbCIpIG5hbWUgPSBuYW1lLmRlc2NyaXB0aW9uID8gIlsiLmNvbmNhdChuYW1lLmRlc2NyaXB0aW9uLCAiXSIpIDogIiI7DQogICAgcmV0dXJuIE9iamVjdC5kZWZpbmVQcm9wZXJ0eShmLCAibmFtZSIsIHsgY29uZmlndXJhYmxlOiB0cnVlLCB2YWx1ZTogcHJlZml4ID8gIiIuY29uY2F0KHByZWZpeCwgIiAiLCBuYW1lKSA6IG5hbWUgfSk7DQp9Ow0KdmFyIF9fY2xhc3NQcml2YXRlRmllbGRJbiA9ICh0aGlzICYmIHRoaXMuX19jbGFzc1ByaXZhdGVGaWVsZEluKSB8fCBmdW5jdGlvbihzdGF0ZSwgcmVjZWl2ZXIpIHsNCiAgICBpZiAocmVjZWl2ZXIgPT09IG51bGwgfHwgKHR5cGVvZiByZWNlaXZlciAhPT0gIm9iamVjdCIgJiYgdHlwZW9mIHJlY2VpdmVyICE9PSAiZnVuY3Rpb24iKSkgdGhyb3cgbmV3IFR5cGVFcnJvcigiQ2Fubm90IHVzZSAnaW4nIG9wZXJhdG9yIG9uIG5vbi1vYmplY3QiKTsNCiAgICByZXR1cm4gdHlwZW9mIHN0YXRlID09PSAiZnVuY3Rpb24iID8gcmVjZWl2ZXIgPT09IHN0YXRlIDogc3RhdGUuaGFzKHJlY2VpdmVyKTsNCn07DQp2YXIgX19jbGFzc1ByaXZhdGVGaWVsZEdldCA9ICh0aGlzICYmIHRoaXMuX19jbGFzc1ByaXZhdGVGaWVsZEdldCkgfHwgZnVuY3Rpb24gKHJlY2VpdmVyLCBzdGF0ZSwga2luZCwgZikgew0KICAgIGlmIChraW5kID09PSAiYSIgJiYgIWYpIHRocm93IG5ldyBUeXBlRXJyb3IoIlByaXZhdGUgYWNjZXNzb3Igd2FzIGRlZmluZWQgd2l0aG91dCBhIGdldHRlciIpOw0KICAgIGlmICh0eXBlb2Ygc3RhdGUgPT09ICJmdW5jdGlvbiIgPyByZWNlaXZlciAhPT0gc3RhdGUgfHwgIWYgOiAhc3RhdGUuaGFzKHJlY2VpdmVyKSkgdGhyb3cgbmV3IFR5cGVFcnJvcigiQ2Fubm90IHJlYWQgcHJpdmF0ZSBtZW1iZXIgZnJvbSBhbiBvYmplY3Qgd2hvc2UgY2xhc3MgZGlkIG5vdCBkZWNsYXJlIGl0Iik7DQogICAgcmV0dXJuIGtpbmQgPT09ICJtIiA/IGYgOiBraW5kID09PSAiYSIgPyBmLmNhbGwocmVjZWl2ZXIpIDogZiA/IGYudmFsdWUgOiBzdGF0ZS5nZXQocmVjZWl2ZXIpOw0KfTsNCnZhciBfX2NsYXNzUHJpdmF0ZUZpZWxkU2V0ID0gKHRoaXMgJiYgdGhpcy5fX2NsYXNzUHJpdmF0ZUZpZWxkU2V0KSB8fCBmdW5jdGlvbiAocmVjZWl2ZXIsIHN0YXRlLCB2YWx1ZSwga2luZCwgZikgew0KICAgIGlmIChraW5kID09PSAibSIpIHRocm93IG5ldyBUeXBlRXJyb3IoIlByaXZhdGUgbWV0aG9kIGlzIG5vdCB3cml0YWJsZSIpOw0KICAgIGlmIChraW5kID09PSAiYSIgJiYgIWYpIHRocm93IG5ldyBUeXBlRXJyb3IoIlByaXZhdGUgYWNjZXNzb3Igd2FzIGRlZmluZWQgd2l0aG91dCBhIHNldHRlciIpOw0KICAgIGlmICh0eXBlb2Ygc3RhdGUgPT09ICJmdW5jdGlvbiIgPyByZWNlaXZlciAhPT0gc3RhdGUgfHwgIWYgOiAhc3RhdGUuaGFzKHJlY2VpdmVyKSkgdGhyb3cgbmV3IFR5cGVFcnJvcigiQ2Fubm90IHdyaXRlIHByaXZhdGUgbWVtYmVyIHRvIGFuIG9iamVjdCB3aG9zZSBjbGFzcyBkaWQgbm90IGRlY2xhcmUgaXQiKTsNCiAgICByZXR1cm4gKGtpbmQgPT09ICJhIiA/IGYuY2FsbChyZWNlaXZlciwgdmFsdWUpIDogZiA/IGYudmFsdWUgPSB2YWx1ZSA6IHN0YXRlLnNldChyZWNlaXZlciwgdmFsdWUpKSwgdmFsdWU7DQp9Ow0KbGV0IEMgPSAoKCkgPT4gew0KICAgIHZhciBfbWV0aG9kX2dldCwgX3hfZ2V0LCBfeF9zZXQsIF95LCBfel9hY2Nlc3Nvcl9zdG9yYWdlLCBfel9nZXQsIF96X3NldDsNCiAgICBsZXQgX2NsYXNzRGVjb3JhdG9ycyA9IFtkZWMsIGRlY107DQogICAgbGV0IF9jbGFzc0Rlc2NyaXB0b3I7DQogICAgbGV0IF9jbGFzc0V4dHJhSW5pdGlhbGl6ZXJzID0gW107DQogICAgbGV0IF9jbGFzc1RoaXM7DQogICAgbGV0IF9zdGF0aWNFeHRyYUluaXRpYWxpemVycyA9IFtdOw0KICAgIGxldCBfaW5zdGFuY2VFeHRyYUluaXRpYWxpemVycyA9IFtdOw0KICAgIGxldCBfc3RhdGljX3ByaXZhdGVfbWV0aG9kX2RlY29yYXRvcnM7DQogICAgbGV0IF9zdGF0aWNfcHJpdmF0ZV9tZXRob2RfZGVzY3JpcHRvcjsNCiAgICBsZXQgX3N0YXRpY19wcml2YXRlX2dldF94X2RlY29yYXRvcnM7DQogICAgbGV0IF9zdGF0aWNfcHJpdmF0ZV9nZXRfeF9kZXNjcmlwdG9yOw0KICAgIGxldCBfc3RhdGljX3ByaXZhdGVfc2V0X3hfZGVjb3JhdG9yczsNCiAgICBsZXQgX3N0YXRpY19wcml2YXRlX3NldF94X2Rlc2NyaXB0b3I7DQogICAgbGV0IF9zdGF0aWNfcHJpdmF0ZV95X2RlY29yYXRvcnM7DQogICAgbGV0IF9zdGF0aWNfcHJpdmF0ZV95X2luaXRpYWxpemVycyA9IFtdOw0KICAgIGxldCBfc3RhdGljX3ByaXZhdGVfel9kZWNvcmF0b3JzOw0KICAgIGxldCBfc3RhdGljX3ByaXZhdGVfel9pbml0aWFsaXplcnMgPSBbXTsNCiAgICBsZXQgX3N0YXRpY19wcml2YXRlX3pfZGVzY3JpcHRvcjsNCiAgICBsZXQgX21ldGhvZF9kZWNvcmF0b3JzOw0KICAgIGxldCBfZ2V0X3hfZGVjb3JhdG9yczsNCiAgICBsZXQgX3NldF94X2RlY29yYXRvcnM7DQogICAgbGV0IF95X2RlY29yYXRvcnM7DQogICAgbGV0IF95X2luaXRpYWxpemVycyA9IFtdOw0KICAgIGxldCBfel9kZWNvcmF0b3JzOw0KICAgIGxldCBfel9pbml0aWFsaXplcnMgPSBbXTsNCiAgICB2YXIgQyA9IGNsYXNzIHsNCiAgICAgICAgc3RhdGljIHsgX19zZXRGdW5jdGlvbk5hbWUodGhpcywgIkMiKTsgfQ0KICAgICAgICBzdGF0aWMgeyBfbWV0aG9kX2dldCA9IGZ1bmN0aW9uIF9tZXRob2RfZ2V0KCkgeyByZXR1cm4gX3N0YXRpY19wcml2YXRlX21ldGhvZF9kZXNjcmlwdG9yLnZhbHVlOyB9LCBfeF9nZXQgPSBmdW5jdGlvbiBfeF9nZXQoKSB7IHJldHVybiBfc3RhdGljX3ByaXZhdGVfZ2V0X3hfZGVzY3JpcHRvci5nZXQuY2FsbCh0aGlzKTsgfSwgX3hfc2V0ID0gZnVuY3Rpb24gX3hfc2V0KHZhbHVlKSB7IHJldHVybiBfc3RhdGljX3ByaXZhdGVfc2V0X3hfZGVzY3JpcHRvci5zZXQuY2FsbCh0aGlzLCB2YWx1ZSk7IH0sIF96X2dldCA9IGZ1bmN0aW9uIF96X2dldCgpIHsgcmV0dXJuIF9zdGF0aWNfcHJpdmF0ZV96X2Rlc2NyaXB0b3IuZ2V0LmNhbGwodGhpcyk7IH0sIF96X3NldCA9IGZ1bmN0aW9uIF96X3NldCh2YWx1ZSkgeyByZXR1cm4gX3N0YXRpY19wcml2YXRlX3pfZGVzY3JpcHRvci5zZXQuY2FsbCh0aGlzLCB2YWx1ZSk7IH07IH0NCiAgICAgICAgc3RhdGljIHsNCiAgICAgICAgICAgIF9tZXRob2RfZGVjb3JhdG9ycyA9IFtkZWMsIGRlY107DQogICAgICAgICAgICBfZ2V0X3hfZGVjb3JhdG9ycyA9IFtkZWMsIGRlY107DQogICAgICAgICAgICBfc2V0X3hfZGVjb3JhdG9ycyA9IFtkZWMsIGRlY107DQogICAgICAgICAgICBfeV9kZWNvcmF0b3JzID0gW2RlYywgZGVjXTsNCiAgICAgICAgICAgIF96X2RlY29yYXRvcnMgPSBbZGVjLCBkZWNdOw0KICAgICAgICAgICAgX3N0YXRpY19wcml2YXRlX21ldGhvZF9kZWNvcmF0b3JzID0gW2RlYywgZGVjXTsNCiAgICAgICAgICAgIF9zdGF0aWNfcHJpdmF0ZV9nZXRfeF9kZWNvcmF0b3JzID0gW2RlYywgZGVjXTsNCiAgICAgICAgICAgIF9zdGF0aWNfcHJpdmF0ZV9zZXRfeF9kZWNvcmF0b3JzID0gW2RlYywgZGVjXTsNCiAgICAgICAgICAgIF9zdGF0aWNfcHJpdmF0ZV95X2RlY29yYXRvcnMgPSBbZGVjLCBkZWNdOw0KICAgICAgICAgICAgX3N0YXRpY19wcml2YXRlX3pfZGVjb3JhdG9ycyA9IFtkZWMsIGRlY107DQogICAgICAgICAgICBfX2VzRGVjb3JhdGUodGhpcywgX3N0YXRpY19wcml2YXRlX21ldGhvZF9kZXNjcmlwdG9yID0geyB2YWx1ZTogX19zZXRGdW5jdGlvbk5hbWUoZnVuY3Rpb24gKCkgeyB9LCAiI21ldGhvZCIpIH0sIF9zdGF0aWNfcHJpdmF0ZV9tZXRob2RfZGVjb3JhdG9ycywgeyBraW5kOiAibWV0aG9kIiwgbmFtZTogIiNtZXRob2QiLCBzdGF0aWM6IHRydWUsIHByaXZhdGU6IHRydWUsIGFjY2VzczogeyBoYXM6IG9iaiA9PiBfX2NsYXNzUHJpdmF0ZUZpZWxkSW4oX2NsYXNzVGhpcywgb2JqKSwgZ2V0OiBvYmogPT4gX19jbGFzc1ByaXZhdGVGaWVsZEdldChvYmosIF9jbGFzc1RoaXMsICJhIiwgX21ldGhvZF9nZXQpIH0gfSwgbnVsbCwgX3N0YXRpY0V4dHJhSW5pdGlhbGl6ZXJzKTsNCiAgICAgICAgICAgIF9fZXNEZWNvcmF0ZSh0aGlzLCBfc3RhdGljX3ByaXZhdGVfZ2V0X3hfZGVzY3JpcHRvciA9IHsgZ2V0OiBfX3NldEZ1bmN0aW9uTmFtZShmdW5jdGlvbiAoKSB7IHJldHVybiAxOyB9LCAiI3giLCAiZ2V0IikgfSwgX3N0YXRpY19wcml2YXRlX2dldF94X2RlY29yYXRvcnMsIHsga2luZDogImdldHRlciIsIG5hbWU6ICIjeCIsIHN0YXRpYzogdHJ1ZSwgcHJpdmF0ZTogdHJ1ZSwgYWNjZXNzOiB7IGhhczogb2JqID0+IF9fY2xhc3NQcml2YXRlRmllbGRJbihfY2xhc3NUaGlzLCBvYmopLCBnZXQ6IG9iaiA9PiBfX2NsYXNzUHJpdmF0ZUZpZWxkR2V0KG9iaiwgX2NsYXNzVGhpcywgImEiLCBfeF9nZXQpIH0gfSwgbnVsbCwgX3N0YXRpY0V4dHJhSW5pdGlhbGl6ZXJzKTsNCiAgICAgICAgICAgIF9fZXNEZWNvcmF0ZSh0aGlzLCBfc3RhdGljX3ByaXZhdGVfc2V0X3hfZGVzY3JpcHRvciA9IHsgc2V0OiBfX3NldEZ1bmN0aW9uTmFtZShmdW5jdGlvbiAodmFsdWUpIHsgfSwgIiN4IiwgInNldCIpIH0sIF9zdGF0aWNfcHJpdmF0ZV9zZXRfeF9kZWNvcmF0b3JzLCB7IGtpbmQ6ICJzZXR0ZXIiLCBuYW1lOiAiI3giLCBzdGF0aWM6IHRydWUsIHByaXZhdGU6IHRydWUsIGFjY2VzczogeyBoYXM6IG9iaiA9PiBfX2NsYXNzUHJpdmF0ZUZpZWxkSW4oX2NsYXNzVGhpcywgb2JqKSwgc2V0OiAob2JqLCB2YWx1ZSkgPT4geyBfX2NsYXNzUHJpdmF0ZUZpZWxkU2V0KG9iaiwgX2NsYXNzVGhpcywgdmFsdWUsICJhIiwgX3hfc2V0KTsgfSB9IH0sIG51bGwsIF9zdGF0aWNFeHRyYUluaXRpYWxpemVycyk7DQogICAgICAgICAgICBfX2VzRGVjb3JhdGUodGhpcywgX3N0YXRpY19wcml2YXRlX3pfZGVzY3JpcHRvciA9IHsgZ2V0OiBfX3NldEZ1bmN0aW9uTmFtZShmdW5jdGlvbiAoKSB7IHJldHVybiBfX2NsYXNzUHJpdmF0ZUZpZWxkR2V0KHRoaXMsIF9jbGFzc1RoaXMsICJmIiwgX3pfYWNjZXNzb3Jfc3RvcmFnZSk7IH0sICIjeiIsICJnZXQiKSwgc2V0OiBfX3NldEZ1bmN0aW9uTmFtZShmdW5jdGlvbiAodmFsdWUpIHsgX19jbGFzc1ByaXZhdGVGaWVsZFNldCh0aGlzLCBfY2xhc3NUaGlzLCB2YWx1ZSwgImYiLCBfel9hY2Nlc3Nvcl9zdG9yYWdlKTsgfSwgIiN6IiwgInNldCIpIH0sIF9zdGF0aWNfcHJpdmF0ZV96X2RlY29yYXRvcnMsIHsga2luZDogImFjY2Vzc29yIiwgbmFtZTogIiN6Iiwgc3RhdGljOiB0cnVlLCBwcml2YXRlOiB0cnVlLCBhY2Nlc3M6IHsgaGFzOiBvYmogPT4gX19jbGFzc1ByaXZhdGVGaWVsZEluKF9jbGFzc1RoaXMsIG9iaiksIGdldDogb2JqID0+IF9fY2xhc3NQcml2YXRlRmllbGRHZXQob2JqLCBfY2xhc3NUaGlzLCAiYSIsIF96X2dldCksIHNldDogKG9iaiwgdmFsdWUpID0+IHsgX19jbGFzc1ByaXZhdGVGaWVsZFNldChvYmosIF9jbGFzc1RoaXMsIHZhbHVlLCAiYSIsIF96X3NldCk7IH0gfSB9LCBfc3RhdGljX3ByaXZhdGVfel9pbml0aWFsaXplcnMsIF9zdGF0aWNFeHRyYUluaXRpYWxpemVycyk7DQogICAgICAgICAgICBfX2VzRGVjb3JhdGUodGhpcywgbnVsbCwgX21ldGhvZF9kZWNvcmF0b3JzLCB7IGtpbmQ6ICJtZXRob2QiLCBuYW1lOiAibWV0aG9kIiwgc3RhdGljOiBmYWxzZSwgcHJpdmF0ZTogZmFsc2UsIGFjY2VzczogeyBoYXM6IG9iaiA9PiAibWV0aG9kIiBpbiBvYmosIGdldDogb2JqID0+IG9iai5tZXRob2QgfSB9LCBudWxsLCBfaW5zdGFuY2VFeHRyYUluaXRpYWxpemVycyk7DQogICAgICAgICAgICBfX2VzRGVjb3JhdGUodGhpcywgbnVsbCwgX2dldF94X2RlY29yYXRvcnMsIHsga2luZDogImdldHRlciIsIG5hbWU6ICJ4Iiwgc3RhdGljOiBmYWxzZSwgcHJpdmF0ZTogZmFsc2UsIGFjY2VzczogeyBoYXM6IG9iaiA9PiAieCIgaW4gb2JqLCBnZXQ6IG9iaiA9PiBvYmoueCB9IH0sIG51bGwsIF9pbnN0YW5jZUV4dHJhSW5pdGlhbGl6ZXJzKTsNCiAgICAgICAgICAgIF9fZXNEZWNvcmF0ZSh0aGlzLCBudWxsLCBfc2V0X3hfZGVjb3JhdG9ycywgeyBraW5kOiAic2V0dGVyIiwgbmFtZTogIngiLCBzdGF0aWM6IGZhbHNlLCBwcml2YXRlOiBmYWxzZSwgYWNjZXNzOiB7IGhhczogb2JqID0+ICJ4IiBpbiBvYmosIHNldDogKG9iaiwgdmFsdWUpID0+IHsgb2JqLnggPSB2YWx1ZTsgfSB9IH0sIG51bGwsIF9pbnN0YW5jZUV4dHJhSW5pdGlhbGl6ZXJzKTsNCiAgICAgICAgICAgIF9fZXNEZWNvcmF0ZSh0aGlzLCBudWxsLCBfel9kZWNvcmF0b3JzLCB7IGtpbmQ6ICJhY2Nlc3NvciIsIG5hbWU6ICJ6Iiwgc3RhdGljOiBmYWxzZSwgcHJpdmF0ZTogZmFsc2UsIGFjY2VzczogeyBoYXM6IG9iaiA9PiAieiIgaW4gb2JqLCBnZXQ6IG9iaiA9PiBvYmoueiwgc2V0OiAob2JqLCB2YWx1ZSkgPT4geyBvYmoueiA9IHZhbHVlOyB9IH0gfSwgX3pfaW5pdGlhbGl6ZXJzLCBfaW5zdGFuY2VFeHRyYUluaXRpYWxpemVycyk7DQogICAgICAgICAgICBfX2VzRGVjb3JhdGUobnVsbCwgbnVsbCwgX3N0YXRpY19wcml2YXRlX3lfZGVjb3JhdG9ycywgeyBraW5kOiAiZmllbGQiLCBuYW1lOiAiI3kiLCBzdGF0aWM6IHRydWUsIHByaXZhdGU6IHRydWUsIGFjY2VzczogeyBoYXM6IG9iaiA9PiBfX2NsYXNzUHJpdmF0ZUZpZWxkSW4oX2NsYXNzVGhpcywgb2JqKSwgZ2V0OiBvYmogPT4gX19jbGFzc1ByaXZhdGVGaWVsZEdldChvYmosIF9jbGFzc1RoaXMsICJmIiwgX3kpLCBzZXQ6IChvYmosIHZhbHVlKSA9PiB7IF9fY2xhc3NQcml2YXRlRmllbGRTZXQob2JqLCBfY2xhc3NUaGlzLCB2YWx1ZSwgImYiLCBfeSk7IH0gfSB9LCBfc3RhdGljX3ByaXZhdGVfeV9pbml0aWFsaXplcnMsIF9zdGF0aWNFeHRyYUluaXRpYWxpemVycyk7DQogICAgICAgICAgICBfX2VzRGVjb3JhdGUobnVsbCwgbnVsbCwgX3lfZGVjb3JhdG9ycywgeyBraW5kOiAiZmllbGQiLCBuYW1lOiAieSIsIHN0YXRpYzogZmFsc2UsIHByaXZhdGU6IGZhbHNlLCBhY2Nlc3M6IHsgaGFzOiBvYmogPT4gInkiIGluIG9iaiwgZ2V0OiBvYmogPT4gb2JqLnksIHNldDogKG9iaiwgdmFsdWUpID0+IHsgb2JqLnkgPSB2YWx1ZTsgfSB9IH0sIF95X2luaXRpYWxpemVycywgX2luc3RhbmNlRXh0cmFJbml0aWFsaXplcnMpOw0KICAgICAgICAgICAgX19lc0RlY29yYXRlKG51bGwsIF9jbGFzc0Rlc2NyaXB0b3IgPSB7IHZhbHVlOiB0aGlzIH0sIF9jbGFzc0RlY29yYXRvcnMsIHsga2luZDogImNsYXNzIiwgbmFtZTogdGhpcy5uYW1lIH0sIG51bGwsIF9jbGFzc0V4dHJhSW5pdGlhbGl6ZXJzKTsNCiAgICAgICAgICAgIEMgPSBfY2xhc3NUaGlzID0gX2NsYXNzRGVzY3JpcHRvci52YWx1ZTsNCiAgICAgICAgICAgIF9fcnVuSW5pdGlhbGl6ZXJzKF9jbGFzc1RoaXMsIF9zdGF0aWNFeHRyYUluaXRpYWxpemVycyk7DQogICAgICAgIH0NCiAgICAgICAgbWV0aG9kKCkgeyB9DQogICAgICAgIGdldCB4KCkgeyByZXR1cm4gMTsgfQ0KICAgICAgICBzZXQgeCh2YWx1ZSkgeyB9DQogICAgICAgIHkgPSAoX19ydW5Jbml0aWFsaXplcnModGhpcywgX2luc3RhbmNlRXh0cmFJbml0aWFsaXplcnMpLCBfX3J1bkluaXRpYWxpemVycyh0aGlzLCBfeV9pbml0aWFsaXplcnMsIDEpKTsNCiAgICAgICAgI3pfYWNjZXNzb3Jfc3RvcmFnZSA9IF9fcnVuSW5pdGlhbGl6ZXJzKHRoaXMsIF96X2luaXRpYWxpemVycywgMSk7DQogICAgICAgIGdldCB6KCkgeyByZXR1cm4gdGhpcy4jel9hY2Nlc3Nvcl9zdG9yYWdlOyB9DQogICAgICAgIHNldCB6KHZhbHVlKSB7IHRoaXMuI3pfYWNjZXNzb3Jfc3RvcmFnZSA9IHZhbHVlOyB9DQogICAgICAgIHN0YXRpYyB7DQogICAgICAgICAgICBfeSA9IHsgdmFsdWU6IF9fcnVuSW5pdGlhbGl6ZXJzKF9jbGFzc1RoaXMsIF9zdGF0aWNfcHJpdmF0ZV95X2luaXRpYWxpemVycywgMSkgfTsNCiAgICAgICAgfQ0KICAgICAgICBzdGF0aWMgew0KICAgICAgICAgICAgX3pfYWNjZXNzb3Jfc3RvcmFnZSA9IHsgdmFsdWU6IF9fcnVuSW5pdGlhbGl6ZXJzKF9jbGFzc1RoaXMsIF9zdGF0aWNfcHJpdmF0ZV96X2luaXRpYWxpemVycywgMSkgfTsNCiAgICAgICAgfQ0KICAgICAgICBzdGF0aWMgew0KICAgICAgICAgICAgX19ydW5Jbml0aWFsaXplcnMoX2NsYXNzVGhpcywgX2NsYXNzRXh0cmFJbml0aWFsaXplcnMpOw0KICAgICAgICB9DQogICAgfTsNCiAgICByZXR1cm4gQyA9IF9jbGFzc1RoaXM7DQp9KSgpOw0KLy8jIHNvdXJjZU1hcHBpbmdVUkw9ZXNEZWNvcmF0b3JzLWNsYXNzRGVjbGFyYXRpb24tc291cmNlTWFwLmpzLm1hcA==,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiZXNEZWNvcmF0b3JzLWNsYXNzRGVjbGFyYXRpb24tc291cmNlTWFwLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiZXNEZWNvcmF0b3JzLWNsYXNzRGVjbGFyYXRpb24tc291cmNlTWFwLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7O0lBSU0sQ0FBQzs7NEJBRk4sR0FBRyxFQUNILEdBQUc7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7a0NBRUMsR0FBRyxFQUNILEdBQUc7aUNBR0gsR0FBRyxFQUNILEdBQUc7aUNBR0gsR0FBRyxFQUNILEdBQUc7NkJBR0gsR0FBRyxFQUNILEdBQUc7NkJBR0gsR0FBRyxFQUNILEdBQUc7aURBR0gsR0FBRyxFQUNILEdBQUc7Z0RBR0gsR0FBRyxFQUNILEdBQUc7Z0RBR0gsR0FBRyxFQUNILEdBQUc7NENBR0gsR0FBRyxFQUNILEdBQUc7NENBR0gsR0FBRyxFQUNILEdBQUc7WUFmSix5REFBQSx5QkFBQSxjQUFrQixDQUFDLFlBQUEsZ1JBQUE7WUFJbkIsd0RBQUEsdUJBQUEsY0FBa0IsT0FBTyxDQUFDLENBQUMsQ0FBQyxDQUFDLGNBQUEscVFBQUE7WUFJN0Isd0RBQUEsdUJBQUEsVUFBYyxLQUFhLElBQUksQ0FBQyxjQUFBLDBSQUFBO1lBUWhDLG9EQUFBLHVCQUFBLDBGQUF1QixjQUFBLEVBQXZCLHVCQUFBLCtGQUF1QixjQUFBLG9YQUFBO1lBcEN2QixxS0FBQSxNQUFNLHdDQUFLO1lBSVgsMEpBQUksQ0FBQyx3Q0FBZ0I7WUFJckIscUtBQUksQ0FBQyxtREFBbUI7WUFReEIsd0pBQVMsQ0FBQyw2QkFBRCxDQUFDLDhEQUFLO1lBZ0JmLDhYQUFjO1lBcEJkLHFKQUFBLENBQUMsNkJBQUQsQ0FBQyw4REFBSztZQWZWLDRJQXdDQzs7WUF4Q0ssd0RBQUM7O1FBR0gsTUFBTSxLQUFJLENBQUM7UUFJWCxJQUFJLENBQUMsS0FBSyxPQUFPLENBQUMsQ0FBQyxDQUFDLENBQUM7UUFJckIsSUFBSSxDQUFDLENBQUMsS0FBYSxJQUFJLENBQUM7UUFJeEIsQ0FBQyxrR0FBRyxDQUFDLEdBQUM7UUFJTiwrREFBYSxDQUFDLEVBQUM7UUFBZixJQUFTLENBQUMsdUNBQUs7UUFBZixJQUFTLENBQUMsNkNBQUs7O1lBZ0JSLDRFQUFLLENBQUMsR0FBSixDQUFLOzs7WUFJRSw2RkFBSyxDQUFDLEdBQUosQ0FBSzs7O1lBdkNyQix1REFBQyJ9,ZGVjbGFyZSB2YXIgZGVjOiBhbnk7CgpAZGVjCkBkZWMKY2xhc3MgQyB7CiAgICBAZGVjCiAgICBAZGVjCiAgICBtZXRob2QoKSB7fQoKICAgIEBkZWMKICAgIEBkZWMKICAgIGdldCB4KCkgeyByZXR1cm4gMTsgfQoKICAgIEBkZWMKICAgIEBkZWMKICAgIHNldCB4KHZhbHVlOiBudW1iZXIpIHsgfQoKICAgIEBkZWMKICAgIEBkZWMKICAgIHkgPSAxOwoKICAgIEBkZWMKICAgIEBkZWMKICAgIGFjY2Vzc29yIHogPSAxOwoKICAgIEBkZWMKICAgIEBkZWMKICAgIHN0YXRpYyAjbWV0aG9kKCkge30KCiAgICBAZGVjCiAgICBAZGVjCiAgICBzdGF0aWMgZ2V0ICN4KCkgeyByZXR1cm4gMTsgfQoKICAgIEBkZWMKICAgIEBkZWMKICAgIHN0YXRpYyBzZXQgI3godmFsdWU6IG51bWJlcikgeyB9CgogICAgQGRlYwogICAgQGRlYwogICAgc3RhdGljICN5ID0gMTsKCiAgICBAZGVjCiAgICBAZGVjCiAgICBzdGF0aWMgYWNjZXNzb3IgI3ogPSAxOwp9Cg== +{"version":3,"file":"esDecorators-classDeclaration-sourceMap.js","sourceRoot":"","sources":["esDecorators-classDeclaration-sourceMap.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;IAIM,CAAC;;4BAFN,GAAG,EACH,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;kCAEC,GAAG,EACH,GAAG;iCAGH,GAAG,EACH,GAAG;iCAGH,GAAG,EACH,GAAG;6BAGH,GAAG,EACH,GAAG;6BAGH,GAAG,EACH,GAAG;iDAGH,GAAG,EACH,GAAG;gDAGH,GAAG,EACH,GAAG;gDAGH,GAAG,EACH,GAAG;4CAGH,GAAG,EACH,GAAG;4CAGH,GAAG,EACH,GAAG;YAfJ,yDAAA,yBAAA,cAAkB,CAAC,YAAA,kRAAA;YAInB,wDAAA,uBAAA,cAAkB,OAAO,CAAC,CAAC,CAAC,CAAC,cAAA,uQAAA;YAI7B,wDAAA,uBAAA,UAAc,KAAa,IAAI,CAAC,cAAA,4RAAA;YAQhC,oDAAA,uBAAA,4FAAuB,cAAA,EAAvB,uBAAA,iGAAuB,cAAA,wXAAA;YApCvB,qKAAA,MAAM,wCAAK;YAIX,0JAAI,CAAC,wCAAgB;YAIrB,qKAAI,CAAC,mDAAmB;YAQxB,wJAAS,CAAC,6BAAD,CAAC,8DAAK;YAgBf,kYAAc;YApBd,qJAAA,CAAC,6BAAD,CAAC,8DAAK;YAfV,wJAwCC;;YAxCK,wDAAC;;QAGH,MAAM,KAAI,CAAC;QAIX,IAAI,CAAC,KAAK,OAAO,CAAC,CAAC,CAAC,CAAC;QAIrB,IAAI,CAAC,CAAC,KAAa,IAAI,CAAC;QAIxB,CAAC,kGAAG,CAAC,GAAC;QAIN,+DAAa,CAAC,EAAC;QAAf,IAAS,CAAC,uCAAK;QAAf,IAAS,CAAC,6CAAK;;YAgBR,8EAAK,CAAC,GAAJ,CAAK;;;YAIE,+FAAK,CAAC,GAAJ,CAAK;;;YAvCrB,uDAAC"} +//// https://sokra.github.io/source-map-visualization#base64,dmFyIF9fZXNEZWNvcmF0ZSA9ICh0aGlzICYmIHRoaXMuX19lc0RlY29yYXRlKSB8fCBmdW5jdGlvbiAoY3RvciwgZGVzY3JpcHRvckluLCBkZWNvcmF0b3JzLCBjb250ZXh0SW4sIGluaXRpYWxpemVycywgZXh0cmFJbml0aWFsaXplcnMpIHsNCiAgICBmdW5jdGlvbiBhY2NlcHQoZikgeyBpZiAoZiAhPT0gdm9pZCAwICYmIHR5cGVvZiBmICE9PSAiZnVuY3Rpb24iKSB0aHJvdyBuZXcgVHlwZUVycm9yKCJGdW5jdGlvbiBleHBlY3RlZCIpOyByZXR1cm4gZjsgfQ0KICAgIHZhciBraW5kID0gY29udGV4dEluLmtpbmQsIGtleSA9IGtpbmQgPT09ICJnZXR0ZXIiID8gImdldCIgOiBraW5kID09PSAic2V0dGVyIiA/ICJzZXQiIDogInZhbHVlIjsNCiAgICB2YXIgdGFyZ2V0ID0gIWRlc2NyaXB0b3JJbiAmJiBjdG9yID8gY29udGV4dEluWyJzdGF0aWMiXSA/IGN0b3IgOiBjdG9yLnByb3RvdHlwZSA6IG51bGw7DQogICAgdmFyIGRlc2NyaXB0b3IgPSBkZXNjcmlwdG9ySW4gfHwgKHRhcmdldCA/IE9iamVjdC5nZXRPd25Qcm9wZXJ0eURlc2NyaXB0b3IodGFyZ2V0LCBjb250ZXh0SW4ubmFtZSkgOiB7fSk7DQogICAgdmFyIF8sIGRvbmUgPSBmYWxzZTsNCiAgICBmb3IgKHZhciBpID0gZGVjb3JhdG9ycy5sZW5ndGggLSAxOyBpID49IDA7IGktLSkgew0KICAgICAgICB2YXIgY29udGV4dCA9IHt9Ow0KICAgICAgICBmb3IgKHZhciBwIGluIGNvbnRleHRJbikgY29udGV4dFtwXSA9IHAgPT09ICJhY2Nlc3MiID8ge30gOiBjb250ZXh0SW5bcF07DQogICAgICAgIGZvciAodmFyIHAgaW4gY29udGV4dEluLmFjY2VzcykgY29udGV4dC5hY2Nlc3NbcF0gPSBjb250ZXh0SW4uYWNjZXNzW3BdOw0KICAgICAgICBjb250ZXh0LmFkZEluaXRpYWxpemVyID0gZnVuY3Rpb24gKGYpIHsgaWYgKGRvbmUpIHRocm93IG5ldyBUeXBlRXJyb3IoIkNhbm5vdCBhZGQgaW5pdGlhbGl6ZXJzIGFmdGVyIGRlY29yYXRpb24gaGFzIGNvbXBsZXRlZCIpOyBleHRyYUluaXRpYWxpemVycy5wdXNoKGFjY2VwdChmIHx8IG51bGwpKTsgfTsNCiAgICAgICAgdmFyIHJlc3VsdCA9ICgwLCBkZWNvcmF0b3JzW2ldKShraW5kID09PSAiYWNjZXNzb3IiID8geyBnZXQ6IGRlc2NyaXB0b3IuZ2V0LCBzZXQ6IGRlc2NyaXB0b3Iuc2V0IH0gOiBkZXNjcmlwdG9yW2tleV0sIGNvbnRleHQpOw0KICAgICAgICBpZiAoa2luZCA9PT0gImFjY2Vzc29yIikgew0KICAgICAgICAgICAgaWYgKHJlc3VsdCA9PT0gdm9pZCAwKSBjb250aW51ZTsNCiAgICAgICAgICAgIGlmIChyZXN1bHQgPT09IG51bGwgfHwgdHlwZW9mIHJlc3VsdCAhPT0gIm9iamVjdCIpIHRocm93IG5ldyBUeXBlRXJyb3IoIk9iamVjdCBleHBlY3RlZCIpOw0KICAgICAgICAgICAgaWYgKF8gPSBhY2NlcHQocmVzdWx0LmdldCkpIGRlc2NyaXB0b3IuZ2V0ID0gXzsNCiAgICAgICAgICAgIGlmIChfID0gYWNjZXB0KHJlc3VsdC5zZXQpKSBkZXNjcmlwdG9yLnNldCA9IF87DQogICAgICAgICAgICBpZiAoXyA9IGFjY2VwdChyZXN1bHQuaW5pdCkpIGluaXRpYWxpemVycy51bnNoaWZ0KF8pOw0KICAgICAgICB9DQogICAgICAgIGVsc2UgaWYgKF8gPSBhY2NlcHQocmVzdWx0KSkgew0KICAgICAgICAgICAgaWYgKGtpbmQgPT09ICJmaWVsZCIpIGluaXRpYWxpemVycy51bnNoaWZ0KF8pOw0KICAgICAgICAgICAgZWxzZSBkZXNjcmlwdG9yW2tleV0gPSBfOw0KICAgICAgICB9DQogICAgfQ0KICAgIGlmICh0YXJnZXQpIE9iamVjdC5kZWZpbmVQcm9wZXJ0eSh0YXJnZXQsIGNvbnRleHRJbi5uYW1lLCBkZXNjcmlwdG9yKTsNCiAgICBkb25lID0gdHJ1ZTsNCn07DQp2YXIgX19ydW5Jbml0aWFsaXplcnMgPSAodGhpcyAmJiB0aGlzLl9fcnVuSW5pdGlhbGl6ZXJzKSB8fCBmdW5jdGlvbiAodGhpc0FyZywgaW5pdGlhbGl6ZXJzLCB2YWx1ZSkgew0KICAgIHZhciB1c2VWYWx1ZSA9IGFyZ3VtZW50cy5sZW5ndGggPiAyOw0KICAgIGZvciAodmFyIGkgPSAwOyBpIDwgaW5pdGlhbGl6ZXJzLmxlbmd0aDsgaSsrKSB7DQogICAgICAgIHZhbHVlID0gdXNlVmFsdWUgPyBpbml0aWFsaXplcnNbaV0uY2FsbCh0aGlzQXJnLCB2YWx1ZSkgOiBpbml0aWFsaXplcnNbaV0uY2FsbCh0aGlzQXJnKTsNCiAgICB9DQogICAgcmV0dXJuIHVzZVZhbHVlID8gdmFsdWUgOiB2b2lkIDA7DQp9Ow0KdmFyIF9fc2V0RnVuY3Rpb25OYW1lID0gKHRoaXMgJiYgdGhpcy5fX3NldEZ1bmN0aW9uTmFtZSkgfHwgZnVuY3Rpb24gKGYsIG5hbWUsIHByZWZpeCkgew0KICAgIGlmICh0eXBlb2YgbmFtZSA9PT0gInN5bWJvbCIpIG5hbWUgPSBuYW1lLmRlc2NyaXB0aW9uID8gIlsiLmNvbmNhdChuYW1lLmRlc2NyaXB0aW9uLCAiXSIpIDogIiI7DQogICAgcmV0dXJuIE9iamVjdC5kZWZpbmVQcm9wZXJ0eShmLCAibmFtZSIsIHsgY29uZmlndXJhYmxlOiB0cnVlLCB2YWx1ZTogcHJlZml4ID8gIiIuY29uY2F0KHByZWZpeCwgIiAiLCBuYW1lKSA6IG5hbWUgfSk7DQp9Ow0KdmFyIF9fY2xhc3NQcml2YXRlRmllbGRJbiA9ICh0aGlzICYmIHRoaXMuX19jbGFzc1ByaXZhdGVGaWVsZEluKSB8fCBmdW5jdGlvbihzdGF0ZSwgcmVjZWl2ZXIpIHsNCiAgICBpZiAocmVjZWl2ZXIgPT09IG51bGwgfHwgKHR5cGVvZiByZWNlaXZlciAhPT0gIm9iamVjdCIgJiYgdHlwZW9mIHJlY2VpdmVyICE9PSAiZnVuY3Rpb24iKSkgdGhyb3cgbmV3IFR5cGVFcnJvcigiQ2Fubm90IHVzZSAnaW4nIG9wZXJhdG9yIG9uIG5vbi1vYmplY3QiKTsNCiAgICByZXR1cm4gdHlwZW9mIHN0YXRlID09PSAiZnVuY3Rpb24iID8gcmVjZWl2ZXIgPT09IHN0YXRlIDogc3RhdGUuaGFzKHJlY2VpdmVyKTsNCn07DQp2YXIgX19jbGFzc1ByaXZhdGVGaWVsZEdldCA9ICh0aGlzICYmIHRoaXMuX19jbGFzc1ByaXZhdGVGaWVsZEdldCkgfHwgZnVuY3Rpb24gKHJlY2VpdmVyLCBzdGF0ZSwga2luZCwgZikgew0KICAgIGlmIChraW5kID09PSAiYSIgJiYgIWYpIHRocm93IG5ldyBUeXBlRXJyb3IoIlByaXZhdGUgYWNjZXNzb3Igd2FzIGRlZmluZWQgd2l0aG91dCBhIGdldHRlciIpOw0KICAgIGlmICh0eXBlb2Ygc3RhdGUgPT09ICJmdW5jdGlvbiIgPyByZWNlaXZlciAhPT0gc3RhdGUgfHwgIWYgOiAhc3RhdGUuaGFzKHJlY2VpdmVyKSkgdGhyb3cgbmV3IFR5cGVFcnJvcigiQ2Fubm90IHJlYWQgcHJpdmF0ZSBtZW1iZXIgZnJvbSBhbiBvYmplY3Qgd2hvc2UgY2xhc3MgZGlkIG5vdCBkZWNsYXJlIGl0Iik7DQogICAgcmV0dXJuIGtpbmQgPT09ICJtIiA/IGYgOiBraW5kID09PSAiYSIgPyBmLmNhbGwocmVjZWl2ZXIpIDogZiA/IGYudmFsdWUgOiBzdGF0ZS5nZXQocmVjZWl2ZXIpOw0KfTsNCnZhciBfX2NsYXNzUHJpdmF0ZUZpZWxkU2V0ID0gKHRoaXMgJiYgdGhpcy5fX2NsYXNzUHJpdmF0ZUZpZWxkU2V0KSB8fCBmdW5jdGlvbiAocmVjZWl2ZXIsIHN0YXRlLCB2YWx1ZSwga2luZCwgZikgew0KICAgIGlmIChraW5kID09PSAibSIpIHRocm93IG5ldyBUeXBlRXJyb3IoIlByaXZhdGUgbWV0aG9kIGlzIG5vdCB3cml0YWJsZSIpOw0KICAgIGlmIChraW5kID09PSAiYSIgJiYgIWYpIHRocm93IG5ldyBUeXBlRXJyb3IoIlByaXZhdGUgYWNjZXNzb3Igd2FzIGRlZmluZWQgd2l0aG91dCBhIHNldHRlciIpOw0KICAgIGlmICh0eXBlb2Ygc3RhdGUgPT09ICJmdW5jdGlvbiIgPyByZWNlaXZlciAhPT0gc3RhdGUgfHwgIWYgOiAhc3RhdGUuaGFzKHJlY2VpdmVyKSkgdGhyb3cgbmV3IFR5cGVFcnJvcigiQ2Fubm90IHdyaXRlIHByaXZhdGUgbWVtYmVyIHRvIGFuIG9iamVjdCB3aG9zZSBjbGFzcyBkaWQgbm90IGRlY2xhcmUgaXQiKTsNCiAgICByZXR1cm4gKGtpbmQgPT09ICJhIiA/IGYuY2FsbChyZWNlaXZlciwgdmFsdWUpIDogZiA/IGYudmFsdWUgPSB2YWx1ZSA6IHN0YXRlLnNldChyZWNlaXZlciwgdmFsdWUpKSwgdmFsdWU7DQp9Ow0KbGV0IEMgPSAoKCkgPT4gew0KICAgIHZhciBfQ19tZXRob2RfZ2V0LCBfQ194X2dldCwgX0NfeF9zZXQsIF9DX3ksIF9DX3pfYWNjZXNzb3Jfc3RvcmFnZSwgX0Nfel9nZXQsIF9DX3pfc2V0Ow0KICAgIGxldCBfY2xhc3NEZWNvcmF0b3JzID0gW2RlYywgZGVjXTsNCiAgICBsZXQgX2NsYXNzRGVzY3JpcHRvcjsNCiAgICBsZXQgX2NsYXNzRXh0cmFJbml0aWFsaXplcnMgPSBbXTsNCiAgICBsZXQgX2NsYXNzVGhpczsNCiAgICBsZXQgX3N0YXRpY0V4dHJhSW5pdGlhbGl6ZXJzID0gW107DQogICAgbGV0IF9pbnN0YW5jZUV4dHJhSW5pdGlhbGl6ZXJzID0gW107DQogICAgbGV0IF9zdGF0aWNfcHJpdmF0ZV9tZXRob2RfZGVjb3JhdG9yczsNCiAgICBsZXQgX3N0YXRpY19wcml2YXRlX21ldGhvZF9kZXNjcmlwdG9yOw0KICAgIGxldCBfc3RhdGljX3ByaXZhdGVfZ2V0X3hfZGVjb3JhdG9yczsNCiAgICBsZXQgX3N0YXRpY19wcml2YXRlX2dldF94X2Rlc2NyaXB0b3I7DQogICAgbGV0IF9zdGF0aWNfcHJpdmF0ZV9zZXRfeF9kZWNvcmF0b3JzOw0KICAgIGxldCBfc3RhdGljX3ByaXZhdGVfc2V0X3hfZGVzY3JpcHRvcjsNCiAgICBsZXQgX3N0YXRpY19wcml2YXRlX3lfZGVjb3JhdG9yczsNCiAgICBsZXQgX3N0YXRpY19wcml2YXRlX3lfaW5pdGlhbGl6ZXJzID0gW107DQogICAgbGV0IF9zdGF0aWNfcHJpdmF0ZV96X2RlY29yYXRvcnM7DQogICAgbGV0IF9zdGF0aWNfcHJpdmF0ZV96X2luaXRpYWxpemVycyA9IFtdOw0KICAgIGxldCBfc3RhdGljX3ByaXZhdGVfel9kZXNjcmlwdG9yOw0KICAgIGxldCBfbWV0aG9kX2RlY29yYXRvcnM7DQogICAgbGV0IF9nZXRfeF9kZWNvcmF0b3JzOw0KICAgIGxldCBfc2V0X3hfZGVjb3JhdG9yczsNCiAgICBsZXQgX3lfZGVjb3JhdG9yczsNCiAgICBsZXQgX3lfaW5pdGlhbGl6ZXJzID0gW107DQogICAgbGV0IF96X2RlY29yYXRvcnM7DQogICAgbGV0IF96X2luaXRpYWxpemVycyA9IFtdOw0KICAgIHZhciBDID0gY2xhc3Mgew0KICAgICAgICBzdGF0aWMgeyBfY2xhc3NUaGlzID0gdGhpczsgfQ0KICAgICAgICBzdGF0aWMgeyBfX3NldEZ1bmN0aW9uTmFtZSh0aGlzLCAiQyIpOyB9DQogICAgICAgIHN0YXRpYyB7IF9DX21ldGhvZF9nZXQgPSBmdW5jdGlvbiBfQ19tZXRob2RfZ2V0KCkgeyByZXR1cm4gX3N0YXRpY19wcml2YXRlX21ldGhvZF9kZXNjcmlwdG9yLnZhbHVlOyB9LCBfQ194X2dldCA9IGZ1bmN0aW9uIF9DX3hfZ2V0KCkgeyByZXR1cm4gX3N0YXRpY19wcml2YXRlX2dldF94X2Rlc2NyaXB0b3IuZ2V0LmNhbGwodGhpcyk7IH0sIF9DX3hfc2V0ID0gZnVuY3Rpb24gX0NfeF9zZXQodmFsdWUpIHsgcmV0dXJuIF9zdGF0aWNfcHJpdmF0ZV9zZXRfeF9kZXNjcmlwdG9yLnNldC5jYWxsKHRoaXMsIHZhbHVlKTsgfSwgX0Nfel9nZXQgPSBmdW5jdGlvbiBfQ196X2dldCgpIHsgcmV0dXJuIF9zdGF0aWNfcHJpdmF0ZV96X2Rlc2NyaXB0b3IuZ2V0LmNhbGwodGhpcyk7IH0sIF9DX3pfc2V0ID0gZnVuY3Rpb24gX0Nfel9zZXQodmFsdWUpIHsgcmV0dXJuIF9zdGF0aWNfcHJpdmF0ZV96X2Rlc2NyaXB0b3Iuc2V0LmNhbGwodGhpcywgdmFsdWUpOyB9OyB9DQogICAgICAgIHN0YXRpYyB7DQogICAgICAgICAgICBfbWV0aG9kX2RlY29yYXRvcnMgPSBbZGVjLCBkZWNdOw0KICAgICAgICAgICAgX2dldF94X2RlY29yYXRvcnMgPSBbZGVjLCBkZWNdOw0KICAgICAgICAgICAgX3NldF94X2RlY29yYXRvcnMgPSBbZGVjLCBkZWNdOw0KICAgICAgICAgICAgX3lfZGVjb3JhdG9ycyA9IFtkZWMsIGRlY107DQogICAgICAgICAgICBfel9kZWNvcmF0b3JzID0gW2RlYywgZGVjXTsNCiAgICAgICAgICAgIF9zdGF0aWNfcHJpdmF0ZV9tZXRob2RfZGVjb3JhdG9ycyA9IFtkZWMsIGRlY107DQogICAgICAgICAgICBfc3RhdGljX3ByaXZhdGVfZ2V0X3hfZGVjb3JhdG9ycyA9IFtkZWMsIGRlY107DQogICAgICAgICAgICBfc3RhdGljX3ByaXZhdGVfc2V0X3hfZGVjb3JhdG9ycyA9IFtkZWMsIGRlY107DQogICAgICAgICAgICBfc3RhdGljX3ByaXZhdGVfeV9kZWNvcmF0b3JzID0gW2RlYywgZGVjXTsNCiAgICAgICAgICAgIF9zdGF0aWNfcHJpdmF0ZV96X2RlY29yYXRvcnMgPSBbZGVjLCBkZWNdOw0KICAgICAgICAgICAgX19lc0RlY29yYXRlKHRoaXMsIF9zdGF0aWNfcHJpdmF0ZV9tZXRob2RfZGVzY3JpcHRvciA9IHsgdmFsdWU6IF9fc2V0RnVuY3Rpb25OYW1lKGZ1bmN0aW9uICgpIHsgfSwgIiNtZXRob2QiKSB9LCBfc3RhdGljX3ByaXZhdGVfbWV0aG9kX2RlY29yYXRvcnMsIHsga2luZDogIm1ldGhvZCIsIG5hbWU6ICIjbWV0aG9kIiwgc3RhdGljOiB0cnVlLCBwcml2YXRlOiB0cnVlLCBhY2Nlc3M6IHsgaGFzOiBvYmogPT4gX19jbGFzc1ByaXZhdGVGaWVsZEluKF9jbGFzc1RoaXMsIG9iaiksIGdldDogb2JqID0+IF9fY2xhc3NQcml2YXRlRmllbGRHZXQob2JqLCBfY2xhc3NUaGlzLCAiYSIsIF9DX21ldGhvZF9nZXQpIH0gfSwgbnVsbCwgX3N0YXRpY0V4dHJhSW5pdGlhbGl6ZXJzKTsNCiAgICAgICAgICAgIF9fZXNEZWNvcmF0ZSh0aGlzLCBfc3RhdGljX3ByaXZhdGVfZ2V0X3hfZGVzY3JpcHRvciA9IHsgZ2V0OiBfX3NldEZ1bmN0aW9uTmFtZShmdW5jdGlvbiAoKSB7IHJldHVybiAxOyB9LCAiI3giLCAiZ2V0IikgfSwgX3N0YXRpY19wcml2YXRlX2dldF94X2RlY29yYXRvcnMsIHsga2luZDogImdldHRlciIsIG5hbWU6ICIjeCIsIHN0YXRpYzogdHJ1ZSwgcHJpdmF0ZTogdHJ1ZSwgYWNjZXNzOiB7IGhhczogb2JqID0+IF9fY2xhc3NQcml2YXRlRmllbGRJbihfY2xhc3NUaGlzLCBvYmopLCBnZXQ6IG9iaiA9PiBfX2NsYXNzUHJpdmF0ZUZpZWxkR2V0KG9iaiwgX2NsYXNzVGhpcywgImEiLCBfQ194X2dldCkgfSB9LCBudWxsLCBfc3RhdGljRXh0cmFJbml0aWFsaXplcnMpOw0KICAgICAgICAgICAgX19lc0RlY29yYXRlKHRoaXMsIF9zdGF0aWNfcHJpdmF0ZV9zZXRfeF9kZXNjcmlwdG9yID0geyBzZXQ6IF9fc2V0RnVuY3Rpb25OYW1lKGZ1bmN0aW9uICh2YWx1ZSkgeyB9LCAiI3giLCAic2V0IikgfSwgX3N0YXRpY19wcml2YXRlX3NldF94X2RlY29yYXRvcnMsIHsga2luZDogInNldHRlciIsIG5hbWU6ICIjeCIsIHN0YXRpYzogdHJ1ZSwgcHJpdmF0ZTogdHJ1ZSwgYWNjZXNzOiB7IGhhczogb2JqID0+IF9fY2xhc3NQcml2YXRlRmllbGRJbihfY2xhc3NUaGlzLCBvYmopLCBzZXQ6IChvYmosIHZhbHVlKSA9PiB7IF9fY2xhc3NQcml2YXRlRmllbGRTZXQob2JqLCBfY2xhc3NUaGlzLCB2YWx1ZSwgImEiLCBfQ194X3NldCk7IH0gfSB9LCBudWxsLCBfc3RhdGljRXh0cmFJbml0aWFsaXplcnMpOw0KICAgICAgICAgICAgX19lc0RlY29yYXRlKHRoaXMsIF9zdGF0aWNfcHJpdmF0ZV96X2Rlc2NyaXB0b3IgPSB7IGdldDogX19zZXRGdW5jdGlvbk5hbWUoZnVuY3Rpb24gKCkgeyByZXR1cm4gX19jbGFzc1ByaXZhdGVGaWVsZEdldCh0aGlzLCBfY2xhc3NUaGlzLCAiZiIsIF9DX3pfYWNjZXNzb3Jfc3RvcmFnZSk7IH0sICIjeiIsICJnZXQiKSwgc2V0OiBfX3NldEZ1bmN0aW9uTmFtZShmdW5jdGlvbiAodmFsdWUpIHsgX19jbGFzc1ByaXZhdGVGaWVsZFNldCh0aGlzLCBfY2xhc3NUaGlzLCB2YWx1ZSwgImYiLCBfQ196X2FjY2Vzc29yX3N0b3JhZ2UpOyB9LCAiI3oiLCAic2V0IikgfSwgX3N0YXRpY19wcml2YXRlX3pfZGVjb3JhdG9ycywgeyBraW5kOiAiYWNjZXNzb3IiLCBuYW1lOiAiI3oiLCBzdGF0aWM6IHRydWUsIHByaXZhdGU6IHRydWUsIGFjY2VzczogeyBoYXM6IG9iaiA9PiBfX2NsYXNzUHJpdmF0ZUZpZWxkSW4oX2NsYXNzVGhpcywgb2JqKSwgZ2V0OiBvYmogPT4gX19jbGFzc1ByaXZhdGVGaWVsZEdldChvYmosIF9jbGFzc1RoaXMsICJhIiwgX0Nfel9nZXQpLCBzZXQ6IChvYmosIHZhbHVlKSA9PiB7IF9fY2xhc3NQcml2YXRlRmllbGRTZXQob2JqLCBfY2xhc3NUaGlzLCB2YWx1ZSwgImEiLCBfQ196X3NldCk7IH0gfSB9LCBfc3RhdGljX3ByaXZhdGVfel9pbml0aWFsaXplcnMsIF9zdGF0aWNFeHRyYUluaXRpYWxpemVycyk7DQogICAgICAgICAgICBfX2VzRGVjb3JhdGUodGhpcywgbnVsbCwgX21ldGhvZF9kZWNvcmF0b3JzLCB7IGtpbmQ6ICJtZXRob2QiLCBuYW1lOiAibWV0aG9kIiwgc3RhdGljOiBmYWxzZSwgcHJpdmF0ZTogZmFsc2UsIGFjY2VzczogeyBoYXM6IG9iaiA9PiAibWV0aG9kIiBpbiBvYmosIGdldDogb2JqID0+IG9iai5tZXRob2QgfSB9LCBudWxsLCBfaW5zdGFuY2VFeHRyYUluaXRpYWxpemVycyk7DQogICAgICAgICAgICBfX2VzRGVjb3JhdGUodGhpcywgbnVsbCwgX2dldF94X2RlY29yYXRvcnMsIHsga2luZDogImdldHRlciIsIG5hbWU6ICJ4Iiwgc3RhdGljOiBmYWxzZSwgcHJpdmF0ZTogZmFsc2UsIGFjY2VzczogeyBoYXM6IG9iaiA9PiAieCIgaW4gb2JqLCBnZXQ6IG9iaiA9PiBvYmoueCB9IH0sIG51bGwsIF9pbnN0YW5jZUV4dHJhSW5pdGlhbGl6ZXJzKTsNCiAgICAgICAgICAgIF9fZXNEZWNvcmF0ZSh0aGlzLCBudWxsLCBfc2V0X3hfZGVjb3JhdG9ycywgeyBraW5kOiAic2V0dGVyIiwgbmFtZTogIngiLCBzdGF0aWM6IGZhbHNlLCBwcml2YXRlOiBmYWxzZSwgYWNjZXNzOiB7IGhhczogb2JqID0+ICJ4IiBpbiBvYmosIHNldDogKG9iaiwgdmFsdWUpID0+IHsgb2JqLnggPSB2YWx1ZTsgfSB9IH0sIG51bGwsIF9pbnN0YW5jZUV4dHJhSW5pdGlhbGl6ZXJzKTsNCiAgICAgICAgICAgIF9fZXNEZWNvcmF0ZSh0aGlzLCBudWxsLCBfel9kZWNvcmF0b3JzLCB7IGtpbmQ6ICJhY2Nlc3NvciIsIG5hbWU6ICJ6Iiwgc3RhdGljOiBmYWxzZSwgcHJpdmF0ZTogZmFsc2UsIGFjY2VzczogeyBoYXM6IG9iaiA9PiAieiIgaW4gb2JqLCBnZXQ6IG9iaiA9PiBvYmoueiwgc2V0OiAob2JqLCB2YWx1ZSkgPT4geyBvYmoueiA9IHZhbHVlOyB9IH0gfSwgX3pfaW5pdGlhbGl6ZXJzLCBfaW5zdGFuY2VFeHRyYUluaXRpYWxpemVycyk7DQogICAgICAgICAgICBfX2VzRGVjb3JhdGUobnVsbCwgbnVsbCwgX3N0YXRpY19wcml2YXRlX3lfZGVjb3JhdG9ycywgeyBraW5kOiAiZmllbGQiLCBuYW1lOiAiI3kiLCBzdGF0aWM6IHRydWUsIHByaXZhdGU6IHRydWUsIGFjY2VzczogeyBoYXM6IG9iaiA9PiBfX2NsYXNzUHJpdmF0ZUZpZWxkSW4oX2NsYXNzVGhpcywgb2JqKSwgZ2V0OiBvYmogPT4gX19jbGFzc1ByaXZhdGVGaWVsZEdldChvYmosIF9jbGFzc1RoaXMsICJmIiwgX0NfeSksIHNldDogKG9iaiwgdmFsdWUpID0+IHsgX19jbGFzc1ByaXZhdGVGaWVsZFNldChvYmosIF9jbGFzc1RoaXMsIHZhbHVlLCAiZiIsIF9DX3kpOyB9IH0gfSwgX3N0YXRpY19wcml2YXRlX3lfaW5pdGlhbGl6ZXJzLCBfc3RhdGljRXh0cmFJbml0aWFsaXplcnMpOw0KICAgICAgICAgICAgX19lc0RlY29yYXRlKG51bGwsIG51bGwsIF95X2RlY29yYXRvcnMsIHsga2luZDogImZpZWxkIiwgbmFtZTogInkiLCBzdGF0aWM6IGZhbHNlLCBwcml2YXRlOiBmYWxzZSwgYWNjZXNzOiB7IGhhczogb2JqID0+ICJ5IiBpbiBvYmosIGdldDogb2JqID0+IG9iai55LCBzZXQ6IChvYmosIHZhbHVlKSA9PiB7IG9iai55ID0gdmFsdWU7IH0gfSB9LCBfeV9pbml0aWFsaXplcnMsIF9pbnN0YW5jZUV4dHJhSW5pdGlhbGl6ZXJzKTsNCiAgICAgICAgICAgIF9fZXNEZWNvcmF0ZShudWxsLCBfY2xhc3NEZXNjcmlwdG9yID0geyB2YWx1ZTogX2NsYXNzVGhpcyB9LCBfY2xhc3NEZWNvcmF0b3JzLCB7IGtpbmQ6ICJjbGFzcyIsIG5hbWU6IF9jbGFzc1RoaXMubmFtZSB9LCBudWxsLCBfY2xhc3NFeHRyYUluaXRpYWxpemVycyk7DQogICAgICAgICAgICBDID0gX2NsYXNzVGhpcyA9IF9jbGFzc0Rlc2NyaXB0b3IudmFsdWU7DQogICAgICAgICAgICBfX3J1bkluaXRpYWxpemVycyhfY2xhc3NUaGlzLCBfc3RhdGljRXh0cmFJbml0aWFsaXplcnMpOw0KICAgICAgICB9DQogICAgICAgIG1ldGhvZCgpIHsgfQ0KICAgICAgICBnZXQgeCgpIHsgcmV0dXJuIDE7IH0NCiAgICAgICAgc2V0IHgodmFsdWUpIHsgfQ0KICAgICAgICB5ID0gKF9fcnVuSW5pdGlhbGl6ZXJzKHRoaXMsIF9pbnN0YW5jZUV4dHJhSW5pdGlhbGl6ZXJzKSwgX19ydW5Jbml0aWFsaXplcnModGhpcywgX3lfaW5pdGlhbGl6ZXJzLCAxKSk7DQogICAgICAgICN6X2FjY2Vzc29yX3N0b3JhZ2UgPSBfX3J1bkluaXRpYWxpemVycyh0aGlzLCBfel9pbml0aWFsaXplcnMsIDEpOw0KICAgICAgICBnZXQgeigpIHsgcmV0dXJuIHRoaXMuI3pfYWNjZXNzb3Jfc3RvcmFnZTsgfQ0KICAgICAgICBzZXQgeih2YWx1ZSkgeyB0aGlzLiN6X2FjY2Vzc29yX3N0b3JhZ2UgPSB2YWx1ZTsgfQ0KICAgICAgICBzdGF0aWMgew0KICAgICAgICAgICAgX0NfeSA9IHsgdmFsdWU6IF9fcnVuSW5pdGlhbGl6ZXJzKF9jbGFzc1RoaXMsIF9zdGF0aWNfcHJpdmF0ZV95X2luaXRpYWxpemVycywgMSkgfTsNCiAgICAgICAgfQ0KICAgICAgICBzdGF0aWMgew0KICAgICAgICAgICAgX0Nfel9hY2Nlc3Nvcl9zdG9yYWdlID0geyB2YWx1ZTogX19ydW5Jbml0aWFsaXplcnMoX2NsYXNzVGhpcywgX3N0YXRpY19wcml2YXRlX3pfaW5pdGlhbGl6ZXJzLCAxKSB9Ow0KICAgICAgICB9DQogICAgICAgIHN0YXRpYyB7DQogICAgICAgICAgICBfX3J1bkluaXRpYWxpemVycyhfY2xhc3NUaGlzLCBfY2xhc3NFeHRyYUluaXRpYWxpemVycyk7DQogICAgICAgIH0NCiAgICB9Ow0KICAgIHJldHVybiBDID0gX2NsYXNzVGhpczsNCn0pKCk7DQovLyMgc291cmNlTWFwcGluZ1VSTD1lc0RlY29yYXRvcnMtY2xhc3NEZWNsYXJhdGlvbi1zb3VyY2VNYXAuanMubWFw,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiZXNEZWNvcmF0b3JzLWNsYXNzRGVjbGFyYXRpb24tc291cmNlTWFwLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiZXNEZWNvcmF0b3JzLWNsYXNzRGVjbGFyYXRpb24tc291cmNlTWFwLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7O0lBSU0sQ0FBQzs7NEJBRk4sR0FBRyxFQUNILEdBQUc7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7O2tDQUVDLEdBQUcsRUFDSCxHQUFHO2lDQUdILEdBQUcsRUFDSCxHQUFHO2lDQUdILEdBQUcsRUFDSCxHQUFHOzZCQUdILEdBQUcsRUFDSCxHQUFHOzZCQUdILEdBQUcsRUFDSCxHQUFHO2lEQUdILEdBQUcsRUFDSCxHQUFHO2dEQUdILEdBQUcsRUFDSCxHQUFHO2dEQUdILEdBQUcsRUFDSCxHQUFHOzRDQUdILEdBQUcsRUFDSCxHQUFHOzRDQUdILEdBQUcsRUFDSCxHQUFHO1lBZkoseURBQUEseUJBQUEsY0FBa0IsQ0FBQyxZQUFBLGtSQUFBO1lBSW5CLHdEQUFBLHVCQUFBLGNBQWtCLE9BQU8sQ0FBQyxDQUFDLENBQUMsQ0FBQyxjQUFBLHVRQUFBO1lBSTdCLHdEQUFBLHVCQUFBLFVBQWMsS0FBYSxJQUFJLENBQUMsY0FBQSw0UkFBQTtZQVFoQyxvREFBQSx1QkFBQSw0RkFBdUIsY0FBQSxFQUF2Qix1QkFBQSxpR0FBdUIsY0FBQSx3WEFBQTtZQXBDdkIscUtBQUEsTUFBTSx3Q0FBSztZQUlYLDBKQUFJLENBQUMsd0NBQWdCO1lBSXJCLHFLQUFJLENBQUMsbURBQW1CO1lBUXhCLHdKQUFTLENBQUMsNkJBQUQsQ0FBQyw4REFBSztZQWdCZixrWUFBYztZQXBCZCxxSkFBQSxDQUFDLDZCQUFELENBQUMsOERBQUs7WUFmVix3SkF3Q0M7O1lBeENLLHdEQUFDOztRQUdILE1BQU0sS0FBSSxDQUFDO1FBSVgsSUFBSSxDQUFDLEtBQUssT0FBTyxDQUFDLENBQUMsQ0FBQyxDQUFDO1FBSXJCLElBQUksQ0FBQyxDQUFDLEtBQWEsSUFBSSxDQUFDO1FBSXhCLENBQUMsa0dBQUcsQ0FBQyxHQUFDO1FBSU4sK0RBQWEsQ0FBQyxFQUFDO1FBQWYsSUFBUyxDQUFDLHVDQUFLO1FBQWYsSUFBUyxDQUFDLDZDQUFLOztZQWdCUiw4RUFBSyxDQUFDLEdBQUosQ0FBSzs7O1lBSUUsK0ZBQUssQ0FBQyxHQUFKLENBQUs7OztZQXZDckIsdURBQUMifQ==,ZGVjbGFyZSB2YXIgZGVjOiBhbnk7CgpAZGVjCkBkZWMKY2xhc3MgQyB7CiAgICBAZGVjCiAgICBAZGVjCiAgICBtZXRob2QoKSB7fQoKICAgIEBkZWMKICAgIEBkZWMKICAgIGdldCB4KCkgeyByZXR1cm4gMTsgfQoKICAgIEBkZWMKICAgIEBkZWMKICAgIHNldCB4KHZhbHVlOiBudW1iZXIpIHsgfQoKICAgIEBkZWMKICAgIEBkZWMKICAgIHkgPSAxOwoKICAgIEBkZWMKICAgIEBkZWMKICAgIGFjY2Vzc29yIHogPSAxOwoKICAgIEBkZWMKICAgIEBkZWMKICAgIHN0YXRpYyAjbWV0aG9kKCkge30KCiAgICBAZGVjCiAgICBAZGVjCiAgICBzdGF0aWMgZ2V0ICN4KCkgeyByZXR1cm4gMTsgfQoKICAgIEBkZWMKICAgIEBkZWMKICAgIHN0YXRpYyBzZXQgI3godmFsdWU6IG51bWJlcikgeyB9CgogICAgQGRlYwogICAgQGRlYwogICAgc3RhdGljICN5ID0gMTsKCiAgICBAZGVjCiAgICBAZGVjCiAgICBzdGF0aWMgYWNjZXNzb3IgI3ogPSAxOwp9Cg== //// [esDecorators-classDeclaration-sourceMap.d.ts.map] {"version":3,"file":"esDecorators-classDeclaration-sourceMap.d.ts","sourceRoot":"","sources":["esDecorators-classDeclaration-sourceMap.ts"],"names":[],"mappings":"AAAA,OAAO,CAAC,IAAI,GAAG,EAAE,GAAG,CAAC;AAErB,cAEM,CAAC;;IAGH,MAAM;IAEN,IAEI,CAAC,IAIQ,MAAM,CAJE;IAErB,IAEI,CAAC,CAAC,KAAK,EAAE,MAAM,EAAK;IAIxB,CAAC,SAAK;IAIN,QAAQ,CAAC,CAAC,SAAK;CAqBlB"} diff --git a/tests/baselines/reference/esDecorators-classDeclaration-sourceMap(target=es2022).sourcemap.txt b/tests/baselines/reference/esDecorators-classDeclaration-sourceMap(target=es2022).sourcemap.txt index 05acdcfc7879d..c1e2b24cbb859 100644 --- a/tests/baselines/reference/esDecorators-classDeclaration-sourceMap(target=es2022).sourcemap.txt +++ b/tests/baselines/reference/esDecorators-classDeclaration-sourceMap(target=es2022).sourcemap.txt @@ -64,7 +64,7 @@ sourceFile:esDecorators-classDeclaration-sourceMap.ts >>>let C = (() => { 1 >^^^^ 2 > ^ -3 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> +3 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> 1 >declare var dec: any; > >@dec @@ -74,7 +74,7 @@ sourceFile:esDecorators-classDeclaration-sourceMap.ts 1 >Emitted(54, 5) Source(5, 7) + SourceIndex(0) 2 >Emitted(54, 6) Source(5, 8) + SourceIndex(0) --- ->>> var _method_get, _x_get, _x_set, _y, _z_accessor_storage, _z_get, _z_set; +>>> var _C_method_get, _C_x_get, _C_x_set, _C_y, _C_z_accessor_storage, _C_z_get, _C_z_set; >>> let _classDecorators = [dec, dec]; 1->^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 2 > ^^^ @@ -114,8 +114,9 @@ sourceFile:esDecorators-classDeclaration-sourceMap.ts >>> let _z_decorators; >>> let _z_initializers = []; >>> var C = class { +>>> static { _classThis = this; } >>> static { __setFunctionName(this, "C"); } ->>> static { _method_get = function _method_get() { return _static_private_method_descriptor.value; }, _x_get = function _x_get() { return _static_private_get_x_descriptor.get.call(this); }, _x_set = function _x_set(value) { return _static_private_set_x_descriptor.set.call(this, value); }, _z_get = function _z_get() { return _static_private_z_descriptor.get.call(this); }, _z_set = function _z_set(value) { return _static_private_z_descriptor.set.call(this, value); }; } +>>> static { _C_method_get = function _C_method_get() { return _static_private_method_descriptor.value; }, _C_x_get = function _C_x_get() { return _static_private_get_x_descriptor.get.call(this); }, _C_x_set = function _C_x_set(value) { return _static_private_set_x_descriptor.set.call(this, value); }, _C_z_get = function _C_z_get() { return _static_private_z_descriptor.get.call(this); }, _C_z_set = function _C_z_set(value) { return _static_private_z_descriptor.set.call(this, value); }; } >>> static { >>> _method_decorators = [dec, dec]; 1 >^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -130,10 +131,10 @@ sourceFile:esDecorators-classDeclaration-sourceMap.ts 3 > > @ 4 > dec -1 >Emitted(84, 35) Source(6, 6) + SourceIndex(0) -2 >Emitted(84, 38) Source(6, 9) + SourceIndex(0) -3 >Emitted(84, 40) Source(7, 6) + SourceIndex(0) -4 >Emitted(84, 43) Source(7, 9) + SourceIndex(0) +1 >Emitted(85, 35) Source(6, 6) + SourceIndex(0) +2 >Emitted(85, 38) Source(6, 9) + SourceIndex(0) +3 >Emitted(85, 40) Source(7, 6) + SourceIndex(0) +4 >Emitted(85, 43) Source(7, 9) + SourceIndex(0) --- >>> _get_x_decorators = [dec, dec]; 1->^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -149,10 +150,10 @@ sourceFile:esDecorators-classDeclaration-sourceMap.ts 3 > > @ 4 > dec -1->Emitted(85, 34) Source(10, 6) + SourceIndex(0) -2 >Emitted(85, 37) Source(10, 9) + SourceIndex(0) -3 >Emitted(85, 39) Source(11, 6) + SourceIndex(0) -4 >Emitted(85, 42) Source(11, 9) + SourceIndex(0) +1->Emitted(86, 34) Source(10, 6) + SourceIndex(0) +2 >Emitted(86, 37) Source(10, 9) + SourceIndex(0) +3 >Emitted(86, 39) Source(11, 6) + SourceIndex(0) +4 >Emitted(86, 42) Source(11, 9) + SourceIndex(0) --- >>> _set_x_decorators = [dec, dec]; 1->^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -167,10 +168,10 @@ sourceFile:esDecorators-classDeclaration-sourceMap.ts 3 > > @ 4 > dec -1->Emitted(86, 34) Source(14, 6) + SourceIndex(0) -2 >Emitted(86, 37) Source(14, 9) + SourceIndex(0) -3 >Emitted(86, 39) Source(15, 6) + SourceIndex(0) -4 >Emitted(86, 42) Source(15, 9) + SourceIndex(0) +1->Emitted(87, 34) Source(14, 6) + SourceIndex(0) +2 >Emitted(87, 37) Source(14, 9) + SourceIndex(0) +3 >Emitted(87, 39) Source(15, 6) + SourceIndex(0) +4 >Emitted(87, 42) Source(15, 9) + SourceIndex(0) --- >>> _y_decorators = [dec, dec]; 1 >^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -186,10 +187,10 @@ sourceFile:esDecorators-classDeclaration-sourceMap.ts 3 > > @ 4 > dec -1 >Emitted(87, 30) Source(18, 6) + SourceIndex(0) -2 >Emitted(87, 33) Source(18, 9) + SourceIndex(0) -3 >Emitted(87, 35) Source(19, 6) + SourceIndex(0) -4 >Emitted(87, 38) Source(19, 9) + SourceIndex(0) +1 >Emitted(88, 30) Source(18, 6) + SourceIndex(0) +2 >Emitted(88, 33) Source(18, 9) + SourceIndex(0) +3 >Emitted(88, 35) Source(19, 6) + SourceIndex(0) +4 >Emitted(88, 38) Source(19, 9) + SourceIndex(0) --- >>> _z_decorators = [dec, dec]; 1->^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -205,10 +206,10 @@ sourceFile:esDecorators-classDeclaration-sourceMap.ts 3 > > @ 4 > dec -1->Emitted(88, 30) Source(22, 6) + SourceIndex(0) -2 >Emitted(88, 33) Source(22, 9) + SourceIndex(0) -3 >Emitted(88, 35) Source(23, 6) + SourceIndex(0) -4 >Emitted(88, 38) Source(23, 9) + SourceIndex(0) +1->Emitted(89, 30) Source(22, 6) + SourceIndex(0) +2 >Emitted(89, 33) Source(22, 9) + SourceIndex(0) +3 >Emitted(89, 35) Source(23, 6) + SourceIndex(0) +4 >Emitted(89, 38) Source(23, 9) + SourceIndex(0) --- >>> _static_private_method_decorators = [dec, dec]; 1->^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -224,10 +225,10 @@ sourceFile:esDecorators-classDeclaration-sourceMap.ts 3 > > @ 4 > dec -1->Emitted(89, 50) Source(26, 6) + SourceIndex(0) -2 >Emitted(89, 53) Source(26, 9) + SourceIndex(0) -3 >Emitted(89, 55) Source(27, 6) + SourceIndex(0) -4 >Emitted(89, 58) Source(27, 9) + SourceIndex(0) +1->Emitted(90, 50) Source(26, 6) + SourceIndex(0) +2 >Emitted(90, 53) Source(26, 9) + SourceIndex(0) +3 >Emitted(90, 55) Source(27, 6) + SourceIndex(0) +4 >Emitted(90, 58) Source(27, 9) + SourceIndex(0) --- >>> _static_private_get_x_decorators = [dec, dec]; 1->^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -243,10 +244,10 @@ sourceFile:esDecorators-classDeclaration-sourceMap.ts 3 > > @ 4 > dec -1->Emitted(90, 49) Source(30, 6) + SourceIndex(0) -2 >Emitted(90, 52) Source(30, 9) + SourceIndex(0) -3 >Emitted(90, 54) Source(31, 6) + SourceIndex(0) -4 >Emitted(90, 57) Source(31, 9) + SourceIndex(0) +1->Emitted(91, 49) Source(30, 6) + SourceIndex(0) +2 >Emitted(91, 52) Source(30, 9) + SourceIndex(0) +3 >Emitted(91, 54) Source(31, 6) + SourceIndex(0) +4 >Emitted(91, 57) Source(31, 9) + SourceIndex(0) --- >>> _static_private_set_x_decorators = [dec, dec]; 1->^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -261,10 +262,10 @@ sourceFile:esDecorators-classDeclaration-sourceMap.ts 3 > > @ 4 > dec -1->Emitted(91, 49) Source(34, 6) + SourceIndex(0) -2 >Emitted(91, 52) Source(34, 9) + SourceIndex(0) -3 >Emitted(91, 54) Source(35, 6) + SourceIndex(0) -4 >Emitted(91, 57) Source(35, 9) + SourceIndex(0) +1->Emitted(92, 49) Source(34, 6) + SourceIndex(0) +2 >Emitted(92, 52) Source(34, 9) + SourceIndex(0) +3 >Emitted(92, 54) Source(35, 6) + SourceIndex(0) +4 >Emitted(92, 57) Source(35, 9) + SourceIndex(0) --- >>> _static_private_y_decorators = [dec, dec]; 1 >^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -280,17 +281,17 @@ sourceFile:esDecorators-classDeclaration-sourceMap.ts 3 > > @ 4 > dec -1 >Emitted(92, 45) Source(38, 6) + SourceIndex(0) -2 >Emitted(92, 48) Source(38, 9) + SourceIndex(0) -3 >Emitted(92, 50) Source(39, 6) + SourceIndex(0) -4 >Emitted(92, 53) Source(39, 9) + SourceIndex(0) +1 >Emitted(93, 45) Source(38, 6) + SourceIndex(0) +2 >Emitted(93, 48) Source(38, 9) + SourceIndex(0) +3 >Emitted(93, 50) Source(39, 6) + SourceIndex(0) +4 >Emitted(93, 53) Source(39, 9) + SourceIndex(0) --- >>> _static_private_z_decorators = [dec, dec]; 1->^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 2 > ^^^ 3 > ^^ 4 > ^^^ -5 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> +5 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> 1-> > static #y = 1; > @@ -299,19 +300,19 @@ sourceFile:esDecorators-classDeclaration-sourceMap.ts 3 > > @ 4 > dec -1->Emitted(93, 45) Source(42, 6) + SourceIndex(0) -2 >Emitted(93, 48) Source(42, 9) + SourceIndex(0) -3 >Emitted(93, 50) Source(43, 6) + SourceIndex(0) -4 >Emitted(93, 53) Source(43, 9) + SourceIndex(0) +1->Emitted(94, 45) Source(42, 6) + SourceIndex(0) +2 >Emitted(94, 48) Source(42, 9) + SourceIndex(0) +3 >Emitted(94, 50) Source(43, 6) + SourceIndex(0) +4 >Emitted(94, 53) Source(43, 9) + SourceIndex(0) --- ->>> __esDecorate(this, _static_private_method_descriptor = { value: __setFunctionName(function () { }, "#method") }, _static_private_method_decorators, { kind: "method", name: "#method", static: true, private: true, access: { has: obj => __classPrivateFieldIn(_classThis, obj), get: obj => __classPrivateFieldGet(obj, _classThis, "a", _method_get) } }, null, _staticExtraInitializers); +>>> __esDecorate(this, _static_private_method_descriptor = { value: __setFunctionName(function () { }, "#method") }, _static_private_method_decorators, { kind: "method", name: "#method", static: true, private: true, access: { has: obj => __classPrivateFieldIn(_classThis, obj), get: obj => __classPrivateFieldGet(obj, _classThis, "a", _C_method_get) } }, null, _staticExtraInitializers); 1->^^^^^^^^^^^^ 2 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 3 > ^^^^^^^^^^^^^^^^^^^^^^^^^ 4 > ^^^^^^^^^^^^^^ 5 > ^ 6 > ^^^^^^^^^^^^ -7 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +7 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 1-> 2 > 3 > @@ -319,15 +320,15 @@ sourceFile:esDecorators-classDeclaration-sourceMap.ts 5 > } 6 > 7 > -1->Emitted(94, 13) Source(28, 5) + SourceIndex(0) -2 >Emitted(94, 70) Source(28, 5) + SourceIndex(0) -3 >Emitted(94, 95) Source(28, 5) + SourceIndex(0) -4 >Emitted(94, 109) Source(28, 23) + SourceIndex(0) -5 >Emitted(94, 110) Source(28, 24) + SourceIndex(0) -6 >Emitted(94, 122) Source(28, 24) + SourceIndex(0) -7 >Emitted(94, 394) Source(28, 24) + SourceIndex(0) +1->Emitted(95, 13) Source(28, 5) + SourceIndex(0) +2 >Emitted(95, 70) Source(28, 5) + SourceIndex(0) +3 >Emitted(95, 95) Source(28, 5) + SourceIndex(0) +4 >Emitted(95, 109) Source(28, 23) + SourceIndex(0) +5 >Emitted(95, 110) Source(28, 24) + SourceIndex(0) +6 >Emitted(95, 122) Source(28, 24) + SourceIndex(0) +7 >Emitted(95, 396) Source(28, 24) + SourceIndex(0) --- ->>> __esDecorate(this, _static_private_get_x_descriptor = { get: __setFunctionName(function () { return 1; }, "#x", "get") }, _static_private_get_x_decorators, { kind: "getter", name: "#x", static: true, private: true, access: { has: obj => __classPrivateFieldIn(_classThis, obj), get: obj => __classPrivateFieldGet(obj, _classThis, "a", _x_get) } }, null, _staticExtraInitializers); +>>> __esDecorate(this, _static_private_get_x_descriptor = { get: __setFunctionName(function () { return 1; }, "#x", "get") }, _static_private_get_x_decorators, { kind: "getter", name: "#x", static: true, private: true, access: { has: obj => __classPrivateFieldIn(_classThis, obj), get: obj => __classPrivateFieldGet(obj, _classThis, "a", _C_x_get) } }, null, _staticExtraInitializers); 1 >^^^^^^^^^^^^ 2 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 3 > ^^^^^^^^^^^^^^^^^^^^^^^ @@ -338,8 +339,8 @@ sourceFile:esDecorators-classDeclaration-sourceMap.ts 8 > ^ 9 > ^ 10> ^^^^^^^^^^^^^^ -11> ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -12> ^^^^^^^^^^^^^^^^^-> +11> ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +12> ^^^^^^^^^^^^^^^^^-> 1 > > > @dec @@ -355,19 +356,19 @@ sourceFile:esDecorators-classDeclaration-sourceMap.ts 9 > } 10> 11> -1 >Emitted(95, 13) Source(32, 5) + SourceIndex(0) -2 >Emitted(95, 69) Source(32, 5) + SourceIndex(0) -3 >Emitted(95, 92) Source(32, 5) + SourceIndex(0) -4 >Emitted(95, 106) Source(32, 23) + SourceIndex(0) -5 >Emitted(95, 113) Source(32, 30) + SourceIndex(0) -6 >Emitted(95, 114) Source(32, 31) + SourceIndex(0) -7 >Emitted(95, 115) Source(32, 32) + SourceIndex(0) -8 >Emitted(95, 116) Source(32, 33) + SourceIndex(0) -9 >Emitted(95, 117) Source(32, 34) + SourceIndex(0) -10>Emitted(95, 131) Source(32, 34) + SourceIndex(0) -11>Emitted(95, 392) Source(32, 34) + SourceIndex(0) +1 >Emitted(96, 13) Source(32, 5) + SourceIndex(0) +2 >Emitted(96, 69) Source(32, 5) + SourceIndex(0) +3 >Emitted(96, 92) Source(32, 5) + SourceIndex(0) +4 >Emitted(96, 106) Source(32, 23) + SourceIndex(0) +5 >Emitted(96, 113) Source(32, 30) + SourceIndex(0) +6 >Emitted(96, 114) Source(32, 31) + SourceIndex(0) +7 >Emitted(96, 115) Source(32, 32) + SourceIndex(0) +8 >Emitted(96, 116) Source(32, 33) + SourceIndex(0) +9 >Emitted(96, 117) Source(32, 34) + SourceIndex(0) +10>Emitted(96, 131) Source(32, 34) + SourceIndex(0) +11>Emitted(96, 394) Source(32, 34) + SourceIndex(0) --- ->>> __esDecorate(this, _static_private_set_x_descriptor = { set: __setFunctionName(function (value) { }, "#x", "set") }, _static_private_set_x_decorators, { kind: "setter", name: "#x", static: true, private: true, access: { has: obj => __classPrivateFieldIn(_classThis, obj), set: (obj, value) => { __classPrivateFieldSet(obj, _classThis, value, "a", _x_set); } } }, null, _staticExtraInitializers); +>>> __esDecorate(this, _static_private_set_x_descriptor = { set: __setFunctionName(function (value) { }, "#x", "set") }, _static_private_set_x_decorators, { kind: "setter", name: "#x", static: true, private: true, access: { has: obj => __classPrivateFieldIn(_classThis, obj), set: (obj, value) => { __classPrivateFieldSet(obj, _classThis, value, "a", _C_x_set); } } }, null, _staticExtraInitializers); 1->^^^^^^^^^^^^ 2 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 3 > ^^^^^^^^^^^^^^^^^^^^^^^ @@ -376,8 +377,8 @@ sourceFile:esDecorators-classDeclaration-sourceMap.ts 6 > ^^^^ 7 > ^ 8 > ^^^^^^^^^^^^^^ -9 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -10> ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> +9 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +10> ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> 1-> > > @dec @@ -391,27 +392,27 @@ sourceFile:esDecorators-classDeclaration-sourceMap.ts 7 > } 8 > 9 > -1->Emitted(96, 13) Source(36, 5) + SourceIndex(0) -2 >Emitted(96, 69) Source(36, 5) + SourceIndex(0) -3 >Emitted(96, 92) Source(36, 5) + SourceIndex(0) -4 >Emitted(96, 102) Source(36, 19) + SourceIndex(0) -5 >Emitted(96, 107) Source(36, 32) + SourceIndex(0) -6 >Emitted(96, 111) Source(36, 36) + SourceIndex(0) -7 >Emitted(96, 112) Source(36, 37) + SourceIndex(0) -8 >Emitted(96, 126) Source(36, 37) + SourceIndex(0) -9 >Emitted(96, 408) Source(36, 37) + SourceIndex(0) +1->Emitted(97, 13) Source(36, 5) + SourceIndex(0) +2 >Emitted(97, 69) Source(36, 5) + SourceIndex(0) +3 >Emitted(97, 92) Source(36, 5) + SourceIndex(0) +4 >Emitted(97, 102) Source(36, 19) + SourceIndex(0) +5 >Emitted(97, 107) Source(36, 32) + SourceIndex(0) +6 >Emitted(97, 111) Source(36, 36) + SourceIndex(0) +7 >Emitted(97, 112) Source(36, 37) + SourceIndex(0) +8 >Emitted(97, 126) Source(36, 37) + SourceIndex(0) +9 >Emitted(97, 410) Source(36, 37) + SourceIndex(0) --- ->>> __esDecorate(this, _static_private_z_descriptor = { get: __setFunctionName(function () { return __classPrivateFieldGet(this, _classThis, "f", _z_accessor_storage); }, "#z", "get"), set: __setFunctionName(function (value) { __classPrivateFieldSet(this, _classThis, value, "f", _z_accessor_storage); }, "#z", "set") }, _static_private_z_decorators, { kind: "accessor", name: "#z", static: true, private: true, access: { has: obj => __classPrivateFieldIn(_classThis, obj), get: obj => __classPrivateFieldGet(obj, _classThis, "a", _z_get), set: (obj, value) => { __classPrivateFieldSet(obj, _classThis, value, "a", _z_set); } } }, _static_private_z_initializers, _staticExtraInitializers); +>>> __esDecorate(this, _static_private_z_descriptor = { get: __setFunctionName(function () { return __classPrivateFieldGet(this, _classThis, "f", _C_z_accessor_storage); }, "#z", "get"), set: __setFunctionName(function (value) { __classPrivateFieldSet(this, _classThis, value, "f", _C_z_accessor_storage); }, "#z", "set") }, _static_private_z_decorators, { kind: "accessor", name: "#z", static: true, private: true, access: { has: obj => __classPrivateFieldIn(_classThis, obj), get: obj => __classPrivateFieldGet(obj, _classThis, "a", _C_z_get), set: (obj, value) => { __classPrivateFieldSet(obj, _classThis, value, "a", _C_z_set); } } }, _static_private_z_initializers, _staticExtraInitializers); 1->^^^^^^^^^^^^ 2 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 3 > ^^^^^^^^^^^^^^^^^^^^^^^ -4 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -5 > ^^^^^^^^^^^^^^ -6 > ^^ -7 > ^^^^^^^^^^^^^^^^^^^^^^^ -8 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -9 > ^^^^^^^^^^^^^^ -10> ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +4 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +5 > ^^^^^^^^^^^^^^ +6 > ^^ +7 > ^^^^^^^^^^^^^^^^^^^^^^^ +8 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +9 > ^^^^^^^^^^^^^^ +10> ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 1-> > > @dec @@ -424,22 +425,22 @@ sourceFile:esDecorators-classDeclaration-sourceMap.ts 2 > 3 > 4 > static accessor #z = 1; -5 > -6 > -7 > -8 > static accessor #z = 1; -9 > -10> -1->Emitted(97, 13) Source(44, 5) + SourceIndex(0) -2 >Emitted(97, 65) Source(44, 5) + SourceIndex(0) -3 >Emitted(97, 88) Source(44, 5) + SourceIndex(0) -4 >Emitted(97, 178) Source(44, 28) + SourceIndex(0) -5 >Emitted(97, 192) Source(44, 28) + SourceIndex(0) -6 >Emitted(97, 194) Source(44, 5) + SourceIndex(0) -7 >Emitted(97, 217) Source(44, 5) + SourceIndex(0) -8 >Emitted(97, 312) Source(44, 28) + SourceIndex(0) -9 >Emitted(97, 326) Source(44, 28) + SourceIndex(0) -10>Emitted(97, 698) Source(44, 28) + SourceIndex(0) +5 > +6 > +7 > +8 > static accessor #z = 1; +9 > +10> +1->Emitted(98, 13) Source(44, 5) + SourceIndex(0) +2 >Emitted(98, 65) Source(44, 5) + SourceIndex(0) +3 >Emitted(98, 88) Source(44, 5) + SourceIndex(0) +4 >Emitted(98, 180) Source(44, 28) + SourceIndex(0) +5 >Emitted(98, 194) Source(44, 28) + SourceIndex(0) +6 >Emitted(98, 196) Source(44, 5) + SourceIndex(0) +7 >Emitted(98, 219) Source(44, 5) + SourceIndex(0) +8 >Emitted(98, 316) Source(44, 28) + SourceIndex(0) +9 >Emitted(98, 330) Source(44, 28) + SourceIndex(0) +10>Emitted(98, 706) Source(44, 28) + SourceIndex(0) --- >>> __esDecorate(this, null, _method_decorators, { kind: "method", name: "method", static: false, private: false, access: { has: obj => "method" in obj, get: obj => obj.method } }, null, _instanceExtraInitializers); 1 >^^^^^^^^^^^^ @@ -450,10 +451,10 @@ sourceFile:esDecorators-classDeclaration-sourceMap.ts 2 > 3 > method 4 > () {} -1 >Emitted(98, 13) Source(8, 5) + SourceIndex(0) -2 >Emitted(98, 178) Source(8, 5) + SourceIndex(0) -3 >Emitted(98, 184) Source(8, 11) + SourceIndex(0) -4 >Emitted(98, 224) Source(8, 16) + SourceIndex(0) +1 >Emitted(99, 13) Source(8, 5) + SourceIndex(0) +2 >Emitted(99, 178) Source(8, 5) + SourceIndex(0) +3 >Emitted(99, 184) Source(8, 11) + SourceIndex(0) +4 >Emitted(99, 224) Source(8, 16) + SourceIndex(0) --- >>> __esDecorate(this, null, _get_x_decorators, { kind: "getter", name: "x", static: false, private: false, access: { has: obj => "x" in obj, get: obj => obj.x } }, null, _instanceExtraInitializers); 1 >^^^^^^^^^^^^ @@ -469,10 +470,10 @@ sourceFile:esDecorators-classDeclaration-sourceMap.ts 2 > get 3 > x 4 > () { return 1; } -1 >Emitted(99, 13) Source(12, 5) + SourceIndex(0) -2 >Emitted(99, 167) Source(12, 9) + SourceIndex(0) -3 >Emitted(99, 168) Source(12, 10) + SourceIndex(0) -4 >Emitted(99, 208) Source(12, 26) + SourceIndex(0) +1 >Emitted(100, 13) Source(12, 5) + SourceIndex(0) +2 >Emitted(100, 167) Source(12, 9) + SourceIndex(0) +3 >Emitted(100, 168) Source(12, 10) + SourceIndex(0) +4 >Emitted(100, 208) Source(12, 26) + SourceIndex(0) --- >>> __esDecorate(this, null, _set_x_decorators, { kind: "setter", name: "x", static: false, private: false, access: { has: obj => "x" in obj, set: (obj, value) => { obj.x = value; } } }, null, _instanceExtraInitializers); 1->^^^^^^^^^^^^ @@ -488,10 +489,10 @@ sourceFile:esDecorators-classDeclaration-sourceMap.ts 2 > set 3 > x 4 > (value: number) { } -1->Emitted(100, 13) Source(16, 5) + SourceIndex(0) -2 >Emitted(100, 178) Source(16, 9) + SourceIndex(0) -3 >Emitted(100, 179) Source(16, 10) + SourceIndex(0) -4 >Emitted(100, 230) Source(16, 29) + SourceIndex(0) +1->Emitted(101, 13) Source(16, 5) + SourceIndex(0) +2 >Emitted(101, 178) Source(16, 9) + SourceIndex(0) +3 >Emitted(101, 179) Source(16, 10) + SourceIndex(0) +4 >Emitted(101, 230) Source(16, 29) + SourceIndex(0) --- >>> __esDecorate(this, null, _z_decorators, { kind: "accessor", name: "z", static: false, private: false, access: { has: obj => "z" in obj, get: obj => obj.z, set: (obj, value) => { obj.z = value; } } }, _z_initializers, _instanceExtraInitializers); 1->^^^^^^^^^^^^ @@ -500,7 +501,7 @@ sourceFile:esDecorators-classDeclaration-sourceMap.ts 4 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 5 > ^ 6 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -7 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> +7 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> 1-> > > @dec @@ -515,16 +516,16 @@ sourceFile:esDecorators-classDeclaration-sourceMap.ts 4 > 5 > z 6 > = 1; -1->Emitted(101, 13) Source(24, 5) + SourceIndex(0) -2 >Emitted(101, 165) Source(24, 14) + SourceIndex(0) -3 >Emitted(101, 166) Source(24, 15) + SourceIndex(0) -4 >Emitted(101, 195) Source(24, 14) + SourceIndex(0) -5 >Emitted(101, 196) Source(24, 15) + SourceIndex(0) -6 >Emitted(101, 258) Source(24, 20) + SourceIndex(0) +1->Emitted(102, 13) Source(24, 5) + SourceIndex(0) +2 >Emitted(102, 165) Source(24, 14) + SourceIndex(0) +3 >Emitted(102, 166) Source(24, 15) + SourceIndex(0) +4 >Emitted(102, 195) Source(24, 14) + SourceIndex(0) +5 >Emitted(102, 196) Source(24, 15) + SourceIndex(0) +6 >Emitted(102, 258) Source(24, 20) + SourceIndex(0) --- ->>> __esDecorate(null, null, _static_private_y_decorators, { kind: "field", name: "#y", static: true, private: true, access: { has: obj => __classPrivateFieldIn(_classThis, obj), get: obj => __classPrivateFieldGet(obj, _classThis, "f", _y), set: (obj, value) => { __classPrivateFieldSet(obj, _classThis, value, "f", _y); } } }, _static_private_y_initializers, _staticExtraInitializers); +>>> __esDecorate(null, null, _static_private_y_decorators, { kind: "field", name: "#y", static: true, private: true, access: { has: obj => __classPrivateFieldIn(_classThis, obj), get: obj => __classPrivateFieldGet(obj, _classThis, "f", _C_y), set: (obj, value) => { __classPrivateFieldSet(obj, _classThis, value, "f", _C_y); } } }, _static_private_y_initializers, _staticExtraInitializers); 1->^^^^^^^^^^^^ -2 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +2 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 1-> > > @dec @@ -543,8 +544,8 @@ sourceFile:esDecorators-classDeclaration-sourceMap.ts > @dec > 2 > static #y = 1; -1->Emitted(102, 13) Source(40, 5) + SourceIndex(0) -2 >Emitted(102, 395) Source(40, 19) + SourceIndex(0) +1->Emitted(103, 13) Source(40, 5) + SourceIndex(0) +2 >Emitted(103, 399) Source(40, 19) + SourceIndex(0) --- >>> __esDecorate(null, null, _y_decorators, { kind: "field", name: "y", static: false, private: false, access: { has: obj => "y" in obj, get: obj => obj.y, set: (obj, value) => { obj.y = value; } } }, _y_initializers, _instanceExtraInitializers); 1 >^^^^^^^^^^^^ @@ -559,16 +560,16 @@ sourceFile:esDecorators-classDeclaration-sourceMap.ts 4 > 5 > y 6 > = 1; -1 >Emitted(103, 13) Source(20, 5) + SourceIndex(0) -2 >Emitted(103, 162) Source(20, 5) + SourceIndex(0) -3 >Emitted(103, 163) Source(20, 6) + SourceIndex(0) -4 >Emitted(103, 192) Source(20, 5) + SourceIndex(0) -5 >Emitted(103, 193) Source(20, 6) + SourceIndex(0) -6 >Emitted(103, 255) Source(20, 11) + SourceIndex(0) +1 >Emitted(104, 13) Source(20, 5) + SourceIndex(0) +2 >Emitted(104, 162) Source(20, 5) + SourceIndex(0) +3 >Emitted(104, 163) Source(20, 6) + SourceIndex(0) +4 >Emitted(104, 192) Source(20, 5) + SourceIndex(0) +5 >Emitted(104, 193) Source(20, 6) + SourceIndex(0) +6 >Emitted(104, 255) Source(20, 11) + SourceIndex(0) --- ->>> __esDecorate(null, _classDescriptor = { value: this }, _classDecorators, { kind: "class", name: this.name }, null, _classExtraInitializers); +>>> __esDecorate(null, _classDescriptor = { value: _classThis }, _classDecorators, { kind: "class", name: _classThis.name }, null, _classExtraInitializers); 1 >^^^^^^^^^^^^ -2 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +2 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 1 > 2 > class C { > @dec @@ -611,8 +612,8 @@ sourceFile:esDecorators-classDeclaration-sourceMap.ts > @dec > static accessor #z = 1; > } -1 >Emitted(104, 13) Source(5, 1) + SourceIndex(0) -2 >Emitted(104, 153) Source(45, 2) + SourceIndex(0) +1 >Emitted(105, 13) Source(5, 1) + SourceIndex(0) +2 >Emitted(105, 165) Source(45, 2) + SourceIndex(0) --- >>> C = _classThis = _classDescriptor.value; >>> __runInitializers(_classThis, _staticExtraInitializers); @@ -620,8 +621,8 @@ sourceFile:esDecorators-classDeclaration-sourceMap.ts 2 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 1 > 2 > C -1 >Emitted(106, 13) Source(5, 7) + SourceIndex(0) -2 >Emitted(106, 69) Source(5, 8) + SourceIndex(0) +1 >Emitted(107, 13) Source(5, 7) + SourceIndex(0) +2 >Emitted(107, 69) Source(5, 8) + SourceIndex(0) --- >>> } >>> method() { } @@ -637,10 +638,10 @@ sourceFile:esDecorators-classDeclaration-sourceMap.ts 2 > method 3 > () { 4 > } -1 >Emitted(108, 9) Source(8, 5) + SourceIndex(0) -2 >Emitted(108, 15) Source(8, 11) + SourceIndex(0) -3 >Emitted(108, 20) Source(8, 15) + SourceIndex(0) -4 >Emitted(108, 21) Source(8, 16) + SourceIndex(0) +1 >Emitted(109, 9) Source(8, 5) + SourceIndex(0) +2 >Emitted(109, 15) Source(8, 11) + SourceIndex(0) +3 >Emitted(109, 20) Source(8, 15) + SourceIndex(0) +4 >Emitted(109, 21) Source(8, 16) + SourceIndex(0) --- >>> get x() { return 1; } 1->^^^^^^^^ @@ -665,15 +666,15 @@ sourceFile:esDecorators-classDeclaration-sourceMap.ts 7 > ; 8 > 9 > } -1->Emitted(109, 9) Source(12, 5) + SourceIndex(0) -2 >Emitted(109, 13) Source(12, 9) + SourceIndex(0) -3 >Emitted(109, 14) Source(12, 10) + SourceIndex(0) -4 >Emitted(109, 19) Source(12, 15) + SourceIndex(0) -5 >Emitted(109, 26) Source(12, 22) + SourceIndex(0) -6 >Emitted(109, 27) Source(12, 23) + SourceIndex(0) -7 >Emitted(109, 28) Source(12, 24) + SourceIndex(0) -8 >Emitted(109, 29) Source(12, 25) + SourceIndex(0) -9 >Emitted(109, 30) Source(12, 26) + SourceIndex(0) +1->Emitted(110, 9) Source(12, 5) + SourceIndex(0) +2 >Emitted(110, 13) Source(12, 9) + SourceIndex(0) +3 >Emitted(110, 14) Source(12, 10) + SourceIndex(0) +4 >Emitted(110, 19) Source(12, 15) + SourceIndex(0) +5 >Emitted(110, 26) Source(12, 22) + SourceIndex(0) +6 >Emitted(110, 27) Source(12, 23) + SourceIndex(0) +7 >Emitted(110, 28) Source(12, 24) + SourceIndex(0) +8 >Emitted(110, 29) Source(12, 25) + SourceIndex(0) +9 >Emitted(110, 30) Source(12, 26) + SourceIndex(0) --- >>> set x(value) { } 1 >^^^^^^^^ @@ -695,13 +696,13 @@ sourceFile:esDecorators-classDeclaration-sourceMap.ts 5 > value: number 6 > ) { 7 > } -1 >Emitted(110, 9) Source(16, 5) + SourceIndex(0) -2 >Emitted(110, 13) Source(16, 9) + SourceIndex(0) -3 >Emitted(110, 14) Source(16, 10) + SourceIndex(0) -4 >Emitted(110, 15) Source(16, 11) + SourceIndex(0) -5 >Emitted(110, 20) Source(16, 24) + SourceIndex(0) -6 >Emitted(110, 24) Source(16, 28) + SourceIndex(0) -7 >Emitted(110, 25) Source(16, 29) + SourceIndex(0) +1 >Emitted(111, 9) Source(16, 5) + SourceIndex(0) +2 >Emitted(111, 13) Source(16, 9) + SourceIndex(0) +3 >Emitted(111, 14) Source(16, 10) + SourceIndex(0) +4 >Emitted(111, 15) Source(16, 11) + SourceIndex(0) +5 >Emitted(111, 20) Source(16, 24) + SourceIndex(0) +6 >Emitted(111, 24) Source(16, 28) + SourceIndex(0) +7 >Emitted(111, 25) Source(16, 29) + SourceIndex(0) --- >>> y = (__runInitializers(this, _instanceExtraInitializers), __runInitializers(this, _y_initializers, 1)); 1->^^^^^^^^ @@ -718,11 +719,11 @@ sourceFile:esDecorators-classDeclaration-sourceMap.ts 3 > = 4 > 1 5 > ; -1->Emitted(111, 9) Source(20, 5) + SourceIndex(0) -2 >Emitted(111, 10) Source(20, 6) + SourceIndex(0) -3 >Emitted(111, 108) Source(20, 9) + SourceIndex(0) -4 >Emitted(111, 109) Source(20, 10) + SourceIndex(0) -5 >Emitted(111, 112) Source(20, 11) + SourceIndex(0) +1->Emitted(112, 9) Source(20, 5) + SourceIndex(0) +2 >Emitted(112, 10) Source(20, 6) + SourceIndex(0) +3 >Emitted(112, 108) Source(20, 9) + SourceIndex(0) +4 >Emitted(112, 109) Source(20, 10) + SourceIndex(0) +5 >Emitted(112, 112) Source(20, 11) + SourceIndex(0) --- >>> #z_accessor_storage = __runInitializers(this, _z_initializers, 1); 1 >^^^^^^^^ @@ -737,10 +738,10 @@ sourceFile:esDecorators-classDeclaration-sourceMap.ts 2 > accessor z = 3 > 1 4 > ; -1 >Emitted(112, 9) Source(24, 5) + SourceIndex(0) -2 >Emitted(112, 72) Source(24, 18) + SourceIndex(0) -3 >Emitted(112, 73) Source(24, 19) + SourceIndex(0) -4 >Emitted(112, 75) Source(24, 20) + SourceIndex(0) +1 >Emitted(113, 9) Source(24, 5) + SourceIndex(0) +2 >Emitted(113, 72) Source(24, 18) + SourceIndex(0) +3 >Emitted(113, 73) Source(24, 19) + SourceIndex(0) +4 >Emitted(113, 75) Source(24, 20) + SourceIndex(0) --- >>> get z() { return this.#z_accessor_storage; } 1 >^^^^^^^^ @@ -752,10 +753,10 @@ sourceFile:esDecorators-classDeclaration-sourceMap.ts 2 > accessor 3 > z 4 > = 1; -1 >Emitted(113, 9) Source(24, 5) + SourceIndex(0) -2 >Emitted(113, 13) Source(24, 14) + SourceIndex(0) -3 >Emitted(113, 14) Source(24, 15) + SourceIndex(0) -4 >Emitted(113, 53) Source(24, 20) + SourceIndex(0) +1 >Emitted(114, 9) Source(24, 5) + SourceIndex(0) +2 >Emitted(114, 13) Source(24, 14) + SourceIndex(0) +3 >Emitted(114, 14) Source(24, 15) + SourceIndex(0) +4 >Emitted(114, 53) Source(24, 20) + SourceIndex(0) --- >>> set z(value) { this.#z_accessor_storage = value; } 1->^^^^^^^^ @@ -766,18 +767,18 @@ sourceFile:esDecorators-classDeclaration-sourceMap.ts 2 > accessor 3 > z 4 > = 1; -1->Emitted(114, 9) Source(24, 5) + SourceIndex(0) -2 >Emitted(114, 13) Source(24, 14) + SourceIndex(0) -3 >Emitted(114, 14) Source(24, 15) + SourceIndex(0) -4 >Emitted(114, 59) Source(24, 20) + SourceIndex(0) +1->Emitted(115, 9) Source(24, 5) + SourceIndex(0) +2 >Emitted(115, 13) Source(24, 14) + SourceIndex(0) +3 >Emitted(115, 14) Source(24, 15) + SourceIndex(0) +4 >Emitted(115, 59) Source(24, 20) + SourceIndex(0) --- >>> static { ->>> _y = { value: __runInitializers(_classThis, _static_private_y_initializers, 1) }; +>>> _C_y = { value: __runInitializers(_classThis, _static_private_y_initializers, 1) }; 1 >^^^^^^^^^^^^ -2 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -3 > ^ -4 > ^^^ -5 > ^ +2 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +3 > ^ +4 > ^^^ +5 > ^ 1 > > > @dec @@ -796,37 +797,37 @@ sourceFile:esDecorators-classDeclaration-sourceMap.ts > @dec > static 2 > #y = -3 > 1 -4 > -5 > = 1; -1 >Emitted(116, 13) Source(40, 12) + SourceIndex(0) -2 >Emitted(116, 89) Source(40, 17) + SourceIndex(0) -3 >Emitted(116, 90) Source(40, 18) + SourceIndex(0) -4 >Emitted(116, 93) Source(40, 14) + SourceIndex(0) -5 >Emitted(116, 94) Source(40, 19) + SourceIndex(0) +3 > 1 +4 > +5 > = 1; +1 >Emitted(117, 13) Source(40, 12) + SourceIndex(0) +2 >Emitted(117, 91) Source(40, 17) + SourceIndex(0) +3 >Emitted(117, 92) Source(40, 18) + SourceIndex(0) +4 >Emitted(117, 95) Source(40, 14) + SourceIndex(0) +5 >Emitted(117, 96) Source(40, 19) + SourceIndex(0) --- >>> } >>> static { ->>> _z_accessor_storage = { value: __runInitializers(_classThis, _static_private_z_initializers, 1) }; +>>> _C_z_accessor_storage = { value: __runInitializers(_classThis, _static_private_z_initializers, 1) }; 1 >^^^^^^^^^^^^ -2 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -3 > ^ -4 > ^^^ -5 > ^ +2 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +3 > ^ +4 > ^^^ +5 > ^ 1 > > > @dec > @dec > static accessor 2 > #z = -3 > 1 -4 > -5 > = 1; -1 >Emitted(119, 13) Source(44, 21) + SourceIndex(0) -2 >Emitted(119, 106) Source(44, 26) + SourceIndex(0) -3 >Emitted(119, 107) Source(44, 27) + SourceIndex(0) -4 >Emitted(119, 110) Source(44, 23) + SourceIndex(0) -5 >Emitted(119, 111) Source(44, 28) + SourceIndex(0) +3 > 1 +4 > +5 > = 1; +1 >Emitted(120, 13) Source(44, 21) + SourceIndex(0) +2 >Emitted(120, 108) Source(44, 26) + SourceIndex(0) +3 >Emitted(120, 109) Source(44, 27) + SourceIndex(0) +4 >Emitted(120, 112) Source(44, 23) + SourceIndex(0) +5 >Emitted(120, 113) Source(44, 28) + SourceIndex(0) --- >>> } >>> static { @@ -835,8 +836,8 @@ sourceFile:esDecorators-classDeclaration-sourceMap.ts 2 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 1 > 2 > C -1 >Emitted(122, 13) Source(5, 7) + SourceIndex(0) -2 >Emitted(122, 68) Source(5, 8) + SourceIndex(0) +1 >Emitted(123, 13) Source(5, 7) + SourceIndex(0) +2 >Emitted(123, 68) Source(5, 8) + SourceIndex(0) --- >>> } >>> }; diff --git a/tests/baselines/reference/esDecorators-classExpression-classSuper.1.js b/tests/baselines/reference/esDecorators-classExpression-classSuper.1.js index dfa5dd90a90ad..e6f01b2d0c072 100644 --- a/tests/baselines/reference/esDecorators-classExpression-classSuper.1.js +++ b/tests/baselines/reference/esDecorators-classExpression-classSuper.1.js @@ -31,8 +31,9 @@ const method = "method"; let _classThis; let _classSuper = Base; var C = class extends _classSuper { + static { _classThis = this; } static { - __esDecorate(null, _classDescriptor = { value: this }, _classDecorators, { kind: "class", name: this.name }, null, _classExtraInitializers); + __esDecorate(null, _classDescriptor = { value: _classThis }, _classDecorators, { kind: "class", name: _classThis.name }, null, _classExtraInitializers); C = _classThis = _classDescriptor.value; } static { diff --git a/tests/baselines/reference/esDecorators-classExpression-classSuper.2.js b/tests/baselines/reference/esDecorators-classExpression-classSuper.2.js index e4ea7908a78b2..337eeb74c4abf 100644 --- a/tests/baselines/reference/esDecorators-classExpression-classSuper.2.js +++ b/tests/baselines/reference/esDecorators-classExpression-classSuper.2.js @@ -38,8 +38,9 @@ class C3 extends ((() => {}) as any) { let _classSuper = (0, class { }); var C1 = class extends _classSuper { + static { _classThis = this; } static { - __esDecorate(null, _classDescriptor = { value: this }, _classDecorators, { kind: "class", name: this.name }, null, _classExtraInitializers); + __esDecorate(null, _classDescriptor = { value: _classThis }, _classDecorators, { kind: "class", name: _classThis.name }, null, _classExtraInitializers); C1 = _classThis = _classDescriptor.value; } static { @@ -53,43 +54,45 @@ class C3 extends ((() => {}) as any) { })()); // function expression in extends should not get an assigned name ((() => { - let _classDecorators_1 = [dec]; - let _classDescriptor_1; - let _classExtraInitializers_1 = []; - let _classThis_1; - let _classSuper_1 = (0, function () { }); - var C2 = class extends _classSuper_1 { + let _classDecorators = [dec]; + let _classDescriptor; + let _classExtraInitializers = []; + let _classThis; + let _classSuper = (0, function () { }); + var C2 = class extends _classSuper { + static { _classThis = this; } static { - __esDecorate(null, _classDescriptor_1 = { value: this }, _classDecorators_1, { kind: "class", name: this.name }, null, _classExtraInitializers_1); - C2 = _classThis_1 = _classDescriptor_1.value; + __esDecorate(null, _classDescriptor = { value: _classThis }, _classDecorators, { kind: "class", name: _classThis.name }, null, _classExtraInitializers); + C2 = _classThis = _classDescriptor.value; } static { - Reflect.get(_classSuper_1, "name", _classThis_1); + Reflect.get(_classSuper, "name", _classThis); } static { - __runInitializers(_classThis_1, _classExtraInitializers_1); + __runInitializers(_classThis, _classExtraInitializers); } }; - return C2 = _classThis_1; + return C2 = _classThis; })()); // arrow function in extends should not get an assigned name ((() => { - let _classDecorators_2 = [dec]; - let _classDescriptor_2; - let _classExtraInitializers_2 = []; - let _classThis_2; - let _classSuper_2 = (0, (() => { })); - var C3 = class extends _classSuper_2 { + let _classDecorators = [dec]; + let _classDescriptor; + let _classExtraInitializers = []; + let _classThis; + let _classSuper = (0, (() => { })); + var C3 = class extends _classSuper { + static { _classThis = this; } static { - __esDecorate(null, _classDescriptor_2 = { value: this }, _classDecorators_2, { kind: "class", name: this.name }, null, _classExtraInitializers_2); - C3 = _classThis_2 = _classDescriptor_2.value; + __esDecorate(null, _classDescriptor = { value: _classThis }, _classDecorators, { kind: "class", name: _classThis.name }, null, _classExtraInitializers); + C3 = _classThis = _classDescriptor.value; } static { - Reflect.get(_classSuper_2, "name", _classThis_2); + Reflect.get(_classSuper, "name", _classThis); } static { - __runInitializers(_classThis_2, _classExtraInitializers_2); + __runInitializers(_classThis, _classExtraInitializers); } }; - return C3 = _classThis_2; + return C3 = _classThis; })()); diff --git a/tests/baselines/reference/esDecorators-classExpression-classSuper.3.js b/tests/baselines/reference/esDecorators-classExpression-classSuper.3.js index aa4104c48a88d..d83ef08e29433 100644 --- a/tests/baselines/reference/esDecorators-classExpression-classSuper.3.js +++ b/tests/baselines/reference/esDecorators-classExpression-classSuper.3.js @@ -54,8 +54,9 @@ const x = "x"; let _classThis; let _classSuper = Base; var C = class extends _classSuper { + static { _classThis = this; } static { - __esDecorate(null, _classDescriptor = { value: this }, _classDecorators, { kind: "class", name: this.name }, null, _classExtraInitializers); + __esDecorate(null, _classDescriptor = { value: _classThis }, _classDecorators, { kind: "class", name: _classThis.name }, null, _classExtraInitializers); C = _classThis = _classDescriptor.value; } static { diff --git a/tests/baselines/reference/esDecorators-classExpression-classSuper.4.js b/tests/baselines/reference/esDecorators-classExpression-classSuper.4.js index 73aa13f6ee380..0fcd1b040789a 100644 --- a/tests/baselines/reference/esDecorators-classExpression-classSuper.4.js +++ b/tests/baselines/reference/esDecorators-classExpression-classSuper.4.js @@ -29,8 +29,9 @@ const method = "method"; let _classThis; let _classSuper = Base; var C = class extends _classSuper { + static { _classThis = this; } static { - __esDecorate(null, _classDescriptor = { value: this }, _classDecorators, { kind: "class", name: this.name }, null, _classExtraInitializers); + __esDecorate(null, _classDescriptor = { value: _classThis }, _classDecorators, { kind: "class", name: _classThis.name }, null, _classExtraInitializers); C = _classThis = _classDescriptor.value; } static a = Reflect.get(_classSuper, "method", _classThis).call(_classThis); diff --git a/tests/baselines/reference/esDecorators-classExpression-classSuper.5.js b/tests/baselines/reference/esDecorators-classExpression-classSuper.5.js index 6e528ea497959..b6996be1592e1 100644 --- a/tests/baselines/reference/esDecorators-classExpression-classSuper.5.js +++ b/tests/baselines/reference/esDecorators-classExpression-classSuper.5.js @@ -58,8 +58,9 @@ const x = "x"; let _classThis; let _classSuper = Base; var C1 = class extends _classSuper { + static { _classThis = this; } static { - __esDecorate(null, _classDescriptor = { value: this }, _classDecorators, { kind: "class", name: this.name }, null, _classExtraInitializers); + __esDecorate(null, _classDescriptor = { value: _classThis }, _classDecorators, { kind: "class", name: _classThis.name }, null, _classExtraInitializers); C1 = _classThis = _classDescriptor.value; } static a = Reflect.get(_classSuper, "x", _classThis); @@ -96,90 +97,92 @@ const x = "x"; return C1 = _classThis; })()); ((() => { - let _classDecorators_1 = [dec]; - let _classDescriptor_1; - let _classExtraInitializers_1 = []; - let _classThis_1; - let _classSuper_1 = Base; - var C2 = class extends _classSuper_1 { + let _classDecorators = [dec]; + let _classDescriptor; + let _classExtraInitializers = []; + let _classThis; + let _classSuper = Base; + var C2 = class extends _classSuper { + static { _classThis = this; } static { - __esDecorate(null, _classDescriptor_1 = { value: this }, _classDecorators_1, { kind: "class", name: this.name }, null, _classExtraInitializers_1); - C2 = _classThis_1 = _classDescriptor_1.value; + __esDecorate(null, _classDescriptor = { value: _classThis }, _classDecorators, { kind: "class", name: _classThis.name }, null, _classExtraInitializers); + C2 = _classThis = _classDescriptor.value; } - static a = Reflect.get(_classSuper_1, "x", _classThis_1); + static a = Reflect.get(_classSuper, "x", _classThis); static b = (() => { var _a; - return Reflect.set(_classSuper_1, "x", _a = 1, _classThis_1), _a; + return Reflect.set(_classSuper, "x", _a = 1, _classThis), _a; })(); static c = (() => { var _a; - return Reflect.set(_classSuper_1, "x", _a = Reflect.get(_classSuper_1, "x", _classThis_1) + 1, _classThis_1), _a; + return Reflect.set(_classSuper, "x", _a = Reflect.get(_classSuper, "x", _classThis) + 1, _classThis), _a; })(); static d = (() => { var _a, _b; - return Reflect.set(_classSuper_1, "x", (_b = Reflect.get(_classSuper_1, "x", _classThis_1), _a = _b++, _b), _classThis_1), _a; + return Reflect.set(_classSuper, "x", (_b = Reflect.get(_classSuper, "x", _classThis), _a = _b++, _b), _classThis), _a; })(); static e = (() => { var _a, _b; - return Reflect.set(_classSuper_1, "x", (_b = Reflect.get(_classSuper_1, "x", _classThis_1), _a = _b--, _b), _classThis_1), _a; + return Reflect.set(_classSuper, "x", (_b = Reflect.get(_classSuper, "x", _classThis), _a = _b--, _b), _classThis), _a; })(); static f = (() => { var _a, _b; - return Reflect.set(_classSuper_1, "x", (_b = Reflect.get(_classSuper_1, "x", _classThis_1), _a = ++_b), _classThis_1), _a; + return Reflect.set(_classSuper, "x", (_b = Reflect.get(_classSuper, "x", _classThis), _a = ++_b), _classThis), _a; })(); static g = (() => { var _a, _b; - return Reflect.set(_classSuper_1, "x", (_b = Reflect.get(_classSuper_1, "x", _classThis_1), _a = --_b), _classThis_1), _a; + return Reflect.set(_classSuper, "x", (_b = Reflect.get(_classSuper, "x", _classThis), _a = --_b), _classThis), _a; })(); - static h = ({ x: ({ set value(_a) { Reflect.set(_classSuper_1, "x", _a, _classThis_1); } }).value } = { x: 1 }); - static i = [({ set value(_a) { Reflect.set(_classSuper_1, "x", _a, _classThis_1); } }).value] = [1]; + static h = ({ x: ({ set value(_a) { Reflect.set(_classSuper, "x", _a, _classThis); } }).value } = { x: 1 }); + static i = [({ set value(_a) { Reflect.set(_classSuper, "x", _a, _classThis); } }).value] = [1]; static { - __runInitializers(_classThis_1, _classExtraInitializers_1); + __runInitializers(_classThis, _classExtraInitializers); } }; - return C2 = _classThis_1; + return C2 = _classThis; })()); ((() => { - let _classDecorators_2 = [dec]; - let _classDescriptor_2; - let _classExtraInitializers_2 = []; - let _classThis_2; - let _classSuper_2 = Base; - var C3 = class extends _classSuper_2 { + let _classDecorators = [dec]; + let _classDescriptor; + let _classExtraInitializers = []; + let _classThis; + let _classSuper = Base; + var C3 = class extends _classSuper { + static { _classThis = this; } static { - __esDecorate(null, _classDescriptor_2 = { value: this }, _classDecorators_2, { kind: "class", name: this.name }, null, _classExtraInitializers_2); - C3 = _classThis_2 = _classDescriptor_2.value; + __esDecorate(null, _classDescriptor = { value: _classThis }, _classDecorators, { kind: "class", name: _classThis.name }, null, _classExtraInitializers); + C3 = _classThis = _classDescriptor.value; } - static a = Reflect.get(_classSuper_2, x, _classThis_2); + static a = Reflect.get(_classSuper, x, _classThis); static b = (() => { var _a; - return Reflect.set(_classSuper_2, x, _a = 1, _classThis_2), _a; + return Reflect.set(_classSuper, x, _a = 1, _classThis), _a; })(); static c = (() => { var _a, _b; - return Reflect.set(_classSuper_2, _a = x, _b = Reflect.get(_classSuper_2, _a, _classThis_2) + 1, _classThis_2), _b; + return Reflect.set(_classSuper, _a = x, _b = Reflect.get(_classSuper, _a, _classThis) + 1, _classThis), _b; })(); static d = (() => { var _a, _b, _c; - return Reflect.set(_classSuper_2, _a = x, (_c = Reflect.get(_classSuper_2, _a, _classThis_2), _b = _c++, _c), _classThis_2), _b; + return Reflect.set(_classSuper, _a = x, (_c = Reflect.get(_classSuper, _a, _classThis), _b = _c++, _c), _classThis), _b; })(); static e = (() => { var _a, _b, _c; - return Reflect.set(_classSuper_2, _a = x, (_c = Reflect.get(_classSuper_2, _a, _classThis_2), _b = _c--, _c), _classThis_2), _b; + return Reflect.set(_classSuper, _a = x, (_c = Reflect.get(_classSuper, _a, _classThis), _b = _c--, _c), _classThis), _b; })(); static f = (() => { var _a, _b, _c; - return Reflect.set(_classSuper_2, _a = x, (_c = Reflect.get(_classSuper_2, _a, _classThis_2), _b = ++_c), _classThis_2), _b; + return Reflect.set(_classSuper, _a = x, (_c = Reflect.get(_classSuper, _a, _classThis), _b = ++_c), _classThis), _b; })(); static g = (() => { var _a, _b, _c; - return Reflect.set(_classSuper_2, _a = x, (_c = Reflect.get(_classSuper_2, _a, _classThis_2), _b = --_c), _classThis_2), _b; + return Reflect.set(_classSuper, _a = x, (_c = Reflect.get(_classSuper, _a, _classThis), _b = --_c), _classThis), _b; })(); - static h = ({ x: ({ set value(_a) { Reflect.set(_classSuper_2, x, _a, _classThis_2); } }).value } = { x: 1 }); - static i = [({ set value(_a) { Reflect.set(_classSuper_2, x, _a, _classThis_2); } }).value] = [1]; + static h = ({ x: ({ set value(_a) { Reflect.set(_classSuper, x, _a, _classThis); } }).value } = { x: 1 }); + static i = [({ set value(_a) { Reflect.set(_classSuper, x, _a, _classThis); } }).value] = [1]; static { - __runInitializers(_classThis_2, _classExtraInitializers_2); + __runInitializers(_classThis, _classExtraInitializers); } }; - return C3 = _classThis_2; + return C3 = _classThis; })()); diff --git a/tests/baselines/reference/esDecorators-classExpression-classSuper.6.js b/tests/baselines/reference/esDecorators-classExpression-classSuper.6.js index 881208b12d432..ed594b11c9442 100644 --- a/tests/baselines/reference/esDecorators-classExpression-classSuper.6.js +++ b/tests/baselines/reference/esDecorators-classExpression-classSuper.6.js @@ -35,8 +35,9 @@ class C extends Base { let _classExtraInitializers = []; let _classThis; var C = class extends Base { + static { _classThis = this; } static { - __esDecorate(null, _classDescriptor = { value: this }, _classDecorators, { kind: "class", name: this.name }, null, _classExtraInitializers); + __esDecorate(null, _classDescriptor = { value: _classThis }, _classDecorators, { kind: "class", name: _classThis.name }, null, _classExtraInitializers); C = _classThis = _classDescriptor.value; __runInitializers(_classThis, _classExtraInitializers); } diff --git a/tests/baselines/reference/esDecorators-classExpression-commentPreservation(target=es2015).js b/tests/baselines/reference/esDecorators-classExpression-commentPreservation(target=es2015).js index 3acbc6dbb6e1d..427341245d311 100644 --- a/tests/baselines/reference/esDecorators-classExpression-commentPreservation(target=es2015).js +++ b/tests/baselines/reference/esDecorators-classExpression-commentPreservation(target=es2015).js @@ -87,7 +87,7 @@ class C { //// [esDecorators-classExpression-commentPreservation.js] /*1*/ ((() => { - var _method_get, _x_get, _x_set, _y, _z_accessor_storage, _z_get, _z_set, _z_1_accessor_storage; + var _C_method_get, _C_x_get, _C_x_set, _C_y, _C_z_accessor_storage, _C_z_get, _C_z_set, _C_z_1_accessor_storage; let _classDecorators = [dec, dec]; let _classDescriptor; let _classExtraInitializers = []; @@ -116,7 +116,7 @@ class C { constructor() { /*14*/ this.y = (__runInitializers(this, _instanceExtraInitializers), __runInitializers(this, _y_initializers, 1)); - _z_1_accessor_storage.set(this, __runInitializers(this, _z_initializers, 1)); + _C_z_1_accessor_storage.set(this, __runInitializers(this, _z_initializers, 1)); } /*5*/ method() { } @@ -125,15 +125,15 @@ class C { /*11*/ set x(value) { } /*17*/ - get z() { return __classPrivateFieldGet(this, _z_1_accessor_storage, "f"); } - set z(value) { __classPrivateFieldSet(this, _z_1_accessor_storage, value, "f"); } + get z() { return __classPrivateFieldGet(this, _C_z_1_accessor_storage, "f"); } + set z(value) { __classPrivateFieldSet(this, _C_z_1_accessor_storage, value, "f"); } }, - _z_1_accessor_storage = new WeakMap(), - _method_get = function _method_get() { return _static_private_method_descriptor.value; }, - _x_get = function _x_get() { return _static_private_get_x_descriptor.get.call(this); }, - _x_set = function _x_set(value) { return _static_private_set_x_descriptor.set.call(this, value); }, - _z_get = function _z_get() { return _static_private_z_descriptor.get.call(this); }, - _z_set = function _z_set(value) { return _static_private_z_descriptor.set.call(this, value); }, + _C_z_1_accessor_storage = new WeakMap(), + _C_method_get = function _C_method_get() { return _static_private_method_descriptor.value; }, + _C_x_get = function _C_x_get() { return _static_private_get_x_descriptor.get.call(this); }, + _C_x_set = function _C_x_set(value) { return _static_private_set_x_descriptor.set.call(this, value); }, + _C_z_get = function _C_z_get() { return _static_private_z_descriptor.get.call(this); }, + _C_z_set = function _C_z_set(value) { return _static_private_z_descriptor.set.call(this, value); }, __setFunctionName(_classThis, "C"), (() => { _method_decorators = [dec, dec]; @@ -146,23 +146,23 @@ class C { _static_private_set_x_decorators = [dec, dec]; _static_private_y_decorators = [dec, dec]; _static_private_z_decorators = [dec, dec]; - __esDecorate(_classThis, _static_private_method_descriptor = { value: __setFunctionName(function () { }, "#method") }, _static_private_method_decorators, { kind: "method", name: "#method", static: true, private: true, access: { has: obj => __classPrivateFieldIn(_classThis, obj), get: obj => __classPrivateFieldGet(obj, _classThis, "a", _method_get) } }, null, _staticExtraInitializers); - __esDecorate(_classThis, _static_private_get_x_descriptor = { get: __setFunctionName(function () { return 1; }, "#x", "get") }, _static_private_get_x_decorators, { kind: "getter", name: "#x", static: true, private: true, access: { has: obj => __classPrivateFieldIn(_classThis, obj), get: obj => __classPrivateFieldGet(obj, _classThis, "a", _x_get) } }, null, _staticExtraInitializers); - __esDecorate(_classThis, _static_private_set_x_descriptor = { set: __setFunctionName(function (value) { }, "#x", "set") }, _static_private_set_x_decorators, { kind: "setter", name: "#x", static: true, private: true, access: { has: obj => __classPrivateFieldIn(_classThis, obj), set: (obj, value) => { __classPrivateFieldSet(obj, _classThis, value, "a", _x_set); } } }, null, _staticExtraInitializers); - __esDecorate(_classThis, _static_private_z_descriptor = { get: __setFunctionName(function () { return __classPrivateFieldGet(_classThis, _classThis, "f", _z_accessor_storage); }, "#z", "get"), set: __setFunctionName(function (value) { __classPrivateFieldSet(_classThis, _classThis, value, "f", _z_accessor_storage); }, "#z", "set") }, _static_private_z_decorators, { kind: "accessor", name: "#z", static: true, private: true, access: { has: obj => __classPrivateFieldIn(_classThis, obj), get: obj => __classPrivateFieldGet(obj, _classThis, "a", _z_get), set: (obj, value) => { __classPrivateFieldSet(obj, _classThis, value, "a", _z_set); } } }, _static_private_z_initializers, _staticExtraInitializers); + __esDecorate(_classThis, _static_private_method_descriptor = { value: __setFunctionName(function () { }, "#method") }, _static_private_method_decorators, { kind: "method", name: "#method", static: true, private: true, access: { has: obj => __classPrivateFieldIn(_classThis, obj), get: obj => __classPrivateFieldGet(obj, _classThis, "a", _C_method_get) } }, null, _staticExtraInitializers); + __esDecorate(_classThis, _static_private_get_x_descriptor = { get: __setFunctionName(function () { return 1; }, "#x", "get") }, _static_private_get_x_decorators, { kind: "getter", name: "#x", static: true, private: true, access: { has: obj => __classPrivateFieldIn(_classThis, obj), get: obj => __classPrivateFieldGet(obj, _classThis, "a", _C_x_get) } }, null, _staticExtraInitializers); + __esDecorate(_classThis, _static_private_set_x_descriptor = { set: __setFunctionName(function (value) { }, "#x", "set") }, _static_private_set_x_decorators, { kind: "setter", name: "#x", static: true, private: true, access: { has: obj => __classPrivateFieldIn(_classThis, obj), set: (obj, value) => { __classPrivateFieldSet(obj, _classThis, value, "a", _C_x_set); } } }, null, _staticExtraInitializers); + __esDecorate(_classThis, _static_private_z_descriptor = { get: __setFunctionName(function () { return __classPrivateFieldGet(_classThis, _classThis, "f", _C_z_accessor_storage); }, "#z", "get"), set: __setFunctionName(function (value) { __classPrivateFieldSet(_classThis, _classThis, value, "f", _C_z_accessor_storage); }, "#z", "set") }, _static_private_z_decorators, { kind: "accessor", name: "#z", static: true, private: true, access: { has: obj => __classPrivateFieldIn(_classThis, obj), get: obj => __classPrivateFieldGet(obj, _classThis, "a", _C_z_get), set: (obj, value) => { __classPrivateFieldSet(obj, _classThis, value, "a", _C_z_set); } } }, _static_private_z_initializers, _staticExtraInitializers); __esDecorate(_classThis, null, _method_decorators, { kind: "method", name: "method", static: false, private: false, access: { has: obj => "method" in obj, get: obj => obj.method } }, null, _instanceExtraInitializers); __esDecorate(_classThis, null, _get_x_decorators, { kind: "getter", name: "x", static: false, private: false, access: { has: obj => "x" in obj, get: obj => obj.x } }, null, _instanceExtraInitializers); __esDecorate(_classThis, null, _set_x_decorators, { kind: "setter", name: "x", static: false, private: false, access: { has: obj => "x" in obj, set: (obj, value) => { obj.x = value; } } }, null, _instanceExtraInitializers); __esDecorate(_classThis, null, _z_decorators, { kind: "accessor", name: "z", static: false, private: false, access: { has: obj => "z" in obj, get: obj => obj.z, set: (obj, value) => { obj.z = value; } } }, _z_initializers, _instanceExtraInitializers); - __esDecorate(null, null, _static_private_y_decorators, { kind: "field", name: "#y", static: true, private: true, access: { has: obj => __classPrivateFieldIn(_classThis, obj), get: obj => __classPrivateFieldGet(obj, _classThis, "f", _y), set: (obj, value) => { __classPrivateFieldSet(obj, _classThis, value, "f", _y); } } }, _static_private_y_initializers, _staticExtraInitializers); + __esDecorate(null, null, _static_private_y_decorators, { kind: "field", name: "#y", static: true, private: true, access: { has: obj => __classPrivateFieldIn(_classThis, obj), get: obj => __classPrivateFieldGet(obj, _classThis, "f", _C_y), set: (obj, value) => { __classPrivateFieldSet(obj, _classThis, value, "f", _C_y); } } }, _static_private_y_initializers, _staticExtraInitializers); __esDecorate(null, null, _y_decorators, { kind: "field", name: "y", static: false, private: false, access: { has: obj => "y" in obj, get: obj => obj.y, set: (obj, value) => { obj.y = value; } } }, _y_initializers, _instanceExtraInitializers); __esDecorate(null, _classDescriptor = { value: _classThis }, _classDecorators, { kind: "class", name: _classThis.name }, null, _classExtraInitializers); C = _classThis = _classDescriptor.value; __runInitializers(_classThis, _staticExtraInitializers); })(), /*29*/ - _y = { value: __runInitializers(_classThis, _static_private_y_initializers, 1) }, - _z_accessor_storage = { value: __runInitializers(_classThis, _static_private_z_initializers, 1) }, + _C_y = { value: __runInitializers(_classThis, _static_private_y_initializers, 1) }, + _C_z_accessor_storage = { value: __runInitializers(_classThis, _static_private_z_initializers, 1) }, (() => { __runInitializers(_classThis, _classExtraInitializers); })(), diff --git a/tests/baselines/reference/esDecorators-classExpression-commentPreservation(target=es2022).js b/tests/baselines/reference/esDecorators-classExpression-commentPreservation(target=es2022).js index 16d4e1c12ff32..f51427a9c0130 100644 --- a/tests/baselines/reference/esDecorators-classExpression-commentPreservation(target=es2022).js +++ b/tests/baselines/reference/esDecorators-classExpression-commentPreservation(target=es2022).js @@ -87,7 +87,7 @@ class C { //// [esDecorators-classExpression-commentPreservation.js] /*1*/ ((() => { - var _method_get, _x_get, _x_set, _y, _z_accessor_storage, _z_get, _z_set, _a; + var _C_method_get, _C_x_get, _C_x_set, _C_y, _C_z_accessor_storage, _C_z_get, _C_z_set, _a; let _classDecorators = [dec, dec]; let _classDescriptor; let _classExtraInitializers = []; @@ -113,7 +113,9 @@ class C { let _z_decorators; let _z_initializers = []; var C = (_a = class { - static { _method_get = function _method_get() { return _static_private_method_descriptor.value; }, _x_get = function _x_get() { return _static_private_get_x_descriptor.get.call(this); }, _x_set = function _x_set(value) { return _static_private_set_x_descriptor.set.call(this, value); }, _z_get = function _z_get() { return _static_private_z_descriptor.get.call(this); }, _z_set = function _z_set(value) { return _static_private_z_descriptor.set.call(this, value); }; } + static { _classThis = this; } + static { __setFunctionName(this, "C"); } + static { _C_method_get = function _C_method_get() { return _static_private_method_descriptor.value; }, _C_x_get = function _C_x_get() { return _static_private_get_x_descriptor.get.call(this); }, _C_x_set = function _C_x_set(value) { return _static_private_set_x_descriptor.set.call(this, value); }, _C_z_get = function _C_z_get() { return _static_private_z_descriptor.get.call(this); }, _C_z_set = function _C_z_set(value) { return _static_private_z_descriptor.set.call(this, value); }; } static { _method_decorators = [dec, dec]; _get_x_decorators = [dec, dec]; @@ -125,17 +127,17 @@ class C { _static_private_set_x_decorators = [dec, dec]; _static_private_y_decorators = [dec, dec]; _static_private_z_decorators = [dec, dec]; - __esDecorate(this, _static_private_method_descriptor = { value: __setFunctionName(function () { }, "#method") }, _static_private_method_decorators, { kind: "method", name: "#method", static: true, private: true, access: { has: obj => __classPrivateFieldIn(_classThis, obj), get: obj => __classPrivateFieldGet(obj, _classThis, "a", _method_get) } }, null, _staticExtraInitializers); - __esDecorate(this, _static_private_get_x_descriptor = { get: __setFunctionName(function () { return 1; }, "#x", "get") }, _static_private_get_x_decorators, { kind: "getter", name: "#x", static: true, private: true, access: { has: obj => __classPrivateFieldIn(_classThis, obj), get: obj => __classPrivateFieldGet(obj, _classThis, "a", _x_get) } }, null, _staticExtraInitializers); - __esDecorate(this, _static_private_set_x_descriptor = { set: __setFunctionName(function (value) { }, "#x", "set") }, _static_private_set_x_decorators, { kind: "setter", name: "#x", static: true, private: true, access: { has: obj => __classPrivateFieldIn(_classThis, obj), set: (obj, value) => { __classPrivateFieldSet(obj, _classThis, value, "a", _x_set); } } }, null, _staticExtraInitializers); - __esDecorate(this, _static_private_z_descriptor = { get: __setFunctionName(function () { return __classPrivateFieldGet(this, _classThis, "f", _z_accessor_storage); }, "#z", "get"), set: __setFunctionName(function (value) { __classPrivateFieldSet(this, _classThis, value, "f", _z_accessor_storage); }, "#z", "set") }, _static_private_z_decorators, { kind: "accessor", name: "#z", static: true, private: true, access: { has: obj => __classPrivateFieldIn(_classThis, obj), get: obj => __classPrivateFieldGet(obj, _classThis, "a", _z_get), set: (obj, value) => { __classPrivateFieldSet(obj, _classThis, value, "a", _z_set); } } }, _static_private_z_initializers, _staticExtraInitializers); + __esDecorate(this, _static_private_method_descriptor = { value: __setFunctionName(function () { }, "#method") }, _static_private_method_decorators, { kind: "method", name: "#method", static: true, private: true, access: { has: obj => __classPrivateFieldIn(_classThis, obj), get: obj => __classPrivateFieldGet(obj, _classThis, "a", _C_method_get) } }, null, _staticExtraInitializers); + __esDecorate(this, _static_private_get_x_descriptor = { get: __setFunctionName(function () { return 1; }, "#x", "get") }, _static_private_get_x_decorators, { kind: "getter", name: "#x", static: true, private: true, access: { has: obj => __classPrivateFieldIn(_classThis, obj), get: obj => __classPrivateFieldGet(obj, _classThis, "a", _C_x_get) } }, null, _staticExtraInitializers); + __esDecorate(this, _static_private_set_x_descriptor = { set: __setFunctionName(function (value) { }, "#x", "set") }, _static_private_set_x_decorators, { kind: "setter", name: "#x", static: true, private: true, access: { has: obj => __classPrivateFieldIn(_classThis, obj), set: (obj, value) => { __classPrivateFieldSet(obj, _classThis, value, "a", _C_x_set); } } }, null, _staticExtraInitializers); + __esDecorate(this, _static_private_z_descriptor = { get: __setFunctionName(function () { return __classPrivateFieldGet(this, _classThis, "f", _C_z_accessor_storage); }, "#z", "get"), set: __setFunctionName(function (value) { __classPrivateFieldSet(this, _classThis, value, "f", _C_z_accessor_storage); }, "#z", "set") }, _static_private_z_decorators, { kind: "accessor", name: "#z", static: true, private: true, access: { has: obj => __classPrivateFieldIn(_classThis, obj), get: obj => __classPrivateFieldGet(obj, _classThis, "a", _C_z_get), set: (obj, value) => { __classPrivateFieldSet(obj, _classThis, value, "a", _C_z_set); } } }, _static_private_z_initializers, _staticExtraInitializers); __esDecorate(this, null, _method_decorators, { kind: "method", name: "method", static: false, private: false, access: { has: obj => "method" in obj, get: obj => obj.method } }, null, _instanceExtraInitializers); __esDecorate(this, null, _get_x_decorators, { kind: "getter", name: "x", static: false, private: false, access: { has: obj => "x" in obj, get: obj => obj.x } }, null, _instanceExtraInitializers); __esDecorate(this, null, _set_x_decorators, { kind: "setter", name: "x", static: false, private: false, access: { has: obj => "x" in obj, set: (obj, value) => { obj.x = value; } } }, null, _instanceExtraInitializers); __esDecorate(this, null, _z_decorators, { kind: "accessor", name: "z", static: false, private: false, access: { has: obj => "z" in obj, get: obj => obj.z, set: (obj, value) => { obj.z = value; } } }, _z_initializers, _instanceExtraInitializers); - __esDecorate(null, null, _static_private_y_decorators, { kind: "field", name: "#y", static: true, private: true, access: { has: obj => __classPrivateFieldIn(_classThis, obj), get: obj => __classPrivateFieldGet(obj, _classThis, "f", _y), set: (obj, value) => { __classPrivateFieldSet(obj, _classThis, value, "f", _y); } } }, _static_private_y_initializers, _staticExtraInitializers); + __esDecorate(null, null, _static_private_y_decorators, { kind: "field", name: "#y", static: true, private: true, access: { has: obj => __classPrivateFieldIn(_classThis, obj), get: obj => __classPrivateFieldGet(obj, _classThis, "f", _C_y), set: (obj, value) => { __classPrivateFieldSet(obj, _classThis, value, "f", _C_y); } } }, _static_private_y_initializers, _staticExtraInitializers); __esDecorate(null, null, _y_decorators, { kind: "field", name: "y", static: false, private: false, access: { has: obj => "y" in obj, get: obj => obj.y, set: (obj, value) => { obj.y = value; } } }, _y_initializers, _instanceExtraInitializers); - __esDecorate(null, _classDescriptor = { value: this }, _classDecorators, { kind: "class", name: this.name }, null, _classExtraInitializers); + __esDecorate(null, _classDescriptor = { value: _classThis }, _classDecorators, { kind: "class", name: _classThis.name }, null, _classExtraInitializers); C = _classThis = _classDescriptor.value; __runInitializers(_classThis, _staticExtraInitializers); } @@ -153,19 +155,18 @@ class C { set z(value) { this.#z_accessor_storage = value; } static { /*29*/ - _y = { value: __runInitializers(_classThis, _static_private_y_initializers, 1) }; + _C_y = { value: __runInitializers(_classThis, _static_private_y_initializers, 1) }; } static { - _z_accessor_storage = { value: __runInitializers(_classThis, _static_private_z_initializers, 1) }; + _C_z_accessor_storage = { value: __runInitializers(_classThis, _static_private_z_initializers, 1) }; } static { __runInitializers(_classThis, _classExtraInitializers); } }, - __setFunctionName(_a, "C"), /*29*/ - _y = { value: __runInitializers(_classThis, _static_private_y_initializers, 1) }, - _z_accessor_storage = { value: __runInitializers(_classThis, _static_private_z_initializers, 1) }, + _C_y = { value: __runInitializers(_classThis, _static_private_y_initializers, 1) }, + _C_z_accessor_storage = { value: __runInitializers(_classThis, _static_private_z_initializers, 1) }, _a); return C = _classThis; })()); diff --git a/tests/baselines/reference/esDecorators-classExpression-missingEmitHelpers-classDecorator.1.js b/tests/baselines/reference/esDecorators-classExpression-missingEmitHelpers-classDecorator.1.js index 50b51a2c16037..754ce68f5a3f9 100644 --- a/tests/baselines/reference/esDecorators-classExpression-missingEmitHelpers-classDecorator.1.js +++ b/tests/baselines/reference/esDecorators-classExpression-missingEmitHelpers-classDecorator.1.js @@ -22,9 +22,10 @@ exports.C = (() => { let _classExtraInitializers = []; let _classThis; var class_1 = class { + static { _classThis = this; } + static { tslib_1.__setFunctionName(_classThis, "C"); } static { - tslib_1.__setFunctionName(this, "C"); - tslib_1.__esDecorate(null, _classDescriptor = { value: this }, _classDecorators, { kind: "class", name: this.name }, null, _classExtraInitializers); + tslib_1.__esDecorate(null, _classDescriptor = { value: _classThis }, _classDecorators, { kind: "class", name: _classThis.name }, null, _classExtraInitializers); class_1 = _classThis = _classDescriptor.value; tslib_1.__runInitializers(_classThis, _classExtraInitializers); } diff --git a/tests/baselines/reference/esDecorators-classExpression-missingEmitHelpers-classDecorator.10.js b/tests/baselines/reference/esDecorators-classExpression-missingEmitHelpers-classDecorator.10.js index 197a8d003d7ba..5a7c9f5915396 100644 --- a/tests/baselines/reference/esDecorators-classExpression-missingEmitHelpers-classDecorator.10.js +++ b/tests/baselines/reference/esDecorators-classExpression-missingEmitHelpers-classDecorator.10.js @@ -25,9 +25,10 @@ C &&= (() => { let _classExtraInitializers = []; let _classThis; var class_1 = class { + static { _classThis = this; } + static { tslib_1.__setFunctionName(_classThis, "C"); } static { - tslib_1.__setFunctionName(this, "C"); - tslib_1.__esDecorate(null, _classDescriptor = { value: this }, _classDecorators, { kind: "class", name: this.name }, null, _classExtraInitializers); + tslib_1.__esDecorate(null, _classDescriptor = { value: _classThis }, _classDecorators, { kind: "class", name: _classThis.name }, null, _classExtraInitializers); class_1 = _classThis = _classDescriptor.value; tslib_1.__runInitializers(_classThis, _classExtraInitializers); } diff --git a/tests/baselines/reference/esDecorators-classExpression-missingEmitHelpers-classDecorator.11.js b/tests/baselines/reference/esDecorators-classExpression-missingEmitHelpers-classDecorator.11.js index 3f059fb32ab25..fe34668e46dd4 100644 --- a/tests/baselines/reference/esDecorators-classExpression-missingEmitHelpers-classDecorator.11.js +++ b/tests/baselines/reference/esDecorators-classExpression-missingEmitHelpers-classDecorator.11.js @@ -25,9 +25,10 @@ C ??= (() => { let _classExtraInitializers = []; let _classThis; var class_1 = class { + static { _classThis = this; } + static { tslib_1.__setFunctionName(_classThis, "C"); } static { - tslib_1.__setFunctionName(this, "C"); - tslib_1.__esDecorate(null, _classDescriptor = { value: this }, _classDecorators, { kind: "class", name: this.name }, null, _classExtraInitializers); + tslib_1.__esDecorate(null, _classDescriptor = { value: _classThis }, _classDecorators, { kind: "class", name: _classThis.name }, null, _classExtraInitializers); class_1 = _classThis = _classDescriptor.value; tslib_1.__runInitializers(_classThis, _classExtraInitializers); } diff --git a/tests/baselines/reference/esDecorators-classExpression-missingEmitHelpers-classDecorator.12.js b/tests/baselines/reference/esDecorators-classExpression-missingEmitHelpers-classDecorator.12.js index c5b94a7fee6d5..9d037ab86d06d 100644 --- a/tests/baselines/reference/esDecorators-classExpression-missingEmitHelpers-classDecorator.12.js +++ b/tests/baselines/reference/esDecorators-classExpression-missingEmitHelpers-classDecorator.12.js @@ -22,9 +22,10 @@ function f(C = (() => { let _classExtraInitializers = []; let _classThis; var class_1 = class { + static { _classThis = this; } + static { tslib_1.__setFunctionName(_classThis, "C"); } static { - tslib_1.__setFunctionName(this, "C"); - tslib_1.__esDecorate(null, _classDescriptor = { value: this }, _classDecorators, { kind: "class", name: this.name }, null, _classExtraInitializers); + tslib_1.__esDecorate(null, _classDescriptor = { value: _classThis }, _classDecorators, { kind: "class", name: _classThis.name }, null, _classExtraInitializers); class_1 = _classThis = _classDescriptor.value; tslib_1.__runInitializers(_classThis, _classExtraInitializers); } diff --git a/tests/baselines/reference/esDecorators-classExpression-missingEmitHelpers-classDecorator.13.js b/tests/baselines/reference/esDecorators-classExpression-missingEmitHelpers-classDecorator.13.js index 838ba46d2d42c..5288d3a9ab65a 100644 --- a/tests/baselines/reference/esDecorators-classExpression-missingEmitHelpers-classDecorator.13.js +++ b/tests/baselines/reference/esDecorators-classExpression-missingEmitHelpers-classDecorator.13.js @@ -22,9 +22,10 @@ exports.C = (((() => { let _classExtraInitializers = []; let _classThis; var class_1 = class { + static { _classThis = this; } + static { tslib_1.__setFunctionName(_classThis, "C"); } static { - tslib_1.__setFunctionName(this, "C"); - tslib_1.__esDecorate(null, _classDescriptor = { value: this }, _classDecorators, { kind: "class", name: this.name }, null, _classExtraInitializers); + tslib_1.__esDecorate(null, _classDescriptor = { value: _classThis }, _classDecorators, { kind: "class", name: _classThis.name }, null, _classExtraInitializers); class_1 = _classThis = _classDescriptor.value; tslib_1.__runInitializers(_classThis, _classExtraInitializers); } diff --git a/tests/baselines/reference/esDecorators-classExpression-missingEmitHelpers-classDecorator.14.js b/tests/baselines/reference/esDecorators-classExpression-missingEmitHelpers-classDecorator.14.js index d1b27d09603f9..c84185add0943 100644 --- a/tests/baselines/reference/esDecorators-classExpression-missingEmitHelpers-classDecorator.14.js +++ b/tests/baselines/reference/esDecorators-classExpression-missingEmitHelpers-classDecorator.14.js @@ -24,9 +24,10 @@ const tslib_1 = require("tslib"); let _classExtraInitializers = []; let _classThis; var class_1 = class { + static { _classThis = this; } + static { tslib_1.__setFunctionName(_classThis, _a); } static { - tslib_1.__setFunctionName(this, _a); - tslib_1.__esDecorate(null, _classDescriptor = { value: this }, _classDecorators, { kind: "class", name: this.name }, null, _classExtraInitializers); + tslib_1.__esDecorate(null, _classDescriptor = { value: _classThis }, _classDecorators, { kind: "class", name: _classThis.name }, null, _classExtraInitializers); class_1 = _classThis = _classDescriptor.value; tslib_1.__runInitializers(_classThis, _classExtraInitializers); } diff --git a/tests/baselines/reference/esDecorators-classExpression-missingEmitHelpers-classDecorator.15.js b/tests/baselines/reference/esDecorators-classExpression-missingEmitHelpers-classDecorator.15.js index 76e9f13ae66a2..3feb9c2aa132b 100644 --- a/tests/baselines/reference/esDecorators-classExpression-missingEmitHelpers-classDecorator.15.js +++ b/tests/baselines/reference/esDecorators-classExpression-missingEmitHelpers-classDecorator.15.js @@ -23,9 +23,10 @@ class C { let _classExtraInitializers = []; let _classThis; var class_1 = class { + static { _classThis = this; } + static { tslib_1.__setFunctionName(_classThis, "D"); } static { - tslib_1.__setFunctionName(this, "D"); - tslib_1.__esDecorate(null, _classDescriptor = { value: this }, _classDecorators, { kind: "class", name: this.name }, null, _classExtraInitializers); + tslib_1.__esDecorate(null, _classDescriptor = { value: _classThis }, _classDecorators, { kind: "class", name: _classThis.name }, null, _classExtraInitializers); class_1 = _classThis = _classDescriptor.value; tslib_1.__runInitializers(_classThis, _classExtraInitializers); } diff --git a/tests/baselines/reference/esDecorators-classExpression-missingEmitHelpers-classDecorator.16.js b/tests/baselines/reference/esDecorators-classExpression-missingEmitHelpers-classDecorator.16.js index e61323d969d00..474810fce9503 100644 --- a/tests/baselines/reference/esDecorators-classExpression-missingEmitHelpers-classDecorator.16.js +++ b/tests/baselines/reference/esDecorators-classExpression-missingEmitHelpers-classDecorator.16.js @@ -25,9 +25,10 @@ class C { let _classExtraInitializers = []; let _classThis; var class_1 = class { + static { _classThis = this; } + static { tslib_1.__setFunctionName(_classThis, _a); } static { - tslib_1.__setFunctionName(this, _a); - tslib_1.__esDecorate(null, _classDescriptor = { value: this }, _classDecorators, { kind: "class", name: this.name }, null, _classExtraInitializers); + tslib_1.__esDecorate(null, _classDescriptor = { value: _classThis }, _classDecorators, { kind: "class", name: _classThis.name }, null, _classExtraInitializers); class_1 = _classThis = _classDescriptor.value; tslib_1.__runInitializers(_classThis, _classExtraInitializers); } diff --git a/tests/baselines/reference/esDecorators-classExpression-missingEmitHelpers-classDecorator.17.js b/tests/baselines/reference/esDecorators-classExpression-missingEmitHelpers-classDecorator.17.js index 0c3cc126a9c3a..d53f603065be3 100644 --- a/tests/baselines/reference/esDecorators-classExpression-missingEmitHelpers-classDecorator.17.js +++ b/tests/baselines/reference/esDecorators-classExpression-missingEmitHelpers-classDecorator.17.js @@ -26,9 +26,10 @@ var C; let _classExtraInitializers = []; let _classThis; var class_1 = class { + static { _classThis = this; } + static { tslib_1.__setFunctionName(_classThis, "C"); } static { - tslib_1.__setFunctionName(this, "C"); - tslib_1.__esDecorate(null, _classDescriptor = { value: this }, _classDecorators, { kind: "class", name: this.name }, null, _classExtraInitializers); + tslib_1.__esDecorate(null, _classDescriptor = { value: _classThis }, _classDecorators, { kind: "class", name: _classThis.name }, null, _classExtraInitializers); class_1 = _classThis = _classDescriptor.value; tslib_1.__runInitializers(_classThis, _classExtraInitializers); } diff --git a/tests/baselines/reference/esDecorators-classExpression-missingEmitHelpers-classDecorator.2.js b/tests/baselines/reference/esDecorators-classExpression-missingEmitHelpers-classDecorator.2.js index a6ab301b3cdfa..6931e43693646 100644 --- a/tests/baselines/reference/esDecorators-classExpression-missingEmitHelpers-classDecorator.2.js +++ b/tests/baselines/reference/esDecorators-classExpression-missingEmitHelpers-classDecorator.2.js @@ -22,8 +22,9 @@ exports.C = (() => { let _classExtraInitializers = []; let _classThis; var C = class { + static { _classThis = this; } static { - tslib_1.__esDecorate(null, _classDescriptor = { value: this }, _classDecorators, { kind: "class", name: this.name }, null, _classExtraInitializers); + tslib_1.__esDecorate(null, _classDescriptor = { value: _classThis }, _classDecorators, { kind: "class", name: _classThis.name }, null, _classExtraInitializers); C = _classThis = _classDescriptor.value; tslib_1.__runInitializers(_classThis, _classExtraInitializers); } diff --git a/tests/baselines/reference/esDecorators-classExpression-missingEmitHelpers-classDecorator.3.js b/tests/baselines/reference/esDecorators-classExpression-missingEmitHelpers-classDecorator.3.js index bd13effbc5b9e..5b9ea5b594ab9 100644 --- a/tests/baselines/reference/esDecorators-classExpression-missingEmitHelpers-classDecorator.3.js +++ b/tests/baselines/reference/esDecorators-classExpression-missingEmitHelpers-classDecorator.3.js @@ -21,9 +21,10 @@ exports.default = ((() => { let _classExtraInitializers = []; let _classThis; var class_1 = class { + static { _classThis = this; } + static { tslib_1.__setFunctionName(_classThis, "default"); } static { - tslib_1.__setFunctionName(this, "default"); - tslib_1.__esDecorate(null, _classDescriptor = { value: this }, _classDecorators, { kind: "class", name: this.name }, null, _classExtraInitializers); + tslib_1.__esDecorate(null, _classDescriptor = { value: _classThis }, _classDecorators, { kind: "class", name: _classThis.name }, null, _classExtraInitializers); class_1 = _classThis = _classDescriptor.value; tslib_1.__runInitializers(_classThis, _classExtraInitializers); } diff --git a/tests/baselines/reference/esDecorators-classExpression-missingEmitHelpers-classDecorator.4.js b/tests/baselines/reference/esDecorators-classExpression-missingEmitHelpers-classDecorator.4.js index 1e5e1f8b11b5f..2a0adf73df778 100644 --- a/tests/baselines/reference/esDecorators-classExpression-missingEmitHelpers-classDecorator.4.js +++ b/tests/baselines/reference/esDecorators-classExpression-missingEmitHelpers-classDecorator.4.js @@ -25,9 +25,10 @@ C = (() => { let _classExtraInitializers = []; let _classThis; var class_1 = class { + static { _classThis = this; } + static { tslib_1.__setFunctionName(_classThis, "C"); } static { - tslib_1.__setFunctionName(this, "C"); - tslib_1.__esDecorate(null, _classDescriptor = { value: this }, _classDecorators, { kind: "class", name: this.name }, null, _classExtraInitializers); + tslib_1.__esDecorate(null, _classDescriptor = { value: _classThis }, _classDecorators, { kind: "class", name: _classThis.name }, null, _classExtraInitializers); class_1 = _classThis = _classDescriptor.value; tslib_1.__runInitializers(_classThis, _classExtraInitializers); } diff --git a/tests/baselines/reference/esDecorators-classExpression-missingEmitHelpers-classDecorator.5.js b/tests/baselines/reference/esDecorators-classExpression-missingEmitHelpers-classDecorator.5.js index e772afc6a295a..81d750cb67650 100644 --- a/tests/baselines/reference/esDecorators-classExpression-missingEmitHelpers-classDecorator.5.js +++ b/tests/baselines/reference/esDecorators-classExpression-missingEmitHelpers-classDecorator.5.js @@ -25,9 +25,10 @@ var C; let _classExtraInitializers = []; let _classThis; var class_1 = class { + static { _classThis = this; } + static { tslib_1.__setFunctionName(_classThis, "C"); } static { - tslib_1.__setFunctionName(this, "C"); - tslib_1.__esDecorate(null, _classDescriptor = { value: this }, _classDecorators, { kind: "class", name: this.name }, null, _classExtraInitializers); + tslib_1.__esDecorate(null, _classDescriptor = { value: _classThis }, _classDecorators, { kind: "class", name: _classThis.name }, null, _classExtraInitializers); class_1 = _classThis = _classDescriptor.value; tslib_1.__runInitializers(_classThis, _classExtraInitializers); } diff --git a/tests/baselines/reference/esDecorators-classExpression-missingEmitHelpers-classDecorator.6.js b/tests/baselines/reference/esDecorators-classExpression-missingEmitHelpers-classDecorator.6.js index 6206e34b9b454..1f926cb2b0f95 100644 --- a/tests/baselines/reference/esDecorators-classExpression-missingEmitHelpers-classDecorator.6.js +++ b/tests/baselines/reference/esDecorators-classExpression-missingEmitHelpers-classDecorator.6.js @@ -22,9 +22,10 @@ const tslib_1 = require("tslib"); let _classExtraInitializers = []; let _classThis; var class_1 = class { + static { _classThis = this; } + static { tslib_1.__setFunctionName(_classThis, "C"); } static { - tslib_1.__setFunctionName(this, "C"); - tslib_1.__esDecorate(null, _classDescriptor = { value: this }, _classDecorators, { kind: "class", name: this.name }, null, _classExtraInitializers); + tslib_1.__esDecorate(null, _classDescriptor = { value: _classThis }, _classDecorators, { kind: "class", name: _classThis.name }, null, _classExtraInitializers); class_1 = _classThis = _classDescriptor.value; tslib_1.__runInitializers(_classThis, _classExtraInitializers); } diff --git a/tests/baselines/reference/esDecorators-classExpression-missingEmitHelpers-classDecorator.7.js b/tests/baselines/reference/esDecorators-classExpression-missingEmitHelpers-classDecorator.7.js index d428e95b2f5d5..6c6e7adde11a4 100644 --- a/tests/baselines/reference/esDecorators-classExpression-missingEmitHelpers-classDecorator.7.js +++ b/tests/baselines/reference/esDecorators-classExpression-missingEmitHelpers-classDecorator.7.js @@ -25,9 +25,10 @@ var C; let _classExtraInitializers = []; let _classThis; var class_1 = class { + static { _classThis = this; } + static { tslib_1.__setFunctionName(_classThis, "C"); } static { - tslib_1.__setFunctionName(this, "C"); - tslib_1.__esDecorate(null, _classDescriptor = { value: this }, _classDecorators, { kind: "class", name: this.name }, null, _classExtraInitializers); + tslib_1.__esDecorate(null, _classDescriptor = { value: _classThis }, _classDecorators, { kind: "class", name: _classThis.name }, null, _classExtraInitializers); class_1 = _classThis = _classDescriptor.value; tslib_1.__runInitializers(_classThis, _classExtraInitializers); } diff --git a/tests/baselines/reference/esDecorators-classExpression-missingEmitHelpers-classDecorator.8.js b/tests/baselines/reference/esDecorators-classExpression-missingEmitHelpers-classDecorator.8.js index e5118d682d071..7f9989666060c 100644 --- a/tests/baselines/reference/esDecorators-classExpression-missingEmitHelpers-classDecorator.8.js +++ b/tests/baselines/reference/esDecorators-classExpression-missingEmitHelpers-classDecorator.8.js @@ -25,9 +25,10 @@ var C; let _classExtraInitializers = []; let _classThis; var class_1 = class { + static { _classThis = this; } + static { tslib_1.__setFunctionName(_classThis, "C"); } static { - tslib_1.__setFunctionName(this, "C"); - tslib_1.__esDecorate(null, _classDescriptor = { value: this }, _classDecorators, { kind: "class", name: this.name }, null, _classExtraInitializers); + tslib_1.__esDecorate(null, _classDescriptor = { value: _classThis }, _classDecorators, { kind: "class", name: _classThis.name }, null, _classExtraInitializers); class_1 = _classThis = _classDescriptor.value; tslib_1.__runInitializers(_classThis, _classExtraInitializers); } diff --git a/tests/baselines/reference/esDecorators-classExpression-missingEmitHelpers-classDecorator.9.js b/tests/baselines/reference/esDecorators-classExpression-missingEmitHelpers-classDecorator.9.js index 12695aac79984..2938134bb33b0 100644 --- a/tests/baselines/reference/esDecorators-classExpression-missingEmitHelpers-classDecorator.9.js +++ b/tests/baselines/reference/esDecorators-classExpression-missingEmitHelpers-classDecorator.9.js @@ -25,9 +25,10 @@ C ||= (() => { let _classExtraInitializers = []; let _classThis; var class_1 = class { + static { _classThis = this; } + static { tslib_1.__setFunctionName(_classThis, "C"); } static { - tslib_1.__setFunctionName(this, "C"); - tslib_1.__esDecorate(null, _classDescriptor = { value: this }, _classDecorators, { kind: "class", name: this.name }, null, _classExtraInitializers); + tslib_1.__esDecorate(null, _classDescriptor = { value: _classThis }, _classDecorators, { kind: "class", name: _classThis.name }, null, _classExtraInitializers); class_1 = _classThis = _classDescriptor.value; tslib_1.__runInitializers(_classThis, _classExtraInitializers); } diff --git a/tests/baselines/reference/esDecorators-classExpression-namedEvaluation.1.js b/tests/baselines/reference/esDecorators-classExpression-namedEvaluation.1.js index 9a3cb19e24222..96bdd18d4a346 100644 --- a/tests/baselines/reference/esDecorators-classExpression-namedEvaluation.1.js +++ b/tests/baselines/reference/esDecorators-classExpression-namedEvaluation.1.js @@ -40,9 +40,10 @@ x = (() => { let _classExtraInitializers = []; let _classThis; var class_1 = class { + static { _classThis = this; } + static { __setFunctionName(_classThis, "x"); } static { - __setFunctionName(this, "x"); - __esDecorate(null, _classDescriptor = { value: this }, _classDecorators, { kind: "class", name: this.name }, null, _classExtraInitializers); + __esDecorate(null, _classDescriptor = { value: _classThis }, _classDecorators, { kind: "class", name: _classThis.name }, null, _classExtraInitializers); class_1 = _classThis = _classDescriptor.value; __runInitializers(_classThis, _classExtraInitializers); } @@ -54,8 +55,8 @@ x = (() => { let _y_decorators; let _y_initializers = []; return class { + static { __setFunctionName(this, "x"); } static { - __setFunctionName(this, "x"); _y_decorators = [dec]; __esDecorate(null, null, _y_decorators, { kind: "field", name: "y", static: false, private: false, access: { has: obj => "y" in obj, get: obj => obj.y, set: (obj, value) => { obj.y = value; } } }, _y_initializers, _instanceExtraInitializers); } @@ -65,90 +66,93 @@ x = (() => { // 13.15.2 RS: Evaluation // AssignmentExpression : LeftHandSideExpression `&&=` AssignmentExpression x &&= (() => { - let _classDecorators_1 = [dec]; - let _classDescriptor_1; - let _classExtraInitializers_1 = []; - let _classThis_1; + let _classDecorators = [dec]; + let _classDescriptor; + let _classExtraInitializers = []; + let _classThis; var class_2 = class { + static { _classThis = this; } + static { __setFunctionName(_classThis, "x"); } static { - __setFunctionName(this, "x"); - __esDecorate(null, _classDescriptor_1 = { value: this }, _classDecorators_1, { kind: "class", name: this.name }, null, _classExtraInitializers_1); - class_2 = _classThis_1 = _classDescriptor_1.value; - __runInitializers(_classThis_1, _classExtraInitializers_1); + __esDecorate(null, _classDescriptor = { value: _classThis }, _classDecorators, { kind: "class", name: _classThis.name }, null, _classExtraInitializers); + class_2 = _classThis = _classDescriptor.value; + __runInitializers(_classThis, _classExtraInitializers); } }; - return class_2 = _classThis_1; + return class_2 = _classThis; })(); x &&= (() => { - let _instanceExtraInitializers_1 = []; + let _instanceExtraInitializers = []; let _y_decorators; let _y_initializers = []; return class { + static { __setFunctionName(this, "x"); } static { - __setFunctionName(this, "x"); _y_decorators = [dec]; - __esDecorate(null, null, _y_decorators, { kind: "field", name: "y", static: false, private: false, access: { has: obj => "y" in obj, get: obj => obj.y, set: (obj, value) => { obj.y = value; } } }, _y_initializers, _instanceExtraInitializers_1); + __esDecorate(null, null, _y_decorators, { kind: "field", name: "y", static: false, private: false, access: { has: obj => "y" in obj, get: obj => obj.y, set: (obj, value) => { obj.y = value; } } }, _y_initializers, _instanceExtraInitializers); } - y = (__runInitializers(this, _instanceExtraInitializers_1), __runInitializers(this, _y_initializers, void 0)); + y = (__runInitializers(this, _instanceExtraInitializers), __runInitializers(this, _y_initializers, void 0)); }; })(); // 13.15.2 RS: Evaluation // AssignmentExpression : LeftHandSideExpression `||=` AssignmentExpression x ||= (() => { - let _classDecorators_2 = [dec]; - let _classDescriptor_2; - let _classExtraInitializers_2 = []; - let _classThis_2; + let _classDecorators = [dec]; + let _classDescriptor; + let _classExtraInitializers = []; + let _classThis; var class_3 = class { + static { _classThis = this; } + static { __setFunctionName(_classThis, "x"); } static { - __setFunctionName(this, "x"); - __esDecorate(null, _classDescriptor_2 = { value: this }, _classDecorators_2, { kind: "class", name: this.name }, null, _classExtraInitializers_2); - class_3 = _classThis_2 = _classDescriptor_2.value; - __runInitializers(_classThis_2, _classExtraInitializers_2); + __esDecorate(null, _classDescriptor = { value: _classThis }, _classDecorators, { kind: "class", name: _classThis.name }, null, _classExtraInitializers); + class_3 = _classThis = _classDescriptor.value; + __runInitializers(_classThis, _classExtraInitializers); } }; - return class_3 = _classThis_2; + return class_3 = _classThis; })(); x ||= (() => { - let _instanceExtraInitializers_2 = []; + let _instanceExtraInitializers = []; let _y_decorators; let _y_initializers = []; return class { + static { __setFunctionName(this, "x"); } static { - __setFunctionName(this, "x"); _y_decorators = [dec]; - __esDecorate(null, null, _y_decorators, { kind: "field", name: "y", static: false, private: false, access: { has: obj => "y" in obj, get: obj => obj.y, set: (obj, value) => { obj.y = value; } } }, _y_initializers, _instanceExtraInitializers_2); + __esDecorate(null, null, _y_decorators, { kind: "field", name: "y", static: false, private: false, access: { has: obj => "y" in obj, get: obj => obj.y, set: (obj, value) => { obj.y = value; } } }, _y_initializers, _instanceExtraInitializers); } - y = (__runInitializers(this, _instanceExtraInitializers_2), __runInitializers(this, _y_initializers, void 0)); + y = (__runInitializers(this, _instanceExtraInitializers), __runInitializers(this, _y_initializers, void 0)); }; })(); // 13.15.2 RS: Evaluation // AssignmentExpression : LeftHandSideExpression `??=` AssignmentExpression x ??= (() => { - let _classDecorators_3 = [dec]; - let _classDescriptor_3; - let _classExtraInitializers_3 = []; - let _classThis_3; + let _classDecorators = [dec]; + let _classDescriptor; + let _classExtraInitializers = []; + let _classThis; var class_4 = class { + static { _classThis = this; } + static { __setFunctionName(_classThis, "x"); } static { - __setFunctionName(this, "x"); - __esDecorate(null, _classDescriptor_3 = { value: this }, _classDecorators_3, { kind: "class", name: this.name }, null, _classExtraInitializers_3); - class_4 = _classThis_3 = _classDescriptor_3.value; - __runInitializers(_classThis_3, _classExtraInitializers_3); + __esDecorate(null, _classDescriptor = { value: _classThis }, _classDecorators, { kind: "class", name: _classThis.name }, null, _classExtraInitializers); + class_4 = _classThis = _classDescriptor.value; + __runInitializers(_classThis, _classExtraInitializers); } }; - return class_4 = _classThis_3; + return class_4 = _classThis; })(); x ??= (() => { - let _instanceExtraInitializers_3 = []; + let _instanceExtraInitializers = []; let _y_decorators; let _y_initializers = []; return class { + static { __setFunctionName(this, "x"); } static { - __setFunctionName(this, "x"); _y_decorators = [dec]; - __esDecorate(null, null, _y_decorators, { kind: "field", name: "y", static: false, private: false, access: { has: obj => "y" in obj, get: obj => obj.y, set: (obj, value) => { obj.y = value; } } }, _y_initializers, _instanceExtraInitializers_3); + __esDecorate(null, null, _y_decorators, { kind: "field", name: "y", static: false, private: false, access: { has: obj => "y" in obj, get: obj => obj.y, set: (obj, value) => { obj.y = value; } } }, _y_initializers, _instanceExtraInitializers); } - y = (__runInitializers(this, _instanceExtraInitializers_3), __runInitializers(this, _y_initializers, void 0)); + y = (__runInitializers(this, _instanceExtraInitializers), __runInitializers(this, _y_initializers, void 0)); }; })(); diff --git a/tests/baselines/reference/esDecorators-classExpression-namedEvaluation.10.js b/tests/baselines/reference/esDecorators-classExpression-namedEvaluation.10.js index 1649959a176ce..0e332832d12ee 100644 --- a/tests/baselines/reference/esDecorators-classExpression-namedEvaluation.10.js +++ b/tests/baselines/reference/esDecorators-classExpression-namedEvaluation.10.js @@ -46,9 +46,10 @@ var _a, _b; let _classExtraInitializers = []; let _classThis; var class_1 = class { + static { _classThis = this; } + static { __setFunctionName(_classThis, "x"); } static { - __setFunctionName(this, "x"); - __esDecorate(null, _classDescriptor = { value: this }, _classDecorators, { kind: "class", name: this.name }, null, _classExtraInitializers); + __esDecorate(null, _classDescriptor = { value: _classThis }, _classDecorators, { kind: "class", name: _classThis.name }, null, _classExtraInitializers); class_1 = _classThis = _classDescriptor.value; __runInitializers(_classThis, _classExtraInitializers); } @@ -60,76 +61,80 @@ var _a, _b; { class C { static "x" = (() => { - let _classDecorators_1 = [dec]; - let _classDescriptor_1; - let _classExtraInitializers_1 = []; - let _classThis_1; + let _classDecorators = [dec]; + let _classDescriptor; + let _classExtraInitializers = []; + let _classThis; var class_2 = class { + static { _classThis = this; } + static { __setFunctionName(_classThis, "x"); } static { - __setFunctionName(this, "x"); - __esDecorate(null, _classDescriptor_1 = { value: this }, _classDecorators_1, { kind: "class", name: this.name }, null, _classExtraInitializers_1); - class_2 = _classThis_1 = _classDescriptor_1.value; - __runInitializers(_classThis_1, _classExtraInitializers_1); + __esDecorate(null, _classDescriptor = { value: _classThis }, _classDecorators, { kind: "class", name: _classThis.name }, null, _classExtraInitializers); + class_2 = _classThis = _classDescriptor.value; + __runInitializers(_classThis, _classExtraInitializers); } }; - return class_2 = _classThis_1; + return class_2 = _classThis; })(); } } { class C { static 0 = (() => { - let _classDecorators_2 = [dec]; - let _classDescriptor_2; - let _classExtraInitializers_2 = []; - let _classThis_2; + let _classDecorators = [dec]; + let _classDescriptor; + let _classExtraInitializers = []; + let _classThis; var class_3 = class { + static { _classThis = this; } + static { __setFunctionName(_classThis, "0"); } static { - __setFunctionName(this, "0"); - __esDecorate(null, _classDescriptor_2 = { value: this }, _classDecorators_2, { kind: "class", name: this.name }, null, _classExtraInitializers_2); - class_3 = _classThis_2 = _classDescriptor_2.value; - __runInitializers(_classThis_2, _classExtraInitializers_2); + __esDecorate(null, _classDescriptor = { value: _classThis }, _classDecorators, { kind: "class", name: _classThis.name }, null, _classExtraInitializers); + class_3 = _classThis = _classDescriptor.value; + __runInitializers(_classThis, _classExtraInitializers); } }; - return class_3 = _classThis_2; + return class_3 = _classThis; })(); } } { class C { static ["x"] = (() => { - let _classDecorators_3 = [dec]; - let _classDescriptor_3; - let _classExtraInitializers_3 = []; - let _classThis_3; + let _classDecorators = [dec]; + let _classDescriptor; + let _classExtraInitializers = []; + let _classThis; var class_4 = class { + static { _classThis = this; } + static { __setFunctionName(_classThis, "x"); } static { - __setFunctionName(this, "x"); - __esDecorate(null, _classDescriptor_3 = { value: this }, _classDecorators_3, { kind: "class", name: this.name }, null, _classExtraInitializers_3); - class_4 = _classThis_3 = _classDescriptor_3.value; - __runInitializers(_classThis_3, _classExtraInitializers_3); + __esDecorate(null, _classDescriptor = { value: _classThis }, _classDecorators, { kind: "class", name: _classThis.name }, null, _classExtraInitializers); + class_4 = _classThis = _classDescriptor.value; + __runInitializers(_classThis, _classExtraInitializers); } }; - return class_4 = _classThis_3; + return class_4 = _classThis; })(); } } { class C { static [0] = (() => { - let _classDecorators_4 = [dec]; - let _classDescriptor_4; - let _classExtraInitializers_4 = []; - let _classThis_4; + let _classDecorators = [dec]; + let _classDescriptor; + let _classExtraInitializers = []; + let _classThis; var class_5 = class { + static { _classThis = this; } + static { __setFunctionName(_classThis, "0"); } static { - __setFunctionName(this, "0"); - __esDecorate(null, _classDescriptor_4 = { value: this }, _classDecorators_4, { kind: "class", name: this.name }, null, _classExtraInitializers_4); - class_5 = _classThis_4 = _classDescriptor_4.value; - __runInitializers(_classThis_4, _classExtraInitializers_4); + __esDecorate(null, _classDescriptor = { value: _classThis }, _classDecorators, { kind: "class", name: _classThis.name }, null, _classExtraInitializers); + class_5 = _classThis = _classDescriptor.value; + __runInitializers(_classThis, _classExtraInitializers); } }; - return class_5 = _classThis_4; + return class_5 = _classThis; })(); } } @@ -137,19 +142,20 @@ var _a, _b; { class C { static [_a = __propKey(f())] = (() => { - let _classDecorators_5 = [dec]; - let _classDescriptor_5; - let _classExtraInitializers_5 = []; - let _classThis_5; + let _classDecorators = [dec]; + let _classDescriptor; + let _classExtraInitializers = []; + let _classThis; var class_6 = class { + static { _classThis = this; } + static { __setFunctionName(_classThis, _a); } static { - __setFunctionName(this, _a); - __esDecorate(null, _classDescriptor_5 = { value: this }, _classDecorators_5, { kind: "class", name: this.name }, null, _classExtraInitializers_5); - class_6 = _classThis_5 = _classDescriptor_5.value; - __runInitializers(_classThis_5, _classExtraInitializers_5); + __esDecorate(null, _classDescriptor = { value: _classThis }, _classDecorators, { kind: "class", name: _classThis.name }, null, _classExtraInitializers); + class_6 = _classThis = _classDescriptor.value; + __runInitializers(_classThis, _classExtraInitializers); } }; - return class_6 = _classThis_5; + return class_6 = _classThis; })(); } } @@ -157,38 +163,40 @@ var _a, _b; { class C { static __proto__ = (() => { - let _classDecorators_6 = [dec]; - let _classDescriptor_6; - let _classExtraInitializers_6 = []; - let _classThis_6; + let _classDecorators = [dec]; + let _classDescriptor; + let _classExtraInitializers = []; + let _classThis; var class_7 = class { + static { _classThis = this; } + static { __setFunctionName(_classThis, "__proto__"); } static { - __setFunctionName(this, "__proto__"); - __esDecorate(null, _classDescriptor_6 = { value: this }, _classDecorators_6, { kind: "class", name: this.name }, null, _classExtraInitializers_6); - class_7 = _classThis_6 = _classDescriptor_6.value; - __runInitializers(_classThis_6, _classExtraInitializers_6); + __esDecorate(null, _classDescriptor = { value: _classThis }, _classDecorators, { kind: "class", name: _classThis.name }, null, _classExtraInitializers); + class_7 = _classThis = _classDescriptor.value; + __runInitializers(_classThis, _classExtraInitializers); } }; - return class_7 = _classThis_6; + return class_7 = _classThis; })(); } } { class C { static "__proto__" = (() => { - let _classDecorators_7 = [dec]; - let _classDescriptor_7; - let _classExtraInitializers_7 = []; - let _classThis_7; + let _classDecorators = [dec]; + let _classDescriptor; + let _classExtraInitializers = []; + let _classThis; var class_8 = class { + static { _classThis = this; } + static { __setFunctionName(_classThis, "__proto__"); } static { - __setFunctionName(this, "__proto__"); - __esDecorate(null, _classDescriptor_7 = { value: this }, _classDecorators_7, { kind: "class", name: this.name }, null, _classExtraInitializers_7); - class_8 = _classThis_7 = _classDescriptor_7.value; - __runInitializers(_classThis_7, _classExtraInitializers_7); + __esDecorate(null, _classDescriptor = { value: _classThis }, _classDecorators, { kind: "class", name: _classThis.name }, null, _classExtraInitializers); + class_8 = _classThis = _classDescriptor.value; + __runInitializers(_classThis, _classExtraInitializers); } }; - return class_8 = _classThis_7; + return class_8 = _classThis; })(); } } @@ -199,8 +207,8 @@ var _a, _b; let _y_decorators; let _y_initializers = []; return class { + static { __setFunctionName(this, "x"); } static { - __setFunctionName(this, "x"); _y_decorators = [dec]; __esDecorate(null, null, _y_decorators, { kind: "field", name: "y", static: false, private: false, access: { has: obj => "y" in obj, get: obj => obj.y, set: (obj, value) => { obj.y = value; } } }, _y_initializers, _instanceExtraInitializers); } @@ -212,16 +220,16 @@ var _a, _b; { class C { static "x" = (() => { - let _instanceExtraInitializers_1 = []; + let _instanceExtraInitializers = []; let _y_decorators; let _y_initializers = []; return class { + static { __setFunctionName(this, "x"); } static { - __setFunctionName(this, "x"); _y_decorators = [dec]; - __esDecorate(null, null, _y_decorators, { kind: "field", name: "y", static: false, private: false, access: { has: obj => "y" in obj, get: obj => obj.y, set: (obj, value) => { obj.y = value; } } }, _y_initializers, _instanceExtraInitializers_1); + __esDecorate(null, null, _y_decorators, { kind: "field", name: "y", static: false, private: false, access: { has: obj => "y" in obj, get: obj => obj.y, set: (obj, value) => { obj.y = value; } } }, _y_initializers, _instanceExtraInitializers); } - y = (__runInitializers(this, _instanceExtraInitializers_1), __runInitializers(this, _y_initializers, void 0)); + y = (__runInitializers(this, _instanceExtraInitializers), __runInitializers(this, _y_initializers, void 0)); }; })(); } @@ -229,16 +237,16 @@ var _a, _b; { class C { static 0 = (() => { - let _instanceExtraInitializers_2 = []; + let _instanceExtraInitializers = []; let _y_decorators; let _y_initializers = []; return class { + static { __setFunctionName(this, "0"); } static { - __setFunctionName(this, "0"); _y_decorators = [dec]; - __esDecorate(null, null, _y_decorators, { kind: "field", name: "y", static: false, private: false, access: { has: obj => "y" in obj, get: obj => obj.y, set: (obj, value) => { obj.y = value; } } }, _y_initializers, _instanceExtraInitializers_2); + __esDecorate(null, null, _y_decorators, { kind: "field", name: "y", static: false, private: false, access: { has: obj => "y" in obj, get: obj => obj.y, set: (obj, value) => { obj.y = value; } } }, _y_initializers, _instanceExtraInitializers); } - y = (__runInitializers(this, _instanceExtraInitializers_2), __runInitializers(this, _y_initializers, void 0)); + y = (__runInitializers(this, _instanceExtraInitializers), __runInitializers(this, _y_initializers, void 0)); }; })(); } @@ -246,16 +254,16 @@ var _a, _b; { class C { static ["x"] = (() => { - let _instanceExtraInitializers_3 = []; + let _instanceExtraInitializers = []; let _y_decorators; let _y_initializers = []; return class { + static { __setFunctionName(this, "x"); } static { - __setFunctionName(this, "x"); _y_decorators = [dec]; - __esDecorate(null, null, _y_decorators, { kind: "field", name: "y", static: false, private: false, access: { has: obj => "y" in obj, get: obj => obj.y, set: (obj, value) => { obj.y = value; } } }, _y_initializers, _instanceExtraInitializers_3); + __esDecorate(null, null, _y_decorators, { kind: "field", name: "y", static: false, private: false, access: { has: obj => "y" in obj, get: obj => obj.y, set: (obj, value) => { obj.y = value; } } }, _y_initializers, _instanceExtraInitializers); } - y = (__runInitializers(this, _instanceExtraInitializers_3), __runInitializers(this, _y_initializers, void 0)); + y = (__runInitializers(this, _instanceExtraInitializers), __runInitializers(this, _y_initializers, void 0)); }; })(); } @@ -263,16 +271,16 @@ var _a, _b; { class C { static [0] = (() => { - let _instanceExtraInitializers_4 = []; + let _instanceExtraInitializers = []; let _y_decorators; let _y_initializers = []; return class { + static { __setFunctionName(this, "0"); } static { - __setFunctionName(this, "0"); _y_decorators = [dec]; - __esDecorate(null, null, _y_decorators, { kind: "field", name: "y", static: false, private: false, access: { has: obj => "y" in obj, get: obj => obj.y, set: (obj, value) => { obj.y = value; } } }, _y_initializers, _instanceExtraInitializers_4); + __esDecorate(null, null, _y_decorators, { kind: "field", name: "y", static: false, private: false, access: { has: obj => "y" in obj, get: obj => obj.y, set: (obj, value) => { obj.y = value; } } }, _y_initializers, _instanceExtraInitializers); } - y = (__runInitializers(this, _instanceExtraInitializers_4), __runInitializers(this, _y_initializers, void 0)); + y = (__runInitializers(this, _instanceExtraInitializers), __runInitializers(this, _y_initializers, void 0)); }; })(); } @@ -281,19 +289,20 @@ var _a, _b; { class C { static [_b = __propKey(f())] = (() => { - let _classDecorators_8 = [dec]; - let _classDescriptor_8; - let _classExtraInitializers_8 = []; - let _classThis_8; + let _classDecorators = [dec]; + let _classDescriptor; + let _classExtraInitializers = []; + let _classThis; var class_9 = class { + static { _classThis = this; } + static { __setFunctionName(_classThis, _b); } static { - __setFunctionName(this, _b); - __esDecorate(null, _classDescriptor_8 = { value: this }, _classDecorators_8, { kind: "class", name: this.name }, null, _classExtraInitializers_8); - class_9 = _classThis_8 = _classDescriptor_8.value; - __runInitializers(_classThis_8, _classExtraInitializers_8); + __esDecorate(null, _classDescriptor = { value: _classThis }, _classDecorators, { kind: "class", name: _classThis.name }, null, _classExtraInitializers); + class_9 = _classThis = _classDescriptor.value; + __runInitializers(_classThis, _classExtraInitializers); } }; - return class_9 = _classThis_8; + return class_9 = _classThis; })(); } } @@ -301,16 +310,16 @@ var _a, _b; { class C { static __proto__ = (() => { - let _instanceExtraInitializers_5 = []; + let _instanceExtraInitializers = []; let _y_decorators; let _y_initializers = []; return class { + static { __setFunctionName(this, "__proto__"); } static { - __setFunctionName(this, "__proto__"); _y_decorators = [dec]; - __esDecorate(null, null, _y_decorators, { kind: "field", name: "y", static: false, private: false, access: { has: obj => "y" in obj, get: obj => obj.y, set: (obj, value) => { obj.y = value; } } }, _y_initializers, _instanceExtraInitializers_5); + __esDecorate(null, null, _y_decorators, { kind: "field", name: "y", static: false, private: false, access: { has: obj => "y" in obj, get: obj => obj.y, set: (obj, value) => { obj.y = value; } } }, _y_initializers, _instanceExtraInitializers); } - y = (__runInitializers(this, _instanceExtraInitializers_5), __runInitializers(this, _y_initializers, void 0)); + y = (__runInitializers(this, _instanceExtraInitializers), __runInitializers(this, _y_initializers, void 0)); }; })(); } @@ -318,16 +327,16 @@ var _a, _b; { class C { static "__proto__" = (() => { - let _instanceExtraInitializers_6 = []; + let _instanceExtraInitializers = []; let _y_decorators; let _y_initializers = []; return class { + static { __setFunctionName(this, "__proto__"); } static { - __setFunctionName(this, "__proto__"); _y_decorators = [dec]; - __esDecorate(null, null, _y_decorators, { kind: "field", name: "y", static: false, private: false, access: { has: obj => "y" in obj, get: obj => obj.y, set: (obj, value) => { obj.y = value; } } }, _y_initializers, _instanceExtraInitializers_6); + __esDecorate(null, null, _y_decorators, { kind: "field", name: "y", static: false, private: false, access: { has: obj => "y" in obj, get: obj => obj.y, set: (obj, value) => { obj.y = value; } } }, _y_initializers, _instanceExtraInitializers); } - y = (__runInitializers(this, _instanceExtraInitializers_6), __runInitializers(this, _y_initializers, void 0)); + y = (__runInitializers(this, _instanceExtraInitializers), __runInitializers(this, _y_initializers, void 0)); }; })(); } @@ -345,19 +354,20 @@ var _a, _b; __runInitializers(this, _staticExtraInitializers); } static x = __runInitializers(this, _static_x_initializers, (() => { - let _classDecorators_9 = [dec]; - let _classDescriptor_9; - let _classExtraInitializers_9 = []; - let _classThis_9; + let _classDecorators = [dec]; + let _classDescriptor; + let _classExtraInitializers = []; + let _classThis; var class_10 = class { + static { _classThis = this; } + static { __setFunctionName(_classThis, "x"); } static { - __setFunctionName(this, "x"); - __esDecorate(null, _classDescriptor_9 = { value: this }, _classDecorators_9, { kind: "class", name: this.name }, null, _classExtraInitializers_9); - class_10 = _classThis_9 = _classDescriptor_9.value; - __runInitializers(_classThis_9, _classExtraInitializers_9); + __esDecorate(null, _classDescriptor = { value: _classThis }, _classDecorators, { kind: "class", name: _classThis.name }, null, _classExtraInitializers); + class_10 = _classThis = _classDescriptor.value; + __runInitializers(_classThis, _classExtraInitializers); } }; - return class_10 = _classThis_9; + return class_10 = _classThis; })()); }; })(); diff --git a/tests/baselines/reference/esDecorators-classExpression-namedEvaluation.11.js b/tests/baselines/reference/esDecorators-classExpression-namedEvaluation.11.js index 8244d9bb836cd..87f76af6919bc 100644 --- a/tests/baselines/reference/esDecorators-classExpression-namedEvaluation.11.js +++ b/tests/baselines/reference/esDecorators-classExpression-namedEvaluation.11.js @@ -22,9 +22,10 @@ declare let dec: any; let _classExtraInitializers = []; let _classThis; var class_1 = class { + static { _classThis = this; } + static { __setFunctionName(_classThis, ""); } static { - __setFunctionName(this, ""); - __esDecorate(null, _classDescriptor = { value: this }, _classDecorators, { kind: "class", name: this.name }, null, _classExtraInitializers); + __esDecorate(null, _classDescriptor = { value: _classThis }, _classDecorators, { kind: "class", name: _classThis.name }, null, _classExtraInitializers); class_1 = _classThis = _classDescriptor.value; __runInitializers(_classThis, _classExtraInitializers); } @@ -45,28 +46,29 @@ declare let dec: any; })()); // No NamedEvaluation, class name ((() => { - let _classDecorators_1 = [dec]; - let _classDescriptor_1; - let _classExtraInitializers_1 = []; - let _classThis_1; + let _classDecorators = [dec]; + let _classDescriptor; + let _classExtraInitializers = []; + let _classThis; var C = class { + static { _classThis = this; } static { - __esDecorate(null, _classDescriptor_1 = { value: this }, _classDecorators_1, { kind: "class", name: this.name }, null, _classExtraInitializers_1); - C = _classThis_1 = _classDescriptor_1.value; - __runInitializers(_classThis_1, _classExtraInitializers_1); + __esDecorate(null, _classDescriptor = { value: _classThis }, _classDecorators, { kind: "class", name: _classThis.name }, null, _classExtraInitializers); + C = _classThis = _classDescriptor.value; + __runInitializers(_classThis, _classExtraInitializers); } }; - return C = _classThis_1; + return C = _classThis; })()); ((() => { - let _instanceExtraInitializers_1 = []; + let _instanceExtraInitializers = []; let _y_decorators; let _y_initializers = []; return class C { static { _y_decorators = [dec]; - __esDecorate(null, null, _y_decorators, { kind: "field", name: "y", static: false, private: false, access: { has: obj => "y" in obj, get: obj => obj.y, set: (obj, value) => { obj.y = value; } } }, _y_initializers, _instanceExtraInitializers_1); + __esDecorate(null, null, _y_decorators, { kind: "field", name: "y", static: false, private: false, access: { has: obj => "y" in obj, get: obj => obj.y, set: (obj, value) => { obj.y = value; } } }, _y_initializers, _instanceExtraInitializers); } - y = (__runInitializers(this, _instanceExtraInitializers_1), __runInitializers(this, _y_initializers, void 0)); + y = (__runInitializers(this, _instanceExtraInitializers), __runInitializers(this, _y_initializers, void 0)); }; })()); diff --git a/tests/baselines/reference/esDecorators-classExpression-namedEvaluation.2.js b/tests/baselines/reference/esDecorators-classExpression-namedEvaluation.2.js index 3007f132e6efc..c698897e3bc98 100644 --- a/tests/baselines/reference/esDecorators-classExpression-namedEvaluation.2.js +++ b/tests/baselines/reference/esDecorators-classExpression-namedEvaluation.2.js @@ -44,9 +44,10 @@ let x, f; let _classExtraInitializers = []; let _classThis; var class_1 = class { + static { _classThis = this; } + static { __setFunctionName(_classThis, "x"); } static { - __setFunctionName(this, "x"); - __esDecorate(null, _classDescriptor = { value: this }, _classDecorators, { kind: "class", name: this.name }, null, _classExtraInitializers); + __esDecorate(null, _classDescriptor = { value: _classThis }, _classDecorators, { kind: "class", name: _classThis.name }, null, _classExtraInitializers); class_1 = _classThis = _classDescriptor.value; __runInitializers(_classThis, _classExtraInitializers); } @@ -58,8 +59,8 @@ let x, f; let _y_decorators; let _y_initializers = []; return class { + static { __setFunctionName(this, "x"); } static { - __setFunctionName(this, "x"); _y_decorators = [dec]; __esDecorate(null, null, _y_decorators, { kind: "field", name: "y", static: false, private: false, access: { has: obj => "y" in obj, get: obj => obj.y, set: (obj, value) => { obj.y = value; } } }, _y_initializers, _instanceExtraInitializers); } @@ -67,189 +68,197 @@ let x, f; }; })() }); ({ "x": (() => { - let _classDecorators_1 = [dec]; - let _classDescriptor_1; - let _classExtraInitializers_1 = []; - let _classThis_1; + let _classDecorators = [dec]; + let _classDescriptor; + let _classExtraInitializers = []; + let _classThis; var class_2 = class { + static { _classThis = this; } + static { __setFunctionName(_classThis, "x"); } static { - __setFunctionName(this, "x"); - __esDecorate(null, _classDescriptor_1 = { value: this }, _classDecorators_1, { kind: "class", name: this.name }, null, _classExtraInitializers_1); - class_2 = _classThis_1 = _classDescriptor_1.value; - __runInitializers(_classThis_1, _classExtraInitializers_1); + __esDecorate(null, _classDescriptor = { value: _classThis }, _classDecorators, { kind: "class", name: _classThis.name }, null, _classExtraInitializers); + class_2 = _classThis = _classDescriptor.value; + __runInitializers(_classThis, _classExtraInitializers); } }; - return class_2 = _classThis_1; + return class_2 = _classThis; })() }); ({ "x": (() => { - let _instanceExtraInitializers_1 = []; + let _instanceExtraInitializers = []; let _y_decorators; let _y_initializers = []; return class { + static { __setFunctionName(this, "x"); } static { - __setFunctionName(this, "x"); _y_decorators = [dec]; - __esDecorate(null, null, _y_decorators, { kind: "field", name: "y", static: false, private: false, access: { has: obj => "y" in obj, get: obj => obj.y, set: (obj, value) => { obj.y = value; } } }, _y_initializers, _instanceExtraInitializers_1); + __esDecorate(null, null, _y_decorators, { kind: "field", name: "y", static: false, private: false, access: { has: obj => "y" in obj, get: obj => obj.y, set: (obj, value) => { obj.y = value; } } }, _y_initializers, _instanceExtraInitializers); } - y = (__runInitializers(this, _instanceExtraInitializers_1), __runInitializers(this, _y_initializers, void 0)); + y = (__runInitializers(this, _instanceExtraInitializers), __runInitializers(this, _y_initializers, void 0)); }; })() }); ({ 0: (() => { - let _classDecorators_2 = [dec]; - let _classDescriptor_2; - let _classExtraInitializers_2 = []; - let _classThis_2; + let _classDecorators = [dec]; + let _classDescriptor; + let _classExtraInitializers = []; + let _classThis; var class_3 = class { + static { _classThis = this; } + static { __setFunctionName(_classThis, "0"); } static { - __setFunctionName(this, "0"); - __esDecorate(null, _classDescriptor_2 = { value: this }, _classDecorators_2, { kind: "class", name: this.name }, null, _classExtraInitializers_2); - class_3 = _classThis_2 = _classDescriptor_2.value; - __runInitializers(_classThis_2, _classExtraInitializers_2); + __esDecorate(null, _classDescriptor = { value: _classThis }, _classDecorators, { kind: "class", name: _classThis.name }, null, _classExtraInitializers); + class_3 = _classThis = _classDescriptor.value; + __runInitializers(_classThis, _classExtraInitializers); } }; - return class_3 = _classThis_2; + return class_3 = _classThis; })() }); ({ 0: (() => { - let _instanceExtraInitializers_2 = []; + let _instanceExtraInitializers = []; let _y_decorators; let _y_initializers = []; return class { + static { __setFunctionName(this, "0"); } static { - __setFunctionName(this, "0"); _y_decorators = [dec]; - __esDecorate(null, null, _y_decorators, { kind: "field", name: "y", static: false, private: false, access: { has: obj => "y" in obj, get: obj => obj.y, set: (obj, value) => { obj.y = value; } } }, _y_initializers, _instanceExtraInitializers_2); + __esDecorate(null, null, _y_decorators, { kind: "field", name: "y", static: false, private: false, access: { has: obj => "y" in obj, get: obj => obj.y, set: (obj, value) => { obj.y = value; } } }, _y_initializers, _instanceExtraInitializers); } - y = (__runInitializers(this, _instanceExtraInitializers_2), __runInitializers(this, _y_initializers, void 0)); + y = (__runInitializers(this, _instanceExtraInitializers), __runInitializers(this, _y_initializers, void 0)); }; })() }); ({ ["x"]: (() => { - let _classDecorators_3 = [dec]; - let _classDescriptor_3; - let _classExtraInitializers_3 = []; - let _classThis_3; + let _classDecorators = [dec]; + let _classDescriptor; + let _classExtraInitializers = []; + let _classThis; var class_4 = class { + static { _classThis = this; } + static { __setFunctionName(_classThis, "x"); } static { - __setFunctionName(this, "x"); - __esDecorate(null, _classDescriptor_3 = { value: this }, _classDecorators_3, { kind: "class", name: this.name }, null, _classExtraInitializers_3); - class_4 = _classThis_3 = _classDescriptor_3.value; - __runInitializers(_classThis_3, _classExtraInitializers_3); + __esDecorate(null, _classDescriptor = { value: _classThis }, _classDecorators, { kind: "class", name: _classThis.name }, null, _classExtraInitializers); + class_4 = _classThis = _classDescriptor.value; + __runInitializers(_classThis, _classExtraInitializers); } }; - return class_4 = _classThis_3; + return class_4 = _classThis; })() }); ({ ["x"]: (() => { - let _instanceExtraInitializers_3 = []; + let _instanceExtraInitializers = []; let _y_decorators; let _y_initializers = []; return class { + static { __setFunctionName(this, "x"); } static { - __setFunctionName(this, "x"); _y_decorators = [dec]; - __esDecorate(null, null, _y_decorators, { kind: "field", name: "y", static: false, private: false, access: { has: obj => "y" in obj, get: obj => obj.y, set: (obj, value) => { obj.y = value; } } }, _y_initializers, _instanceExtraInitializers_3); + __esDecorate(null, null, _y_decorators, { kind: "field", name: "y", static: false, private: false, access: { has: obj => "y" in obj, get: obj => obj.y, set: (obj, value) => { obj.y = value; } } }, _y_initializers, _instanceExtraInitializers); } - y = (__runInitializers(this, _instanceExtraInitializers_3), __runInitializers(this, _y_initializers, void 0)); + y = (__runInitializers(this, _instanceExtraInitializers), __runInitializers(this, _y_initializers, void 0)); }; })() }); ({ [0]: (() => { - let _classDecorators_4 = [dec]; - let _classDescriptor_4; - let _classExtraInitializers_4 = []; - let _classThis_4; + let _classDecorators = [dec]; + let _classDescriptor; + let _classExtraInitializers = []; + let _classThis; var class_5 = class { + static { _classThis = this; } + static { __setFunctionName(_classThis, "0"); } static { - __setFunctionName(this, "0"); - __esDecorate(null, _classDescriptor_4 = { value: this }, _classDecorators_4, { kind: "class", name: this.name }, null, _classExtraInitializers_4); - class_5 = _classThis_4 = _classDescriptor_4.value; - __runInitializers(_classThis_4, _classExtraInitializers_4); + __esDecorate(null, _classDescriptor = { value: _classThis }, _classDecorators, { kind: "class", name: _classThis.name }, null, _classExtraInitializers); + class_5 = _classThis = _classDescriptor.value; + __runInitializers(_classThis, _classExtraInitializers); } }; - return class_5 = _classThis_4; + return class_5 = _classThis; })() }); ({ [0]: (() => { - let _instanceExtraInitializers_4 = []; + let _instanceExtraInitializers = []; let _y_decorators; let _y_initializers = []; return class { + static { __setFunctionName(this, "0"); } static { - __setFunctionName(this, "0"); _y_decorators = [dec]; - __esDecorate(null, null, _y_decorators, { kind: "field", name: "y", static: false, private: false, access: { has: obj => "y" in obj, get: obj => obj.y, set: (obj, value) => { obj.y = value; } } }, _y_initializers, _instanceExtraInitializers_4); + __esDecorate(null, null, _y_decorators, { kind: "field", name: "y", static: false, private: false, access: { has: obj => "y" in obj, get: obj => obj.y, set: (obj, value) => { obj.y = value; } } }, _y_initializers, _instanceExtraInitializers); } - y = (__runInitializers(this, _instanceExtraInitializers_4), __runInitializers(this, _y_initializers, void 0)); + y = (__runInitializers(this, _instanceExtraInitializers), __runInitializers(this, _y_initializers, void 0)); }; })() }); ({ [_a = __propKey(f())]: (() => { - let _classDecorators_5 = [dec]; - let _classDescriptor_5; - let _classExtraInitializers_5 = []; - let _classThis_5; + let _classDecorators = [dec]; + let _classDescriptor; + let _classExtraInitializers = []; + let _classThis; var class_6 = class { + static { _classThis = this; } + static { __setFunctionName(_classThis, _a); } static { - __setFunctionName(this, _a); - __esDecorate(null, _classDescriptor_5 = { value: this }, _classDecorators_5, { kind: "class", name: this.name }, null, _classExtraInitializers_5); - class_6 = _classThis_5 = _classDescriptor_5.value; - __runInitializers(_classThis_5, _classExtraInitializers_5); + __esDecorate(null, _classDescriptor = { value: _classThis }, _classDecorators, { kind: "class", name: _classThis.name }, null, _classExtraInitializers); + class_6 = _classThis = _classDescriptor.value; + __runInitializers(_classThis, _classExtraInitializers); } }; - return class_6 = _classThis_5; + return class_6 = _classThis; })() }); ({ [_b = __propKey(f())]: (() => { - let _instanceExtraInitializers_5 = []; + let _instanceExtraInitializers = []; let _y_decorators; let _y_initializers = []; return class { + static { __setFunctionName(this, _b); } static { - __setFunctionName(this, _b); _y_decorators = [dec]; - __esDecorate(null, null, _y_decorators, { kind: "field", name: "y", static: false, private: false, access: { has: obj => "y" in obj, get: obj => obj.y, set: (obj, value) => { obj.y = value; } } }, _y_initializers, _instanceExtraInitializers_5); + __esDecorate(null, null, _y_decorators, { kind: "field", name: "y", static: false, private: false, access: { has: obj => "y" in obj, get: obj => obj.y, set: (obj, value) => { obj.y = value; } } }, _y_initializers, _instanceExtraInitializers); } - y = (__runInitializers(this, _instanceExtraInitializers_5), __runInitializers(this, _y_initializers, void 0)); + y = (__runInitializers(this, _instanceExtraInitializers), __runInitializers(this, _y_initializers, void 0)); }; })() }); // __proto__ setters do not perform NamedEvaluation ({ __proto__: (() => { - let _classDecorators_6 = [dec]; - let _classDescriptor_6; - let _classExtraInitializers_6 = []; - let _classThis_6; + let _classDecorators = [dec]; + let _classDescriptor; + let _classExtraInitializers = []; + let _classThis; var class_7 = class { + static { _classThis = this; } + static { __setFunctionName(_classThis, ""); } static { - __setFunctionName(this, ""); - __esDecorate(null, _classDescriptor_6 = { value: this }, _classDecorators_6, { kind: "class", name: this.name }, null, _classExtraInitializers_6); - class_7 = _classThis_6 = _classDescriptor_6.value; - __runInitializers(_classThis_6, _classExtraInitializers_6); + __esDecorate(null, _classDescriptor = { value: _classThis }, _classDecorators, { kind: "class", name: _classThis.name }, null, _classExtraInitializers); + class_7 = _classThis = _classDescriptor.value; + __runInitializers(_classThis, _classExtraInitializers); } }; - return class_7 = _classThis_6; + return class_7 = _classThis; })() }); ({ "__proto__": (() => { - let _classDecorators_7 = [dec]; - let _classDescriptor_7; - let _classExtraInitializers_7 = []; - let _classThis_7; + let _classDecorators = [dec]; + let _classDescriptor; + let _classExtraInitializers = []; + let _classThis; var class_8 = class { + static { _classThis = this; } + static { __setFunctionName(_classThis, ""); } static { - __setFunctionName(this, ""); - __esDecorate(null, _classDescriptor_7 = { value: this }, _classDecorators_7, { kind: "class", name: this.name }, null, _classExtraInitializers_7); - class_8 = _classThis_7 = _classDescriptor_7.value; - __runInitializers(_classThis_7, _classExtraInitializers_7); + __esDecorate(null, _classDescriptor = { value: _classThis }, _classDecorators, { kind: "class", name: _classThis.name }, null, _classExtraInitializers); + class_8 = _classThis = _classDescriptor.value; + __runInitializers(_classThis, _classExtraInitializers); } }; - return class_8 = _classThis_7; + return class_8 = _classThis; })() }); // "__proto__" in a computed property name *does* perform NamedEvaluation ({ ["__proto__"]: (() => { - let _classDecorators_8 = [dec]; - let _classDescriptor_8; - let _classExtraInitializers_8 = []; - let _classThis_8; + let _classDecorators = [dec]; + let _classDescriptor; + let _classExtraInitializers = []; + let _classThis; var class_9 = class { + static { _classThis = this; } + static { __setFunctionName(_classThis, "__proto__"); } static { - __setFunctionName(this, "__proto__"); - __esDecorate(null, _classDescriptor_8 = { value: this }, _classDecorators_8, { kind: "class", name: this.name }, null, _classExtraInitializers_8); - class_9 = _classThis_8 = _classDescriptor_8.value; - __runInitializers(_classThis_8, _classExtraInitializers_8); + __esDecorate(null, _classDescriptor = { value: _classThis }, _classDecorators, { kind: "class", name: _classThis.name }, null, _classExtraInitializers); + class_9 = _classThis = _classDescriptor.value; + __runInitializers(_classThis, _classExtraInitializers); } }; - return class_9 = _classThis_8; + return class_9 = _classThis; })() }); diff --git a/tests/baselines/reference/esDecorators-classExpression-namedEvaluation.3.js b/tests/baselines/reference/esDecorators-classExpression-namedEvaluation.3.js index 35ae75922d9b5..43402ed43e6bb 100644 --- a/tests/baselines/reference/esDecorators-classExpression-namedEvaluation.3.js +++ b/tests/baselines/reference/esDecorators-classExpression-namedEvaluation.3.js @@ -29,9 +29,10 @@ declare let dec: any; let _classExtraInitializers = []; let _classThis; var class_1 = class { + static { _classThis = this; } + static { __setFunctionName(_classThis, "x"); } static { - __setFunctionName(this, "x"); - __esDecorate(null, _classDescriptor = { value: this }, _classDecorators, { kind: "class", name: this.name }, null, _classExtraInitializers); + __esDecorate(null, _classDescriptor = { value: _classThis }, _classDecorators, { kind: "class", name: _classThis.name }, null, _classExtraInitializers); class_1 = _classThis = _classDescriptor.value; __runInitializers(_classThis, _classExtraInitializers); } @@ -45,8 +46,8 @@ declare let dec: any; let _y_decorators; let _y_initializers = []; return class { + static { __setFunctionName(this, "x"); } static { - __setFunctionName(this, "x"); _y_decorators = [dec]; __esDecorate(null, null, _y_decorators, { kind: "field", name: "y", static: false, private: false, access: { has: obj => "y" in obj, get: obj => obj.y, set: (obj, value) => { obj.y = value; } } }, _y_initializers, _instanceExtraInitializers); } @@ -56,33 +57,34 @@ declare let dec: any; } { const x = (() => { - let _classDecorators_1 = [dec]; - let _classDescriptor_1; - let _classExtraInitializers_1 = []; - let _classThis_1; + let _classDecorators = [dec]; + let _classDescriptor; + let _classExtraInitializers = []; + let _classThis; var class_2 = class { + static { _classThis = this; } + static { __setFunctionName(_classThis, "x"); } static { - __setFunctionName(this, "x"); - __esDecorate(null, _classDescriptor_1 = { value: this }, _classDecorators_1, { kind: "class", name: this.name }, null, _classExtraInitializers_1); - class_2 = _classThis_1 = _classDescriptor_1.value; - __runInitializers(_classThis_1, _classExtraInitializers_1); + __esDecorate(null, _classDescriptor = { value: _classThis }, _classDecorators, { kind: "class", name: _classThis.name }, null, _classExtraInitializers); + class_2 = _classThis = _classDescriptor.value; + __runInitializers(_classThis, _classExtraInitializers); } }; - return class_2 = _classThis_1; + return class_2 = _classThis; })(); } { const x = (() => { - let _instanceExtraInitializers_1 = []; + let _instanceExtraInitializers = []; let _y_decorators; let _y_initializers = []; return class { + static { __setFunctionName(this, "x"); } static { - __setFunctionName(this, "x"); _y_decorators = [dec]; - __esDecorate(null, null, _y_decorators, { kind: "field", name: "y", static: false, private: false, access: { has: obj => "y" in obj, get: obj => obj.y, set: (obj, value) => { obj.y = value; } } }, _y_initializers, _instanceExtraInitializers_1); + __esDecorate(null, null, _y_decorators, { kind: "field", name: "y", static: false, private: false, access: { has: obj => "y" in obj, get: obj => obj.y, set: (obj, value) => { obj.y = value; } } }, _y_initializers, _instanceExtraInitializers); } - y = (__runInitializers(this, _instanceExtraInitializers_1), __runInitializers(this, _y_initializers, void 0)); + y = (__runInitializers(this, _instanceExtraInitializers), __runInitializers(this, _y_initializers, void 0)); }; })(); } @@ -90,33 +92,34 @@ declare let dec: any; // VariableDeclaration : BindingIdentifier Initializer { var x2 = (() => { - let _classDecorators_2 = [dec]; - let _classDescriptor_2; - let _classExtraInitializers_2 = []; - let _classThis_2; + let _classDecorators = [dec]; + let _classDescriptor; + let _classExtraInitializers = []; + let _classThis; var class_3 = class { + static { _classThis = this; } + static { __setFunctionName(_classThis, "x2"); } static { - __setFunctionName(this, "x2"); - __esDecorate(null, _classDescriptor_2 = { value: this }, _classDecorators_2, { kind: "class", name: this.name }, null, _classExtraInitializers_2); - class_3 = _classThis_2 = _classDescriptor_2.value; - __runInitializers(_classThis_2, _classExtraInitializers_2); + __esDecorate(null, _classDescriptor = { value: _classThis }, _classDecorators, { kind: "class", name: _classThis.name }, null, _classExtraInitializers); + class_3 = _classThis = _classDescriptor.value; + __runInitializers(_classThis, _classExtraInitializers); } }; - return class_3 = _classThis_2; + return class_3 = _classThis; })(); } { var x1 = (() => { - let _instanceExtraInitializers_2 = []; + let _instanceExtraInitializers = []; let _y_decorators; let _y_initializers = []; return class { + static { __setFunctionName(this, "x1"); } static { - __setFunctionName(this, "x1"); _y_decorators = [dec]; - __esDecorate(null, null, _y_decorators, { kind: "field", name: "y", static: false, private: false, access: { has: obj => "y" in obj, get: obj => obj.y, set: (obj, value) => { obj.y = value; } } }, _y_initializers, _instanceExtraInitializers_2); + __esDecorate(null, null, _y_decorators, { kind: "field", name: "y", static: false, private: false, access: { has: obj => "y" in obj, get: obj => obj.y, set: (obj, value) => { obj.y = value; } } }, _y_initializers, _instanceExtraInitializers); } - y = (__runInitializers(this, _instanceExtraInitializers_2), __runInitializers(this, _y_initializers, void 0)); + y = (__runInitializers(this, _instanceExtraInitializers), __runInitializers(this, _y_initializers, void 0)); }; })(); } diff --git a/tests/baselines/reference/esDecorators-classExpression-namedEvaluation.4.js b/tests/baselines/reference/esDecorators-classExpression-namedEvaluation.4.js index f55622075d03b..17204f7827d6c 100644 --- a/tests/baselines/reference/esDecorators-classExpression-namedEvaluation.4.js +++ b/tests/baselines/reference/esDecorators-classExpression-namedEvaluation.4.js @@ -30,9 +30,10 @@ declare let dec: any, obj: any; let _classExtraInitializers = []; let _classThis; var class_1 = class { + static { _classThis = this; } + static { __setFunctionName(_classThis, "x"); } static { - __setFunctionName(this, "x"); - __esDecorate(null, _classDescriptor = { value: this }, _classDecorators, { kind: "class", name: this.name }, null, _classExtraInitializers); + __esDecorate(null, _classDescriptor = { value: _classThis }, _classDecorators, { kind: "class", name: _classThis.name }, null, _classExtraInitializers); class_1 = _classThis = _classDescriptor.value; __runInitializers(_classThis, _classExtraInitializers); } @@ -46,8 +47,8 @@ declare let dec: any, obj: any; let _y_decorators; let _y_initializers = []; return class { + static { __setFunctionName(this, "x"); } static { - __setFunctionName(this, "x"); _y_decorators = [dec]; __esDecorate(null, null, _y_decorators, { kind: "field", name: "y", static: false, private: false, access: { has: obj => "y" in obj, get: obj => obj.y, set: (obj, value) => { obj.y = value; } } }, _y_initializers, _instanceExtraInitializers); } @@ -59,65 +60,67 @@ declare let dec: any, obj: any; // SingleNameBinding : BindingIdentifier Initializer? { const { x = (() => { - let _classDecorators_1 = [dec]; - let _classDescriptor_1; - let _classExtraInitializers_1 = []; - let _classThis_1; + let _classDecorators = [dec]; + let _classDescriptor; + let _classExtraInitializers = []; + let _classThis; var class_2 = class { + static { _classThis = this; } + static { __setFunctionName(_classThis, "x"); } static { - __setFunctionName(this, "x"); - __esDecorate(null, _classDescriptor_1 = { value: this }, _classDecorators_1, { kind: "class", name: this.name }, null, _classExtraInitializers_1); - class_2 = _classThis_1 = _classDescriptor_1.value; - __runInitializers(_classThis_1, _classExtraInitializers_1); + __esDecorate(null, _classDescriptor = { value: _classThis }, _classDecorators, { kind: "class", name: _classThis.name }, null, _classExtraInitializers); + class_2 = _classThis = _classDescriptor.value; + __runInitializers(_classThis, _classExtraInitializers); } }; - return class_2 = _classThis_1; + return class_2 = _classThis; })() } = obj; } { const { x = (() => { - let _instanceExtraInitializers_1 = []; + let _instanceExtraInitializers = []; let _y_decorators; let _y_initializers = []; return class { + static { __setFunctionName(this, "x"); } static { - __setFunctionName(this, "x"); _y_decorators = [dec]; - __esDecorate(null, null, _y_decorators, { kind: "field", name: "y", static: false, private: false, access: { has: obj => "y" in obj, get: obj => obj.y, set: (obj, value) => { obj.y = value; } } }, _y_initializers, _instanceExtraInitializers_1); + __esDecorate(null, null, _y_decorators, { kind: "field", name: "y", static: false, private: false, access: { has: obj => "y" in obj, get: obj => obj.y, set: (obj, value) => { obj.y = value; } } }, _y_initializers, _instanceExtraInitializers); } - y = (__runInitializers(this, _instanceExtraInitializers_1), __runInitializers(this, _y_initializers, void 0)); + y = (__runInitializers(this, _instanceExtraInitializers), __runInitializers(this, _y_initializers, void 0)); }; })() } = obj; } { const { y: x = (() => { - let _classDecorators_2 = [dec]; - let _classDescriptor_2; - let _classExtraInitializers_2 = []; - let _classThis_2; + let _classDecorators = [dec]; + let _classDescriptor; + let _classExtraInitializers = []; + let _classThis; var class_3 = class { + static { _classThis = this; } + static { __setFunctionName(_classThis, "x"); } static { - __setFunctionName(this, "x"); - __esDecorate(null, _classDescriptor_2 = { value: this }, _classDecorators_2, { kind: "class", name: this.name }, null, _classExtraInitializers_2); - class_3 = _classThis_2 = _classDescriptor_2.value; - __runInitializers(_classThis_2, _classExtraInitializers_2); + __esDecorate(null, _classDescriptor = { value: _classThis }, _classDecorators, { kind: "class", name: _classThis.name }, null, _classExtraInitializers); + class_3 = _classThis = _classDescriptor.value; + __runInitializers(_classThis, _classExtraInitializers); } }; - return class_3 = _classThis_2; + return class_3 = _classThis; })() } = obj; } { const { y: x = (() => { - let _instanceExtraInitializers_2 = []; + let _instanceExtraInitializers = []; let _y_decorators; let _y_initializers = []; return class { + static { __setFunctionName(this, "x"); } static { - __setFunctionName(this, "x"); _y_decorators = [dec]; - __esDecorate(null, null, _y_decorators, { kind: "field", name: "y", static: false, private: false, access: { has: obj => "y" in obj, get: obj => obj.y, set: (obj, value) => { obj.y = value; } } }, _y_initializers, _instanceExtraInitializers_2); + __esDecorate(null, null, _y_decorators, { kind: "field", name: "y", static: false, private: false, access: { has: obj => "y" in obj, get: obj => obj.y, set: (obj, value) => { obj.y = value; } } }, _y_initializers, _instanceExtraInitializers); } - y = (__runInitializers(this, _instanceExtraInitializers_2), __runInitializers(this, _y_initializers, void 0)); + y = (__runInitializers(this, _instanceExtraInitializers), __runInitializers(this, _y_initializers, void 0)); }; })() } = obj; } diff --git a/tests/baselines/reference/esDecorators-classExpression-namedEvaluation.5.js b/tests/baselines/reference/esDecorators-classExpression-namedEvaluation.5.js index b36091aebe25c..e024e3a08ddb9 100644 --- a/tests/baselines/reference/esDecorators-classExpression-namedEvaluation.5.js +++ b/tests/baselines/reference/esDecorators-classExpression-namedEvaluation.5.js @@ -19,9 +19,10 @@ declare let dec: any, obj: any, x: any; let _classExtraInitializers = []; let _classThis; var class_1 = class { + static { _classThis = this; } + static { __setFunctionName(_classThis, "x"); } static { - __setFunctionName(this, "x"); - __esDecorate(null, _classDescriptor = { value: this }, _classDecorators, { kind: "class", name: this.name }, null, _classExtraInitializers); + __esDecorate(null, _classDescriptor = { value: _classThis }, _classDecorators, { kind: "class", name: _classThis.name }, null, _classExtraInitializers); class_1 = _classThis = _classDescriptor.value; __runInitializers(_classThis, _classExtraInitializers); } @@ -33,8 +34,8 @@ declare let dec: any, obj: any, x: any; let _y_decorators; let _y_initializers = []; return class { + static { __setFunctionName(this, "x"); } static { - __setFunctionName(this, "x"); _y_decorators = [dec]; __esDecorate(null, null, _y_decorators, { kind: "field", name: "y", static: false, private: false, access: { has: obj => "y" in obj, get: obj => obj.y, set: (obj, value) => { obj.y = value; } } }, _y_initializers, _instanceExtraInitializers); } diff --git a/tests/baselines/reference/esDecorators-classExpression-namedEvaluation.6.js b/tests/baselines/reference/esDecorators-classExpression-namedEvaluation.6.js index c345b7badcee3..e5f81d3396c89 100644 --- a/tests/baselines/reference/esDecorators-classExpression-namedEvaluation.6.js +++ b/tests/baselines/reference/esDecorators-classExpression-namedEvaluation.6.js @@ -19,9 +19,10 @@ declare let dec: any, obj: any, x: any; let _classExtraInitializers = []; let _classThis; var class_1 = class { + static { _classThis = this; } + static { __setFunctionName(_classThis, "x"); } static { - __setFunctionName(this, "x"); - __esDecorate(null, _classDescriptor = { value: this }, _classDecorators, { kind: "class", name: this.name }, null, _classExtraInitializers); + __esDecorate(null, _classDescriptor = { value: _classThis }, _classDecorators, { kind: "class", name: _classThis.name }, null, _classExtraInitializers); class_1 = _classThis = _classDescriptor.value; __runInitializers(_classThis, _classExtraInitializers); } @@ -33,8 +34,8 @@ declare let dec: any, obj: any, x: any; let _y_decorators; let _y_initializers = []; return class { + static { __setFunctionName(this, "x"); } static { - __setFunctionName(this, "x"); _y_decorators = [dec]; __esDecorate(null, null, _y_decorators, { kind: "field", name: "y", static: false, private: false, access: { has: obj => "y" in obj, get: obj => obj.y, set: (obj, value) => { obj.y = value; } } }, _y_initializers, _instanceExtraInitializers); } diff --git a/tests/baselines/reference/esDecorators-classExpression-namedEvaluation.7.js b/tests/baselines/reference/esDecorators-classExpression-namedEvaluation.7.js index de766d9a1d996..86f3a72966a5a 100644 --- a/tests/baselines/reference/esDecorators-classExpression-namedEvaluation.7.js +++ b/tests/baselines/reference/esDecorators-classExpression-namedEvaluation.7.js @@ -19,9 +19,10 @@ declare let dec: any, obj: any, x: any; let _classExtraInitializers = []; let _classThis; var class_1 = class { + static { _classThis = this; } + static { __setFunctionName(_classThis, "x"); } static { - __setFunctionName(this, "x"); - __esDecorate(null, _classDescriptor = { value: this }, _classDecorators, { kind: "class", name: this.name }, null, _classExtraInitializers); + __esDecorate(null, _classDescriptor = { value: _classThis }, _classDecorators, { kind: "class", name: _classThis.name }, null, _classExtraInitializers); class_1 = _classThis = _classDescriptor.value; __runInitializers(_classThis, _classExtraInitializers); } @@ -33,8 +34,8 @@ declare let dec: any, obj: any, x: any; let _y_decorators; let _y_initializers = []; return class { + static { __setFunctionName(this, "x"); } static { - __setFunctionName(this, "x"); _y_decorators = [dec]; __esDecorate(null, null, _y_decorators, { kind: "field", name: "y", static: false, private: false, access: { has: obj => "y" in obj, get: obj => obj.y, set: (obj, value) => { obj.y = value; } } }, _y_initializers, _instanceExtraInitializers); } diff --git a/tests/baselines/reference/esDecorators-classExpression-namedEvaluation.8.js b/tests/baselines/reference/esDecorators-classExpression-namedEvaluation.8.js index 8f2a6b536ff2e..6a40353123f48 100644 --- a/tests/baselines/reference/esDecorators-classExpression-namedEvaluation.8.js +++ b/tests/baselines/reference/esDecorators-classExpression-namedEvaluation.8.js @@ -25,9 +25,10 @@ export default ((() => { let _classExtraInitializers = []; let _classThis; var class_1 = class { + static { _classThis = this; } + static { __setFunctionName(_classThis, "default"); } static { - __setFunctionName(this, "default"); - __esDecorate(null, _classDescriptor = { value: this }, _classDecorators, { kind: "class", name: this.name }, null, _classExtraInitializers); + __esDecorate(null, _classDescriptor = { value: _classThis }, _classDecorators, { kind: "class", name: _classThis.name }, null, _classExtraInitializers); class_1 = _classThis = _classDescriptor.value; __runInitializers(_classThis, _classExtraInitializers); } @@ -42,8 +43,8 @@ export default ((() => { let _y_decorators; let _y_initializers = []; return class { + static { __setFunctionName(this, "default"); } static { - __setFunctionName(this, "default"); _y_decorators = [dec]; __esDecorate(null, null, _y_decorators, { kind: "field", name: "y", static: false, private: false, access: { has: obj => "y" in obj, get: obj => obj.y, set: (obj, value) => { obj.y = value; } } }, _y_initializers, _instanceExtraInitializers); } diff --git a/tests/baselines/reference/esDecorators-classExpression-namedEvaluation.9.js b/tests/baselines/reference/esDecorators-classExpression-namedEvaluation.9.js index 166c601801c7d..30507680ebc5c 100644 --- a/tests/baselines/reference/esDecorators-classExpression-namedEvaluation.9.js +++ b/tests/baselines/reference/esDecorators-classExpression-namedEvaluation.9.js @@ -18,9 +18,10 @@ module.exports = (() => { let _classExtraInitializers = []; let _classThis; var class_1 = class { + static { _classThis = this; } + static { __setFunctionName(_classThis, ""); } static { - __setFunctionName(this, ""); - __esDecorate(null, _classDescriptor = { value: this }, _classDecorators, { kind: "class", name: this.name }, null, _classExtraInitializers); + __esDecorate(null, _classDescriptor = { value: _classThis }, _classDecorators, { kind: "class", name: _classThis.name }, null, _classExtraInitializers); class_1 = _classThis = _classDescriptor.value; __runInitializers(_classThis, _classExtraInitializers); } diff --git a/tests/baselines/reference/esDecorators-emitDecoratorMetadata(target=es2015).js b/tests/baselines/reference/esDecorators-emitDecoratorMetadata(target=es2015).js index cc1200fad22b6..3f4948ba22ca6 100644 --- a/tests/baselines/reference/esDecorators-emitDecoratorMetadata(target=es2015).js +++ b/tests/baselines/reference/esDecorators-emitDecoratorMetadata(target=es2015).js @@ -98,12 +98,12 @@ let C = (() => { return C = _classThis; })(); ((() => { - let _classDecorators_1 = [dec]; - let _classDescriptor_1; - let _classExtraInitializers_1 = []; - let _classThis_1; - let _staticExtraInitializers_1 = []; - let _instanceExtraInitializers_1 = []; + let _classDecorators = [dec]; + let _classDescriptor; + let _classExtraInitializers = []; + let _classThis; + let _staticExtraInitializers = []; + let _instanceExtraInitializers = []; let _static_method_decorators; let _static_set_x_decorators; let _static_y_decorators; @@ -112,16 +112,16 @@ let C = (() => { let _set_x_decorators; let _y_decorators; let _y_initializers = []; - var C = (_classThis_1 = class { + var C = (_classThis = class { constructor(x) { - this.y = (__runInitializers(this, _instanceExtraInitializers_1), __runInitializers(this, _y_initializers, void 0)); + this.y = (__runInitializers(this, _instanceExtraInitializers), __runInitializers(this, _y_initializers, void 0)); } method(x) { } set x(x) { } static method(x) { } static set x(x) { } }, - __setFunctionName(_classThis_1, "C"), + __setFunctionName(_classThis, "C"), (() => { _method_decorators = [dec]; _set_x_decorators = [dec]; @@ -129,20 +129,20 @@ let C = (() => { _static_method_decorators = [dec]; _static_set_x_decorators = [dec]; _static_y_decorators = [dec]; - __esDecorate(_classThis_1, null, _static_method_decorators, { kind: "method", name: "method", static: true, private: false, access: { has: obj => "method" in obj, get: obj => obj.method } }, null, _staticExtraInitializers_1); - __esDecorate(_classThis_1, null, _static_set_x_decorators, { kind: "setter", name: "x", static: true, private: false, access: { has: obj => "x" in obj, set: (obj, value) => { obj.x = value; } } }, null, _staticExtraInitializers_1); - __esDecorate(_classThis_1, null, _method_decorators, { kind: "method", name: "method", static: false, private: false, access: { has: obj => "method" in obj, get: obj => obj.method } }, null, _instanceExtraInitializers_1); - __esDecorate(_classThis_1, null, _set_x_decorators, { kind: "setter", name: "x", static: false, private: false, access: { has: obj => "x" in obj, set: (obj, value) => { obj.x = value; } } }, null, _instanceExtraInitializers_1); - __esDecorate(null, null, _static_y_decorators, { kind: "field", name: "y", static: true, private: false, access: { has: obj => "y" in obj, get: obj => obj.y, set: (obj, value) => { obj.y = value; } } }, _static_y_initializers, _staticExtraInitializers_1); - __esDecorate(null, null, _y_decorators, { kind: "field", name: "y", static: false, private: false, access: { has: obj => "y" in obj, get: obj => obj.y, set: (obj, value) => { obj.y = value; } } }, _y_initializers, _instanceExtraInitializers_1); - __esDecorate(null, _classDescriptor_1 = { value: _classThis_1 }, _classDecorators_1, { kind: "class", name: _classThis_1.name }, null, _classExtraInitializers_1); - C = _classThis_1 = _classDescriptor_1.value; - __runInitializers(_classThis_1, _staticExtraInitializers_1); + __esDecorate(_classThis, null, _static_method_decorators, { kind: "method", name: "method", static: true, private: false, access: { has: obj => "method" in obj, get: obj => obj.method } }, null, _staticExtraInitializers); + __esDecorate(_classThis, null, _static_set_x_decorators, { kind: "setter", name: "x", static: true, private: false, access: { has: obj => "x" in obj, set: (obj, value) => { obj.x = value; } } }, null, _staticExtraInitializers); + __esDecorate(_classThis, null, _method_decorators, { kind: "method", name: "method", static: false, private: false, access: { has: obj => "method" in obj, get: obj => obj.method } }, null, _instanceExtraInitializers); + __esDecorate(_classThis, null, _set_x_decorators, { kind: "setter", name: "x", static: false, private: false, access: { has: obj => "x" in obj, set: (obj, value) => { obj.x = value; } } }, null, _instanceExtraInitializers); + __esDecorate(null, null, _static_y_decorators, { kind: "field", name: "y", static: true, private: false, access: { has: obj => "y" in obj, get: obj => obj.y, set: (obj, value) => { obj.y = value; } } }, _static_y_initializers, _staticExtraInitializers); + __esDecorate(null, null, _y_decorators, { kind: "field", name: "y", static: false, private: false, access: { has: obj => "y" in obj, get: obj => obj.y, set: (obj, value) => { obj.y = value; } } }, _y_initializers, _instanceExtraInitializers); + __esDecorate(null, _classDescriptor = { value: _classThis }, _classDecorators, { kind: "class", name: _classThis.name }, null, _classExtraInitializers); + C = _classThis = _classDescriptor.value; + __runInitializers(_classThis, _staticExtraInitializers); })(), - _classThis_1.y = __runInitializers(_classThis_1, _static_y_initializers, void 0), + _classThis.y = __runInitializers(_classThis, _static_y_initializers, void 0), (() => { - __runInitializers(_classThis_1, _classExtraInitializers_1); + __runInitializers(_classThis, _classExtraInitializers); })(), - _classThis_1); - return C = _classThis_1; + _classThis); + return C = _classThis; })()); diff --git a/tests/baselines/reference/esDecorators-emitDecoratorMetadata(target=es2022).js b/tests/baselines/reference/esDecorators-emitDecoratorMetadata(target=es2022).js index fec2864b5b771..5cb50c2cba733 100644 --- a/tests/baselines/reference/esDecorators-emitDecoratorMetadata(target=es2022).js +++ b/tests/baselines/reference/esDecorators-emitDecoratorMetadata(target=es2022).js @@ -65,6 +65,7 @@ let C = (() => { let _y_decorators; let _y_initializers = []; var C = class { + static { _classThis = this; } static { _method_decorators = [dec]; _set_x_decorators = [dec]; @@ -78,7 +79,7 @@ let C = (() => { __esDecorate(this, null, _set_x_decorators, { kind: "setter", name: "x", static: false, private: false, access: { has: obj => "x" in obj, set: (obj, value) => { obj.x = value; } } }, null, _instanceExtraInitializers); __esDecorate(null, null, _static_y_decorators, { kind: "field", name: "y", static: true, private: false, access: { has: obj => "y" in obj, get: obj => obj.y, set: (obj, value) => { obj.y = value; } } }, _static_y_initializers, _staticExtraInitializers); __esDecorate(null, null, _y_decorators, { kind: "field", name: "y", static: false, private: false, access: { has: obj => "y" in obj, get: obj => obj.y, set: (obj, value) => { obj.y = value; } } }, _y_initializers, _instanceExtraInitializers); - __esDecorate(null, _classDescriptor = { value: this }, _classDecorators, { kind: "class", name: this.name }, null, _classExtraInitializers); + __esDecorate(null, _classDescriptor = { value: _classThis }, _classDecorators, { kind: "class", name: _classThis.name }, null, _classExtraInitializers); C = _classThis = _classDescriptor.value; __runInitializers(_classThis, _staticExtraInitializers); } @@ -96,12 +97,12 @@ let C = (() => { return C = _classThis; })(); ((() => { - let _classDecorators_1 = [dec]; - let _classDescriptor_1; - let _classExtraInitializers_1 = []; - let _classThis_1; - let _staticExtraInitializers_1 = []; - let _instanceExtraInitializers_1 = []; + let _classDecorators = [dec]; + let _classDescriptor; + let _classExtraInitializers = []; + let _classThis; + let _staticExtraInitializers = []; + let _instanceExtraInitializers = []; let _static_method_decorators; let _static_set_x_decorators; let _static_y_decorators; @@ -111,6 +112,7 @@ let C = (() => { let _y_decorators; let _y_initializers = []; var C = class { + static { _classThis = this; } static { _method_decorators = [dec]; _set_x_decorators = [dec]; @@ -118,26 +120,26 @@ let C = (() => { _static_method_decorators = [dec]; _static_set_x_decorators = [dec]; _static_y_decorators = [dec]; - __esDecorate(this, null, _static_method_decorators, { kind: "method", name: "method", static: true, private: false, access: { has: obj => "method" in obj, get: obj => obj.method } }, null, _staticExtraInitializers_1); - __esDecorate(this, null, _static_set_x_decorators, { kind: "setter", name: "x", static: true, private: false, access: { has: obj => "x" in obj, set: (obj, value) => { obj.x = value; } } }, null, _staticExtraInitializers_1); - __esDecorate(this, null, _method_decorators, { kind: "method", name: "method", static: false, private: false, access: { has: obj => "method" in obj, get: obj => obj.method } }, null, _instanceExtraInitializers_1); - __esDecorate(this, null, _set_x_decorators, { kind: "setter", name: "x", static: false, private: false, access: { has: obj => "x" in obj, set: (obj, value) => { obj.x = value; } } }, null, _instanceExtraInitializers_1); - __esDecorate(null, null, _static_y_decorators, { kind: "field", name: "y", static: true, private: false, access: { has: obj => "y" in obj, get: obj => obj.y, set: (obj, value) => { obj.y = value; } } }, _static_y_initializers, _staticExtraInitializers_1); - __esDecorate(null, null, _y_decorators, { kind: "field", name: "y", static: false, private: false, access: { has: obj => "y" in obj, get: obj => obj.y, set: (obj, value) => { obj.y = value; } } }, _y_initializers, _instanceExtraInitializers_1); - __esDecorate(null, _classDescriptor_1 = { value: this }, _classDecorators_1, { kind: "class", name: this.name }, null, _classExtraInitializers_1); - C = _classThis_1 = _classDescriptor_1.value; - __runInitializers(_classThis_1, _staticExtraInitializers_1); + __esDecorate(this, null, _static_method_decorators, { kind: "method", name: "method", static: true, private: false, access: { has: obj => "method" in obj, get: obj => obj.method } }, null, _staticExtraInitializers); + __esDecorate(this, null, _static_set_x_decorators, { kind: "setter", name: "x", static: true, private: false, access: { has: obj => "x" in obj, set: (obj, value) => { obj.x = value; } } }, null, _staticExtraInitializers); + __esDecorate(this, null, _method_decorators, { kind: "method", name: "method", static: false, private: false, access: { has: obj => "method" in obj, get: obj => obj.method } }, null, _instanceExtraInitializers); + __esDecorate(this, null, _set_x_decorators, { kind: "setter", name: "x", static: false, private: false, access: { has: obj => "x" in obj, set: (obj, value) => { obj.x = value; } } }, null, _instanceExtraInitializers); + __esDecorate(null, null, _static_y_decorators, { kind: "field", name: "y", static: true, private: false, access: { has: obj => "y" in obj, get: obj => obj.y, set: (obj, value) => { obj.y = value; } } }, _static_y_initializers, _staticExtraInitializers); + __esDecorate(null, null, _y_decorators, { kind: "field", name: "y", static: false, private: false, access: { has: obj => "y" in obj, get: obj => obj.y, set: (obj, value) => { obj.y = value; } } }, _y_initializers, _instanceExtraInitializers); + __esDecorate(null, _classDescriptor = { value: _classThis }, _classDecorators, { kind: "class", name: _classThis.name }, null, _classExtraInitializers); + C = _classThis = _classDescriptor.value; + __runInitializers(_classThis, _staticExtraInitializers); } constructor(x) { } method(x) { } set x(x) { } - y = (__runInitializers(this, _instanceExtraInitializers_1), __runInitializers(this, _y_initializers, void 0)); + y = (__runInitializers(this, _instanceExtraInitializers), __runInitializers(this, _y_initializers, void 0)); static method(x) { } static set x(x) { } - static y = __runInitializers(_classThis_1, _static_y_initializers, void 0); + static y = __runInitializers(_classThis, _static_y_initializers, void 0); static { - __runInitializers(_classThis_1, _classExtraInitializers_1); + __runInitializers(_classThis, _classExtraInitializers); } }; - return C = _classThis_1; + return C = _classThis; })()); diff --git a/tests/baselines/reference/esDecorators-emitDecoratorMetadata(target=es5).js b/tests/baselines/reference/esDecorators-emitDecoratorMetadata(target=es5).js index 7ee7ed280e21a..9402cc94d1de2 100644 --- a/tests/baselines/reference/esDecorators-emitDecoratorMetadata(target=es5).js +++ b/tests/baselines/reference/esDecorators-emitDecoratorMetadata(target=es5).js @@ -49,7 +49,6 @@ class C { }); //// [esDecorators-emitDecoratorMetadata.js] -var _this = this; var C = function () { var _classDecorators = [dec]; var _classDescriptor; @@ -108,12 +107,12 @@ var C = function () { return C = _classThis; }(); ((function () { - var _classDecorators_1 = [dec]; - var _classDescriptor_1; - var _classExtraInitializers_1 = []; - var _classThis_1; - var _staticExtraInitializers_1 = []; - var _instanceExtraInitializers_1 = []; + var _classDecorators = [dec]; + var _classDescriptor; + var _classExtraInitializers = []; + var _classThis; + var _staticExtraInitializers = []; + var _instanceExtraInitializers = []; var _static_method_decorators; var _static_set_x_decorators; var _static_y_decorators; @@ -122,9 +121,9 @@ var C = function () { var _set_x_decorators; var _y_decorators; var _y_initializers = []; - var C = (_classThis_1 = /** @class */ (function () { + var C = (_classThis = /** @class */ (function () { function class_1(x) { - this.y = (__runInitializers(this, _instanceExtraInitializers_1), __runInitializers(this, _y_initializers, void 0)); + this.y = (__runInitializers(this, _instanceExtraInitializers), __runInitializers(this, _y_initializers, void 0)); } class_1.prototype.method = function (x) { }; Object.defineProperty(class_1.prototype, "x", { @@ -140,7 +139,7 @@ var C = function () { }); return class_1; }()), - __setFunctionName(_classThis_1, "C"), + __setFunctionName(_classThis, "C"), (function () { _method_decorators = [dec]; _set_x_decorators = [dec]; @@ -148,20 +147,20 @@ var C = function () { _static_method_decorators = [dec]; _static_set_x_decorators = [dec]; _static_y_decorators = [dec]; - __esDecorate(_classThis_1, null, _static_method_decorators, { kind: "method", name: "method", static: true, private: false, access: { has: function (obj) { return "method" in obj; }, get: function (obj) { return obj.method; } } }, null, _staticExtraInitializers_1); - __esDecorate(_classThis_1, null, _static_set_x_decorators, { kind: "setter", name: "x", static: true, private: false, access: { has: function (obj) { return "x" in obj; }, set: function (obj, value) { obj.x = value; } } }, null, _staticExtraInitializers_1); - __esDecorate(_classThis_1, null, _method_decorators, { kind: "method", name: "method", static: false, private: false, access: { has: function (obj) { return "method" in obj; }, get: function (obj) { return obj.method; } } }, null, _instanceExtraInitializers_1); - __esDecorate(_classThis_1, null, _set_x_decorators, { kind: "setter", name: "x", static: false, private: false, access: { has: function (obj) { return "x" in obj; }, set: function (obj, value) { obj.x = value; } } }, null, _instanceExtraInitializers_1); - __esDecorate(null, null, _static_y_decorators, { kind: "field", name: "y", static: true, private: false, access: { has: function (obj) { return "y" in obj; }, get: function (obj) { return obj.y; }, set: function (obj, value) { obj.y = value; } } }, _static_y_initializers, _staticExtraInitializers_1); - __esDecorate(null, null, _y_decorators, { kind: "field", name: "y", static: false, private: false, access: { has: function (obj) { return "y" in obj; }, get: function (obj) { return obj.y; }, set: function (obj, value) { obj.y = value; } } }, _y_initializers, _instanceExtraInitializers_1); - __esDecorate(null, _classDescriptor_1 = { value: _classThis_1 }, _classDecorators_1, { kind: "class", name: _classThis_1.name }, null, _classExtraInitializers_1); - C = _classThis_1 = _classDescriptor_1.value; - __runInitializers(_classThis_1, _staticExtraInitializers_1); + __esDecorate(_classThis, null, _static_method_decorators, { kind: "method", name: "method", static: true, private: false, access: { has: function (obj) { return "method" in obj; }, get: function (obj) { return obj.method; } } }, null, _staticExtraInitializers); + __esDecorate(_classThis, null, _static_set_x_decorators, { kind: "setter", name: "x", static: true, private: false, access: { has: function (obj) { return "x" in obj; }, set: function (obj, value) { obj.x = value; } } }, null, _staticExtraInitializers); + __esDecorate(_classThis, null, _method_decorators, { kind: "method", name: "method", static: false, private: false, access: { has: function (obj) { return "method" in obj; }, get: function (obj) { return obj.method; } } }, null, _instanceExtraInitializers); + __esDecorate(_classThis, null, _set_x_decorators, { kind: "setter", name: "x", static: false, private: false, access: { has: function (obj) { return "x" in obj; }, set: function (obj, value) { obj.x = value; } } }, null, _instanceExtraInitializers); + __esDecorate(null, null, _static_y_decorators, { kind: "field", name: "y", static: true, private: false, access: { has: function (obj) { return "y" in obj; }, get: function (obj) { return obj.y; }, set: function (obj, value) { obj.y = value; } } }, _static_y_initializers, _staticExtraInitializers); + __esDecorate(null, null, _y_decorators, { kind: "field", name: "y", static: false, private: false, access: { has: function (obj) { return "y" in obj; }, get: function (obj) { return obj.y; }, set: function (obj, value) { obj.y = value; } } }, _y_initializers, _instanceExtraInitializers); + __esDecorate(null, _classDescriptor = { value: _classThis }, _classDecorators, { kind: "class", name: _classThis.name }, null, _classExtraInitializers); + C = _classThis = _classDescriptor.value; + __runInitializers(_classThis, _staticExtraInitializers); })(), - _classThis_1.y = __runInitializers(_classThis_1, _static_y_initializers, void 0), + _classThis.y = __runInitializers(_classThis, _static_y_initializers, void 0), (function () { - __runInitializers(_classThis_1, _classExtraInitializers_1); + __runInitializers(_classThis, _classExtraInitializers); })(), - _classThis_1); - return C = _classThis_1; + _classThis); + return C = _classThis; })()); diff --git a/tests/baselines/reference/esnextmodulekindWithES5Target.js b/tests/baselines/reference/esnextmodulekindWithES5Target.js index 6ef97503cd2df..21d0ceb3ae39e 100644 --- a/tests/baselines/reference/esnextmodulekindWithES5Target.js +++ b/tests/baselines/reference/esnextmodulekindWithES5Target.js @@ -28,7 +28,7 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key, else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; return c > 3 && r && Object.defineProperty(target, key, r), r; }; -export var C = /** @class */ (function () { +var C = /** @class */ (function () { function C() { this.p = 1; } @@ -36,8 +36,9 @@ export var C = /** @class */ (function () { C.s = 0; return C; }()); +export { C }; export { C as C2 }; -export var D = /** @class */ (function () { +var D = /** @class */ (function () { function D() { this.p = 1; } @@ -48,6 +49,7 @@ export var D = /** @class */ (function () { ], D); return D; }()); +export { D }; export { D as D2 }; var E = /** @class */ (function () { function E() { diff --git a/tests/baselines/reference/for-of-excess-declarations.errors.txt b/tests/baselines/reference/for-of-excess-declarations.errors.txt new file mode 100644 index 0000000000000..516dfb68ce90b --- /dev/null +++ b/tests/baselines/reference/for-of-excess-declarations.errors.txt @@ -0,0 +1,15 @@ +for-of-excess-declarations.ts(1,15): error TS1188: Only a single variable declaration is allowed in a 'for...of' statement. +for-of-excess-declarations.ts(1,18): error TS2304: Cannot find name 'b'. +for-of-excess-declarations.ts(1,18): error TS2538: Type 'any' cannot be used as an index type. + + +==== for-of-excess-declarations.ts (3 errors) ==== + for (const a, { [b]: c} of [1]) { + ~ +!!! error TS1188: Only a single variable declaration is allowed in a 'for...of' statement. + ~ +!!! error TS2304: Cannot find name 'b'. + ~ +!!! error TS2538: Type 'any' cannot be used as an index type. + + } \ No newline at end of file diff --git a/tests/baselines/reference/for-of-excess-declarations.js b/tests/baselines/reference/for-of-excess-declarations.js new file mode 100644 index 0000000000000..84783caa013aa --- /dev/null +++ b/tests/baselines/reference/for-of-excess-declarations.js @@ -0,0 +1,10 @@ +//// [tests/cases/conformance/es6/for-ofStatements/for-of-excess-declarations.ts] //// + +//// [for-of-excess-declarations.ts] +for (const a, { [b]: c} of [1]) { + +} + +//// [for-of-excess-declarations.js] +for (const a, { [b]: c } of [1]) { +} diff --git a/tests/baselines/reference/for-of-excess-declarations.symbols b/tests/baselines/reference/for-of-excess-declarations.symbols new file mode 100644 index 0000000000000..3fdc2f7f45978 --- /dev/null +++ b/tests/baselines/reference/for-of-excess-declarations.symbols @@ -0,0 +1,8 @@ +//// [tests/cases/conformance/es6/for-ofStatements/for-of-excess-declarations.ts] //// + +=== for-of-excess-declarations.ts === +for (const a, { [b]: c} of [1]) { +>a : Symbol(a, Decl(for-of-excess-declarations.ts, 0, 10)) +>c : Symbol(c, Decl(for-of-excess-declarations.ts, 0, 15)) + +} diff --git a/tests/baselines/reference/for-of-excess-declarations.types b/tests/baselines/reference/for-of-excess-declarations.types new file mode 100644 index 0000000000000..31fa3901c5f48 --- /dev/null +++ b/tests/baselines/reference/for-of-excess-declarations.types @@ -0,0 +1,11 @@ +//// [tests/cases/conformance/es6/for-ofStatements/for-of-excess-declarations.ts] //// + +=== for-of-excess-declarations.ts === +for (const a, { [b]: c} of [1]) { +>a : number +>b : any +>c : any +>[1] : number[] +>1 : 1 + +} diff --git a/tests/baselines/reference/importHelpersES6.js b/tests/baselines/reference/importHelpersES6.js index 92c57ba8bedb6..ec2ca96a54b62 100644 --- a/tests/baselines/reference/importHelpersES6.js +++ b/tests/baselines/reference/importHelpersES6.js @@ -25,7 +25,7 @@ export declare function __classPrivateFieldIn(a: any, b: any): boolean; //// [a.js] var _A_x; import { __awaiter, __classPrivateFieldGet, __classPrivateFieldIn, __classPrivateFieldSet, __decorate } from "tslib"; -export let A = class A { +let A = class A { constructor() { _A_x.set(this, 1); } @@ -38,5 +38,6 @@ _A_x = new WeakMap(); A = __decorate([ dec ], A); +export { A }; const o = { a: 1 }; const y = Object.assign({}, o); diff --git a/tests/baselines/reference/importHelpersWithLocalCollisions(module=amd).js b/tests/baselines/reference/importHelpersWithLocalCollisions(module=amd).js index 260f6f64d0f96..8cd41ea7a3e7c 100644 --- a/tests/baselines/reference/importHelpersWithLocalCollisions(module=amd).js +++ b/tests/baselines/reference/importHelpersWithLocalCollisions(module=amd).js @@ -22,8 +22,9 @@ define(["require", "exports", "tslib"], function (require, exports, tslib_1) { "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.A = void 0; - let A = exports.A = class A { + let A = class A { }; + exports.A = A; exports.A = A = tslib_1.__decorate([ dec ], A); diff --git a/tests/baselines/reference/importHelpersWithLocalCollisions(module=commonjs).js b/tests/baselines/reference/importHelpersWithLocalCollisions(module=commonjs).js index 2a8868ef91410..adaba14dce798 100644 --- a/tests/baselines/reference/importHelpersWithLocalCollisions(module=commonjs).js +++ b/tests/baselines/reference/importHelpersWithLocalCollisions(module=commonjs).js @@ -22,8 +22,9 @@ export declare function __awaiter(thisArg: any, _arguments: any, P: Function, ge Object.defineProperty(exports, "__esModule", { value: true }); exports.A = void 0; const tslib_1 = require("tslib"); -let A = exports.A = class A { +let A = class A { }; +exports.A = A; exports.A = A = tslib_1.__decorate([ dec ], A); diff --git a/tests/baselines/reference/importHelpersWithLocalCollisions(module=es2015).js b/tests/baselines/reference/importHelpersWithLocalCollisions(module=es2015).js index 1225d694aea8e..ba22069c306f2 100644 --- a/tests/baselines/reference/importHelpersWithLocalCollisions(module=es2015).js +++ b/tests/baselines/reference/importHelpersWithLocalCollisions(module=es2015).js @@ -19,10 +19,11 @@ export declare function __awaiter(thisArg: any, _arguments: any, P: Function, ge //// [a.js] import { __decorate as __decorate_1 } from "tslib"; -export let A = class A { +let A = class A { }; A = __decorate_1([ dec ], A); +export { A }; const o = { a: 1 }; const y = Object.assign({}, o); diff --git a/tests/baselines/reference/importHelpersWithLocalCollisions(module=system).js b/tests/baselines/reference/importHelpersWithLocalCollisions(module=system).js index 189159cd0efed..788e5ae4d8d46 100644 --- a/tests/baselines/reference/importHelpersWithLocalCollisions(module=system).js +++ b/tests/baselines/reference/importHelpersWithLocalCollisions(module=system).js @@ -29,8 +29,9 @@ System.register(["tslib"], function (exports_1, context_1) { } ], execute: function () { - exports_1("A", A = class A { - }); + A = class A { + }; + exports_1("A", A); exports_1("A", A = tslib_1.__decorate([ dec ], A)); diff --git a/tests/baselines/reference/importImportOnlyModule.js b/tests/baselines/reference/importImportOnlyModule.js index d60eaa7206aa6..b770810648b5b 100644 --- a/tests/baselines/reference/importImportOnlyModule.js +++ b/tests/baselines/reference/importImportOnlyModule.js @@ -20,13 +20,14 @@ define(["require", "exports"], function (require, exports) { "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.C1 = void 0; - var C1 = exports.C1 = /** @class */ (function () { + var C1 = /** @class */ (function () { function C1() { this.m1 = 42; } C1.s1 = true; return C1; }()); + exports.C1 = C1; }); //// [foo_1.js] define(["require", "exports"], function (require, exports) { diff --git a/tests/baselines/reference/javascriptThisAssignmentInStaticBlock.js b/tests/baselines/reference/javascriptThisAssignmentInStaticBlock.js index 5d9fa75d5a83a..bae195f802150 100644 --- a/tests/baselines/reference/javascriptThisAssignmentInStaticBlock.js +++ b/tests/baselines/reference/javascriptThisAssignmentInStaticBlock.js @@ -37,7 +37,6 @@ var __extends = (this && this.__extends) || (function () { }; })(); var _a, _b; -var _this = this; var Thing = /** @class */ (function () { function Thing() { } diff --git a/tests/baselines/reference/jsDeclarationsClasses.js b/tests/baselines/reference/jsDeclarationsClasses.js index c751e3ae04a3c..ec208cded7d48 100644 --- a/tests/baselines/reference/jsDeclarationsClasses.js +++ b/tests/baselines/reference/jsDeclarationsClasses.js @@ -221,13 +221,14 @@ var A = /** @class */ (function () { return A; }()); exports.A = A; -var B = exports.B = /** @class */ (function () { +var B = /** @class */ (function () { function B() { } B.cat = "cat"; return B; }()); -var C = exports.C = /** @class */ (function () { +exports.B = B; +var C = /** @class */ (function () { function C() { } C.Cls = /** @class */ (function () { @@ -237,6 +238,7 @@ var C = exports.C = /** @class */ (function () { }()); return C; }()); +exports.C = C; var D = /** @class */ (function () { /** * @param {number} a @@ -250,7 +252,7 @@ exports.D = D; /** * @template T,U */ -var E = exports.E = /** @class */ (function () { +var E = /** @class */ (function () { /** * @param {T} a * @param {U} b @@ -317,6 +319,7 @@ var E = exports.E = /** @class */ (function () { E.staticInitializedField = 12; return E; }()); +exports.E = E; /** * @template T,U */ diff --git a/tests/baselines/reference/jsDeclarationsComputedNames.js b/tests/baselines/reference/jsDeclarationsComputedNames.js index 8b21f98c0b84d..127b4604583da 100644 --- a/tests/baselines/reference/jsDeclarationsComputedNames.js +++ b/tests/baselines/reference/jsDeclarationsComputedNames.js @@ -50,7 +50,7 @@ Object.defineProperty(exports, "__esModule", { value: true }); exports.MyClass = void 0; var TopLevelSym = Symbol(); var InnerSym = Symbol(); -var MyClass = exports.MyClass = /** @class */ (function () { +var MyClass = /** @class */ (function () { /** * @param {typeof TopLevelSym | typeof InnerSym} _p */ @@ -64,6 +64,7 @@ var MyClass = exports.MyClass = /** @class */ (function () { MyClass[_a] = 12; return MyClass; }()); +exports.MyClass = MyClass; //// [index.d.ts] diff --git a/tests/baselines/reference/letDeclarations-invalidContexts.errors.txt b/tests/baselines/reference/letDeclarations-invalidContexts.errors.txt index 229ebdba0d757..645962e02e130 100644 --- a/tests/baselines/reference/letDeclarations-invalidContexts.errors.txt +++ b/tests/baselines/reference/letDeclarations-invalidContexts.errors.txt @@ -1,12 +1,12 @@ -letDeclarations-invalidContexts.ts(3,5): error TS1157: 'let' declarations can only be declared inside a block. -letDeclarations-invalidContexts.ts(5,5): error TS1157: 'let' declarations can only be declared inside a block. -letDeclarations-invalidContexts.ts(8,5): error TS1157: 'let' declarations can only be declared inside a block. -letDeclarations-invalidContexts.ts(11,5): error TS1157: 'let' declarations can only be declared inside a block. +letDeclarations-invalidContexts.ts(3,5): error TS1156: 'let' declarations can only be declared inside a block. +letDeclarations-invalidContexts.ts(5,5): error TS1156: 'let' declarations can only be declared inside a block. +letDeclarations-invalidContexts.ts(8,5): error TS1156: 'let' declarations can only be declared inside a block. +letDeclarations-invalidContexts.ts(11,5): error TS1156: 'let' declarations can only be declared inside a block. letDeclarations-invalidContexts.ts(15,1): error TS2410: The 'with' statement is not supported. All symbols in a 'with' block will have type 'any'. -letDeclarations-invalidContexts.ts(19,5): error TS1157: 'let' declarations can only be declared inside a block. -letDeclarations-invalidContexts.ts(22,5): error TS1157: 'let' declarations can only be declared inside a block. -letDeclarations-invalidContexts.ts(25,12): error TS1157: 'let' declarations can only be declared inside a block. -letDeclarations-invalidContexts.ts(28,29): error TS1157: 'let' declarations can only be declared inside a block. +letDeclarations-invalidContexts.ts(19,5): error TS1156: 'let' declarations can only be declared inside a block. +letDeclarations-invalidContexts.ts(22,5): error TS1156: 'let' declarations can only be declared inside a block. +letDeclarations-invalidContexts.ts(25,12): error TS1156: 'let' declarations can only be declared inside a block. +letDeclarations-invalidContexts.ts(28,29): error TS1156: 'let' declarations can only be declared inside a block. ==== letDeclarations-invalidContexts.ts (9 errors) ==== @@ -14,21 +14,21 @@ letDeclarations-invalidContexts.ts(28,29): error TS1157: 'let' declarations can if (true) let l1 = 0; ~~~~~~~~~~~ -!!! error TS1157: 'let' declarations can only be declared inside a block. +!!! error TS1156: 'let' declarations can only be declared inside a block. else let l2 = 0; ~~~~~~~~~~~ -!!! error TS1157: 'let' declarations can only be declared inside a block. +!!! error TS1156: 'let' declarations can only be declared inside a block. while (true) let l3 = 0; ~~~~~~~~~~~ -!!! error TS1157: 'let' declarations can only be declared inside a block. +!!! error TS1156: 'let' declarations can only be declared inside a block. do let l4 = 0; ~~~~~~~~~~~ -!!! error TS1157: 'let' declarations can only be declared inside a block. +!!! error TS1156: 'let' declarations can only be declared inside a block. while (true); var obj; @@ -40,22 +40,22 @@ letDeclarations-invalidContexts.ts(28,29): error TS1157: 'let' declarations can for (var i = 0; i < 10; i++) let l6 = 0; ~~~~~~~~~~~ -!!! error TS1157: 'let' declarations can only be declared inside a block. +!!! error TS1156: 'let' declarations can only be declared inside a block. for (var i2 in {}) let l7 = 0; ~~~~~~~~~~~ -!!! error TS1157: 'let' declarations can only be declared inside a block. +!!! error TS1156: 'let' declarations can only be declared inside a block. if (true) label: let l8 = 0; ~~~~~~~~~~~ -!!! error TS1157: 'let' declarations can only be declared inside a block. +!!! error TS1156: 'let' declarations can only be declared inside a block. while (false) label2: label3: label4: let l9 = 0; ~~~~~~~~~~~ -!!! error TS1157: 'let' declarations can only be declared inside a block. +!!! error TS1156: 'let' declarations can only be declared inside a block. diff --git a/tests/baselines/reference/metadataImportType.js b/tests/baselines/reference/metadataImportType.js index 46560f9e14825..f37594ca136c0 100644 --- a/tests/baselines/reference/metadataImportType.js +++ b/tests/baselines/reference/metadataImportType.js @@ -19,7 +19,7 @@ var __metadata = (this && this.__metadata) || function (k, v) { }; Object.defineProperty(exports, "__esModule", { value: true }); exports.A = void 0; -var A = exports.A = /** @class */ (function () { +var A = /** @class */ (function () { function A() { } __decorate([ @@ -28,3 +28,4 @@ var A = exports.A = /** @class */ (function () { ], A.prototype, "b", void 0); return A; }()); +exports.A = A; diff --git a/tests/baselines/reference/metadataOfClassFromAlias.js b/tests/baselines/reference/metadataOfClassFromAlias.js index e63697b564d18..657cdf21f975f 100644 --- a/tests/baselines/reference/metadataOfClassFromAlias.js +++ b/tests/baselines/reference/metadataOfClassFromAlias.js @@ -41,7 +41,7 @@ var auxiliry_1 = require("./auxiliry"); function annotation() { return function (target) { }; } -var ClassA = exports.ClassA = /** @class */ (function () { +var ClassA = /** @class */ (function () { function ClassA() { } __decorate([ @@ -50,3 +50,4 @@ var ClassA = exports.ClassA = /** @class */ (function () { ], ClassA.prototype, "array", void 0); return ClassA; }()); +exports.ClassA = ClassA; diff --git a/tests/baselines/reference/metadataOfClassFromAlias2.js b/tests/baselines/reference/metadataOfClassFromAlias2.js index 02d2626a97e39..8b7a2b93130fd 100644 --- a/tests/baselines/reference/metadataOfClassFromAlias2.js +++ b/tests/baselines/reference/metadataOfClassFromAlias2.js @@ -40,7 +40,7 @@ exports.ClassA = void 0; function annotation() { return function (target) { }; } -var ClassA = exports.ClassA = /** @class */ (function () { +var ClassA = /** @class */ (function () { function ClassA() { } __decorate([ @@ -49,3 +49,4 @@ var ClassA = exports.ClassA = /** @class */ (function () { ], ClassA.prototype, "array", void 0); return ClassA; }()); +exports.ClassA = ClassA; diff --git a/tests/baselines/reference/metadataOfEventAlias.js b/tests/baselines/reference/metadataOfEventAlias.js index c4d49829539f2..9993967432eae 100644 --- a/tests/baselines/reference/metadataOfEventAlias.js +++ b/tests/baselines/reference/metadataOfEventAlias.js @@ -28,7 +28,7 @@ var __metadata = (this && this.__metadata) || function (k, v) { Object.defineProperty(exports, "__esModule", { value: true }); exports.SomeClass = void 0; function Input(target, key) { } -var SomeClass = exports.SomeClass = /** @class */ (function () { +var SomeClass = /** @class */ (function () { function SomeClass() { } __decorate([ @@ -37,3 +37,4 @@ var SomeClass = exports.SomeClass = /** @class */ (function () { ], SomeClass.prototype, "event", void 0); return SomeClass; }()); +exports.SomeClass = SomeClass; diff --git a/tests/baselines/reference/metadataReferencedWithinFilteredUnion.js b/tests/baselines/reference/metadataReferencedWithinFilteredUnion.js index 1462af8a63290..7c7d70c749b5a 100644 --- a/tests/baselines/reference/metadataReferencedWithinFilteredUnion.js +++ b/tests/baselines/reference/metadataReferencedWithinFilteredUnion.js @@ -42,7 +42,7 @@ exports.Class2 = void 0; var Class1_1 = require("./Class1"); function decorate(target, propertyKey) { } -var Class2 = exports.Class2 = /** @class */ (function () { +var Class2 = /** @class */ (function () { function Class2() { } Object.defineProperty(Class2.prototype, "prop", { @@ -59,3 +59,4 @@ var Class2 = exports.Class2 = /** @class */ (function () { ], Class2.prototype, "prop", null); return Class2; }()); +exports.Class2 = Class2; diff --git a/tests/baselines/reference/plainJSGrammarErrors.errors.txt b/tests/baselines/reference/plainJSGrammarErrors.errors.txt index b855bc6b1dc51..8b015217e305f 100644 --- a/tests/baselines/reference/plainJSGrammarErrors.errors.txt +++ b/tests/baselines/reference/plainJSGrammarErrors.errors.txt @@ -1,7 +1,7 @@ plainJSGrammarErrors.js(3,9): error TS1451: Private identifiers are only allowed in class bodies and may only be used as part of a class member declaration, property access, or on the left-hand-side of an 'in' expression plainJSGrammarErrors.js(5,9): error TS1451: Private identifiers are only allowed in class bodies and may only be used as part of a class member declaration, property access, or on the left-hand-side of an 'in' expression plainJSGrammarErrors.js(10,15): error TS2803: Cannot assign to private method '#m'. Private methods are not writable. -plainJSGrammarErrors.js(14,13): error TS18038: 'For await' loops cannot be used inside a class static block. +plainJSGrammarErrors.js(14,13): error TS18038: 'for await' loops cannot be used inside a class static block. plainJSGrammarErrors.js(17,9): error TS18041: A 'return' statement cannot be used inside a class static block. plainJSGrammarErrors.js(20,5): error TS1089: 'static' modifier cannot appear on a constructor declaration. plainJSGrammarErrors.js(21,5): error TS1089: 'async' modifier cannot appear on a constructor declaration. @@ -77,7 +77,7 @@ plainJSGrammarErrors.js(120,7): error TS1182: A destructuring declaration must h plainJSGrammarErrors.js(121,7): error TS1155: 'const' declarations must be initialized. plainJSGrammarErrors.js(122,5): error TS1214: Identifier expected. 'let' is a reserved word in strict mode. Modules are automatically in strict mode. plainJSGrammarErrors.js(122,5): error TS2480: 'let' is not allowed to be used as a name in 'let' or 'const' declarations. -plainJSGrammarErrors.js(124,5): error TS1157: 'let' declarations can only be declared inside a block. +plainJSGrammarErrors.js(124,5): error TS1156: 'let' declarations can only be declared inside a block. plainJSGrammarErrors.js(126,5): error TS1156: 'const' declarations can only be declared inside a block. plainJSGrammarErrors.js(131,6): error TS1106: The left-hand side of a 'for...of' statement may not be 'async'. plainJSGrammarErrors.js(134,12): error TS1190: The variable declaration of a 'for...of' statement cannot have an initializer. @@ -124,7 +124,7 @@ plainJSGrammarErrors.js(205,36): error TS1325: Argument of dynamic import cannot static { for await (const x of [1,2,3]) { ~~~~~ -!!! error TS18038: 'For await' loops cannot be used inside a class static block. +!!! error TS18038: 'for await' loops cannot be used inside a class static block. console.log(x) } return null @@ -386,7 +386,7 @@ plainJSGrammarErrors.js(205,36): error TS1325: Argument of dynamic import cannot if (true) let onlyBlockLet = 17; ~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS1157: 'let' declarations can only be declared inside a block. +!!! error TS1156: 'let' declarations can only be declared inside a block. if (true) const onlyBlockConst = 18; ~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/tests/baselines/reference/privacyCannotNameVarTypeDeclFile.js b/tests/baselines/reference/privacyCannotNameVarTypeDeclFile.js index a95b49ad8dd77..cc61a1f860a0a 100644 --- a/tests/baselines/reference/privacyCannotNameVarTypeDeclFile.js +++ b/tests/baselines/reference/privacyCannotNameVarTypeDeclFile.js @@ -156,7 +156,7 @@ exports.createExportedWidget4 = createExportedWidget4; Object.defineProperty(exports, "__esModule", { value: true }); exports.publicVarWithPrivateModulePropertyTypes1 = exports.publicVarWithPrivateModulePropertyTypes = exports.publicClassWithPrivateModulePropertyTypes = exports.publicVarWithPrivatePropertyTypes1 = exports.publicVarWithPrivatePropertyTypes = exports.publicClassWithWithPrivatePropertyTypes = void 0; var exporter = require("./privacyCannotNameVarTypeDeclFile_exporter"); -var publicClassWithWithPrivatePropertyTypes = exports.publicClassWithWithPrivatePropertyTypes = /** @class */ (function () { +var publicClassWithWithPrivatePropertyTypes = /** @class */ (function () { function publicClassWithWithPrivatePropertyTypes() { this.myPublicProperty = exporter.createExportedWidget1(); // Error this.myPrivateProperty = exporter.createExportedWidget1(); @@ -169,6 +169,7 @@ var publicClassWithWithPrivatePropertyTypes = exports.publicClassWithWithPrivate publicClassWithWithPrivatePropertyTypes.myPrivateStaticProperty1 = exporter.createExportedWidget3(); return publicClassWithWithPrivatePropertyTypes; }()); +exports.publicClassWithWithPrivatePropertyTypes = publicClassWithWithPrivatePropertyTypes; var privateClassWithWithPrivatePropertyTypes = /** @class */ (function () { function privateClassWithWithPrivatePropertyTypes() { this.myPublicProperty = exporter.createExportedWidget1(); @@ -186,7 +187,7 @@ exports.publicVarWithPrivatePropertyTypes = exporter.createExportedWidget1(); // var privateVarWithPrivatePropertyTypes = exporter.createExportedWidget1(); exports.publicVarWithPrivatePropertyTypes1 = exporter.createExportedWidget3(); // Error var privateVarWithPrivatePropertyTypes1 = exporter.createExportedWidget3(); -var publicClassWithPrivateModulePropertyTypes = exports.publicClassWithPrivateModulePropertyTypes = /** @class */ (function () { +var publicClassWithPrivateModulePropertyTypes = /** @class */ (function () { function publicClassWithPrivateModulePropertyTypes() { this.myPublicProperty = exporter.createExportedWidget2(); // Error this.myPublicProperty1 = exporter.createExportedWidget4(); // Error @@ -195,6 +196,7 @@ var publicClassWithPrivateModulePropertyTypes = exports.publicClassWithPrivateMo publicClassWithPrivateModulePropertyTypes.myPublicStaticProperty1 = exporter.createExportedWidget4(); // Error return publicClassWithPrivateModulePropertyTypes; }()); +exports.publicClassWithPrivateModulePropertyTypes = publicClassWithPrivateModulePropertyTypes; exports.publicVarWithPrivateModulePropertyTypes = exporter.createExportedWidget2(); // Error exports.publicVarWithPrivateModulePropertyTypes1 = exporter.createExportedWidget4(); // Error var privateClassWithPrivateModulePropertyTypes = /** @class */ (function () { diff --git a/tests/baselines/reference/project/emitDecoratorMetadataCommonJSISolatedModules/amd/main.js b/tests/baselines/reference/project/emitDecoratorMetadataCommonJSISolatedModules/amd/main.js index 523abb1315121..9ca20dffe6e8f 100644 --- a/tests/baselines/reference/project/emitDecoratorMetadataCommonJSISolatedModules/amd/main.js +++ b/tests/baselines/reference/project/emitDecoratorMetadataCommonJSISolatedModules/amd/main.js @@ -11,7 +11,7 @@ define(["require", "exports", "angular2/core"], function (require, exports, ng) "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.MyClass1 = void 0; - var MyClass1 = exports.MyClass1 = /** @class */ (function () { + var MyClass1 = /** @class */ (function () { function MyClass1(_elementRef) { this._elementRef = _elementRef; } @@ -22,4 +22,5 @@ define(["require", "exports", "angular2/core"], function (require, exports, ng) ], MyClass1); return MyClass1; }()); + exports.MyClass1 = MyClass1; }); diff --git a/tests/baselines/reference/project/emitDecoratorMetadataCommonJSISolatedModules/node/main.js b/tests/baselines/reference/project/emitDecoratorMetadataCommonJSISolatedModules/node/main.js index adbff7ffa99a7..7a668087a0301 100644 --- a/tests/baselines/reference/project/emitDecoratorMetadataCommonJSISolatedModules/node/main.js +++ b/tests/baselines/reference/project/emitDecoratorMetadataCommonJSISolatedModules/node/main.js @@ -11,7 +11,7 @@ var __metadata = (this && this.__metadata) || function (k, v) { Object.defineProperty(exports, "__esModule", { value: true }); exports.MyClass1 = void 0; var ng = require("angular2/core"); -var MyClass1 = exports.MyClass1 = /** @class */ (function () { +var MyClass1 = /** @class */ (function () { function MyClass1(_elementRef) { this._elementRef = _elementRef; } @@ -22,3 +22,4 @@ var MyClass1 = exports.MyClass1 = /** @class */ (function () { ], MyClass1); return MyClass1; }()); +exports.MyClass1 = MyClass1; diff --git a/tests/baselines/reference/project/emitDecoratorMetadataCommonJSISolatedModulesNoResolve/amd/main.js b/tests/baselines/reference/project/emitDecoratorMetadataCommonJSISolatedModulesNoResolve/amd/main.js index 523abb1315121..9ca20dffe6e8f 100644 --- a/tests/baselines/reference/project/emitDecoratorMetadataCommonJSISolatedModulesNoResolve/amd/main.js +++ b/tests/baselines/reference/project/emitDecoratorMetadataCommonJSISolatedModulesNoResolve/amd/main.js @@ -11,7 +11,7 @@ define(["require", "exports", "angular2/core"], function (require, exports, ng) "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.MyClass1 = void 0; - var MyClass1 = exports.MyClass1 = /** @class */ (function () { + var MyClass1 = /** @class */ (function () { function MyClass1(_elementRef) { this._elementRef = _elementRef; } @@ -22,4 +22,5 @@ define(["require", "exports", "angular2/core"], function (require, exports, ng) ], MyClass1); return MyClass1; }()); + exports.MyClass1 = MyClass1; }); diff --git a/tests/baselines/reference/project/emitDecoratorMetadataCommonJSISolatedModulesNoResolve/node/main.js b/tests/baselines/reference/project/emitDecoratorMetadataCommonJSISolatedModulesNoResolve/node/main.js index adbff7ffa99a7..7a668087a0301 100644 --- a/tests/baselines/reference/project/emitDecoratorMetadataCommonJSISolatedModulesNoResolve/node/main.js +++ b/tests/baselines/reference/project/emitDecoratorMetadataCommonJSISolatedModulesNoResolve/node/main.js @@ -11,7 +11,7 @@ var __metadata = (this && this.__metadata) || function (k, v) { Object.defineProperty(exports, "__esModule", { value: true }); exports.MyClass1 = void 0; var ng = require("angular2/core"); -var MyClass1 = exports.MyClass1 = /** @class */ (function () { +var MyClass1 = /** @class */ (function () { function MyClass1(_elementRef) { this._elementRef = _elementRef; } @@ -22,3 +22,4 @@ var MyClass1 = exports.MyClass1 = /** @class */ (function () { ], MyClass1); return MyClass1; }()); +exports.MyClass1 = MyClass1; diff --git a/tests/baselines/reference/project/emitDecoratorMetadataSystemJS/amd/main.js b/tests/baselines/reference/project/emitDecoratorMetadataSystemJS/amd/main.js index 523abb1315121..9ca20dffe6e8f 100644 --- a/tests/baselines/reference/project/emitDecoratorMetadataSystemJS/amd/main.js +++ b/tests/baselines/reference/project/emitDecoratorMetadataSystemJS/amd/main.js @@ -11,7 +11,7 @@ define(["require", "exports", "angular2/core"], function (require, exports, ng) "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.MyClass1 = void 0; - var MyClass1 = exports.MyClass1 = /** @class */ (function () { + var MyClass1 = /** @class */ (function () { function MyClass1(_elementRef) { this._elementRef = _elementRef; } @@ -22,4 +22,5 @@ define(["require", "exports", "angular2/core"], function (require, exports, ng) ], MyClass1); return MyClass1; }()); + exports.MyClass1 = MyClass1; }); diff --git a/tests/baselines/reference/project/emitDecoratorMetadataSystemJS/node/main.js b/tests/baselines/reference/project/emitDecoratorMetadataSystemJS/node/main.js index adbff7ffa99a7..7a668087a0301 100644 --- a/tests/baselines/reference/project/emitDecoratorMetadataSystemJS/node/main.js +++ b/tests/baselines/reference/project/emitDecoratorMetadataSystemJS/node/main.js @@ -11,7 +11,7 @@ var __metadata = (this && this.__metadata) || function (k, v) { Object.defineProperty(exports, "__esModule", { value: true }); exports.MyClass1 = void 0; var ng = require("angular2/core"); -var MyClass1 = exports.MyClass1 = /** @class */ (function () { +var MyClass1 = /** @class */ (function () { function MyClass1(_elementRef) { this._elementRef = _elementRef; } @@ -22,3 +22,4 @@ var MyClass1 = exports.MyClass1 = /** @class */ (function () { ], MyClass1); return MyClass1; }()); +exports.MyClass1 = MyClass1; diff --git a/tests/baselines/reference/project/emitDecoratorMetadataSystemJSISolatedModules/amd/main.js b/tests/baselines/reference/project/emitDecoratorMetadataSystemJSISolatedModules/amd/main.js index 523abb1315121..9ca20dffe6e8f 100644 --- a/tests/baselines/reference/project/emitDecoratorMetadataSystemJSISolatedModules/amd/main.js +++ b/tests/baselines/reference/project/emitDecoratorMetadataSystemJSISolatedModules/amd/main.js @@ -11,7 +11,7 @@ define(["require", "exports", "angular2/core"], function (require, exports, ng) "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.MyClass1 = void 0; - var MyClass1 = exports.MyClass1 = /** @class */ (function () { + var MyClass1 = /** @class */ (function () { function MyClass1(_elementRef) { this._elementRef = _elementRef; } @@ -22,4 +22,5 @@ define(["require", "exports", "angular2/core"], function (require, exports, ng) ], MyClass1); return MyClass1; }()); + exports.MyClass1 = MyClass1; }); diff --git a/tests/baselines/reference/project/emitDecoratorMetadataSystemJSISolatedModules/node/main.js b/tests/baselines/reference/project/emitDecoratorMetadataSystemJSISolatedModules/node/main.js index adbff7ffa99a7..7a668087a0301 100644 --- a/tests/baselines/reference/project/emitDecoratorMetadataSystemJSISolatedModules/node/main.js +++ b/tests/baselines/reference/project/emitDecoratorMetadataSystemJSISolatedModules/node/main.js @@ -11,7 +11,7 @@ var __metadata = (this && this.__metadata) || function (k, v) { Object.defineProperty(exports, "__esModule", { value: true }); exports.MyClass1 = void 0; var ng = require("angular2/core"); -var MyClass1 = exports.MyClass1 = /** @class */ (function () { +var MyClass1 = /** @class */ (function () { function MyClass1(_elementRef) { this._elementRef = _elementRef; } @@ -22,3 +22,4 @@ var MyClass1 = exports.MyClass1 = /** @class */ (function () { ], MyClass1); return MyClass1; }()); +exports.MyClass1 = MyClass1; diff --git a/tests/baselines/reference/project/emitDecoratorMetadataSystemJSISolatedModulesNoResolve/amd/main.js b/tests/baselines/reference/project/emitDecoratorMetadataSystemJSISolatedModulesNoResolve/amd/main.js index 523abb1315121..9ca20dffe6e8f 100644 --- a/tests/baselines/reference/project/emitDecoratorMetadataSystemJSISolatedModulesNoResolve/amd/main.js +++ b/tests/baselines/reference/project/emitDecoratorMetadataSystemJSISolatedModulesNoResolve/amd/main.js @@ -11,7 +11,7 @@ define(["require", "exports", "angular2/core"], function (require, exports, ng) "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.MyClass1 = void 0; - var MyClass1 = exports.MyClass1 = /** @class */ (function () { + var MyClass1 = /** @class */ (function () { function MyClass1(_elementRef) { this._elementRef = _elementRef; } @@ -22,4 +22,5 @@ define(["require", "exports", "angular2/core"], function (require, exports, ng) ], MyClass1); return MyClass1; }()); + exports.MyClass1 = MyClass1; }); diff --git a/tests/baselines/reference/project/emitDecoratorMetadataSystemJSISolatedModulesNoResolve/node/main.js b/tests/baselines/reference/project/emitDecoratorMetadataSystemJSISolatedModulesNoResolve/node/main.js index adbff7ffa99a7..7a668087a0301 100644 --- a/tests/baselines/reference/project/emitDecoratorMetadataSystemJSISolatedModulesNoResolve/node/main.js +++ b/tests/baselines/reference/project/emitDecoratorMetadataSystemJSISolatedModulesNoResolve/node/main.js @@ -11,7 +11,7 @@ var __metadata = (this && this.__metadata) || function (k, v) { Object.defineProperty(exports, "__esModule", { value: true }); exports.MyClass1 = void 0; var ng = require("angular2/core"); -var MyClass1 = exports.MyClass1 = /** @class */ (function () { +var MyClass1 = /** @class */ (function () { function MyClass1(_elementRef) { this._elementRef = _elementRef; } @@ -22,3 +22,4 @@ var MyClass1 = exports.MyClass1 = /** @class */ (function () { ], MyClass1); return MyClass1; }()); +exports.MyClass1 = MyClass1; diff --git a/tests/baselines/reference/staticFieldWithInterfaceContext.js b/tests/baselines/reference/staticFieldWithInterfaceContext.js index ef805ebc01738..fbc5257904418 100644 --- a/tests/baselines/reference/staticFieldWithInterfaceContext.js +++ b/tests/baselines/reference/staticFieldWithInterfaceContext.js @@ -45,15 +45,15 @@ var c = (_a = /** @class */ (function () { _a); c.x = { a: "a" }; var ex = "x"; -var c2 = (_c = /** @class */ (function () { +var c2 = (_b = /** @class */ (function () { function class_2() { } return class_2; }()), - _b = ex, - __setFunctionName(_c, "c2"), - _c[_b] = { a: "a" }, - _c); + _c = ex, + __setFunctionName(_b, "c2"), + _b[_c] = { a: "a" }, + _b); c[ex] = { a: "a" }; function f(c) { var _a; diff --git a/tests/baselines/reference/strictModeInConstructor.js b/tests/baselines/reference/strictModeInConstructor.js index 749e451280229..c0cf843fcec07 100644 --- a/tests/baselines/reference/strictModeInConstructor.js +++ b/tests/baselines/reference/strictModeInConstructor.js @@ -129,8 +129,8 @@ var Bs = /** @class */ (function (_super) { var Cs = /** @class */ (function (_super) { __extends(Cs, _super); function Cs() { - "use strict"; var _this = _super.call(this) || this; + "use strict"; return _this; } Cs.s = 9; @@ -139,10 +139,10 @@ var Cs = /** @class */ (function (_super) { var Ds = /** @class */ (function (_super) { __extends(Ds, _super); function Ds() { - "use strict"; var _this = this; var x = 1; // no Error _this = _super.call(this) || this; + "use strict"; return _this; } Ds.s = 9; diff --git a/tests/baselines/reference/targetEs6DecoratorMetadataImportNotElided.js b/tests/baselines/reference/targetEs6DecoratorMetadataImportNotElided.js index 891f04581f436..d4781b57b5ca5 100644 --- a/tests/baselines/reference/targetEs6DecoratorMetadataImportNotElided.js +++ b/tests/baselines/reference/targetEs6DecoratorMetadataImportNotElided.js @@ -35,7 +35,7 @@ var __metadata = (this && this.__metadata) || function (k, v) { if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v); }; import { Input, TemplateRef } from './deps'; -export var MyComponent = /** @class */ (function () { +var MyComponent = /** @class */ (function () { function MyComponent() { } Object.defineProperty(MyComponent.prototype, "ref", { @@ -51,3 +51,4 @@ export var MyComponent = /** @class */ (function () { ], MyComponent.prototype, "ref", null); return MyComponent; }()); +export { MyComponent }; diff --git a/tests/baselines/reference/templateLiteralsAndDecoratorMetadata.js b/tests/baselines/reference/templateLiteralsAndDecoratorMetadata.js index 69bdedff6366d..8b28bb3a80626 100644 --- a/tests/baselines/reference/templateLiteralsAndDecoratorMetadata.js +++ b/tests/baselines/reference/templateLiteralsAndDecoratorMetadata.js @@ -20,7 +20,7 @@ var __metadata = (this && this.__metadata) || function (k, v) { }; Object.defineProperty(exports, "__esModule", { value: true }); exports.Greeter = void 0; -var Greeter = exports.Greeter = /** @class */ (function () { +var Greeter = /** @class */ (function () { function Greeter() { this.greeting = "employee"; //template literals on this line cause the issue } @@ -30,3 +30,4 @@ var Greeter = exports.Greeter = /** @class */ (function () { ], Greeter.prototype, "greeting", void 0); return Greeter; }()); +exports.Greeter = Greeter; diff --git a/tests/baselines/reference/thisInConstructorParameter2.js b/tests/baselines/reference/thisInConstructorParameter2.js index b8540253c4d96..61abc7e52d4b9 100644 --- a/tests/baselines/reference/thisInConstructorParameter2.js +++ b/tests/baselines/reference/thisInConstructorParameter2.js @@ -16,13 +16,13 @@ class P { //// [thisInConstructorParameter2.js] var P = /** @class */ (function () { function P(z, zz, zzz) { + var _this = this; if (z === void 0) { z = this; } if (zz === void 0) { zz = this; } if (zzz === void 0) { zzz = function (p) { if (p === void 0) { p = _this; } return _this; }; } - var _this = this; this.z = z; this.x = this; zzz = function (p) { diff --git a/tests/baselines/reference/tsc/runWithoutArgs/does-not-add-color-when-NO_COLOR-is-set.js b/tests/baselines/reference/tsc/runWithoutArgs/does-not-add-color-when-NO_COLOR-is-set.js index 2fb4a9cc6cb09..878fcc68edc1a 100644 --- a/tests/baselines/reference/tsc/runWithoutArgs/does-not-add-color-when-NO_COLOR-is-set.js +++ b/tests/baselines/reference/tsc/runWithoutArgs/does-not-add-color-when-NO_COLOR-is-set.js @@ -111,7 +111,7 @@ default: undefined --lib Specify a set of bundled library declaration files that describe the target runtime environment. -one or more: es5, es6/es2015, es7/es2016, es2017, es2018, es2019, es2020, es2021, es2022, es2023, esnext, dom, dom.iterable, webworker, webworker.importscripts, webworker.iterable, scripthost, es2015.core, es2015.collection, es2015.generator, es2015.iterable, es2015.promise, es2015.proxy, es2015.reflect, es2015.symbol, es2015.symbol.wellknown, es2016.array.include, es2017.date, es2017.object, es2017.sharedmemory, es2017.string, es2017.intl, es2017.typedarrays, es2018.asyncgenerator, es2018.asynciterable/esnext.asynciterable, es2018.intl, es2018.promise, es2018.regexp, es2019.array, es2019.object, es2019.string, es2019.symbol/esnext.symbol, es2019.intl, es2020.bigint/esnext.bigint, es2020.date, es2020.promise, es2020.sharedmemory, es2020.string, es2020.symbol.wellknown, es2020.intl, es2020.number, es2021.promise/esnext.promise, es2021.string, es2021.weakref/esnext.weakref, es2021.intl, es2022.array, es2022.error, es2022.intl, es2022.object, es2022.sharedmemory, es2022.string/esnext.string, es2022.regexp, es2023.array/esnext.array, es2023.collection/esnext.collection, esnext.intl, decorators, decorators.legacy +one or more: es5, es6/es2015, es7/es2016, es2017, es2018, es2019, es2020, es2021, es2022, es2023, esnext, dom, dom.iterable, webworker, webworker.importscripts, webworker.iterable, scripthost, es2015.core, es2015.collection, es2015.generator, es2015.iterable, es2015.promise, es2015.proxy, es2015.reflect, es2015.symbol, es2015.symbol.wellknown, es2016.array.include, es2017.date, es2017.object, es2017.sharedmemory, es2017.string, es2017.intl, es2017.typedarrays, es2018.asyncgenerator, es2018.asynciterable/esnext.asynciterable, es2018.intl, es2018.promise, es2018.regexp, es2019.array, es2019.object, es2019.string, es2019.symbol/esnext.symbol, es2019.intl, es2020.bigint/esnext.bigint, es2020.date, es2020.promise, es2020.sharedmemory, es2020.string, es2020.symbol.wellknown, es2020.intl, es2020.number, es2021.promise/esnext.promise, es2021.string, es2021.weakref/esnext.weakref, es2021.intl, es2022.array, es2022.error, es2022.intl, es2022.object, es2022.sharedmemory, es2022.string/esnext.string, es2022.regexp, es2023.array/esnext.array, es2023.collection/esnext.collection, esnext.intl, esnext.disposable, decorators, decorators.legacy default: undefined --allowJs diff --git a/tests/baselines/reference/tsc/runWithoutArgs/show-help-with-ExitStatus.DiagnosticsPresent_OutputsSkipped-when-host-can't-provide-terminal-width.js b/tests/baselines/reference/tsc/runWithoutArgs/show-help-with-ExitStatus.DiagnosticsPresent_OutputsSkipped-when-host-can't-provide-terminal-width.js index 0c77e3ad9331a..ac9f0f14dc50a 100644 --- a/tests/baselines/reference/tsc/runWithoutArgs/show-help-with-ExitStatus.DiagnosticsPresent_OutputsSkipped-when-host-can't-provide-terminal-width.js +++ b/tests/baselines/reference/tsc/runWithoutArgs/show-help-with-ExitStatus.DiagnosticsPresent_OutputsSkipped-when-host-can't-provide-terminal-width.js @@ -111,7 +111,7 @@ default: undefined --lib Specify a set of bundled library declaration files that describe the target runtime environment. -one or more: es5, es6/es2015, es7/es2016, es2017, es2018, es2019, es2020, es2021, es2022, es2023, esnext, dom, dom.iterable, webworker, webworker.importscripts, webworker.iterable, scripthost, es2015.core, es2015.collection, es2015.generator, es2015.iterable, es2015.promise, es2015.proxy, es2015.reflect, es2015.symbol, es2015.symbol.wellknown, es2016.array.include, es2017.date, es2017.object, es2017.sharedmemory, es2017.string, es2017.intl, es2017.typedarrays, es2018.asyncgenerator, es2018.asynciterable/esnext.asynciterable, es2018.intl, es2018.promise, es2018.regexp, es2019.array, es2019.object, es2019.string, es2019.symbol/esnext.symbol, es2019.intl, es2020.bigint/esnext.bigint, es2020.date, es2020.promise, es2020.sharedmemory, es2020.string, es2020.symbol.wellknown, es2020.intl, es2020.number, es2021.promise/esnext.promise, es2021.string, es2021.weakref/esnext.weakref, es2021.intl, es2022.array, es2022.error, es2022.intl, es2022.object, es2022.sharedmemory, es2022.string/esnext.string, es2022.regexp, es2023.array/esnext.array, es2023.collection/esnext.collection, esnext.intl, decorators, decorators.legacy +one or more: es5, es6/es2015, es7/es2016, es2017, es2018, es2019, es2020, es2021, es2022, es2023, esnext, dom, dom.iterable, webworker, webworker.importscripts, webworker.iterable, scripthost, es2015.core, es2015.collection, es2015.generator, es2015.iterable, es2015.promise, es2015.proxy, es2015.reflect, es2015.symbol, es2015.symbol.wellknown, es2016.array.include, es2017.date, es2017.object, es2017.sharedmemory, es2017.string, es2017.intl, es2017.typedarrays, es2018.asyncgenerator, es2018.asynciterable/esnext.asynciterable, es2018.intl, es2018.promise, es2018.regexp, es2019.array, es2019.object, es2019.string, es2019.symbol/esnext.symbol, es2019.intl, es2020.bigint/esnext.bigint, es2020.date, es2020.promise, es2020.sharedmemory, es2020.string, es2020.symbol.wellknown, es2020.intl, es2020.number, es2021.promise/esnext.promise, es2021.string, es2021.weakref/esnext.weakref, es2021.intl, es2022.array, es2022.error, es2022.intl, es2022.object, es2022.sharedmemory, es2022.string/esnext.string, es2022.regexp, es2023.array/esnext.array, es2023.collection/esnext.collection, esnext.intl, esnext.disposable, decorators, decorators.legacy default: undefined --allowJs diff --git a/tests/baselines/reference/tsc/runWithoutArgs/show-help-with-ExitStatus.DiagnosticsPresent_OutputsSkipped.js b/tests/baselines/reference/tsc/runWithoutArgs/show-help-with-ExitStatus.DiagnosticsPresent_OutputsSkipped.js index 0c77e3ad9331a..ac9f0f14dc50a 100644 --- a/tests/baselines/reference/tsc/runWithoutArgs/show-help-with-ExitStatus.DiagnosticsPresent_OutputsSkipped.js +++ b/tests/baselines/reference/tsc/runWithoutArgs/show-help-with-ExitStatus.DiagnosticsPresent_OutputsSkipped.js @@ -111,7 +111,7 @@ default: undefined --lib Specify a set of bundled library declaration files that describe the target runtime environment. -one or more: es5, es6/es2015, es7/es2016, es2017, es2018, es2019, es2020, es2021, es2022, es2023, esnext, dom, dom.iterable, webworker, webworker.importscripts, webworker.iterable, scripthost, es2015.core, es2015.collection, es2015.generator, es2015.iterable, es2015.promise, es2015.proxy, es2015.reflect, es2015.symbol, es2015.symbol.wellknown, es2016.array.include, es2017.date, es2017.object, es2017.sharedmemory, es2017.string, es2017.intl, es2017.typedarrays, es2018.asyncgenerator, es2018.asynciterable/esnext.asynciterable, es2018.intl, es2018.promise, es2018.regexp, es2019.array, es2019.object, es2019.string, es2019.symbol/esnext.symbol, es2019.intl, es2020.bigint/esnext.bigint, es2020.date, es2020.promise, es2020.sharedmemory, es2020.string, es2020.symbol.wellknown, es2020.intl, es2020.number, es2021.promise/esnext.promise, es2021.string, es2021.weakref/esnext.weakref, es2021.intl, es2022.array, es2022.error, es2022.intl, es2022.object, es2022.sharedmemory, es2022.string/esnext.string, es2022.regexp, es2023.array/esnext.array, es2023.collection/esnext.collection, esnext.intl, decorators, decorators.legacy +one or more: es5, es6/es2015, es7/es2016, es2017, es2018, es2019, es2020, es2021, es2022, es2023, esnext, dom, dom.iterable, webworker, webworker.importscripts, webworker.iterable, scripthost, es2015.core, es2015.collection, es2015.generator, es2015.iterable, es2015.promise, es2015.proxy, es2015.reflect, es2015.symbol, es2015.symbol.wellknown, es2016.array.include, es2017.date, es2017.object, es2017.sharedmemory, es2017.string, es2017.intl, es2017.typedarrays, es2018.asyncgenerator, es2018.asynciterable/esnext.asynciterable, es2018.intl, es2018.promise, es2018.regexp, es2019.array, es2019.object, es2019.string, es2019.symbol/esnext.symbol, es2019.intl, es2020.bigint/esnext.bigint, es2020.date, es2020.promise, es2020.sharedmemory, es2020.string, es2020.symbol.wellknown, es2020.intl, es2020.number, es2021.promise/esnext.promise, es2021.string, es2021.weakref/esnext.weakref, es2021.intl, es2022.array, es2022.error, es2022.intl, es2022.object, es2022.sharedmemory, es2022.string/esnext.string, es2022.regexp, es2023.array/esnext.array, es2023.collection/esnext.collection, esnext.intl, esnext.disposable, decorators, decorators.legacy default: undefined --allowJs diff --git a/tests/baselines/reference/tscWatch/programUpdates/updates-diagnostics-and-emit-for-decorators.js b/tests/baselines/reference/tscWatch/programUpdates/updates-diagnostics-and-emit-for-decorators.js index cc323419fa41d..d0faf0c6dcc8f 100644 --- a/tests/baselines/reference/tscWatch/programUpdates/updates-diagnostics-and-emit-for-decorators.js +++ b/tests/baselines/reference/tscWatch/programUpdates/updates-diagnostics-and-emit-for-decorators.js @@ -118,7 +118,7 @@ var __setFunctionName = (this && this.__setFunctionName) || function (f, name, p return Object.defineProperty(f, "name", { configurable: true, value: prefix ? "".concat(prefix, " ", name) : name }); }; import './b'; -export let A = (() => { +let A = (() => { let _classDecorators = [((_) => { })]; let _classDescriptor; let _classExtraInitializers = []; @@ -134,6 +134,7 @@ export let A = (() => { })(); return A = _classThis; })(); +export { A }; @@ -184,12 +185,13 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key, return c > 3 && r && Object.defineProperty(target, key, r), r; }; import './b'; -export let A = class A { +let A = class A { constructor(p) { } }; A = __decorate([ ((_) => { }) ], A); +export { A }; @@ -243,12 +245,13 @@ var __metadata = (this && this.__metadata) || function (k, v) { if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v); }; import { B } from './b'; -export let A = class A { +let A = class A { constructor(p) { } }; A = __decorate([ ((_) => { }), __metadata("design:paramtypes", [B]) ], A); +export { A }; diff --git a/tests/baselines/reference/tslibReExportHelpers.js b/tests/baselines/reference/tslibReExportHelpers.js index 033bd963f07f1..db2f3a48c64cc 100644 --- a/tests/baselines/reference/tslibReExportHelpers.js +++ b/tests/baselines/reference/tslibReExportHelpers.js @@ -29,7 +29,7 @@ export class Foo {} //// [index.mjs] import { __decorate } from "tslib"; -export var Foo = /** @class */ (function () { +var Foo = /** @class */ (function () { function Foo() { } Foo = __decorate([ @@ -37,3 +37,4 @@ export var Foo = /** @class */ (function () { ], Foo); return Foo; }()); +export { Foo }; diff --git a/tests/baselines/reference/tsserver/telemetry/does-not-expose-paths.js b/tests/baselines/reference/tsserver/telemetry/does-not-expose-paths.js index 31410efa3eff0..e3392cc157150 100644 --- a/tests/baselines/reference/tsserver/telemetry/does-not-expose-paths.js +++ b/tests/baselines/reference/tsserver/telemetry/does-not-expose-paths.js @@ -430,7 +430,7 @@ Info seq [hh:mm:ss:mss] event: "line": 1, "offset": 431 }, - "text": "Argument for '--lib' option must be: 'es5', 'es6', 'es2015', 'es7', 'es2016', 'es2017', 'es2018', 'es2019', 'es2020', 'es2021', 'es2022', 'es2023', 'esnext', 'dom', 'dom.iterable', 'webworker', 'webworker.importscripts', 'webworker.iterable', 'scripthost', 'es2015.core', 'es2015.collection', 'es2015.generator', 'es2015.iterable', 'es2015.promise', 'es2015.proxy', 'es2015.reflect', 'es2015.symbol', 'es2015.symbol.wellknown', 'es2016.array.include', 'es2017.date', 'es2017.object', 'es2017.sharedmemory', 'es2017.string', 'es2017.intl', 'es2017.typedarrays', 'es2018.asyncgenerator', 'es2018.asynciterable', 'es2018.intl', 'es2018.promise', 'es2018.regexp', 'es2019.array', 'es2019.object', 'es2019.string', 'es2019.symbol', 'es2019.intl', 'es2020.bigint', 'es2020.date', 'es2020.promise', 'es2020.sharedmemory', 'es2020.string', 'es2020.symbol.wellknown', 'es2020.intl', 'es2020.number', 'es2021.promise', 'es2021.string', 'es2021.weakref', 'es2021.intl', 'es2022.array', 'es2022.error', 'es2022.intl', 'es2022.object', 'es2022.sharedmemory', 'es2022.string', 'es2022.regexp', 'es2023.array', 'es2023.collection', 'esnext.array', 'esnext.collection', 'esnext.symbol', 'esnext.asynciterable', 'esnext.intl', 'esnext.bigint', 'esnext.string', 'esnext.promise', 'esnext.weakref', 'decorators', 'decorators.legacy'.", + "text": "Argument for '--lib' option must be: 'es5', 'es6', 'es2015', 'es7', 'es2016', 'es2017', 'es2018', 'es2019', 'es2020', 'es2021', 'es2022', 'es2023', 'esnext', 'dom', 'dom.iterable', 'webworker', 'webworker.importscripts', 'webworker.iterable', 'scripthost', 'es2015.core', 'es2015.collection', 'es2015.generator', 'es2015.iterable', 'es2015.promise', 'es2015.proxy', 'es2015.reflect', 'es2015.symbol', 'es2015.symbol.wellknown', 'es2016.array.include', 'es2017.date', 'es2017.object', 'es2017.sharedmemory', 'es2017.string', 'es2017.intl', 'es2017.typedarrays', 'es2018.asyncgenerator', 'es2018.asynciterable', 'es2018.intl', 'es2018.promise', 'es2018.regexp', 'es2019.array', 'es2019.object', 'es2019.string', 'es2019.symbol', 'es2019.intl', 'es2020.bigint', 'es2020.date', 'es2020.promise', 'es2020.sharedmemory', 'es2020.string', 'es2020.symbol.wellknown', 'es2020.intl', 'es2020.number', 'es2021.promise', 'es2021.string', 'es2021.weakref', 'es2021.intl', 'es2022.array', 'es2022.error', 'es2022.intl', 'es2022.object', 'es2022.sharedmemory', 'es2022.string', 'es2022.regexp', 'es2023.array', 'es2023.collection', 'esnext.array', 'esnext.collection', 'esnext.symbol', 'esnext.asynciterable', 'esnext.intl', 'esnext.disposable', 'esnext.bigint', 'esnext.string', 'esnext.promise', 'esnext.weakref', 'decorators', 'decorators.legacy'.", "code": 6046, "category": "error", "fileName": "/tsconfig.json" diff --git a/tests/baselines/reference/typesVersions.ambientModules.trace.json b/tests/baselines/reference/typesVersions.ambientModules.trace.json index 0a410f50e0b3e..3adfc2c0dec03 100644 --- a/tests/baselines/reference/typesVersions.ambientModules.trace.json +++ b/tests/baselines/reference/typesVersions.ambientModules.trace.json @@ -786,6 +786,18 @@ "Searching all ancestor node_modules directories for fallback extensions: JavaScript.", "Directory '/node_modules' does not exist, skipping all lookups in it.", "======== Module name '@typescript/lib-esnext/intl' was not resolved. ========", + "======== Resolving module '@typescript/lib-esnext/disposable' from '/.src/__lib_node_modules_lookup_lib.esnext.disposable.d.ts__.ts'. ========", + "Explicitly specified module resolution kind: 'Node10'.", + "Loading module '@typescript/lib-esnext/disposable' from 'node_modules' folder, target file types: TypeScript, Declaration.", + "Searching all ancestor node_modules directories for preferred extensions: TypeScript, Declaration.", + "Directory '/.src/node_modules/@types' does not exist, skipping all lookups in it.", + "Scoped package detected, looking in 'typescript__lib-esnext/disposable'", + "Directory '/node_modules' does not exist, skipping all lookups in it.", + "Scoped package detected, looking in 'typescript__lib-esnext/disposable'", + "Loading module '@typescript/lib-esnext/disposable' from 'node_modules' folder, target file types: JavaScript.", + "Searching all ancestor node_modules directories for fallback extensions: JavaScript.", + "Directory '/node_modules' does not exist, skipping all lookups in it.", + "======== Module name '@typescript/lib-esnext/disposable' was not resolved. ========", "======== Resolving module '@typescript/lib-dom' from '/.src/__lib_node_modules_lookup_lib.dom.d.ts__.ts'. ========", "Explicitly specified module resolution kind: 'Node10'.", "Loading module '@typescript/lib-dom' from 'node_modules' folder, target file types: TypeScript, Declaration.", diff --git a/tests/baselines/reference/typesVersions.emptyTypes.trace.json b/tests/baselines/reference/typesVersions.emptyTypes.trace.json index 8d0744b55cfa9..2fd6b050cc1e4 100644 --- a/tests/baselines/reference/typesVersions.emptyTypes.trace.json +++ b/tests/baselines/reference/typesVersions.emptyTypes.trace.json @@ -814,6 +814,19 @@ "Directory '/.src/node_modules' does not exist, skipping all lookups in it.", "Directory '/node_modules' does not exist, skipping all lookups in it.", "======== Module name '@typescript/lib-esnext/intl' was not resolved. ========", + "======== Resolving module '@typescript/lib-esnext/disposable' from '/.src/__lib_node_modules_lookup_lib.esnext.disposable.d.ts__.ts'. ========", + "Explicitly specified module resolution kind: 'Node10'.", + "Loading module '@typescript/lib-esnext/disposable' from 'node_modules' folder, target file types: TypeScript, Declaration.", + "Searching all ancestor node_modules directories for preferred extensions: TypeScript, Declaration.", + "Directory '/.src/node_modules' does not exist, skipping all lookups in it.", + "Scoped package detected, looking in 'typescript__lib-esnext/disposable'", + "Directory '/node_modules' does not exist, skipping all lookups in it.", + "Scoped package detected, looking in 'typescript__lib-esnext/disposable'", + "Loading module '@typescript/lib-esnext/disposable' from 'node_modules' folder, target file types: JavaScript.", + "Searching all ancestor node_modules directories for fallback extensions: JavaScript.", + "Directory '/.src/node_modules' does not exist, skipping all lookups in it.", + "Directory '/node_modules' does not exist, skipping all lookups in it.", + "======== Module name '@typescript/lib-esnext/disposable' was not resolved. ========", "======== Resolving module '@typescript/lib-dom' from '/.src/__lib_node_modules_lookup_lib.dom.d.ts__.ts'. ========", "Explicitly specified module resolution kind: 'Node10'.", "Loading module '@typescript/lib-dom' from 'node_modules' folder, target file types: TypeScript, Declaration.", diff --git a/tests/baselines/reference/typesVersions.justIndex.trace.json b/tests/baselines/reference/typesVersions.justIndex.trace.json index 3ae541cf1d29a..bd509b985d7ab 100644 --- a/tests/baselines/reference/typesVersions.justIndex.trace.json +++ b/tests/baselines/reference/typesVersions.justIndex.trace.json @@ -814,6 +814,19 @@ "Directory '/.src/node_modules' does not exist, skipping all lookups in it.", "Directory '/node_modules' does not exist, skipping all lookups in it.", "======== Module name '@typescript/lib-esnext/intl' was not resolved. ========", + "======== Resolving module '@typescript/lib-esnext/disposable' from '/.src/__lib_node_modules_lookup_lib.esnext.disposable.d.ts__.ts'. ========", + "Explicitly specified module resolution kind: 'Node10'.", + "Loading module '@typescript/lib-esnext/disposable' from 'node_modules' folder, target file types: TypeScript, Declaration.", + "Searching all ancestor node_modules directories for preferred extensions: TypeScript, Declaration.", + "Directory '/.src/node_modules' does not exist, skipping all lookups in it.", + "Scoped package detected, looking in 'typescript__lib-esnext/disposable'", + "Directory '/node_modules' does not exist, skipping all lookups in it.", + "Scoped package detected, looking in 'typescript__lib-esnext/disposable'", + "Loading module '@typescript/lib-esnext/disposable' from 'node_modules' folder, target file types: JavaScript.", + "Searching all ancestor node_modules directories for fallback extensions: JavaScript.", + "Directory '/.src/node_modules' does not exist, skipping all lookups in it.", + "Directory '/node_modules' does not exist, skipping all lookups in it.", + "======== Module name '@typescript/lib-esnext/disposable' was not resolved. ========", "======== Resolving module '@typescript/lib-dom' from '/.src/__lib_node_modules_lookup_lib.dom.d.ts__.ts'. ========", "Explicitly specified module resolution kind: 'Node10'.", "Loading module '@typescript/lib-dom' from 'node_modules' folder, target file types: TypeScript, Declaration.", diff --git a/tests/baselines/reference/typesVersions.multiFile.trace.json b/tests/baselines/reference/typesVersions.multiFile.trace.json index defb376cbe4e7..b3f0b7ef29319 100644 --- a/tests/baselines/reference/typesVersions.multiFile.trace.json +++ b/tests/baselines/reference/typesVersions.multiFile.trace.json @@ -765,6 +765,18 @@ "Searching all ancestor node_modules directories for fallback extensions: JavaScript.", "Directory '/node_modules' does not exist, skipping all lookups in it.", "======== Module name '@typescript/lib-esnext/intl' was not resolved. ========", + "======== Resolving module '@typescript/lib-esnext/disposable' from '/.src/__lib_node_modules_lookup_lib.esnext.disposable.d.ts__.ts'. ========", + "Explicitly specified module resolution kind: 'Node10'.", + "Loading module '@typescript/lib-esnext/disposable' from 'node_modules' folder, target file types: TypeScript, Declaration.", + "Searching all ancestor node_modules directories for preferred extensions: TypeScript, Declaration.", + "Directory '/.src/node_modules/@types' does not exist, skipping all lookups in it.", + "Scoped package detected, looking in 'typescript__lib-esnext/disposable'", + "Directory '/node_modules' does not exist, skipping all lookups in it.", + "Scoped package detected, looking in 'typescript__lib-esnext/disposable'", + "Loading module '@typescript/lib-esnext/disposable' from 'node_modules' folder, target file types: JavaScript.", + "Searching all ancestor node_modules directories for fallback extensions: JavaScript.", + "Directory '/node_modules' does not exist, skipping all lookups in it.", + "======== Module name '@typescript/lib-esnext/disposable' was not resolved. ========", "======== Resolving module '@typescript/lib-dom' from '/.src/__lib_node_modules_lookup_lib.dom.d.ts__.ts'. ========", "Explicitly specified module resolution kind: 'Node10'.", "Loading module '@typescript/lib-dom' from 'node_modules' folder, target file types: TypeScript, Declaration.", diff --git a/tests/baselines/reference/typesVersionsDeclarationEmit.ambient.trace.json b/tests/baselines/reference/typesVersionsDeclarationEmit.ambient.trace.json index 0a410f50e0b3e..3adfc2c0dec03 100644 --- a/tests/baselines/reference/typesVersionsDeclarationEmit.ambient.trace.json +++ b/tests/baselines/reference/typesVersionsDeclarationEmit.ambient.trace.json @@ -786,6 +786,18 @@ "Searching all ancestor node_modules directories for fallback extensions: JavaScript.", "Directory '/node_modules' does not exist, skipping all lookups in it.", "======== Module name '@typescript/lib-esnext/intl' was not resolved. ========", + "======== Resolving module '@typescript/lib-esnext/disposable' from '/.src/__lib_node_modules_lookup_lib.esnext.disposable.d.ts__.ts'. ========", + "Explicitly specified module resolution kind: 'Node10'.", + "Loading module '@typescript/lib-esnext/disposable' from 'node_modules' folder, target file types: TypeScript, Declaration.", + "Searching all ancestor node_modules directories for preferred extensions: TypeScript, Declaration.", + "Directory '/.src/node_modules/@types' does not exist, skipping all lookups in it.", + "Scoped package detected, looking in 'typescript__lib-esnext/disposable'", + "Directory '/node_modules' does not exist, skipping all lookups in it.", + "Scoped package detected, looking in 'typescript__lib-esnext/disposable'", + "Loading module '@typescript/lib-esnext/disposable' from 'node_modules' folder, target file types: JavaScript.", + "Searching all ancestor node_modules directories for fallback extensions: JavaScript.", + "Directory '/node_modules' does not exist, skipping all lookups in it.", + "======== Module name '@typescript/lib-esnext/disposable' was not resolved. ========", "======== Resolving module '@typescript/lib-dom' from '/.src/__lib_node_modules_lookup_lib.dom.d.ts__.ts'. ========", "Explicitly specified module resolution kind: 'Node10'.", "Loading module '@typescript/lib-dom' from 'node_modules' folder, target file types: TypeScript, Declaration.", diff --git a/tests/baselines/reference/typesVersionsDeclarationEmit.multiFile.trace.json b/tests/baselines/reference/typesVersionsDeclarationEmit.multiFile.trace.json index defb376cbe4e7..b3f0b7ef29319 100644 --- a/tests/baselines/reference/typesVersionsDeclarationEmit.multiFile.trace.json +++ b/tests/baselines/reference/typesVersionsDeclarationEmit.multiFile.trace.json @@ -765,6 +765,18 @@ "Searching all ancestor node_modules directories for fallback extensions: JavaScript.", "Directory '/node_modules' does not exist, skipping all lookups in it.", "======== Module name '@typescript/lib-esnext/intl' was not resolved. ========", + "======== Resolving module '@typescript/lib-esnext/disposable' from '/.src/__lib_node_modules_lookup_lib.esnext.disposable.d.ts__.ts'. ========", + "Explicitly specified module resolution kind: 'Node10'.", + "Loading module '@typescript/lib-esnext/disposable' from 'node_modules' folder, target file types: TypeScript, Declaration.", + "Searching all ancestor node_modules directories for preferred extensions: TypeScript, Declaration.", + "Directory '/.src/node_modules/@types' does not exist, skipping all lookups in it.", + "Scoped package detected, looking in 'typescript__lib-esnext/disposable'", + "Directory '/node_modules' does not exist, skipping all lookups in it.", + "Scoped package detected, looking in 'typescript__lib-esnext/disposable'", + "Loading module '@typescript/lib-esnext/disposable' from 'node_modules' folder, target file types: JavaScript.", + "Searching all ancestor node_modules directories for fallback extensions: JavaScript.", + "Directory '/node_modules' does not exist, skipping all lookups in it.", + "======== Module name '@typescript/lib-esnext/disposable' was not resolved. ========", "======== Resolving module '@typescript/lib-dom' from '/.src/__lib_node_modules_lookup_lib.dom.d.ts__.ts'. ========", "Explicitly specified module resolution kind: 'Node10'.", "Loading module '@typescript/lib-dom' from 'node_modules' folder, target file types: TypeScript, Declaration.", diff --git a/tests/baselines/reference/typesVersionsDeclarationEmit.multiFileBackReferenceToSelf.trace.json b/tests/baselines/reference/typesVersionsDeclarationEmit.multiFileBackReferenceToSelf.trace.json index 14703ef05c6b3..d6eea6bd79278 100644 --- a/tests/baselines/reference/typesVersionsDeclarationEmit.multiFileBackReferenceToSelf.trace.json +++ b/tests/baselines/reference/typesVersionsDeclarationEmit.multiFileBackReferenceToSelf.trace.json @@ -788,6 +788,18 @@ "Searching all ancestor node_modules directories for fallback extensions: JavaScript.", "Directory '/node_modules' does not exist, skipping all lookups in it.", "======== Module name '@typescript/lib-esnext/intl' was not resolved. ========", + "======== Resolving module '@typescript/lib-esnext/disposable' from '/.src/__lib_node_modules_lookup_lib.esnext.disposable.d.ts__.ts'. ========", + "Explicitly specified module resolution kind: 'Node10'.", + "Loading module '@typescript/lib-esnext/disposable' from 'node_modules' folder, target file types: TypeScript, Declaration.", + "Searching all ancestor node_modules directories for preferred extensions: TypeScript, Declaration.", + "Directory '/.src/node_modules/@types' does not exist, skipping all lookups in it.", + "Scoped package detected, looking in 'typescript__lib-esnext/disposable'", + "Directory '/node_modules' does not exist, skipping all lookups in it.", + "Scoped package detected, looking in 'typescript__lib-esnext/disposable'", + "Loading module '@typescript/lib-esnext/disposable' from 'node_modules' folder, target file types: JavaScript.", + "Searching all ancestor node_modules directories for fallback extensions: JavaScript.", + "Directory '/node_modules' does not exist, skipping all lookups in it.", + "======== Module name '@typescript/lib-esnext/disposable' was not resolved. ========", "======== Resolving module '@typescript/lib-dom' from '/.src/__lib_node_modules_lookup_lib.dom.d.ts__.ts'. ========", "Explicitly specified module resolution kind: 'Node10'.", "Loading module '@typescript/lib-dom' from 'node_modules' folder, target file types: TypeScript, Declaration.", diff --git a/tests/baselines/reference/typesVersionsDeclarationEmit.multiFileBackReferenceToUnmapped.trace.json b/tests/baselines/reference/typesVersionsDeclarationEmit.multiFileBackReferenceToUnmapped.trace.json index 009cab1a57a7e..c8bb8ebcf46ee 100644 --- a/tests/baselines/reference/typesVersionsDeclarationEmit.multiFileBackReferenceToUnmapped.trace.json +++ b/tests/baselines/reference/typesVersionsDeclarationEmit.multiFileBackReferenceToUnmapped.trace.json @@ -771,6 +771,18 @@ "Searching all ancestor node_modules directories for fallback extensions: JavaScript.", "Directory '/node_modules' does not exist, skipping all lookups in it.", "======== Module name '@typescript/lib-esnext/intl' was not resolved. ========", + "======== Resolving module '@typescript/lib-esnext/disposable' from '/.src/__lib_node_modules_lookup_lib.esnext.disposable.d.ts__.ts'. ========", + "Explicitly specified module resolution kind: 'Node10'.", + "Loading module '@typescript/lib-esnext/disposable' from 'node_modules' folder, target file types: TypeScript, Declaration.", + "Searching all ancestor node_modules directories for preferred extensions: TypeScript, Declaration.", + "Directory '/.src/node_modules/@types' does not exist, skipping all lookups in it.", + "Scoped package detected, looking in 'typescript__lib-esnext/disposable'", + "Directory '/node_modules' does not exist, skipping all lookups in it.", + "Scoped package detected, looking in 'typescript__lib-esnext/disposable'", + "Loading module '@typescript/lib-esnext/disposable' from 'node_modules' folder, target file types: JavaScript.", + "Searching all ancestor node_modules directories for fallback extensions: JavaScript.", + "Directory '/node_modules' does not exist, skipping all lookups in it.", + "======== Module name '@typescript/lib-esnext/disposable' was not resolved. ========", "======== Resolving module '@typescript/lib-dom' from '/.src/__lib_node_modules_lookup_lib.dom.d.ts__.ts'. ========", "Explicitly specified module resolution kind: 'Node10'.", "Loading module '@typescript/lib-dom' from 'node_modules' folder, target file types: TypeScript, Declaration.", diff --git a/tests/baselines/reference/usingDeclarations.1(target=es2015).js b/tests/baselines/reference/usingDeclarations.1(target=es2015).js new file mode 100644 index 0000000000000..c10bc21fb1f6d --- /dev/null +++ b/tests/baselines/reference/usingDeclarations.1(target=es2015).js @@ -0,0 +1,665 @@ +//// [tests/cases/conformance/statements/VariableStatements/usingDeclarations/usingDeclarations.1.ts] //// + +//// [usingDeclarations.1.ts] +using d1 = { [Symbol.dispose]() {} }; + +function f() { + using d2 = { [Symbol.dispose]() {} }; +} + +async function af() { + using d3 = { [Symbol.dispose]() {} }; + await null; +} + +function * g() { + using d4 = { [Symbol.dispose]() {} }; + yield; +} + +async function * ag() { + using d5 = { [Symbol.dispose]() {} }; + yield; + await null; +} + +const a = () => { + using d6 = { [Symbol.dispose]() {} }; +} + +class C1 { + a = () => { + using d7 = { [Symbol.dispose]() {} }; + } + + constructor() { + using d8 = { [Symbol.dispose]() {} }; + } + + static { + using d9 = { [Symbol.dispose]() {} }; + } + + m() { + using d10 = { [Symbol.dispose]() {} }; + } + + get x() { + using d11 = { [Symbol.dispose]() {} }; + return 0; + } + + set x(v) { + using d12 = { [Symbol.dispose]() {} }; + } + + async am() { + using d13 = { [Symbol.dispose]() {} }; + await null; + } + + * g() { + using d14 = { [Symbol.dispose]() {} }; + yield; + } + + async * ag() { + using d15 = { [Symbol.dispose]() {} }; + yield; + await null; + } +} + +class C2 extends C1 { + constructor() { + using d16 = { [Symbol.dispose]() {} }; + super(); + } +} + +class C3 extends C1 { + y = 1; + constructor() { + using d17 = { [Symbol.dispose]() {} }; + super(); + } +} + +namespace N { + using d18 = { [Symbol.dispose]() {} }; +} + +{ + using d19 = { [Symbol.dispose]() {} }; +} + +switch (Math.random()) { + case 0: + using d20 = { [Symbol.dispose]() {} }; + break; + + case 1: + using d21 = { [Symbol.dispose]() {} }; + break; +} + +if (true) + switch (0) { + case 0: + using d22 = { [Symbol.dispose]() {} }; + break; + } + +try { + using d23 = { [Symbol.dispose]() {} }; +} +catch { + using d24 = { [Symbol.dispose]() {} }; +} +finally { + using d25 = { [Symbol.dispose]() {} }; +} + +if (true) { + using d26 = { [Symbol.dispose]() {} }; +} +else { + using d27 = { [Symbol.dispose]() {} }; +} + +while (true) { + using d28 = { [Symbol.dispose]() {} }; + break; +} + +do { + using d29 = { [Symbol.dispose]() {} }; + break; +} +while (true); + +for (;;) { + using d30 = { [Symbol.dispose]() {} }; + break; +} + +for (const x in {}) { + using d31 = { [Symbol.dispose]() {} }; +} + +for (const x of []) { + using d32 = { [Symbol.dispose]() {} }; +} + +export {}; + +//// [usingDeclarations.1.js] +var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { + function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } + return new (P || (P = Promise))(function (resolve, reject) { + function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } + function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } + function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } + step((generator = generator.apply(thisArg, _arguments || [])).next()); + }); +}; +var __addDisposableResource = (this && this.__addDisposableResource) || function (env, value, async) { + if (value !== null && value !== void 0) { + if (typeof value !== "object") throw new TypeError("Object expected."); + var dispose; + if (async) { + if (!Symbol.asyncDispose) throw new TypeError("Symbol.asyncDispose is not defined."); + dispose = value[Symbol.asyncDispose]; + } + if (dispose === void 0) { + if (!Symbol.dispose) throw new TypeError("Symbol.dispose is not defined."); + dispose = value[Symbol.dispose]; + } + if (typeof dispose !== "function") throw new TypeError("Object not disposable."); + env.stack.push({ value: value, dispose: dispose, async: async }); + } + else if (async) { + env.stack.push({ async: true }); + } + return value; +}; +var __disposeResources = (this && this.__disposeResources) || (function (SuppressedError) { + return function (env) { + function fail(e) { + env.error = env.hasError ? new SuppressedError(e, env.error, "An error was suppressed during disposal.") : e; + env.hasError = true; + } + function next() { + while (env.stack.length) { + var rec = env.stack.pop(); + try { + var result = rec.dispose && rec.dispose.call(rec.value); + if (rec.async) return Promise.resolve(result).then(next, function(e) { fail(e); return next(); }); + } + catch (e) { + fail(e); + } + } + if (env.hasError) throw env.error; + } + return next(); + }; +})(typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) { + var e = new Error(message); + return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e; +}); +var __await = (this && this.__await) || function (v) { return this instanceof __await ? (this.v = v, this) : new __await(v); } +var __asyncGenerator = (this && this.__asyncGenerator) || function (thisArg, _arguments, generator) { + if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined."); + var g = generator.apply(thisArg, _arguments || []), i, q = []; + return i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i; + function verb(n) { if (g[n]) i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; } + function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(q[0][3], e); } } + function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); } + function fulfill(value) { resume("next", value); } + function reject(value) { resume("throw", value); } + function settle(f, v) { if (f(v), q.shift(), q.length) resume(q[0][0], q[0][1]); } +}; +var _a; +function f() { + const env_15 = { stack: [], error: void 0, hasError: false }; + try { + const d2 = __addDisposableResource(env_15, { [Symbol.dispose]() { } }, false); + } + catch (e_15) { + env_15.error = e_15; + env_15.hasError = true; + } + finally { + __disposeResources(env_15); + } +} +function af() { + return __awaiter(this, void 0, void 0, function* () { + const env_16 = { stack: [], error: void 0, hasError: false }; + try { + const d3 = __addDisposableResource(env_16, { [Symbol.dispose]() { } }, false); + yield null; + } + catch (e_16) { + env_16.error = e_16; + env_16.hasError = true; + } + finally { + __disposeResources(env_16); + } + }); +} +function* g() { + const env_17 = { stack: [], error: void 0, hasError: false }; + try { + const d4 = __addDisposableResource(env_17, { [Symbol.dispose]() { } }, false); + yield; + } + catch (e_17) { + env_17.error = e_17; + env_17.hasError = true; + } + finally { + __disposeResources(env_17); + } +} +function ag() { + return __asyncGenerator(this, arguments, function* ag_1() { + const env_18 = { stack: [], error: void 0, hasError: false }; + try { + const d5 = __addDisposableResource(env_18, { [Symbol.dispose]() { } }, false); + yield yield __await(void 0); + yield __await(null); + } + catch (e_18) { + env_18.error = e_18; + env_18.hasError = true; + } + finally { + __disposeResources(env_18); + } + }); +} +var d1, a, C1, C2, C3, N, env_1; +const env_2 = { stack: [], error: void 0, hasError: false }; +try { + d1 = __addDisposableResource(env_2, { [Symbol.dispose]() { } }, false); + a = () => { + const env_19 = { stack: [], error: void 0, hasError: false }; + try { + const d6 = __addDisposableResource(env_19, { [Symbol.dispose]() { } }, false); + } + catch (e_19) { + env_19.error = e_19; + env_19.hasError = true; + } + finally { + __disposeResources(env_19); + } + }; + C1 = (_a = class C1 { + constructor() { + this.a = () => { + const env_21 = { stack: [], error: void 0, hasError: false }; + try { + const d7 = __addDisposableResource(env_21, { [Symbol.dispose]() { } }, false); + } + catch (e_21) { + env_21.error = e_21; + env_21.hasError = true; + } + finally { + __disposeResources(env_21); + } + }; + const env_20 = { stack: [], error: void 0, hasError: false }; + try { + const d8 = __addDisposableResource(env_20, { [Symbol.dispose]() { } }, false); + } + catch (e_20) { + env_20.error = e_20; + env_20.hasError = true; + } + finally { + __disposeResources(env_20); + } + } + m() { + const env_22 = { stack: [], error: void 0, hasError: false }; + try { + const d10 = __addDisposableResource(env_22, { [Symbol.dispose]() { } }, false); + } + catch (e_22) { + env_22.error = e_22; + env_22.hasError = true; + } + finally { + __disposeResources(env_22); + } + } + get x() { + const env_23 = { stack: [], error: void 0, hasError: false }; + try { + const d11 = __addDisposableResource(env_23, { [Symbol.dispose]() { } }, false); + return 0; + } + catch (e_23) { + env_23.error = e_23; + env_23.hasError = true; + } + finally { + __disposeResources(env_23); + } + } + set x(v) { + const env_24 = { stack: [], error: void 0, hasError: false }; + try { + const d12 = __addDisposableResource(env_24, { [Symbol.dispose]() { } }, false); + } + catch (e_24) { + env_24.error = e_24; + env_24.hasError = true; + } + finally { + __disposeResources(env_24); + } + } + am() { + return __awaiter(this, void 0, void 0, function* () { + const env_25 = { stack: [], error: void 0, hasError: false }; + try { + const d13 = __addDisposableResource(env_25, { [Symbol.dispose]() { } }, false); + yield null; + } + catch (e_25) { + env_25.error = e_25; + env_25.hasError = true; + } + finally { + __disposeResources(env_25); + } + }); + } + *g() { + const env_26 = { stack: [], error: void 0, hasError: false }; + try { + const d14 = __addDisposableResource(env_26, { [Symbol.dispose]() { } }, false); + yield; + } + catch (e_26) { + env_26.error = e_26; + env_26.hasError = true; + } + finally { + __disposeResources(env_26); + } + } + ag() { + return __asyncGenerator(this, arguments, function* ag_2() { + const env_27 = { stack: [], error: void 0, hasError: false }; + try { + const d15 = __addDisposableResource(env_27, { [Symbol.dispose]() { } }, false); + yield yield __await(void 0); + yield __await(null); + } + catch (e_27) { + env_27.error = e_27; + env_27.hasError = true; + } + finally { + __disposeResources(env_27); + } + }); + } + }, + (() => { + const env_28 = { stack: [], error: void 0, hasError: false }; + try { + const d9 = __addDisposableResource(env_28, { [Symbol.dispose]() { } }, false); + } + catch (e_28) { + env_28.error = e_28; + env_28.hasError = true; + } + finally { + __disposeResources(env_28); + } + })(), + _a); + C2 = class C2 extends C1 { + constructor() { + const env_29 = { stack: [], error: void 0, hasError: false }; + try { + const d16 = __addDisposableResource(env_29, { [Symbol.dispose]() { } }, false); + super(); + } + catch (e_29) { + env_29.error = e_29; + env_29.hasError = true; + } + finally { + __disposeResources(env_29); + } + } + }; + C3 = class C3 extends C1 { + constructor() { + const env_30 = { stack: [], error: void 0, hasError: false }; + try { + const d17 = __addDisposableResource(env_30, { [Symbol.dispose]() { } }, false); + super(); + this.y = 1; + } + catch (e_30) { + env_30.error = e_30; + env_30.hasError = true; + } + finally { + __disposeResources(env_30); + } + } + }; + (function (N) { + const env_31 = { stack: [], error: void 0, hasError: false }; + try { + const d18 = __addDisposableResource(env_31, { [Symbol.dispose]() { } }, false); + } + catch (e_31) { + env_31.error = e_31; + env_31.hasError = true; + } + finally { + __disposeResources(env_31); + } + })(N || (N = {})); + { + const env_3 = { stack: [], error: void 0, hasError: false }; + try { + const d19 = __addDisposableResource(env_3, { [Symbol.dispose]() { } }, false); + } + catch (e_1) { + env_3.error = e_1; + env_3.hasError = true; + } + finally { + __disposeResources(env_3); + } + } + env_1 = { stack: [], error: void 0, hasError: false }; + try { + switch (Math.random()) { + case 0: + const d20 = __addDisposableResource(env_1, { [Symbol.dispose]() { } }, false); + break; + case 1: + const d21 = __addDisposableResource(env_1, { [Symbol.dispose]() { } }, false); + break; + } + } + catch (e_2) { + env_1.error = e_2; + env_1.hasError = true; + } + finally { + __disposeResources(env_1); + } + if (true) { + const env_4 = { stack: [], error: void 0, hasError: false }; + try { + switch (0) { + case 0: + const d22 = __addDisposableResource(env_4, { [Symbol.dispose]() { } }, false); + break; + } + } + catch (e_3) { + env_4.error = e_3; + env_4.hasError = true; + } + finally { + __disposeResources(env_4); + } + } + try { + const env_5 = { stack: [], error: void 0, hasError: false }; + try { + const d23 = __addDisposableResource(env_5, { [Symbol.dispose]() { } }, false); + } + catch (e_4) { + env_5.error = e_4; + env_5.hasError = true; + } + finally { + __disposeResources(env_5); + } + } + catch (_b) { + const env_6 = { stack: [], error: void 0, hasError: false }; + try { + const d24 = __addDisposableResource(env_6, { [Symbol.dispose]() { } }, false); + } + catch (e_5) { + env_6.error = e_5; + env_6.hasError = true; + } + finally { + __disposeResources(env_6); + } + } + finally { + const env_7 = { stack: [], error: void 0, hasError: false }; + try { + const d25 = __addDisposableResource(env_7, { [Symbol.dispose]() { } }, false); + } + catch (e_6) { + env_7.error = e_6; + env_7.hasError = true; + } + finally { + __disposeResources(env_7); + } + } + if (true) { + const env_8 = { stack: [], error: void 0, hasError: false }; + try { + const d26 = __addDisposableResource(env_8, { [Symbol.dispose]() { } }, false); + } + catch (e_7) { + env_8.error = e_7; + env_8.hasError = true; + } + finally { + __disposeResources(env_8); + } + } + else { + const env_9 = { stack: [], error: void 0, hasError: false }; + try { + const d27 = __addDisposableResource(env_9, { [Symbol.dispose]() { } }, false); + } + catch (e_8) { + env_9.error = e_8; + env_9.hasError = true; + } + finally { + __disposeResources(env_9); + } + } + while (true) { + const env_10 = { stack: [], error: void 0, hasError: false }; + try { + const d28 = __addDisposableResource(env_10, { [Symbol.dispose]() { } }, false); + break; + } + catch (e_9) { + env_10.error = e_9; + env_10.hasError = true; + } + finally { + __disposeResources(env_10); + } + } + do { + const env_11 = { stack: [], error: void 0, hasError: false }; + try { + const d29 = __addDisposableResource(env_11, { [Symbol.dispose]() { } }, false); + break; + } + catch (e_10) { + env_11.error = e_10; + env_11.hasError = true; + } + finally { + __disposeResources(env_11); + } + } while (true); + for (;;) { + const env_12 = { stack: [], error: void 0, hasError: false }; + try { + const d30 = __addDisposableResource(env_12, { [Symbol.dispose]() { } }, false); + break; + } + catch (e_11) { + env_12.error = e_11; + env_12.hasError = true; + } + finally { + __disposeResources(env_12); + } + } + for (const x in {}) { + const env_13 = { stack: [], error: void 0, hasError: false }; + try { + const d31 = __addDisposableResource(env_13, { [Symbol.dispose]() { } }, false); + } + catch (e_12) { + env_13.error = e_12; + env_13.hasError = true; + } + finally { + __disposeResources(env_13); + } + } + for (const x of []) { + const env_14 = { stack: [], error: void 0, hasError: false }; + try { + const d32 = __addDisposableResource(env_14, { [Symbol.dispose]() { } }, false); + } + catch (e_13) { + env_14.error = e_13; + env_14.hasError = true; + } + finally { + __disposeResources(env_14); + } + } +} +catch (e_14) { + env_2.error = e_14; + env_2.hasError = true; +} +finally { + __disposeResources(env_2); +} +export {}; diff --git a/tests/baselines/reference/usingDeclarations.1(target=es2017).js b/tests/baselines/reference/usingDeclarations.1(target=es2017).js new file mode 100644 index 0000000000000..f65b33bc977dc --- /dev/null +++ b/tests/baselines/reference/usingDeclarations.1(target=es2017).js @@ -0,0 +1,652 @@ +//// [tests/cases/conformance/statements/VariableStatements/usingDeclarations/usingDeclarations.1.ts] //// + +//// [usingDeclarations.1.ts] +using d1 = { [Symbol.dispose]() {} }; + +function f() { + using d2 = { [Symbol.dispose]() {} }; +} + +async function af() { + using d3 = { [Symbol.dispose]() {} }; + await null; +} + +function * g() { + using d4 = { [Symbol.dispose]() {} }; + yield; +} + +async function * ag() { + using d5 = { [Symbol.dispose]() {} }; + yield; + await null; +} + +const a = () => { + using d6 = { [Symbol.dispose]() {} }; +} + +class C1 { + a = () => { + using d7 = { [Symbol.dispose]() {} }; + } + + constructor() { + using d8 = { [Symbol.dispose]() {} }; + } + + static { + using d9 = { [Symbol.dispose]() {} }; + } + + m() { + using d10 = { [Symbol.dispose]() {} }; + } + + get x() { + using d11 = { [Symbol.dispose]() {} }; + return 0; + } + + set x(v) { + using d12 = { [Symbol.dispose]() {} }; + } + + async am() { + using d13 = { [Symbol.dispose]() {} }; + await null; + } + + * g() { + using d14 = { [Symbol.dispose]() {} }; + yield; + } + + async * ag() { + using d15 = { [Symbol.dispose]() {} }; + yield; + await null; + } +} + +class C2 extends C1 { + constructor() { + using d16 = { [Symbol.dispose]() {} }; + super(); + } +} + +class C3 extends C1 { + y = 1; + constructor() { + using d17 = { [Symbol.dispose]() {} }; + super(); + } +} + +namespace N { + using d18 = { [Symbol.dispose]() {} }; +} + +{ + using d19 = { [Symbol.dispose]() {} }; +} + +switch (Math.random()) { + case 0: + using d20 = { [Symbol.dispose]() {} }; + break; + + case 1: + using d21 = { [Symbol.dispose]() {} }; + break; +} + +if (true) + switch (0) { + case 0: + using d22 = { [Symbol.dispose]() {} }; + break; + } + +try { + using d23 = { [Symbol.dispose]() {} }; +} +catch { + using d24 = { [Symbol.dispose]() {} }; +} +finally { + using d25 = { [Symbol.dispose]() {} }; +} + +if (true) { + using d26 = { [Symbol.dispose]() {} }; +} +else { + using d27 = { [Symbol.dispose]() {} }; +} + +while (true) { + using d28 = { [Symbol.dispose]() {} }; + break; +} + +do { + using d29 = { [Symbol.dispose]() {} }; + break; +} +while (true); + +for (;;) { + using d30 = { [Symbol.dispose]() {} }; + break; +} + +for (const x in {}) { + using d31 = { [Symbol.dispose]() {} }; +} + +for (const x of []) { + using d32 = { [Symbol.dispose]() {} }; +} + +export {}; + +//// [usingDeclarations.1.js] +var __addDisposableResource = (this && this.__addDisposableResource) || function (env, value, async) { + if (value !== null && value !== void 0) { + if (typeof value !== "object") throw new TypeError("Object expected."); + var dispose; + if (async) { + if (!Symbol.asyncDispose) throw new TypeError("Symbol.asyncDispose is not defined."); + dispose = value[Symbol.asyncDispose]; + } + if (dispose === void 0) { + if (!Symbol.dispose) throw new TypeError("Symbol.dispose is not defined."); + dispose = value[Symbol.dispose]; + } + if (typeof dispose !== "function") throw new TypeError("Object not disposable."); + env.stack.push({ value: value, dispose: dispose, async: async }); + } + else if (async) { + env.stack.push({ async: true }); + } + return value; +}; +var __disposeResources = (this && this.__disposeResources) || (function (SuppressedError) { + return function (env) { + function fail(e) { + env.error = env.hasError ? new SuppressedError(e, env.error, "An error was suppressed during disposal.") : e; + env.hasError = true; + } + function next() { + while (env.stack.length) { + var rec = env.stack.pop(); + try { + var result = rec.dispose && rec.dispose.call(rec.value); + if (rec.async) return Promise.resolve(result).then(next, function(e) { fail(e); return next(); }); + } + catch (e) { + fail(e); + } + } + if (env.hasError) throw env.error; + } + return next(); + }; +})(typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) { + var e = new Error(message); + return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e; +}); +var __await = (this && this.__await) || function (v) { return this instanceof __await ? (this.v = v, this) : new __await(v); } +var __asyncGenerator = (this && this.__asyncGenerator) || function (thisArg, _arguments, generator) { + if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined."); + var g = generator.apply(thisArg, _arguments || []), i, q = []; + return i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i; + function verb(n) { if (g[n]) i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; } + function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(q[0][3], e); } } + function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); } + function fulfill(value) { resume("next", value); } + function reject(value) { resume("throw", value); } + function settle(f, v) { if (f(v), q.shift(), q.length) resume(q[0][0], q[0][1]); } +}; +var _a; +function f() { + const env_15 = { stack: [], error: void 0, hasError: false }; + try { + const d2 = __addDisposableResource(env_15, { [Symbol.dispose]() { } }, false); + } + catch (e_15) { + env_15.error = e_15; + env_15.hasError = true; + } + finally { + __disposeResources(env_15); + } +} +async function af() { + const env_16 = { stack: [], error: void 0, hasError: false }; + try { + const d3 = __addDisposableResource(env_16, { [Symbol.dispose]() { } }, false); + await null; + } + catch (e_16) { + env_16.error = e_16; + env_16.hasError = true; + } + finally { + __disposeResources(env_16); + } +} +function* g() { + const env_17 = { stack: [], error: void 0, hasError: false }; + try { + const d4 = __addDisposableResource(env_17, { [Symbol.dispose]() { } }, false); + yield; + } + catch (e_17) { + env_17.error = e_17; + env_17.hasError = true; + } + finally { + __disposeResources(env_17); + } +} +function ag() { + return __asyncGenerator(this, arguments, function* ag_1() { + const env_18 = { stack: [], error: void 0, hasError: false }; + try { + const d5 = __addDisposableResource(env_18, { [Symbol.dispose]() { } }, false); + yield yield __await(void 0); + yield __await(null); + } + catch (e_18) { + env_18.error = e_18; + env_18.hasError = true; + } + finally { + __disposeResources(env_18); + } + }); +} +var d1, a, C1, C2, C3, N, env_1; +const env_2 = { stack: [], error: void 0, hasError: false }; +try { + d1 = __addDisposableResource(env_2, { [Symbol.dispose]() { } }, false); + a = () => { + const env_19 = { stack: [], error: void 0, hasError: false }; + try { + const d6 = __addDisposableResource(env_19, { [Symbol.dispose]() { } }, false); + } + catch (e_19) { + env_19.error = e_19; + env_19.hasError = true; + } + finally { + __disposeResources(env_19); + } + }; + C1 = (_a = class C1 { + constructor() { + this.a = () => { + const env_21 = { stack: [], error: void 0, hasError: false }; + try { + const d7 = __addDisposableResource(env_21, { [Symbol.dispose]() { } }, false); + } + catch (e_21) { + env_21.error = e_21; + env_21.hasError = true; + } + finally { + __disposeResources(env_21); + } + }; + const env_20 = { stack: [], error: void 0, hasError: false }; + try { + const d8 = __addDisposableResource(env_20, { [Symbol.dispose]() { } }, false); + } + catch (e_20) { + env_20.error = e_20; + env_20.hasError = true; + } + finally { + __disposeResources(env_20); + } + } + m() { + const env_22 = { stack: [], error: void 0, hasError: false }; + try { + const d10 = __addDisposableResource(env_22, { [Symbol.dispose]() { } }, false); + } + catch (e_22) { + env_22.error = e_22; + env_22.hasError = true; + } + finally { + __disposeResources(env_22); + } + } + get x() { + const env_23 = { stack: [], error: void 0, hasError: false }; + try { + const d11 = __addDisposableResource(env_23, { [Symbol.dispose]() { } }, false); + return 0; + } + catch (e_23) { + env_23.error = e_23; + env_23.hasError = true; + } + finally { + __disposeResources(env_23); + } + } + set x(v) { + const env_24 = { stack: [], error: void 0, hasError: false }; + try { + const d12 = __addDisposableResource(env_24, { [Symbol.dispose]() { } }, false); + } + catch (e_24) { + env_24.error = e_24; + env_24.hasError = true; + } + finally { + __disposeResources(env_24); + } + } + async am() { + const env_25 = { stack: [], error: void 0, hasError: false }; + try { + const d13 = __addDisposableResource(env_25, { [Symbol.dispose]() { } }, false); + await null; + } + catch (e_25) { + env_25.error = e_25; + env_25.hasError = true; + } + finally { + __disposeResources(env_25); + } + } + *g() { + const env_26 = { stack: [], error: void 0, hasError: false }; + try { + const d14 = __addDisposableResource(env_26, { [Symbol.dispose]() { } }, false); + yield; + } + catch (e_26) { + env_26.error = e_26; + env_26.hasError = true; + } + finally { + __disposeResources(env_26); + } + } + ag() { + return __asyncGenerator(this, arguments, function* ag_2() { + const env_27 = { stack: [], error: void 0, hasError: false }; + try { + const d15 = __addDisposableResource(env_27, { [Symbol.dispose]() { } }, false); + yield yield __await(void 0); + yield __await(null); + } + catch (e_27) { + env_27.error = e_27; + env_27.hasError = true; + } + finally { + __disposeResources(env_27); + } + }); + } + }, + (() => { + const env_28 = { stack: [], error: void 0, hasError: false }; + try { + const d9 = __addDisposableResource(env_28, { [Symbol.dispose]() { } }, false); + } + catch (e_28) { + env_28.error = e_28; + env_28.hasError = true; + } + finally { + __disposeResources(env_28); + } + })(), + _a); + C2 = class C2 extends C1 { + constructor() { + const env_29 = { stack: [], error: void 0, hasError: false }; + try { + const d16 = __addDisposableResource(env_29, { [Symbol.dispose]() { } }, false); + super(); + } + catch (e_29) { + env_29.error = e_29; + env_29.hasError = true; + } + finally { + __disposeResources(env_29); + } + } + }; + C3 = class C3 extends C1 { + constructor() { + const env_30 = { stack: [], error: void 0, hasError: false }; + try { + const d17 = __addDisposableResource(env_30, { [Symbol.dispose]() { } }, false); + super(); + this.y = 1; + } + catch (e_30) { + env_30.error = e_30; + env_30.hasError = true; + } + finally { + __disposeResources(env_30); + } + } + }; + (function (N) { + const env_31 = { stack: [], error: void 0, hasError: false }; + try { + const d18 = __addDisposableResource(env_31, { [Symbol.dispose]() { } }, false); + } + catch (e_31) { + env_31.error = e_31; + env_31.hasError = true; + } + finally { + __disposeResources(env_31); + } + })(N || (N = {})); + { + const env_3 = { stack: [], error: void 0, hasError: false }; + try { + const d19 = __addDisposableResource(env_3, { [Symbol.dispose]() { } }, false); + } + catch (e_1) { + env_3.error = e_1; + env_3.hasError = true; + } + finally { + __disposeResources(env_3); + } + } + env_1 = { stack: [], error: void 0, hasError: false }; + try { + switch (Math.random()) { + case 0: + const d20 = __addDisposableResource(env_1, { [Symbol.dispose]() { } }, false); + break; + case 1: + const d21 = __addDisposableResource(env_1, { [Symbol.dispose]() { } }, false); + break; + } + } + catch (e_2) { + env_1.error = e_2; + env_1.hasError = true; + } + finally { + __disposeResources(env_1); + } + if (true) { + const env_4 = { stack: [], error: void 0, hasError: false }; + try { + switch (0) { + case 0: + const d22 = __addDisposableResource(env_4, { [Symbol.dispose]() { } }, false); + break; + } + } + catch (e_3) { + env_4.error = e_3; + env_4.hasError = true; + } + finally { + __disposeResources(env_4); + } + } + try { + const env_5 = { stack: [], error: void 0, hasError: false }; + try { + const d23 = __addDisposableResource(env_5, { [Symbol.dispose]() { } }, false); + } + catch (e_4) { + env_5.error = e_4; + env_5.hasError = true; + } + finally { + __disposeResources(env_5); + } + } + catch (_b) { + const env_6 = { stack: [], error: void 0, hasError: false }; + try { + const d24 = __addDisposableResource(env_6, { [Symbol.dispose]() { } }, false); + } + catch (e_5) { + env_6.error = e_5; + env_6.hasError = true; + } + finally { + __disposeResources(env_6); + } + } + finally { + const env_7 = { stack: [], error: void 0, hasError: false }; + try { + const d25 = __addDisposableResource(env_7, { [Symbol.dispose]() { } }, false); + } + catch (e_6) { + env_7.error = e_6; + env_7.hasError = true; + } + finally { + __disposeResources(env_7); + } + } + if (true) { + const env_8 = { stack: [], error: void 0, hasError: false }; + try { + const d26 = __addDisposableResource(env_8, { [Symbol.dispose]() { } }, false); + } + catch (e_7) { + env_8.error = e_7; + env_8.hasError = true; + } + finally { + __disposeResources(env_8); + } + } + else { + const env_9 = { stack: [], error: void 0, hasError: false }; + try { + const d27 = __addDisposableResource(env_9, { [Symbol.dispose]() { } }, false); + } + catch (e_8) { + env_9.error = e_8; + env_9.hasError = true; + } + finally { + __disposeResources(env_9); + } + } + while (true) { + const env_10 = { stack: [], error: void 0, hasError: false }; + try { + const d28 = __addDisposableResource(env_10, { [Symbol.dispose]() { } }, false); + break; + } + catch (e_9) { + env_10.error = e_9; + env_10.hasError = true; + } + finally { + __disposeResources(env_10); + } + } + do { + const env_11 = { stack: [], error: void 0, hasError: false }; + try { + const d29 = __addDisposableResource(env_11, { [Symbol.dispose]() { } }, false); + break; + } + catch (e_10) { + env_11.error = e_10; + env_11.hasError = true; + } + finally { + __disposeResources(env_11); + } + } while (true); + for (;;) { + const env_12 = { stack: [], error: void 0, hasError: false }; + try { + const d30 = __addDisposableResource(env_12, { [Symbol.dispose]() { } }, false); + break; + } + catch (e_11) { + env_12.error = e_11; + env_12.hasError = true; + } + finally { + __disposeResources(env_12); + } + } + for (const x in {}) { + const env_13 = { stack: [], error: void 0, hasError: false }; + try { + const d31 = __addDisposableResource(env_13, { [Symbol.dispose]() { } }, false); + } + catch (e_12) { + env_13.error = e_12; + env_13.hasError = true; + } + finally { + __disposeResources(env_13); + } + } + for (const x of []) { + const env_14 = { stack: [], error: void 0, hasError: false }; + try { + const d32 = __addDisposableResource(env_14, { [Symbol.dispose]() { } }, false); + } + catch (e_13) { + env_14.error = e_13; + env_14.hasError = true; + } + finally { + __disposeResources(env_14); + } + } +} +catch (e_14) { + env_2.error = e_14; + env_2.hasError = true; +} +finally { + __disposeResources(env_2); +} +export {}; diff --git a/tests/baselines/reference/usingDeclarations.1(target=es2022).js b/tests/baselines/reference/usingDeclarations.1(target=es2022).js new file mode 100644 index 0000000000000..f5bf25b81c93b --- /dev/null +++ b/tests/baselines/reference/usingDeclarations.1(target=es2022).js @@ -0,0 +1,634 @@ +//// [tests/cases/conformance/statements/VariableStatements/usingDeclarations/usingDeclarations.1.ts] //// + +//// [usingDeclarations.1.ts] +using d1 = { [Symbol.dispose]() {} }; + +function f() { + using d2 = { [Symbol.dispose]() {} }; +} + +async function af() { + using d3 = { [Symbol.dispose]() {} }; + await null; +} + +function * g() { + using d4 = { [Symbol.dispose]() {} }; + yield; +} + +async function * ag() { + using d5 = { [Symbol.dispose]() {} }; + yield; + await null; +} + +const a = () => { + using d6 = { [Symbol.dispose]() {} }; +} + +class C1 { + a = () => { + using d7 = { [Symbol.dispose]() {} }; + } + + constructor() { + using d8 = { [Symbol.dispose]() {} }; + } + + static { + using d9 = { [Symbol.dispose]() {} }; + } + + m() { + using d10 = { [Symbol.dispose]() {} }; + } + + get x() { + using d11 = { [Symbol.dispose]() {} }; + return 0; + } + + set x(v) { + using d12 = { [Symbol.dispose]() {} }; + } + + async am() { + using d13 = { [Symbol.dispose]() {} }; + await null; + } + + * g() { + using d14 = { [Symbol.dispose]() {} }; + yield; + } + + async * ag() { + using d15 = { [Symbol.dispose]() {} }; + yield; + await null; + } +} + +class C2 extends C1 { + constructor() { + using d16 = { [Symbol.dispose]() {} }; + super(); + } +} + +class C3 extends C1 { + y = 1; + constructor() { + using d17 = { [Symbol.dispose]() {} }; + super(); + } +} + +namespace N { + using d18 = { [Symbol.dispose]() {} }; +} + +{ + using d19 = { [Symbol.dispose]() {} }; +} + +switch (Math.random()) { + case 0: + using d20 = { [Symbol.dispose]() {} }; + break; + + case 1: + using d21 = { [Symbol.dispose]() {} }; + break; +} + +if (true) + switch (0) { + case 0: + using d22 = { [Symbol.dispose]() {} }; + break; + } + +try { + using d23 = { [Symbol.dispose]() {} }; +} +catch { + using d24 = { [Symbol.dispose]() {} }; +} +finally { + using d25 = { [Symbol.dispose]() {} }; +} + +if (true) { + using d26 = { [Symbol.dispose]() {} }; +} +else { + using d27 = { [Symbol.dispose]() {} }; +} + +while (true) { + using d28 = { [Symbol.dispose]() {} }; + break; +} + +do { + using d29 = { [Symbol.dispose]() {} }; + break; +} +while (true); + +for (;;) { + using d30 = { [Symbol.dispose]() {} }; + break; +} + +for (const x in {}) { + using d31 = { [Symbol.dispose]() {} }; +} + +for (const x of []) { + using d32 = { [Symbol.dispose]() {} }; +} + +export {}; + +//// [usingDeclarations.1.js] +var __addDisposableResource = (this && this.__addDisposableResource) || function (env, value, async) { + if (value !== null && value !== void 0) { + if (typeof value !== "object") throw new TypeError("Object expected."); + var dispose; + if (async) { + if (!Symbol.asyncDispose) throw new TypeError("Symbol.asyncDispose is not defined."); + dispose = value[Symbol.asyncDispose]; + } + if (dispose === void 0) { + if (!Symbol.dispose) throw new TypeError("Symbol.dispose is not defined."); + dispose = value[Symbol.dispose]; + } + if (typeof dispose !== "function") throw new TypeError("Object not disposable."); + env.stack.push({ value: value, dispose: dispose, async: async }); + } + else if (async) { + env.stack.push({ async: true }); + } + return value; +}; +var __disposeResources = (this && this.__disposeResources) || (function (SuppressedError) { + return function (env) { + function fail(e) { + env.error = env.hasError ? new SuppressedError(e, env.error, "An error was suppressed during disposal.") : e; + env.hasError = true; + } + function next() { + while (env.stack.length) { + var rec = env.stack.pop(); + try { + var result = rec.dispose && rec.dispose.call(rec.value); + if (rec.async) return Promise.resolve(result).then(next, function(e) { fail(e); return next(); }); + } + catch (e) { + fail(e); + } + } + if (env.hasError) throw env.error; + } + return next(); + }; +})(typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) { + var e = new Error(message); + return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e; +}); +function f() { + const env_15 = { stack: [], error: void 0, hasError: false }; + try { + const d2 = __addDisposableResource(env_15, { [Symbol.dispose]() { } }, false); + } + catch (e_15) { + env_15.error = e_15; + env_15.hasError = true; + } + finally { + __disposeResources(env_15); + } +} +async function af() { + const env_16 = { stack: [], error: void 0, hasError: false }; + try { + const d3 = __addDisposableResource(env_16, { [Symbol.dispose]() { } }, false); + await null; + } + catch (e_16) { + env_16.error = e_16; + env_16.hasError = true; + } + finally { + __disposeResources(env_16); + } +} +function* g() { + const env_17 = { stack: [], error: void 0, hasError: false }; + try { + const d4 = __addDisposableResource(env_17, { [Symbol.dispose]() { } }, false); + yield; + } + catch (e_17) { + env_17.error = e_17; + env_17.hasError = true; + } + finally { + __disposeResources(env_17); + } +} +async function* ag() { + const env_18 = { stack: [], error: void 0, hasError: false }; + try { + const d5 = __addDisposableResource(env_18, { [Symbol.dispose]() { } }, false); + yield; + await null; + } + catch (e_18) { + env_18.error = e_18; + env_18.hasError = true; + } + finally { + __disposeResources(env_18); + } +} +var d1, a, C1, C2, C3, N, env_1; +const env_2 = { stack: [], error: void 0, hasError: false }; +try { + d1 = __addDisposableResource(env_2, { [Symbol.dispose]() { } }, false); + a = () => { + const env_19 = { stack: [], error: void 0, hasError: false }; + try { + const d6 = __addDisposableResource(env_19, { [Symbol.dispose]() { } }, false); + } + catch (e_19) { + env_19.error = e_19; + env_19.hasError = true; + } + finally { + __disposeResources(env_19); + } + }; + C1 = class C1 { + a = () => { + const env_20 = { stack: [], error: void 0, hasError: false }; + try { + const d7 = __addDisposableResource(env_20, { [Symbol.dispose]() { } }, false); + } + catch (e_20) { + env_20.error = e_20; + env_20.hasError = true; + } + finally { + __disposeResources(env_20); + } + }; + constructor() { + const env_21 = { stack: [], error: void 0, hasError: false }; + try { + const d8 = __addDisposableResource(env_21, { [Symbol.dispose]() { } }, false); + } + catch (e_21) { + env_21.error = e_21; + env_21.hasError = true; + } + finally { + __disposeResources(env_21); + } + } + static { + const env_22 = { stack: [], error: void 0, hasError: false }; + try { + const d9 = __addDisposableResource(env_22, { [Symbol.dispose]() { } }, false); + } + catch (e_22) { + env_22.error = e_22; + env_22.hasError = true; + } + finally { + __disposeResources(env_22); + } + } + m() { + const env_23 = { stack: [], error: void 0, hasError: false }; + try { + const d10 = __addDisposableResource(env_23, { [Symbol.dispose]() { } }, false); + } + catch (e_23) { + env_23.error = e_23; + env_23.hasError = true; + } + finally { + __disposeResources(env_23); + } + } + get x() { + const env_24 = { stack: [], error: void 0, hasError: false }; + try { + const d11 = __addDisposableResource(env_24, { [Symbol.dispose]() { } }, false); + return 0; + } + catch (e_24) { + env_24.error = e_24; + env_24.hasError = true; + } + finally { + __disposeResources(env_24); + } + } + set x(v) { + const env_25 = { stack: [], error: void 0, hasError: false }; + try { + const d12 = __addDisposableResource(env_25, { [Symbol.dispose]() { } }, false); + } + catch (e_25) { + env_25.error = e_25; + env_25.hasError = true; + } + finally { + __disposeResources(env_25); + } + } + async am() { + const env_26 = { stack: [], error: void 0, hasError: false }; + try { + const d13 = __addDisposableResource(env_26, { [Symbol.dispose]() { } }, false); + await null; + } + catch (e_26) { + env_26.error = e_26; + env_26.hasError = true; + } + finally { + __disposeResources(env_26); + } + } + *g() { + const env_27 = { stack: [], error: void 0, hasError: false }; + try { + const d14 = __addDisposableResource(env_27, { [Symbol.dispose]() { } }, false); + yield; + } + catch (e_27) { + env_27.error = e_27; + env_27.hasError = true; + } + finally { + __disposeResources(env_27); + } + } + async *ag() { + const env_28 = { stack: [], error: void 0, hasError: false }; + try { + const d15 = __addDisposableResource(env_28, { [Symbol.dispose]() { } }, false); + yield; + await null; + } + catch (e_28) { + env_28.error = e_28; + env_28.hasError = true; + } + finally { + __disposeResources(env_28); + } + } + }; + C2 = class C2 extends C1 { + constructor() { + const env_29 = { stack: [], error: void 0, hasError: false }; + try { + const d16 = __addDisposableResource(env_29, { [Symbol.dispose]() { } }, false); + super(); + } + catch (e_29) { + env_29.error = e_29; + env_29.hasError = true; + } + finally { + __disposeResources(env_29); + } + } + }; + C3 = class C3 extends C1 { + y = 1; + constructor() { + const env_30 = { stack: [], error: void 0, hasError: false }; + try { + const d17 = __addDisposableResource(env_30, { [Symbol.dispose]() { } }, false); + super(); + } + catch (e_30) { + env_30.error = e_30; + env_30.hasError = true; + } + finally { + __disposeResources(env_30); + } + } + }; + (function (N) { + const env_31 = { stack: [], error: void 0, hasError: false }; + try { + const d18 = __addDisposableResource(env_31, { [Symbol.dispose]() { } }, false); + } + catch (e_31) { + env_31.error = e_31; + env_31.hasError = true; + } + finally { + __disposeResources(env_31); + } + })(N || (N = {})); + { + const env_3 = { stack: [], error: void 0, hasError: false }; + try { + const d19 = __addDisposableResource(env_3, { [Symbol.dispose]() { } }, false); + } + catch (e_1) { + env_3.error = e_1; + env_3.hasError = true; + } + finally { + __disposeResources(env_3); + } + } + env_1 = { stack: [], error: void 0, hasError: false }; + try { + switch (Math.random()) { + case 0: + const d20 = __addDisposableResource(env_1, { [Symbol.dispose]() { } }, false); + break; + case 1: + const d21 = __addDisposableResource(env_1, { [Symbol.dispose]() { } }, false); + break; + } + } + catch (e_2) { + env_1.error = e_2; + env_1.hasError = true; + } + finally { + __disposeResources(env_1); + } + if (true) { + const env_4 = { stack: [], error: void 0, hasError: false }; + try { + switch (0) { + case 0: + const d22 = __addDisposableResource(env_4, { [Symbol.dispose]() { } }, false); + break; + } + } + catch (e_3) { + env_4.error = e_3; + env_4.hasError = true; + } + finally { + __disposeResources(env_4); + } + } + try { + const env_5 = { stack: [], error: void 0, hasError: false }; + try { + const d23 = __addDisposableResource(env_5, { [Symbol.dispose]() { } }, false); + } + catch (e_4) { + env_5.error = e_4; + env_5.hasError = true; + } + finally { + __disposeResources(env_5); + } + } + catch { + const env_6 = { stack: [], error: void 0, hasError: false }; + try { + const d24 = __addDisposableResource(env_6, { [Symbol.dispose]() { } }, false); + } + catch (e_5) { + env_6.error = e_5; + env_6.hasError = true; + } + finally { + __disposeResources(env_6); + } + } + finally { + const env_7 = { stack: [], error: void 0, hasError: false }; + try { + const d25 = __addDisposableResource(env_7, { [Symbol.dispose]() { } }, false); + } + catch (e_6) { + env_7.error = e_6; + env_7.hasError = true; + } + finally { + __disposeResources(env_7); + } + } + if (true) { + const env_8 = { stack: [], error: void 0, hasError: false }; + try { + const d26 = __addDisposableResource(env_8, { [Symbol.dispose]() { } }, false); + } + catch (e_7) { + env_8.error = e_7; + env_8.hasError = true; + } + finally { + __disposeResources(env_8); + } + } + else { + const env_9 = { stack: [], error: void 0, hasError: false }; + try { + const d27 = __addDisposableResource(env_9, { [Symbol.dispose]() { } }, false); + } + catch (e_8) { + env_9.error = e_8; + env_9.hasError = true; + } + finally { + __disposeResources(env_9); + } + } + while (true) { + const env_10 = { stack: [], error: void 0, hasError: false }; + try { + const d28 = __addDisposableResource(env_10, { [Symbol.dispose]() { } }, false); + break; + } + catch (e_9) { + env_10.error = e_9; + env_10.hasError = true; + } + finally { + __disposeResources(env_10); + } + } + do { + const env_11 = { stack: [], error: void 0, hasError: false }; + try { + const d29 = __addDisposableResource(env_11, { [Symbol.dispose]() { } }, false); + break; + } + catch (e_10) { + env_11.error = e_10; + env_11.hasError = true; + } + finally { + __disposeResources(env_11); + } + } while (true); + for (;;) { + const env_12 = { stack: [], error: void 0, hasError: false }; + try { + const d30 = __addDisposableResource(env_12, { [Symbol.dispose]() { } }, false); + break; + } + catch (e_11) { + env_12.error = e_11; + env_12.hasError = true; + } + finally { + __disposeResources(env_12); + } + } + for (const x in {}) { + const env_13 = { stack: [], error: void 0, hasError: false }; + try { + const d31 = __addDisposableResource(env_13, { [Symbol.dispose]() { } }, false); + } + catch (e_12) { + env_13.error = e_12; + env_13.hasError = true; + } + finally { + __disposeResources(env_13); + } + } + for (const x of []) { + const env_14 = { stack: [], error: void 0, hasError: false }; + try { + const d32 = __addDisposableResource(env_14, { [Symbol.dispose]() { } }, false); + } + catch (e_13) { + env_14.error = e_13; + env_14.hasError = true; + } + finally { + __disposeResources(env_14); + } + } +} +catch (e_14) { + env_2.error = e_14; + env_2.hasError = true; +} +finally { + __disposeResources(env_2); +} +export {}; diff --git a/tests/baselines/reference/usingDeclarations.1(target=es5).js b/tests/baselines/reference/usingDeclarations.1(target=es5).js new file mode 100644 index 0000000000000..369559dff3a1d --- /dev/null +++ b/tests/baselines/reference/usingDeclarations.1(target=es5).js @@ -0,0 +1,814 @@ +//// [tests/cases/conformance/statements/VariableStatements/usingDeclarations/usingDeclarations.1.ts] //// + +//// [usingDeclarations.1.ts] +using d1 = { [Symbol.dispose]() {} }; + +function f() { + using d2 = { [Symbol.dispose]() {} }; +} + +async function af() { + using d3 = { [Symbol.dispose]() {} }; + await null; +} + +function * g() { + using d4 = { [Symbol.dispose]() {} }; + yield; +} + +async function * ag() { + using d5 = { [Symbol.dispose]() {} }; + yield; + await null; +} + +const a = () => { + using d6 = { [Symbol.dispose]() {} }; +} + +class C1 { + a = () => { + using d7 = { [Symbol.dispose]() {} }; + } + + constructor() { + using d8 = { [Symbol.dispose]() {} }; + } + + static { + using d9 = { [Symbol.dispose]() {} }; + } + + m() { + using d10 = { [Symbol.dispose]() {} }; + } + + get x() { + using d11 = { [Symbol.dispose]() {} }; + return 0; + } + + set x(v) { + using d12 = { [Symbol.dispose]() {} }; + } + + async am() { + using d13 = { [Symbol.dispose]() {} }; + await null; + } + + * g() { + using d14 = { [Symbol.dispose]() {} }; + yield; + } + + async * ag() { + using d15 = { [Symbol.dispose]() {} }; + yield; + await null; + } +} + +class C2 extends C1 { + constructor() { + using d16 = { [Symbol.dispose]() {} }; + super(); + } +} + +class C3 extends C1 { + y = 1; + constructor() { + using d17 = { [Symbol.dispose]() {} }; + super(); + } +} + +namespace N { + using d18 = { [Symbol.dispose]() {} }; +} + +{ + using d19 = { [Symbol.dispose]() {} }; +} + +switch (Math.random()) { + case 0: + using d20 = { [Symbol.dispose]() {} }; + break; + + case 1: + using d21 = { [Symbol.dispose]() {} }; + break; +} + +if (true) + switch (0) { + case 0: + using d22 = { [Symbol.dispose]() {} }; + break; + } + +try { + using d23 = { [Symbol.dispose]() {} }; +} +catch { + using d24 = { [Symbol.dispose]() {} }; +} +finally { + using d25 = { [Symbol.dispose]() {} }; +} + +if (true) { + using d26 = { [Symbol.dispose]() {} }; +} +else { + using d27 = { [Symbol.dispose]() {} }; +} + +while (true) { + using d28 = { [Symbol.dispose]() {} }; + break; +} + +do { + using d29 = { [Symbol.dispose]() {} }; + break; +} +while (true); + +for (;;) { + using d30 = { [Symbol.dispose]() {} }; + break; +} + +for (const x in {}) { + using d31 = { [Symbol.dispose]() {} }; +} + +for (const x of []) { + using d32 = { [Symbol.dispose]() {} }; +} + +export {}; + +//// [usingDeclarations.1.js] +var __extends = (this && this.__extends) || (function () { + var extendStatics = function (d, b) { + extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; }; + return extendStatics(d, b); + }; + return function (d, b) { + if (typeof b !== "function" && b !== null) + throw new TypeError("Class extends value " + String(b) + " is not a constructor or null"); + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); +var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { + function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } + return new (P || (P = Promise))(function (resolve, reject) { + function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } + function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } + function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } + step((generator = generator.apply(thisArg, _arguments || [])).next()); + }); +}; +var __generator = (this && this.__generator) || function (thisArg, body) { + var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g; + return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g; + function verb(n) { return function (v) { return step([n, v]); }; } + function step(op) { + if (f) throw new TypeError("Generator is already executing."); + while (g && (g = 0, op[0] && (_ = 0)), _) try { + if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t; + if (y = 0, t) op = [op[0] & 2, t.value]; + switch (op[0]) { + case 0: case 1: t = op; break; + case 4: _.label++; return { value: op[1], done: false }; + case 5: _.label++; y = op[1]; op = [0]; continue; + case 7: op = _.ops.pop(); _.trys.pop(); continue; + default: + if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; } + if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; } + if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; } + if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; } + if (t[2]) _.ops.pop(); + _.trys.pop(); continue; + } + op = body.call(thisArg, _); + } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; } + if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true }; + } +}; +var __addDisposableResource = (this && this.__addDisposableResource) || function (env, value, async) { + if (value !== null && value !== void 0) { + if (typeof value !== "object") throw new TypeError("Object expected."); + var dispose; + if (async) { + if (!Symbol.asyncDispose) throw new TypeError("Symbol.asyncDispose is not defined."); + dispose = value[Symbol.asyncDispose]; + } + if (dispose === void 0) { + if (!Symbol.dispose) throw new TypeError("Symbol.dispose is not defined."); + dispose = value[Symbol.dispose]; + } + if (typeof dispose !== "function") throw new TypeError("Object not disposable."); + env.stack.push({ value: value, dispose: dispose, async: async }); + } + else if (async) { + env.stack.push({ async: true }); + } + return value; +}; +var __disposeResources = (this && this.__disposeResources) || (function (SuppressedError) { + return function (env) { + function fail(e) { + env.error = env.hasError ? new SuppressedError(e, env.error, "An error was suppressed during disposal.") : e; + env.hasError = true; + } + function next() { + while (env.stack.length) { + var rec = env.stack.pop(); + try { + var result = rec.dispose && rec.dispose.call(rec.value); + if (rec.async) return Promise.resolve(result).then(next, function(e) { fail(e); return next(); }); + } + catch (e) { + fail(e); + } + } + if (env.hasError) throw env.error; + } + return next(); + }; +})(typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) { + var e = new Error(message); + return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e; +}); +var __await = (this && this.__await) || function (v) { return this instanceof __await ? (this.v = v, this) : new __await(v); } +var __asyncGenerator = (this && this.__asyncGenerator) || function (thisArg, _arguments, generator) { + if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined."); + var g = generator.apply(thisArg, _arguments || []), i, q = []; + return i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i; + function verb(n) { if (g[n]) i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; } + function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(q[0][3], e); } } + function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); } + function fulfill(value) { resume("next", value); } + function reject(value) { resume("throw", value); } + function settle(f, v) { if (f(v), q.shift(), q.length) resume(q[0][0], q[0][1]); } +}; +var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q; +var _r; +function f() { + var _a; + var env_15 = { stack: [], error: void 0, hasError: false }; + try { + var d2 = __addDisposableResource(env_15, (_a = {}, _a[Symbol.dispose] = function () { }, _a), false); + } + catch (e_15) { + env_15.error = e_15; + env_15.hasError = true; + } + finally { + __disposeResources(env_15); + } +} +function af() { + return __awaiter(this, void 0, void 0, function () { + var env_16, d3, e_16; + var _a; + return __generator(this, function (_b) { + switch (_b.label) { + case 0: + env_16 = { stack: [], error: void 0, hasError: false }; + _b.label = 1; + case 1: + _b.trys.push([1, 3, 4, 5]); + d3 = __addDisposableResource(env_16, (_a = {}, _a[Symbol.dispose] = function () { }, _a), false); + return [4 /*yield*/, null]; + case 2: + _b.sent(); + return [3 /*break*/, 5]; + case 3: + e_16 = _b.sent(); + env_16.error = e_16; + env_16.hasError = true; + return [3 /*break*/, 5]; + case 4: + __disposeResources(env_16); + return [7 /*endfinally*/]; + case 5: return [2 /*return*/]; + } + }); + }); +} +function g() { + var env_17, d4, e_17; + var _a; + return __generator(this, function (_b) { + switch (_b.label) { + case 0: + env_17 = { stack: [], error: void 0, hasError: false }; + _b.label = 1; + case 1: + _b.trys.push([1, 3, 4, 5]); + d4 = __addDisposableResource(env_17, (_a = {}, _a[Symbol.dispose] = function () { }, _a), false); + return [4 /*yield*/]; + case 2: + _b.sent(); + return [3 /*break*/, 5]; + case 3: + e_17 = _b.sent(); + env_17.error = e_17; + env_17.hasError = true; + return [3 /*break*/, 5]; + case 4: + __disposeResources(env_17); + return [7 /*endfinally*/]; + case 5: return [2 /*return*/]; + } + }); +} +function ag() { + return __asyncGenerator(this, arguments, function ag_1() { + var env_18, d5, e_18; + var _a; + return __generator(this, function (_b) { + switch (_b.label) { + case 0: + env_18 = { stack: [], error: void 0, hasError: false }; + _b.label = 1; + case 1: + _b.trys.push([1, 5, 6, 7]); + d5 = __addDisposableResource(env_18, (_a = {}, _a[Symbol.dispose] = function () { }, _a), false); + return [4 /*yield*/, __await(void 0)]; + case 2: return [4 /*yield*/, _b.sent()]; + case 3: + _b.sent(); + return [4 /*yield*/, __await(null)]; + case 4: + _b.sent(); + return [3 /*break*/, 7]; + case 5: + e_18 = _b.sent(); + env_18.error = e_18; + env_18.hasError = true; + return [3 /*break*/, 7]; + case 6: + __disposeResources(env_18); + return [7 /*endfinally*/]; + case 7: return [2 /*return*/]; + } + }); + }); +} +var d1, a, C1, C2, C3, N, env_1; +var env_2 = { stack: [], error: void 0, hasError: false }; +try { + d1 = __addDisposableResource(env_2, (_a = {}, _a[Symbol.dispose] = function () { }, _a), false); + a = function () { + var _a; + var env_19 = { stack: [], error: void 0, hasError: false }; + try { + var d6 = __addDisposableResource(env_19, (_a = {}, _a[Symbol.dispose] = function () { }, _a), false); + } + catch (e_19) { + env_19.error = e_19; + env_19.hasError = true; + } + finally { + __disposeResources(env_19); + } + }; + C1 = (_r = /** @class */ (function () { + function C1() { + var _a; + this.a = function () { + var _a; + var env_21 = { stack: [], error: void 0, hasError: false }; + try { + var d7 = __addDisposableResource(env_21, (_a = {}, _a[Symbol.dispose] = function () { }, _a), false); + } + catch (e_21) { + env_21.error = e_21; + env_21.hasError = true; + } + finally { + __disposeResources(env_21); + } + }; + var env_20 = { stack: [], error: void 0, hasError: false }; + try { + var d8 = __addDisposableResource(env_20, (_a = {}, _a[Symbol.dispose] = function () { }, _a), false); + } + catch (e_20) { + env_20.error = e_20; + env_20.hasError = true; + } + finally { + __disposeResources(env_20); + } + } + C1.prototype.m = function () { + var _a; + var env_22 = { stack: [], error: void 0, hasError: false }; + try { + var d10 = __addDisposableResource(env_22, (_a = {}, _a[Symbol.dispose] = function () { }, _a), false); + } + catch (e_22) { + env_22.error = e_22; + env_22.hasError = true; + } + finally { + __disposeResources(env_22); + } + }; + Object.defineProperty(C1.prototype, "x", { + get: function () { + var _a; + var env_23 = { stack: [], error: void 0, hasError: false }; + try { + var d11 = __addDisposableResource(env_23, (_a = {}, _a[Symbol.dispose] = function () { }, _a), false); + return 0; + } + catch (e_23) { + env_23.error = e_23; + env_23.hasError = true; + } + finally { + __disposeResources(env_23); + } + }, + set: function (v) { + var _a; + var env_24 = { stack: [], error: void 0, hasError: false }; + try { + var d12 = __addDisposableResource(env_24, (_a = {}, _a[Symbol.dispose] = function () { }, _a), false); + } + catch (e_24) { + env_24.error = e_24; + env_24.hasError = true; + } + finally { + __disposeResources(env_24); + } + }, + enumerable: false, + configurable: true + }); + C1.prototype.am = function () { + return __awaiter(this, void 0, void 0, function () { + var env_25, d13, e_25; + var _a; + return __generator(this, function (_b) { + switch (_b.label) { + case 0: + env_25 = { stack: [], error: void 0, hasError: false }; + _b.label = 1; + case 1: + _b.trys.push([1, 3, 4, 5]); + d13 = __addDisposableResource(env_25, (_a = {}, _a[Symbol.dispose] = function () { }, _a), false); + return [4 /*yield*/, null]; + case 2: + _b.sent(); + return [3 /*break*/, 5]; + case 3: + e_25 = _b.sent(); + env_25.error = e_25; + env_25.hasError = true; + return [3 /*break*/, 5]; + case 4: + __disposeResources(env_25); + return [7 /*endfinally*/]; + case 5: return [2 /*return*/]; + } + }); + }); + }; + C1.prototype.g = function () { + var env_26, d14, e_26; + var _a; + return __generator(this, function (_b) { + switch (_b.label) { + case 0: + env_26 = { stack: [], error: void 0, hasError: false }; + _b.label = 1; + case 1: + _b.trys.push([1, 3, 4, 5]); + d14 = __addDisposableResource(env_26, (_a = {}, _a[Symbol.dispose] = function () { }, _a), false); + return [4 /*yield*/]; + case 2: + _b.sent(); + return [3 /*break*/, 5]; + case 3: + e_26 = _b.sent(); + env_26.error = e_26; + env_26.hasError = true; + return [3 /*break*/, 5]; + case 4: + __disposeResources(env_26); + return [7 /*endfinally*/]; + case 5: return [2 /*return*/]; + } + }); + }; + C1.prototype.ag = function () { + return __asyncGenerator(this, arguments, function ag_2() { + var env_27, d15, e_27; + var _a; + return __generator(this, function (_b) { + switch (_b.label) { + case 0: + env_27 = { stack: [], error: void 0, hasError: false }; + _b.label = 1; + case 1: + _b.trys.push([1, 5, 6, 7]); + d15 = __addDisposableResource(env_27, (_a = {}, _a[Symbol.dispose] = function () { }, _a), false); + return [4 /*yield*/, __await(void 0)]; + case 2: return [4 /*yield*/, _b.sent()]; + case 3: + _b.sent(); + return [4 /*yield*/, __await(null)]; + case 4: + _b.sent(); + return [3 /*break*/, 7]; + case 5: + e_27 = _b.sent(); + env_27.error = e_27; + env_27.hasError = true; + return [3 /*break*/, 7]; + case 6: + __disposeResources(env_27); + return [7 /*endfinally*/]; + case 7: return [2 /*return*/]; + } + }); + }); + }; + return C1; + }()), + (function () { + var _a; + var env_28 = { stack: [], error: void 0, hasError: false }; + try { + var d9 = __addDisposableResource(env_28, (_a = {}, _a[Symbol.dispose] = function () { }, _a), false); + } + catch (e_28) { + env_28.error = e_28; + env_28.hasError = true; + } + finally { + __disposeResources(env_28); + } + })(), + _r); + C2 = /** @class */ (function (_super) { + __extends(C2, _super); + function C2() { + var _a; + var env_29 = { stack: [], error: void 0, hasError: false }; + try { + var d16 = __addDisposableResource(env_29, (_a = {}, _a[Symbol.dispose] = function () { }, _a), false); + return _super.call(this) || this; + } + catch (e_29) { + env_29.error = e_29; + env_29.hasError = true; + } + finally { + __disposeResources(env_29); + } + } + return C2; + }(C1)); + C3 = /** @class */ (function (_super) { + __extends(C3, _super); + function C3() { + var _a; + var env_30 = { stack: [], error: void 0, hasError: false }; + try { + var _this = _super.call(this) || this; + var d17 = __addDisposableResource(env_30, (_a = {}, _a[Symbol.dispose] = function () { }, _a), false); + _this.y = 1; + } + catch (e_30) { + env_30.error = e_30; + env_30.hasError = true; + } + finally { + __disposeResources(env_30); + } + return _this; + } + return C3; + }(C1)); + (function (N) { + var _a; + var env_31 = { stack: [], error: void 0, hasError: false }; + try { + var d18 = __addDisposableResource(env_31, (_a = {}, _a[Symbol.dispose] = function () { }, _a), false); + } + catch (e_31) { + env_31.error = e_31; + env_31.hasError = true; + } + finally { + __disposeResources(env_31); + } + })(N || (N = {})); + { + var env_3 = { stack: [], error: void 0, hasError: false }; + try { + var d19 = __addDisposableResource(env_3, (_b = {}, _b[Symbol.dispose] = function () { }, _b), false); + } + catch (e_1) { + env_3.error = e_1; + env_3.hasError = true; + } + finally { + __disposeResources(env_3); + } + } + env_1 = { stack: [], error: void 0, hasError: false }; + try { + switch (Math.random()) { + case 0: + var d20 = __addDisposableResource(env_1, (_c = {}, _c[Symbol.dispose] = function () { }, _c), false); + break; + case 1: + var d21 = __addDisposableResource(env_1, (_d = {}, _d[Symbol.dispose] = function () { }, _d), false); + break; + } + } + catch (e_2) { + env_1.error = e_2; + env_1.hasError = true; + } + finally { + __disposeResources(env_1); + } + if (true) { + var env_4 = { stack: [], error: void 0, hasError: false }; + try { + switch (0) { + case 0: + var d22 = __addDisposableResource(env_4, (_e = {}, _e[Symbol.dispose] = function () { }, _e), false); + break; + } + } + catch (e_3) { + env_4.error = e_3; + env_4.hasError = true; + } + finally { + __disposeResources(env_4); + } + } + try { + var env_5 = { stack: [], error: void 0, hasError: false }; + try { + var d23 = __addDisposableResource(env_5, (_f = {}, _f[Symbol.dispose] = function () { }, _f), false); + } + catch (e_4) { + env_5.error = e_4; + env_5.hasError = true; + } + finally { + __disposeResources(env_5); + } + } + catch (_s) { + var env_6 = { stack: [], error: void 0, hasError: false }; + try { + var d24 = __addDisposableResource(env_6, (_g = {}, _g[Symbol.dispose] = function () { }, _g), false); + } + catch (e_5) { + env_6.error = e_5; + env_6.hasError = true; + } + finally { + __disposeResources(env_6); + } + } + finally { + var env_7 = { stack: [], error: void 0, hasError: false }; + try { + var d25 = __addDisposableResource(env_7, (_h = {}, _h[Symbol.dispose] = function () { }, _h), false); + } + catch (e_6) { + env_7.error = e_6; + env_7.hasError = true; + } + finally { + __disposeResources(env_7); + } + } + if (true) { + var env_8 = { stack: [], error: void 0, hasError: false }; + try { + var d26 = __addDisposableResource(env_8, (_j = {}, _j[Symbol.dispose] = function () { }, _j), false); + } + catch (e_7) { + env_8.error = e_7; + env_8.hasError = true; + } + finally { + __disposeResources(env_8); + } + } + else { + var env_9 = { stack: [], error: void 0, hasError: false }; + try { + var d27 = __addDisposableResource(env_9, (_k = {}, _k[Symbol.dispose] = function () { }, _k), false); + } + catch (e_8) { + env_9.error = e_8; + env_9.hasError = true; + } + finally { + __disposeResources(env_9); + } + } + while (true) { + var env_10 = { stack: [], error: void 0, hasError: false }; + try { + var d28 = __addDisposableResource(env_10, (_l = {}, _l[Symbol.dispose] = function () { }, _l), false); + break; + } + catch (e_9) { + env_10.error = e_9; + env_10.hasError = true; + } + finally { + __disposeResources(env_10); + } + } + do { + var env_11 = { stack: [], error: void 0, hasError: false }; + try { + var d29 = __addDisposableResource(env_11, (_m = {}, _m[Symbol.dispose] = function () { }, _m), false); + break; + } + catch (e_10) { + env_11.error = e_10; + env_11.hasError = true; + } + finally { + __disposeResources(env_11); + } + } while (true); + for (;;) { + var env_12 = { stack: [], error: void 0, hasError: false }; + try { + var d30 = __addDisposableResource(env_12, (_o = {}, _o[Symbol.dispose] = function () { }, _o), false); + break; + } + catch (e_11) { + env_12.error = e_11; + env_12.hasError = true; + } + finally { + __disposeResources(env_12); + } + } + for (var x in {}) { + var env_13 = { stack: [], error: void 0, hasError: false }; + try { + var d31 = __addDisposableResource(env_13, (_p = {}, _p[Symbol.dispose] = function () { }, _p), false); + } + catch (e_12) { + env_13.error = e_12; + env_13.hasError = true; + } + finally { + __disposeResources(env_13); + } + } + for (var _i = 0, _t = []; _i < _t.length; _i++) { + var x = _t[_i]; + var env_14 = { stack: [], error: void 0, hasError: false }; + try { + var d32 = __addDisposableResource(env_14, (_q = {}, _q[Symbol.dispose] = function () { }, _q), false); + } + catch (e_13) { + env_14.error = e_13; + env_14.hasError = true; + } + finally { + __disposeResources(env_14); + } + } +} +catch (e_14) { + env_2.error = e_14; + env_2.hasError = true; +} +finally { + __disposeResources(env_2); +} +export {}; diff --git a/tests/baselines/reference/usingDeclarations.1(target=esnext).js b/tests/baselines/reference/usingDeclarations.1(target=esnext).js new file mode 100644 index 0000000000000..7f52b6f359409 --- /dev/null +++ b/tests/baselines/reference/usingDeclarations.1(target=esnext).js @@ -0,0 +1,278 @@ +//// [tests/cases/conformance/statements/VariableStatements/usingDeclarations/usingDeclarations.1.ts] //// + +//// [usingDeclarations.1.ts] +using d1 = { [Symbol.dispose]() {} }; + +function f() { + using d2 = { [Symbol.dispose]() {} }; +} + +async function af() { + using d3 = { [Symbol.dispose]() {} }; + await null; +} + +function * g() { + using d4 = { [Symbol.dispose]() {} }; + yield; +} + +async function * ag() { + using d5 = { [Symbol.dispose]() {} }; + yield; + await null; +} + +const a = () => { + using d6 = { [Symbol.dispose]() {} }; +} + +class C1 { + a = () => { + using d7 = { [Symbol.dispose]() {} }; + } + + constructor() { + using d8 = { [Symbol.dispose]() {} }; + } + + static { + using d9 = { [Symbol.dispose]() {} }; + } + + m() { + using d10 = { [Symbol.dispose]() {} }; + } + + get x() { + using d11 = { [Symbol.dispose]() {} }; + return 0; + } + + set x(v) { + using d12 = { [Symbol.dispose]() {} }; + } + + async am() { + using d13 = { [Symbol.dispose]() {} }; + await null; + } + + * g() { + using d14 = { [Symbol.dispose]() {} }; + yield; + } + + async * ag() { + using d15 = { [Symbol.dispose]() {} }; + yield; + await null; + } +} + +class C2 extends C1 { + constructor() { + using d16 = { [Symbol.dispose]() {} }; + super(); + } +} + +class C3 extends C1 { + y = 1; + constructor() { + using d17 = { [Symbol.dispose]() {} }; + super(); + } +} + +namespace N { + using d18 = { [Symbol.dispose]() {} }; +} + +{ + using d19 = { [Symbol.dispose]() {} }; +} + +switch (Math.random()) { + case 0: + using d20 = { [Symbol.dispose]() {} }; + break; + + case 1: + using d21 = { [Symbol.dispose]() {} }; + break; +} + +if (true) + switch (0) { + case 0: + using d22 = { [Symbol.dispose]() {} }; + break; + } + +try { + using d23 = { [Symbol.dispose]() {} }; +} +catch { + using d24 = { [Symbol.dispose]() {} }; +} +finally { + using d25 = { [Symbol.dispose]() {} }; +} + +if (true) { + using d26 = { [Symbol.dispose]() {} }; +} +else { + using d27 = { [Symbol.dispose]() {} }; +} + +while (true) { + using d28 = { [Symbol.dispose]() {} }; + break; +} + +do { + using d29 = { [Symbol.dispose]() {} }; + break; +} +while (true); + +for (;;) { + using d30 = { [Symbol.dispose]() {} }; + break; +} + +for (const x in {}) { + using d31 = { [Symbol.dispose]() {} }; +} + +for (const x of []) { + using d32 = { [Symbol.dispose]() {} }; +} + +export {}; + +//// [usingDeclarations.1.js] +using d1 = { [Symbol.dispose]() { } }; +function f() { + using d2 = { [Symbol.dispose]() { } }; +} +async function af() { + using d3 = { [Symbol.dispose]() { } }; + await null; +} +function* g() { + using d4 = { [Symbol.dispose]() { } }; + yield; +} +async function* ag() { + using d5 = { [Symbol.dispose]() { } }; + yield; + await null; +} +const a = () => { + using d6 = { [Symbol.dispose]() { } }; +}; +class C1 { + a = () => { + using d7 = { [Symbol.dispose]() { } }; + }; + constructor() { + using d8 = { [Symbol.dispose]() { } }; + } + static { + using d9 = { [Symbol.dispose]() { } }; + } + m() { + using d10 = { [Symbol.dispose]() { } }; + } + get x() { + using d11 = { [Symbol.dispose]() { } }; + return 0; + } + set x(v) { + using d12 = { [Symbol.dispose]() { } }; + } + async am() { + using d13 = { [Symbol.dispose]() { } }; + await null; + } + *g() { + using d14 = { [Symbol.dispose]() { } }; + yield; + } + async *ag() { + using d15 = { [Symbol.dispose]() { } }; + yield; + await null; + } +} +class C2 extends C1 { + constructor() { + using d16 = { [Symbol.dispose]() { } }; + super(); + } +} +class C3 extends C1 { + y = 1; + constructor() { + using d17 = { [Symbol.dispose]() { } }; + super(); + } +} +var N; +(function (N) { + using d18 = { [Symbol.dispose]() { } }; +})(N || (N = {})); +{ + using d19 = { [Symbol.dispose]() { } }; +} +switch (Math.random()) { + case 0: + using d20 = { [Symbol.dispose]() { } }; + break; + case 1: + using d21 = { [Symbol.dispose]() { } }; + break; +} +if (true) + switch (0) { + case 0: + using d22 = { [Symbol.dispose]() { } }; + break; + } +try { + using d23 = { [Symbol.dispose]() { } }; +} +catch { + using d24 = { [Symbol.dispose]() { } }; +} +finally { + using d25 = { [Symbol.dispose]() { } }; +} +if (true) { + using d26 = { [Symbol.dispose]() { } }; +} +else { + using d27 = { [Symbol.dispose]() { } }; +} +while (true) { + using d28 = { [Symbol.dispose]() { } }; + break; +} +do { + using d29 = { [Symbol.dispose]() { } }; + break; +} while (true); +for (;;) { + using d30 = { [Symbol.dispose]() { } }; + break; +} +for (const x in {}) { + using d31 = { [Symbol.dispose]() { } }; +} +for (const x of []) { + using d32 = { [Symbol.dispose]() { } }; +} +export {}; diff --git a/tests/baselines/reference/usingDeclarations.10.errors.txt b/tests/baselines/reference/usingDeclarations.10.errors.txt new file mode 100644 index 0000000000000..b53dd18962da7 --- /dev/null +++ b/tests/baselines/reference/usingDeclarations.10.errors.txt @@ -0,0 +1,9 @@ +usingDeclarations.10.ts(2,8): error TS1156: 'using' declarations can only be declared inside a block. + + +==== usingDeclarations.10.ts (1 errors) ==== + declare var x: any; + if (x) using a = null; + ~~~~~~~~~~~~~~~ +!!! error TS1156: 'using' declarations can only be declared inside a block. + \ No newline at end of file diff --git a/tests/baselines/reference/usingDeclarations.10.js b/tests/baselines/reference/usingDeclarations.10.js new file mode 100644 index 0000000000000..91c2e067aef7a --- /dev/null +++ b/tests/baselines/reference/usingDeclarations.10.js @@ -0,0 +1,10 @@ +//// [tests/cases/conformance/statements/VariableStatements/usingDeclarations/usingDeclarations.10.ts] //// + +//// [usingDeclarations.10.ts] +declare var x: any; +if (x) using a = null; + + +//// [usingDeclarations.10.js] +if (x) + using a = null; diff --git a/tests/baselines/reference/usingDeclarations.11.js b/tests/baselines/reference/usingDeclarations.11.js new file mode 100644 index 0000000000000..3cce2dda67ff0 --- /dev/null +++ b/tests/baselines/reference/usingDeclarations.11.js @@ -0,0 +1,202 @@ +//// [tests/cases/conformance/statements/VariableStatements/usingDeclarations/usingDeclarations.11.ts] //// + +//// [usingDeclarations.11.ts] +class A {} +class C1 extends A { + constructor() { + using x = null; + super(); + } +} +class C2 extends A { + constructor() { + super(); + using x = null; + } +} +class C3 extends A { + y = 1; + constructor() { + using x = null; + super(); + } +} +class C4 extends A { + constructor(public y: number) { + using x = null; + super(); + } +} +class C5 extends A { + z = 1; + constructor(public y: number) { + using x = null; + super(); + } +} + + +//// [usingDeclarations.11.js] +var __extends = (this && this.__extends) || (function () { + var extendStatics = function (d, b) { + extendStatics = Object.setPrototypeOf || + ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || + function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; }; + return extendStatics(d, b); + }; + return function (d, b) { + if (typeof b !== "function" && b !== null) + throw new TypeError("Class extends value " + String(b) + " is not a constructor or null"); + extendStatics(d, b); + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); + }; +})(); +var __addDisposableResource = (this && this.__addDisposableResource) || function (env, value, async) { + if (value !== null && value !== void 0) { + if (typeof value !== "object") throw new TypeError("Object expected."); + var dispose; + if (async) { + if (!Symbol.asyncDispose) throw new TypeError("Symbol.asyncDispose is not defined."); + dispose = value[Symbol.asyncDispose]; + } + if (dispose === void 0) { + if (!Symbol.dispose) throw new TypeError("Symbol.dispose is not defined."); + dispose = value[Symbol.dispose]; + } + if (typeof dispose !== "function") throw new TypeError("Object not disposable."); + env.stack.push({ value: value, dispose: dispose, async: async }); + } + else if (async) { + env.stack.push({ async: true }); + } + return value; +}; +var __disposeResources = (this && this.__disposeResources) || (function (SuppressedError) { + return function (env) { + function fail(e) { + env.error = env.hasError ? new SuppressedError(e, env.error, "An error was suppressed during disposal.") : e; + env.hasError = true; + } + function next() { + while (env.stack.length) { + var rec = env.stack.pop(); + try { + var result = rec.dispose && rec.dispose.call(rec.value); + if (rec.async) return Promise.resolve(result).then(next, function(e) { fail(e); return next(); }); + } + catch (e) { + fail(e); + } + } + if (env.hasError) throw env.error; + } + return next(); + }; +})(typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) { + var e = new Error(message); + return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e; +}); +var A = /** @class */ (function () { + function A() { + } + return A; +}()); +var C1 = /** @class */ (function (_super) { + __extends(C1, _super); + function C1() { + var env_1 = { stack: [], error: void 0, hasError: false }; + try { + var x = __addDisposableResource(env_1, null, false); + return _super.call(this) || this; + } + catch (e_1) { + env_1.error = e_1; + env_1.hasError = true; + } + finally { + __disposeResources(env_1); + } + } + return C1; +}(A)); +var C2 = /** @class */ (function (_super) { + __extends(C2, _super); + function C2() { + var env_2 = { stack: [], error: void 0, hasError: false }; + try { + var _this = _super.call(this) || this; + var x = __addDisposableResource(env_2, null, false); + } + catch (e_2) { + env_2.error = e_2; + env_2.hasError = true; + } + finally { + __disposeResources(env_2); + } + return _this; + } + return C2; +}(A)); +var C3 = /** @class */ (function (_super) { + __extends(C3, _super); + function C3() { + var env_3 = { stack: [], error: void 0, hasError: false }; + try { + var _this = _super.call(this) || this; + var x = __addDisposableResource(env_3, null, false); + _this.y = 1; + } + catch (e_3) { + env_3.error = e_3; + env_3.hasError = true; + } + finally { + __disposeResources(env_3); + } + return _this; + } + return C3; +}(A)); +var C4 = /** @class */ (function (_super) { + __extends(C4, _super); + function C4(y) { + var env_4 = { stack: [], error: void 0, hasError: false }; + try { + var _this = _super.call(this) || this; + var x = __addDisposableResource(env_4, null, false); + _this.y = y; + } + catch (e_4) { + env_4.error = e_4; + env_4.hasError = true; + } + finally { + __disposeResources(env_4); + } + return _this; + } + return C4; +}(A)); +var C5 = /** @class */ (function (_super) { + __extends(C5, _super); + function C5(y) { + var env_5 = { stack: [], error: void 0, hasError: false }; + try { + var _this = _super.call(this) || this; + var x = __addDisposableResource(env_5, null, false); + _this.y = y; + _this.z = 1; + } + catch (e_5) { + env_5.error = e_5; + env_5.hasError = true; + } + finally { + __disposeResources(env_5); + } + return _this; + } + return C5; +}(A)); diff --git a/tests/baselines/reference/usingDeclarations.12(usedefineforclassfields=false).js b/tests/baselines/reference/usingDeclarations.12(usedefineforclassfields=false).js new file mode 100644 index 0000000000000..768b5142fd37d --- /dev/null +++ b/tests/baselines/reference/usingDeclarations.12(usedefineforclassfields=false).js @@ -0,0 +1,81 @@ +//// [tests/cases/conformance/statements/VariableStatements/usingDeclarations/usingDeclarations.12.ts] //// + +//// [usingDeclarations.12.ts] +class C1 { + constructor() {} +} + +class C2 extends C1 { + y = 1; + constructor() { + super(); + using d17 = { [Symbol.dispose]() {} }; + } +} + +//// [usingDeclarations.12.js] +var __addDisposableResource = (this && this.__addDisposableResource) || function (env, value, async) { + if (value !== null && value !== void 0) { + if (typeof value !== "object") throw new TypeError("Object expected."); + var dispose; + if (async) { + if (!Symbol.asyncDispose) throw new TypeError("Symbol.asyncDispose is not defined."); + dispose = value[Symbol.asyncDispose]; + } + if (dispose === void 0) { + if (!Symbol.dispose) throw new TypeError("Symbol.dispose is not defined."); + dispose = value[Symbol.dispose]; + } + if (typeof dispose !== "function") throw new TypeError("Object not disposable."); + env.stack.push({ value: value, dispose: dispose, async: async }); + } + else if (async) { + env.stack.push({ async: true }); + } + return value; +}; +var __disposeResources = (this && this.__disposeResources) || (function (SuppressedError) { + return function (env) { + function fail(e) { + env.error = env.hasError ? new SuppressedError(e, env.error, "An error was suppressed during disposal.") : e; + env.hasError = true; + } + function next() { + while (env.stack.length) { + var rec = env.stack.pop(); + try { + var result = rec.dispose && rec.dispose.call(rec.value); + if (rec.async) return Promise.resolve(result).then(next, function(e) { fail(e); return next(); }); + } + catch (e) { + fail(e); + } + } + if (env.hasError) throw env.error; + } + return next(); + }; +})(typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) { + var e = new Error(message); + return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e; +}); +class C1 { + constructor() { } +} +class C2 extends C1 { + constructor() { + const env_1 = { stack: [], error: void 0, hasError: false }; + try { + super(); + this.y = 1; + const d17 = __addDisposableResource(env_1, { [Symbol.dispose]() { } }, false); + } + catch (e_1) { + env_1.error = e_1; + env_1.hasError = true; + } + finally { + __disposeResources(env_1); + } + } +} diff --git a/tests/baselines/reference/usingDeclarations.12(usedefineforclassfields=true).js b/tests/baselines/reference/usingDeclarations.12(usedefineforclassfields=true).js new file mode 100644 index 0000000000000..641d086c19ea4 --- /dev/null +++ b/tests/baselines/reference/usingDeclarations.12(usedefineforclassfields=true).js @@ -0,0 +1,86 @@ +//// [tests/cases/conformance/statements/VariableStatements/usingDeclarations/usingDeclarations.12.ts] //// + +//// [usingDeclarations.12.ts] +class C1 { + constructor() {} +} + +class C2 extends C1 { + y = 1; + constructor() { + super(); + using d17 = { [Symbol.dispose]() {} }; + } +} + +//// [usingDeclarations.12.js] +var __addDisposableResource = (this && this.__addDisposableResource) || function (env, value, async) { + if (value !== null && value !== void 0) { + if (typeof value !== "object") throw new TypeError("Object expected."); + var dispose; + if (async) { + if (!Symbol.asyncDispose) throw new TypeError("Symbol.asyncDispose is not defined."); + dispose = value[Symbol.asyncDispose]; + } + if (dispose === void 0) { + if (!Symbol.dispose) throw new TypeError("Symbol.dispose is not defined."); + dispose = value[Symbol.dispose]; + } + if (typeof dispose !== "function") throw new TypeError("Object not disposable."); + env.stack.push({ value: value, dispose: dispose, async: async }); + } + else if (async) { + env.stack.push({ async: true }); + } + return value; +}; +var __disposeResources = (this && this.__disposeResources) || (function (SuppressedError) { + return function (env) { + function fail(e) { + env.error = env.hasError ? new SuppressedError(e, env.error, "An error was suppressed during disposal.") : e; + env.hasError = true; + } + function next() { + while (env.stack.length) { + var rec = env.stack.pop(); + try { + var result = rec.dispose && rec.dispose.call(rec.value); + if (rec.async) return Promise.resolve(result).then(next, function(e) { fail(e); return next(); }); + } + catch (e) { + fail(e); + } + } + if (env.hasError) throw env.error; + } + return next(); + }; +})(typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) { + var e = new Error(message); + return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e; +}); +class C1 { + constructor() { } +} +class C2 extends C1 { + constructor() { + const env_1 = { stack: [], error: void 0, hasError: false }; + try { + super(); + Object.defineProperty(this, "y", { + enumerable: true, + configurable: true, + writable: true, + value: 1 + }); + const d17 = __addDisposableResource(env_1, { [Symbol.dispose]() { } }, false); + } + catch (e_1) { + env_1.error = e_1; + env_1.hasError = true; + } + finally { + __disposeResources(env_1); + } + } +} diff --git a/tests/baselines/reference/usingDeclarations.13.errors.txt b/tests/baselines/reference/usingDeclarations.13.errors.txt new file mode 100644 index 0000000000000..b121a1570721e --- /dev/null +++ b/tests/baselines/reference/usingDeclarations.13.errors.txt @@ -0,0 +1,12 @@ +usingDeclarations.13.ts(1,1): error TS1491: 'export' modifier cannot appear on a 'using' declaration. +usingDeclarations.13.ts(2,1): error TS1491: 'declare' modifier cannot appear on a 'using' declaration. + + +==== usingDeclarations.13.ts (2 errors) ==== + export using x = null; + ~~~~~~ +!!! error TS1491: 'export' modifier cannot appear on a 'using' declaration. + declare using y: null; + ~~~~~~~ +!!! error TS1491: 'declare' modifier cannot appear on a 'using' declaration. + \ No newline at end of file diff --git a/tests/baselines/reference/usingDeclarations.13.js b/tests/baselines/reference/usingDeclarations.13.js new file mode 100644 index 0000000000000..4b6587a990412 --- /dev/null +++ b/tests/baselines/reference/usingDeclarations.13.js @@ -0,0 +1,9 @@ +//// [tests/cases/conformance/statements/VariableStatements/usingDeclarations/usingDeclarations.13.ts] //// + +//// [usingDeclarations.13.ts] +export using x = null; +declare using y: null; + + +//// [usingDeclarations.13.js] +export using x = null; diff --git a/tests/baselines/reference/usingDeclarations.14.errors.txt b/tests/baselines/reference/usingDeclarations.14.errors.txt new file mode 100644 index 0000000000000..5d3e1507f6adf --- /dev/null +++ b/tests/baselines/reference/usingDeclarations.14.errors.txt @@ -0,0 +1,10 @@ +usingDeclarations.14.ts(1,11): error TS2850: The initializer of a 'using' declaration must be either an object with a '[Symbol.dispose]()' method, or be 'null' or 'undefined'. + Property '[Symbol.dispose]' is missing in type '{}' but required in type 'Disposable'. + + +==== usingDeclarations.14.ts (1 errors) ==== + using x = {}; + ~~ +!!! error TS2850: The initializer of a 'using' declaration must be either an object with a '[Symbol.dispose]()' method, or be 'null' or 'undefined'. +!!! error TS2850: Property '[Symbol.dispose]' is missing in type '{}' but required in type 'Disposable'. +!!! related TS2728 lib.esnext.disposable.d.ts:--:--: '[Symbol.dispose]' is declared here. \ No newline at end of file diff --git a/tests/baselines/reference/usingDeclarations.14.js b/tests/baselines/reference/usingDeclarations.14.js new file mode 100644 index 0000000000000..600af3d7103f3 --- /dev/null +++ b/tests/baselines/reference/usingDeclarations.14.js @@ -0,0 +1,7 @@ +//// [tests/cases/conformance/statements/VariableStatements/usingDeclarations/usingDeclarations.14.ts] //// + +//// [usingDeclarations.14.ts] +using x = {}; + +//// [usingDeclarations.14.js] +using x = {}; diff --git a/tests/baselines/reference/usingDeclarations.15.js b/tests/baselines/reference/usingDeclarations.15.js new file mode 100644 index 0000000000000..aeab9a3839275 --- /dev/null +++ b/tests/baselines/reference/usingDeclarations.15.js @@ -0,0 +1,10 @@ +//// [tests/cases/conformance/statements/VariableStatements/usingDeclarations/usingDeclarations.15.ts] //// + +//// [usingDeclarations.15.ts] +export {}; + +using _ = { [Symbol.dispose]() {} }; + +//// [usingDeclarations.15.js] +using _ = { [Symbol.dispose]() { } }; +export {}; diff --git a/tests/baselines/reference/usingDeclarations.2(target=es2015).js b/tests/baselines/reference/usingDeclarations.2(target=es2015).js new file mode 100644 index 0000000000000..66c7f0b962df0 --- /dev/null +++ b/tests/baselines/reference/usingDeclarations.2(target=es2015).js @@ -0,0 +1,68 @@ +//// [tests/cases/conformance/statements/VariableStatements/usingDeclarations/usingDeclarations.2.ts] //// + +//// [usingDeclarations.2.ts] +{ + using d1 = { [Symbol.dispose]() {} }, + d2 = { [Symbol.dispose]() {} }; +} + + +//// [usingDeclarations.2.js] +var __addDisposableResource = (this && this.__addDisposableResource) || function (env, value, async) { + if (value !== null && value !== void 0) { + if (typeof value !== "object") throw new TypeError("Object expected."); + var dispose; + if (async) { + if (!Symbol.asyncDispose) throw new TypeError("Symbol.asyncDispose is not defined."); + dispose = value[Symbol.asyncDispose]; + } + if (dispose === void 0) { + if (!Symbol.dispose) throw new TypeError("Symbol.dispose is not defined."); + dispose = value[Symbol.dispose]; + } + if (typeof dispose !== "function") throw new TypeError("Object not disposable."); + env.stack.push({ value: value, dispose: dispose, async: async }); + } + else if (async) { + env.stack.push({ async: true }); + } + return value; +}; +var __disposeResources = (this && this.__disposeResources) || (function (SuppressedError) { + return function (env) { + function fail(e) { + env.error = env.hasError ? new SuppressedError(e, env.error, "An error was suppressed during disposal.") : e; + env.hasError = true; + } + function next() { + while (env.stack.length) { + var rec = env.stack.pop(); + try { + var result = rec.dispose && rec.dispose.call(rec.value); + if (rec.async) return Promise.resolve(result).then(next, function(e) { fail(e); return next(); }); + } + catch (e) { + fail(e); + } + } + if (env.hasError) throw env.error; + } + return next(); + }; +})(typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) { + var e = new Error(message); + return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e; +}); +{ + const env_1 = { stack: [], error: void 0, hasError: false }; + try { + const d1 = __addDisposableResource(env_1, { [Symbol.dispose]() { } }, false), d2 = __addDisposableResource(env_1, { [Symbol.dispose]() { } }, false); + } + catch (e_1) { + env_1.error = e_1; + env_1.hasError = true; + } + finally { + __disposeResources(env_1); + } +} diff --git a/tests/baselines/reference/usingDeclarations.2(target=es2017).js b/tests/baselines/reference/usingDeclarations.2(target=es2017).js new file mode 100644 index 0000000000000..66c7f0b962df0 --- /dev/null +++ b/tests/baselines/reference/usingDeclarations.2(target=es2017).js @@ -0,0 +1,68 @@ +//// [tests/cases/conformance/statements/VariableStatements/usingDeclarations/usingDeclarations.2.ts] //// + +//// [usingDeclarations.2.ts] +{ + using d1 = { [Symbol.dispose]() {} }, + d2 = { [Symbol.dispose]() {} }; +} + + +//// [usingDeclarations.2.js] +var __addDisposableResource = (this && this.__addDisposableResource) || function (env, value, async) { + if (value !== null && value !== void 0) { + if (typeof value !== "object") throw new TypeError("Object expected."); + var dispose; + if (async) { + if (!Symbol.asyncDispose) throw new TypeError("Symbol.asyncDispose is not defined."); + dispose = value[Symbol.asyncDispose]; + } + if (dispose === void 0) { + if (!Symbol.dispose) throw new TypeError("Symbol.dispose is not defined."); + dispose = value[Symbol.dispose]; + } + if (typeof dispose !== "function") throw new TypeError("Object not disposable."); + env.stack.push({ value: value, dispose: dispose, async: async }); + } + else if (async) { + env.stack.push({ async: true }); + } + return value; +}; +var __disposeResources = (this && this.__disposeResources) || (function (SuppressedError) { + return function (env) { + function fail(e) { + env.error = env.hasError ? new SuppressedError(e, env.error, "An error was suppressed during disposal.") : e; + env.hasError = true; + } + function next() { + while (env.stack.length) { + var rec = env.stack.pop(); + try { + var result = rec.dispose && rec.dispose.call(rec.value); + if (rec.async) return Promise.resolve(result).then(next, function(e) { fail(e); return next(); }); + } + catch (e) { + fail(e); + } + } + if (env.hasError) throw env.error; + } + return next(); + }; +})(typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) { + var e = new Error(message); + return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e; +}); +{ + const env_1 = { stack: [], error: void 0, hasError: false }; + try { + const d1 = __addDisposableResource(env_1, { [Symbol.dispose]() { } }, false), d2 = __addDisposableResource(env_1, { [Symbol.dispose]() { } }, false); + } + catch (e_1) { + env_1.error = e_1; + env_1.hasError = true; + } + finally { + __disposeResources(env_1); + } +} diff --git a/tests/baselines/reference/usingDeclarations.2(target=es2022).js b/tests/baselines/reference/usingDeclarations.2(target=es2022).js new file mode 100644 index 0000000000000..66c7f0b962df0 --- /dev/null +++ b/tests/baselines/reference/usingDeclarations.2(target=es2022).js @@ -0,0 +1,68 @@ +//// [tests/cases/conformance/statements/VariableStatements/usingDeclarations/usingDeclarations.2.ts] //// + +//// [usingDeclarations.2.ts] +{ + using d1 = { [Symbol.dispose]() {} }, + d2 = { [Symbol.dispose]() {} }; +} + + +//// [usingDeclarations.2.js] +var __addDisposableResource = (this && this.__addDisposableResource) || function (env, value, async) { + if (value !== null && value !== void 0) { + if (typeof value !== "object") throw new TypeError("Object expected."); + var dispose; + if (async) { + if (!Symbol.asyncDispose) throw new TypeError("Symbol.asyncDispose is not defined."); + dispose = value[Symbol.asyncDispose]; + } + if (dispose === void 0) { + if (!Symbol.dispose) throw new TypeError("Symbol.dispose is not defined."); + dispose = value[Symbol.dispose]; + } + if (typeof dispose !== "function") throw new TypeError("Object not disposable."); + env.stack.push({ value: value, dispose: dispose, async: async }); + } + else if (async) { + env.stack.push({ async: true }); + } + return value; +}; +var __disposeResources = (this && this.__disposeResources) || (function (SuppressedError) { + return function (env) { + function fail(e) { + env.error = env.hasError ? new SuppressedError(e, env.error, "An error was suppressed during disposal.") : e; + env.hasError = true; + } + function next() { + while (env.stack.length) { + var rec = env.stack.pop(); + try { + var result = rec.dispose && rec.dispose.call(rec.value); + if (rec.async) return Promise.resolve(result).then(next, function(e) { fail(e); return next(); }); + } + catch (e) { + fail(e); + } + } + if (env.hasError) throw env.error; + } + return next(); + }; +})(typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) { + var e = new Error(message); + return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e; +}); +{ + const env_1 = { stack: [], error: void 0, hasError: false }; + try { + const d1 = __addDisposableResource(env_1, { [Symbol.dispose]() { } }, false), d2 = __addDisposableResource(env_1, { [Symbol.dispose]() { } }, false); + } + catch (e_1) { + env_1.error = e_1; + env_1.hasError = true; + } + finally { + __disposeResources(env_1); + } +} diff --git a/tests/baselines/reference/usingDeclarations.2(target=es5).js b/tests/baselines/reference/usingDeclarations.2(target=es5).js new file mode 100644 index 0000000000000..cb89d9fb7ef97 --- /dev/null +++ b/tests/baselines/reference/usingDeclarations.2(target=es5).js @@ -0,0 +1,69 @@ +//// [tests/cases/conformance/statements/VariableStatements/usingDeclarations/usingDeclarations.2.ts] //// + +//// [usingDeclarations.2.ts] +{ + using d1 = { [Symbol.dispose]() {} }, + d2 = { [Symbol.dispose]() {} }; +} + + +//// [usingDeclarations.2.js] +var __addDisposableResource = (this && this.__addDisposableResource) || function (env, value, async) { + if (value !== null && value !== void 0) { + if (typeof value !== "object") throw new TypeError("Object expected."); + var dispose; + if (async) { + if (!Symbol.asyncDispose) throw new TypeError("Symbol.asyncDispose is not defined."); + dispose = value[Symbol.asyncDispose]; + } + if (dispose === void 0) { + if (!Symbol.dispose) throw new TypeError("Symbol.dispose is not defined."); + dispose = value[Symbol.dispose]; + } + if (typeof dispose !== "function") throw new TypeError("Object not disposable."); + env.stack.push({ value: value, dispose: dispose, async: async }); + } + else if (async) { + env.stack.push({ async: true }); + } + return value; +}; +var __disposeResources = (this && this.__disposeResources) || (function (SuppressedError) { + return function (env) { + function fail(e) { + env.error = env.hasError ? new SuppressedError(e, env.error, "An error was suppressed during disposal.") : e; + env.hasError = true; + } + function next() { + while (env.stack.length) { + var rec = env.stack.pop(); + try { + var result = rec.dispose && rec.dispose.call(rec.value); + if (rec.async) return Promise.resolve(result).then(next, function(e) { fail(e); return next(); }); + } + catch (e) { + fail(e); + } + } + if (env.hasError) throw env.error; + } + return next(); + }; +})(typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) { + var e = new Error(message); + return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e; +}); +var _a, _b; +{ + var env_1 = { stack: [], error: void 0, hasError: false }; + try { + var d1 = __addDisposableResource(env_1, (_a = {}, _a[Symbol.dispose] = function () { }, _a), false), d2 = __addDisposableResource(env_1, (_b = {}, _b[Symbol.dispose] = function () { }, _b), false); + } + catch (e_1) { + env_1.error = e_1; + env_1.hasError = true; + } + finally { + __disposeResources(env_1); + } +} diff --git a/tests/baselines/reference/usingDeclarations.2(target=esnext).js b/tests/baselines/reference/usingDeclarations.2(target=esnext).js new file mode 100644 index 0000000000000..ad15c171c08a2 --- /dev/null +++ b/tests/baselines/reference/usingDeclarations.2(target=esnext).js @@ -0,0 +1,13 @@ +//// [tests/cases/conformance/statements/VariableStatements/usingDeclarations/usingDeclarations.2.ts] //// + +//// [usingDeclarations.2.ts] +{ + using d1 = { [Symbol.dispose]() {} }, + d2 = { [Symbol.dispose]() {} }; +} + + +//// [usingDeclarations.2.js] +{ + using d1 = { [Symbol.dispose]() { } }, d2 = { [Symbol.dispose]() { } }; +} diff --git a/tests/baselines/reference/usingDeclarations.3(target=es2015).js b/tests/baselines/reference/usingDeclarations.3(target=es2015).js new file mode 100644 index 0000000000000..061c93eba32b6 --- /dev/null +++ b/tests/baselines/reference/usingDeclarations.3(target=es2015).js @@ -0,0 +1,70 @@ +//// [tests/cases/conformance/statements/VariableStatements/usingDeclarations/usingDeclarations.3.ts] //// + +//// [usingDeclarations.3.ts] +{ + using d1 = { [Symbol.dispose]() {} }, + d2 = null, + d3 = undefined, + d4 = { [Symbol.dispose]() {} }; +} + + +//// [usingDeclarations.3.js] +var __addDisposableResource = (this && this.__addDisposableResource) || function (env, value, async) { + if (value !== null && value !== void 0) { + if (typeof value !== "object") throw new TypeError("Object expected."); + var dispose; + if (async) { + if (!Symbol.asyncDispose) throw new TypeError("Symbol.asyncDispose is not defined."); + dispose = value[Symbol.asyncDispose]; + } + if (dispose === void 0) { + if (!Symbol.dispose) throw new TypeError("Symbol.dispose is not defined."); + dispose = value[Symbol.dispose]; + } + if (typeof dispose !== "function") throw new TypeError("Object not disposable."); + env.stack.push({ value: value, dispose: dispose, async: async }); + } + else if (async) { + env.stack.push({ async: true }); + } + return value; +}; +var __disposeResources = (this && this.__disposeResources) || (function (SuppressedError) { + return function (env) { + function fail(e) { + env.error = env.hasError ? new SuppressedError(e, env.error, "An error was suppressed during disposal.") : e; + env.hasError = true; + } + function next() { + while (env.stack.length) { + var rec = env.stack.pop(); + try { + var result = rec.dispose && rec.dispose.call(rec.value); + if (rec.async) return Promise.resolve(result).then(next, function(e) { fail(e); return next(); }); + } + catch (e) { + fail(e); + } + } + if (env.hasError) throw env.error; + } + return next(); + }; +})(typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) { + var e = new Error(message); + return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e; +}); +{ + const env_1 = { stack: [], error: void 0, hasError: false }; + try { + const d1 = __addDisposableResource(env_1, { [Symbol.dispose]() { } }, false), d2 = __addDisposableResource(env_1, null, false), d3 = __addDisposableResource(env_1, undefined, false), d4 = __addDisposableResource(env_1, { [Symbol.dispose]() { } }, false); + } + catch (e_1) { + env_1.error = e_1; + env_1.hasError = true; + } + finally { + __disposeResources(env_1); + } +} diff --git a/tests/baselines/reference/usingDeclarations.3(target=es2017).js b/tests/baselines/reference/usingDeclarations.3(target=es2017).js new file mode 100644 index 0000000000000..061c93eba32b6 --- /dev/null +++ b/tests/baselines/reference/usingDeclarations.3(target=es2017).js @@ -0,0 +1,70 @@ +//// [tests/cases/conformance/statements/VariableStatements/usingDeclarations/usingDeclarations.3.ts] //// + +//// [usingDeclarations.3.ts] +{ + using d1 = { [Symbol.dispose]() {} }, + d2 = null, + d3 = undefined, + d4 = { [Symbol.dispose]() {} }; +} + + +//// [usingDeclarations.3.js] +var __addDisposableResource = (this && this.__addDisposableResource) || function (env, value, async) { + if (value !== null && value !== void 0) { + if (typeof value !== "object") throw new TypeError("Object expected."); + var dispose; + if (async) { + if (!Symbol.asyncDispose) throw new TypeError("Symbol.asyncDispose is not defined."); + dispose = value[Symbol.asyncDispose]; + } + if (dispose === void 0) { + if (!Symbol.dispose) throw new TypeError("Symbol.dispose is not defined."); + dispose = value[Symbol.dispose]; + } + if (typeof dispose !== "function") throw new TypeError("Object not disposable."); + env.stack.push({ value: value, dispose: dispose, async: async }); + } + else if (async) { + env.stack.push({ async: true }); + } + return value; +}; +var __disposeResources = (this && this.__disposeResources) || (function (SuppressedError) { + return function (env) { + function fail(e) { + env.error = env.hasError ? new SuppressedError(e, env.error, "An error was suppressed during disposal.") : e; + env.hasError = true; + } + function next() { + while (env.stack.length) { + var rec = env.stack.pop(); + try { + var result = rec.dispose && rec.dispose.call(rec.value); + if (rec.async) return Promise.resolve(result).then(next, function(e) { fail(e); return next(); }); + } + catch (e) { + fail(e); + } + } + if (env.hasError) throw env.error; + } + return next(); + }; +})(typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) { + var e = new Error(message); + return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e; +}); +{ + const env_1 = { stack: [], error: void 0, hasError: false }; + try { + const d1 = __addDisposableResource(env_1, { [Symbol.dispose]() { } }, false), d2 = __addDisposableResource(env_1, null, false), d3 = __addDisposableResource(env_1, undefined, false), d4 = __addDisposableResource(env_1, { [Symbol.dispose]() { } }, false); + } + catch (e_1) { + env_1.error = e_1; + env_1.hasError = true; + } + finally { + __disposeResources(env_1); + } +} diff --git a/tests/baselines/reference/usingDeclarations.3(target=es2022).js b/tests/baselines/reference/usingDeclarations.3(target=es2022).js new file mode 100644 index 0000000000000..061c93eba32b6 --- /dev/null +++ b/tests/baselines/reference/usingDeclarations.3(target=es2022).js @@ -0,0 +1,70 @@ +//// [tests/cases/conformance/statements/VariableStatements/usingDeclarations/usingDeclarations.3.ts] //// + +//// [usingDeclarations.3.ts] +{ + using d1 = { [Symbol.dispose]() {} }, + d2 = null, + d3 = undefined, + d4 = { [Symbol.dispose]() {} }; +} + + +//// [usingDeclarations.3.js] +var __addDisposableResource = (this && this.__addDisposableResource) || function (env, value, async) { + if (value !== null && value !== void 0) { + if (typeof value !== "object") throw new TypeError("Object expected."); + var dispose; + if (async) { + if (!Symbol.asyncDispose) throw new TypeError("Symbol.asyncDispose is not defined."); + dispose = value[Symbol.asyncDispose]; + } + if (dispose === void 0) { + if (!Symbol.dispose) throw new TypeError("Symbol.dispose is not defined."); + dispose = value[Symbol.dispose]; + } + if (typeof dispose !== "function") throw new TypeError("Object not disposable."); + env.stack.push({ value: value, dispose: dispose, async: async }); + } + else if (async) { + env.stack.push({ async: true }); + } + return value; +}; +var __disposeResources = (this && this.__disposeResources) || (function (SuppressedError) { + return function (env) { + function fail(e) { + env.error = env.hasError ? new SuppressedError(e, env.error, "An error was suppressed during disposal.") : e; + env.hasError = true; + } + function next() { + while (env.stack.length) { + var rec = env.stack.pop(); + try { + var result = rec.dispose && rec.dispose.call(rec.value); + if (rec.async) return Promise.resolve(result).then(next, function(e) { fail(e); return next(); }); + } + catch (e) { + fail(e); + } + } + if (env.hasError) throw env.error; + } + return next(); + }; +})(typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) { + var e = new Error(message); + return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e; +}); +{ + const env_1 = { stack: [], error: void 0, hasError: false }; + try { + const d1 = __addDisposableResource(env_1, { [Symbol.dispose]() { } }, false), d2 = __addDisposableResource(env_1, null, false), d3 = __addDisposableResource(env_1, undefined, false), d4 = __addDisposableResource(env_1, { [Symbol.dispose]() { } }, false); + } + catch (e_1) { + env_1.error = e_1; + env_1.hasError = true; + } + finally { + __disposeResources(env_1); + } +} diff --git a/tests/baselines/reference/usingDeclarations.3(target=es5).js b/tests/baselines/reference/usingDeclarations.3(target=es5).js new file mode 100644 index 0000000000000..baf9f20969335 --- /dev/null +++ b/tests/baselines/reference/usingDeclarations.3(target=es5).js @@ -0,0 +1,71 @@ +//// [tests/cases/conformance/statements/VariableStatements/usingDeclarations/usingDeclarations.3.ts] //// + +//// [usingDeclarations.3.ts] +{ + using d1 = { [Symbol.dispose]() {} }, + d2 = null, + d3 = undefined, + d4 = { [Symbol.dispose]() {} }; +} + + +//// [usingDeclarations.3.js] +var __addDisposableResource = (this && this.__addDisposableResource) || function (env, value, async) { + if (value !== null && value !== void 0) { + if (typeof value !== "object") throw new TypeError("Object expected."); + var dispose; + if (async) { + if (!Symbol.asyncDispose) throw new TypeError("Symbol.asyncDispose is not defined."); + dispose = value[Symbol.asyncDispose]; + } + if (dispose === void 0) { + if (!Symbol.dispose) throw new TypeError("Symbol.dispose is not defined."); + dispose = value[Symbol.dispose]; + } + if (typeof dispose !== "function") throw new TypeError("Object not disposable."); + env.stack.push({ value: value, dispose: dispose, async: async }); + } + else if (async) { + env.stack.push({ async: true }); + } + return value; +}; +var __disposeResources = (this && this.__disposeResources) || (function (SuppressedError) { + return function (env) { + function fail(e) { + env.error = env.hasError ? new SuppressedError(e, env.error, "An error was suppressed during disposal.") : e; + env.hasError = true; + } + function next() { + while (env.stack.length) { + var rec = env.stack.pop(); + try { + var result = rec.dispose && rec.dispose.call(rec.value); + if (rec.async) return Promise.resolve(result).then(next, function(e) { fail(e); return next(); }); + } + catch (e) { + fail(e); + } + } + if (env.hasError) throw env.error; + } + return next(); + }; +})(typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) { + var e = new Error(message); + return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e; +}); +var _a, _b; +{ + var env_1 = { stack: [], error: void 0, hasError: false }; + try { + var d1 = __addDisposableResource(env_1, (_a = {}, _a[Symbol.dispose] = function () { }, _a), false), d2 = __addDisposableResource(env_1, null, false), d3 = __addDisposableResource(env_1, undefined, false), d4 = __addDisposableResource(env_1, (_b = {}, _b[Symbol.dispose] = function () { }, _b), false); + } + catch (e_1) { + env_1.error = e_1; + env_1.hasError = true; + } + finally { + __disposeResources(env_1); + } +} diff --git a/tests/baselines/reference/usingDeclarations.3(target=esnext).js b/tests/baselines/reference/usingDeclarations.3(target=esnext).js new file mode 100644 index 0000000000000..7b58965954fb8 --- /dev/null +++ b/tests/baselines/reference/usingDeclarations.3(target=esnext).js @@ -0,0 +1,15 @@ +//// [tests/cases/conformance/statements/VariableStatements/usingDeclarations/usingDeclarations.3.ts] //// + +//// [usingDeclarations.3.ts] +{ + using d1 = { [Symbol.dispose]() {} }, + d2 = null, + d3 = undefined, + d4 = { [Symbol.dispose]() {} }; +} + + +//// [usingDeclarations.3.js] +{ + using d1 = { [Symbol.dispose]() { } }, d2 = null, d3 = undefined, d4 = { [Symbol.dispose]() { } }; +} diff --git a/tests/baselines/reference/usingDeclarations.4.errors.txt b/tests/baselines/reference/usingDeclarations.4.errors.txt new file mode 100644 index 0000000000000..649ee1af922f9 --- /dev/null +++ b/tests/baselines/reference/usingDeclarations.4.errors.txt @@ -0,0 +1,12 @@ +usingDeclarations.4.ts(2,5): error TS2304: Cannot find name 'using'. +usingDeclarations.4.ts(2,12): error TS2304: Cannot find name 'a'. + + +==== usingDeclarations.4.ts (2 errors) ==== + { + using [a] = null; + ~~~~~ +!!! error TS2304: Cannot find name 'using'. + ~ +!!! error TS2304: Cannot find name 'a'. + } \ No newline at end of file diff --git a/tests/baselines/reference/usingDeclarations.4.js b/tests/baselines/reference/usingDeclarations.4.js new file mode 100644 index 0000000000000..38ca6b16c1107 --- /dev/null +++ b/tests/baselines/reference/usingDeclarations.4.js @@ -0,0 +1,11 @@ +//// [tests/cases/conformance/statements/VariableStatements/usingDeclarations/usingDeclarations.4.ts] //// + +//// [usingDeclarations.4.ts] +{ + using [a] = null; +} + +//// [usingDeclarations.4.js] +{ + using[a] = null; +} diff --git a/tests/baselines/reference/usingDeclarations.5.errors.txt b/tests/baselines/reference/usingDeclarations.5.errors.txt new file mode 100644 index 0000000000000..ddb56031aa2c8 --- /dev/null +++ b/tests/baselines/reference/usingDeclarations.5.errors.txt @@ -0,0 +1,15 @@ +usingDeclarations.5.ts(3,11): error TS1492: 'using' declarations may not have binding patterns. +usingDeclarations.5.ts(3,11): error TS2488: Type 'null' must have a '[Symbol.iterator]()' method that returns an iterator. + + +==== usingDeclarations.5.ts (2 errors) ==== + { + using a = null, + [b] = null, + ~~~ +!!! error TS1492: 'using' declarations may not have binding patterns. + ~~~ +!!! error TS2488: Type 'null' must have a '[Symbol.iterator]()' method that returns an iterator. + c = null; + } + \ No newline at end of file diff --git a/tests/baselines/reference/usingDeclarations.5.js b/tests/baselines/reference/usingDeclarations.5.js new file mode 100644 index 0000000000000..31062246156f4 --- /dev/null +++ b/tests/baselines/reference/usingDeclarations.5.js @@ -0,0 +1,14 @@ +//// [tests/cases/conformance/statements/VariableStatements/usingDeclarations/usingDeclarations.5.ts] //// + +//// [usingDeclarations.5.ts] +{ + using a = null, + [b] = null, + c = null; +} + + +//// [usingDeclarations.5.js] +{ + using a = null, [b] = null, c = null; +} diff --git a/tests/baselines/reference/usingDeclarations.6.errors.txt b/tests/baselines/reference/usingDeclarations.6.errors.txt new file mode 100644 index 0000000000000..b031165266971 --- /dev/null +++ b/tests/baselines/reference/usingDeclarations.6.errors.txt @@ -0,0 +1,13 @@ +usingDeclarations.6.ts(2,11): error TS1492: 'using' declarations may not have binding patterns. +usingDeclarations.6.ts(2,12): error TS2339: Property 'a' does not exist on type 'null'. + + +==== usingDeclarations.6.ts (2 errors) ==== + { + using {a} = null; + ~~~ +!!! error TS1492: 'using' declarations may not have binding patterns. + ~ +!!! error TS2339: Property 'a' does not exist on type 'null'. + } + \ No newline at end of file diff --git a/tests/baselines/reference/usingDeclarations.6.js b/tests/baselines/reference/usingDeclarations.6.js new file mode 100644 index 0000000000000..c7fef333511fd --- /dev/null +++ b/tests/baselines/reference/usingDeclarations.6.js @@ -0,0 +1,12 @@ +//// [tests/cases/conformance/statements/VariableStatements/usingDeclarations/usingDeclarations.6.ts] //// + +//// [usingDeclarations.6.ts] +{ + using {a} = null; +} + + +//// [usingDeclarations.6.js] +{ + using { a } = null; +} diff --git a/tests/baselines/reference/usingDeclarations.7.errors.txt b/tests/baselines/reference/usingDeclarations.7.errors.txt new file mode 100644 index 0000000000000..78bb1f9050195 --- /dev/null +++ b/tests/baselines/reference/usingDeclarations.7.errors.txt @@ -0,0 +1,14 @@ +usingDeclarations.7.ts(3,11): error TS1492: 'using' declarations may not have binding patterns. +usingDeclarations.7.ts(3,12): error TS2339: Property 'b' does not exist on type 'null'. + + +==== usingDeclarations.7.ts (2 errors) ==== + { + using a = null, + {b} = null, + ~~~ +!!! error TS1492: 'using' declarations may not have binding patterns. + ~ +!!! error TS2339: Property 'b' does not exist on type 'null'. + c = null; + } \ No newline at end of file diff --git a/tests/baselines/reference/usingDeclarations.7.js b/tests/baselines/reference/usingDeclarations.7.js new file mode 100644 index 0000000000000..c92c8929aa719 --- /dev/null +++ b/tests/baselines/reference/usingDeclarations.7.js @@ -0,0 +1,13 @@ +//// [tests/cases/conformance/statements/VariableStatements/usingDeclarations/usingDeclarations.7.ts] //// + +//// [usingDeclarations.7.ts] +{ + using a = null, + {b} = null, + c = null; +} + +//// [usingDeclarations.7.js] +{ + using a = null, { b } = null, c = null; +} diff --git a/tests/baselines/reference/usingDeclarations.8.errors.txt b/tests/baselines/reference/usingDeclarations.8.errors.txt new file mode 100644 index 0000000000000..4ed183efe393e --- /dev/null +++ b/tests/baselines/reference/usingDeclarations.8.errors.txt @@ -0,0 +1,9 @@ +usingDeclarations.8.ts(2,11): error TS1155: 'using' declarations must be initialized. + + +==== usingDeclarations.8.ts (1 errors) ==== + { + using a; + ~ +!!! error TS1155: 'using' declarations must be initialized. + } \ No newline at end of file diff --git a/tests/baselines/reference/usingDeclarations.8.js b/tests/baselines/reference/usingDeclarations.8.js new file mode 100644 index 0000000000000..3bfabea2c9e51 --- /dev/null +++ b/tests/baselines/reference/usingDeclarations.8.js @@ -0,0 +1,11 @@ +//// [tests/cases/conformance/statements/VariableStatements/usingDeclarations/usingDeclarations.8.ts] //// + +//// [usingDeclarations.8.ts] +{ + using a; +} + +//// [usingDeclarations.8.js] +{ + using a; +} diff --git a/tests/baselines/reference/usingDeclarations.9.errors.txt b/tests/baselines/reference/usingDeclarations.9.errors.txt new file mode 100644 index 0000000000000..9fec9843d1c28 --- /dev/null +++ b/tests/baselines/reference/usingDeclarations.9.errors.txt @@ -0,0 +1,8 @@ +error TS2318: Cannot find global type 'Disposable'. + + +!!! error TS2318: Cannot find global type 'Disposable'. +==== usingDeclarations.9.ts (0 errors) ==== + { + using a = null; + } \ No newline at end of file diff --git a/tests/baselines/reference/usingDeclarations.9.js b/tests/baselines/reference/usingDeclarations.9.js new file mode 100644 index 0000000000000..d423904e8b2a9 --- /dev/null +++ b/tests/baselines/reference/usingDeclarations.9.js @@ -0,0 +1,11 @@ +//// [tests/cases/conformance/statements/VariableStatements/usingDeclarations/usingDeclarations.9.ts] //// + +//// [usingDeclarations.9.ts] +{ + using a = null; +} + +//// [usingDeclarations.9.js] +{ + using a = null; +} diff --git a/tests/baselines/reference/usingDeclarationsDeclarationEmit.1.js b/tests/baselines/reference/usingDeclarationsDeclarationEmit.1.js new file mode 100644 index 0000000000000..8148df0310845 --- /dev/null +++ b/tests/baselines/reference/usingDeclarationsDeclarationEmit.1.js @@ -0,0 +1,26 @@ +//// [tests/cases/conformance/statements/VariableStatements/usingDeclarations/usingDeclarationsDeclarationEmit.1.ts] //// + +//// [usingDeclarationsDeclarationEmit.1.ts] +using r1 = { [Symbol.dispose]() {} }; +export { r1 }; + +await using r2 = { async [Symbol.asyncDispose]() {} }; +export { r2 }; + + +//// [usingDeclarationsDeclarationEmit.1.js] +using r1 = { [Symbol.dispose]() { } }; +export { r1 }; +await using r2 = { async [Symbol.asyncDispose]() { } }; +export { r2 }; + + +//// [usingDeclarationsDeclarationEmit.1.d.ts] +declare const r1: { + [Symbol.dispose](): void; +}; +export { r1 }; +declare const r2: { + [Symbol.asyncDispose](): Promise; +}; +export { r2 }; diff --git a/tests/baselines/reference/usingDeclarationsDeclarationEmit.2.js b/tests/baselines/reference/usingDeclarationsDeclarationEmit.2.js new file mode 100644 index 0000000000000..f65f38ed8b7b0 --- /dev/null +++ b/tests/baselines/reference/usingDeclarationsDeclarationEmit.2.js @@ -0,0 +1,26 @@ +//// [tests/cases/conformance/statements/VariableStatements/usingDeclarations/usingDeclarationsDeclarationEmit.2.ts] //// + +//// [usingDeclarationsDeclarationEmit.2.ts] +using r1 = { [Symbol.dispose]() {} }; +export type R1 = typeof r1; + +await using r2 = { async [Symbol.asyncDispose]() {} }; +export type R2 = typeof r2; + + +//// [usingDeclarationsDeclarationEmit.2.js] +using r1 = { [Symbol.dispose]() { } }; +await using r2 = { async [Symbol.asyncDispose]() { } }; +export {}; + + +//// [usingDeclarationsDeclarationEmit.2.d.ts] +declare const r1: { + [Symbol.dispose](): void; +}; +export type R1 = typeof r1; +declare const r2: { + [Symbol.asyncDispose](): Promise; +}; +export type R2 = typeof r2; +export {}; diff --git a/tests/baselines/reference/usingDeclarationsInFor(target=es2015).js b/tests/baselines/reference/usingDeclarationsInFor(target=es2015).js new file mode 100644 index 0000000000000..7138c307899ff --- /dev/null +++ b/tests/baselines/reference/usingDeclarationsInFor(target=es2015).js @@ -0,0 +1,68 @@ +//// [tests/cases/conformance/statements/VariableStatements/usingDeclarations/usingDeclarationsInFor.ts] //// + +//// [usingDeclarationsInFor.ts] +for (using d1 = { [Symbol.dispose]() {} }, d2 = null, d3 = undefined;;) { +} + + +//// [usingDeclarationsInFor.js] +var __addDisposableResource = (this && this.__addDisposableResource) || function (env, value, async) { + if (value !== null && value !== void 0) { + if (typeof value !== "object") throw new TypeError("Object expected."); + var dispose; + if (async) { + if (!Symbol.asyncDispose) throw new TypeError("Symbol.asyncDispose is not defined."); + dispose = value[Symbol.asyncDispose]; + } + if (dispose === void 0) { + if (!Symbol.dispose) throw new TypeError("Symbol.dispose is not defined."); + dispose = value[Symbol.dispose]; + } + if (typeof dispose !== "function") throw new TypeError("Object not disposable."); + env.stack.push({ value: value, dispose: dispose, async: async }); + } + else if (async) { + env.stack.push({ async: true }); + } + return value; +}; +var __disposeResources = (this && this.__disposeResources) || (function (SuppressedError) { + return function (env) { + function fail(e) { + env.error = env.hasError ? new SuppressedError(e, env.error, "An error was suppressed during disposal.") : e; + env.hasError = true; + } + function next() { + while (env.stack.length) { + var rec = env.stack.pop(); + try { + var result = rec.dispose && rec.dispose.call(rec.value); + if (rec.async) return Promise.resolve(result).then(next, function(e) { fail(e); return next(); }); + } + catch (e) { + fail(e); + } + } + if (env.hasError) throw env.error; + } + return next(); + }; +})(typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) { + var e = new Error(message); + return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e; +}); +{ + const env_1 = { stack: [], error: void 0, hasError: false }; + try { + const d1 = __addDisposableResource(env_1, { [Symbol.dispose]() { } }, false), d2 = __addDisposableResource(env_1, null, false), d3 = __addDisposableResource(env_1, undefined, false); + for (;;) { + } + } + catch (e_1) { + env_1.error = e_1; + env_1.hasError = true; + } + finally { + __disposeResources(env_1); + } +} diff --git a/tests/baselines/reference/usingDeclarationsInFor(target=es2017).js b/tests/baselines/reference/usingDeclarationsInFor(target=es2017).js new file mode 100644 index 0000000000000..7138c307899ff --- /dev/null +++ b/tests/baselines/reference/usingDeclarationsInFor(target=es2017).js @@ -0,0 +1,68 @@ +//// [tests/cases/conformance/statements/VariableStatements/usingDeclarations/usingDeclarationsInFor.ts] //// + +//// [usingDeclarationsInFor.ts] +for (using d1 = { [Symbol.dispose]() {} }, d2 = null, d3 = undefined;;) { +} + + +//// [usingDeclarationsInFor.js] +var __addDisposableResource = (this && this.__addDisposableResource) || function (env, value, async) { + if (value !== null && value !== void 0) { + if (typeof value !== "object") throw new TypeError("Object expected."); + var dispose; + if (async) { + if (!Symbol.asyncDispose) throw new TypeError("Symbol.asyncDispose is not defined."); + dispose = value[Symbol.asyncDispose]; + } + if (dispose === void 0) { + if (!Symbol.dispose) throw new TypeError("Symbol.dispose is not defined."); + dispose = value[Symbol.dispose]; + } + if (typeof dispose !== "function") throw new TypeError("Object not disposable."); + env.stack.push({ value: value, dispose: dispose, async: async }); + } + else if (async) { + env.stack.push({ async: true }); + } + return value; +}; +var __disposeResources = (this && this.__disposeResources) || (function (SuppressedError) { + return function (env) { + function fail(e) { + env.error = env.hasError ? new SuppressedError(e, env.error, "An error was suppressed during disposal.") : e; + env.hasError = true; + } + function next() { + while (env.stack.length) { + var rec = env.stack.pop(); + try { + var result = rec.dispose && rec.dispose.call(rec.value); + if (rec.async) return Promise.resolve(result).then(next, function(e) { fail(e); return next(); }); + } + catch (e) { + fail(e); + } + } + if (env.hasError) throw env.error; + } + return next(); + }; +})(typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) { + var e = new Error(message); + return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e; +}); +{ + const env_1 = { stack: [], error: void 0, hasError: false }; + try { + const d1 = __addDisposableResource(env_1, { [Symbol.dispose]() { } }, false), d2 = __addDisposableResource(env_1, null, false), d3 = __addDisposableResource(env_1, undefined, false); + for (;;) { + } + } + catch (e_1) { + env_1.error = e_1; + env_1.hasError = true; + } + finally { + __disposeResources(env_1); + } +} diff --git a/tests/baselines/reference/usingDeclarationsInFor(target=es2022).js b/tests/baselines/reference/usingDeclarationsInFor(target=es2022).js new file mode 100644 index 0000000000000..7138c307899ff --- /dev/null +++ b/tests/baselines/reference/usingDeclarationsInFor(target=es2022).js @@ -0,0 +1,68 @@ +//// [tests/cases/conformance/statements/VariableStatements/usingDeclarations/usingDeclarationsInFor.ts] //// + +//// [usingDeclarationsInFor.ts] +for (using d1 = { [Symbol.dispose]() {} }, d2 = null, d3 = undefined;;) { +} + + +//// [usingDeclarationsInFor.js] +var __addDisposableResource = (this && this.__addDisposableResource) || function (env, value, async) { + if (value !== null && value !== void 0) { + if (typeof value !== "object") throw new TypeError("Object expected."); + var dispose; + if (async) { + if (!Symbol.asyncDispose) throw new TypeError("Symbol.asyncDispose is not defined."); + dispose = value[Symbol.asyncDispose]; + } + if (dispose === void 0) { + if (!Symbol.dispose) throw new TypeError("Symbol.dispose is not defined."); + dispose = value[Symbol.dispose]; + } + if (typeof dispose !== "function") throw new TypeError("Object not disposable."); + env.stack.push({ value: value, dispose: dispose, async: async }); + } + else if (async) { + env.stack.push({ async: true }); + } + return value; +}; +var __disposeResources = (this && this.__disposeResources) || (function (SuppressedError) { + return function (env) { + function fail(e) { + env.error = env.hasError ? new SuppressedError(e, env.error, "An error was suppressed during disposal.") : e; + env.hasError = true; + } + function next() { + while (env.stack.length) { + var rec = env.stack.pop(); + try { + var result = rec.dispose && rec.dispose.call(rec.value); + if (rec.async) return Promise.resolve(result).then(next, function(e) { fail(e); return next(); }); + } + catch (e) { + fail(e); + } + } + if (env.hasError) throw env.error; + } + return next(); + }; +})(typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) { + var e = new Error(message); + return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e; +}); +{ + const env_1 = { stack: [], error: void 0, hasError: false }; + try { + const d1 = __addDisposableResource(env_1, { [Symbol.dispose]() { } }, false), d2 = __addDisposableResource(env_1, null, false), d3 = __addDisposableResource(env_1, undefined, false); + for (;;) { + } + } + catch (e_1) { + env_1.error = e_1; + env_1.hasError = true; + } + finally { + __disposeResources(env_1); + } +} diff --git a/tests/baselines/reference/usingDeclarationsInFor(target=es5).js b/tests/baselines/reference/usingDeclarationsInFor(target=es5).js new file mode 100644 index 0000000000000..c8cff8bb8d96d --- /dev/null +++ b/tests/baselines/reference/usingDeclarationsInFor(target=es5).js @@ -0,0 +1,69 @@ +//// [tests/cases/conformance/statements/VariableStatements/usingDeclarations/usingDeclarationsInFor.ts] //// + +//// [usingDeclarationsInFor.ts] +for (using d1 = { [Symbol.dispose]() {} }, d2 = null, d3 = undefined;;) { +} + + +//// [usingDeclarationsInFor.js] +var __addDisposableResource = (this && this.__addDisposableResource) || function (env, value, async) { + if (value !== null && value !== void 0) { + if (typeof value !== "object") throw new TypeError("Object expected."); + var dispose; + if (async) { + if (!Symbol.asyncDispose) throw new TypeError("Symbol.asyncDispose is not defined."); + dispose = value[Symbol.asyncDispose]; + } + if (dispose === void 0) { + if (!Symbol.dispose) throw new TypeError("Symbol.dispose is not defined."); + dispose = value[Symbol.dispose]; + } + if (typeof dispose !== "function") throw new TypeError("Object not disposable."); + env.stack.push({ value: value, dispose: dispose, async: async }); + } + else if (async) { + env.stack.push({ async: true }); + } + return value; +}; +var __disposeResources = (this && this.__disposeResources) || (function (SuppressedError) { + return function (env) { + function fail(e) { + env.error = env.hasError ? new SuppressedError(e, env.error, "An error was suppressed during disposal.") : e; + env.hasError = true; + } + function next() { + while (env.stack.length) { + var rec = env.stack.pop(); + try { + var result = rec.dispose && rec.dispose.call(rec.value); + if (rec.async) return Promise.resolve(result).then(next, function(e) { fail(e); return next(); }); + } + catch (e) { + fail(e); + } + } + if (env.hasError) throw env.error; + } + return next(); + }; +})(typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) { + var e = new Error(message); + return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e; +}); +var _a; +{ + var env_1 = { stack: [], error: void 0, hasError: false }; + try { + var d1 = __addDisposableResource(env_1, (_a = {}, _a[Symbol.dispose] = function () { }, _a), false), d2 = __addDisposableResource(env_1, null, false), d3 = __addDisposableResource(env_1, undefined, false); + for (;;) { + } + } + catch (e_1) { + env_1.error = e_1; + env_1.hasError = true; + } + finally { + __disposeResources(env_1); + } +} diff --git a/tests/baselines/reference/usingDeclarationsInFor(target=esnext).js b/tests/baselines/reference/usingDeclarationsInFor(target=esnext).js new file mode 100644 index 0000000000000..f279fdb59e3b4 --- /dev/null +++ b/tests/baselines/reference/usingDeclarationsInFor(target=esnext).js @@ -0,0 +1,10 @@ +//// [tests/cases/conformance/statements/VariableStatements/usingDeclarations/usingDeclarationsInFor.ts] //// + +//// [usingDeclarationsInFor.ts] +for (using d1 = { [Symbol.dispose]() {} }, d2 = null, d3 = undefined;;) { +} + + +//// [usingDeclarationsInFor.js] +for (using d1 = { [Symbol.dispose]() { } }, d2 = null, d3 = undefined;;) { +} diff --git a/tests/baselines/reference/usingDeclarationsInForAwaitOf(target=es2015).js b/tests/baselines/reference/usingDeclarationsInForAwaitOf(target=es2015).js new file mode 100644 index 0000000000000..24f12546aa64a --- /dev/null +++ b/tests/baselines/reference/usingDeclarationsInForAwaitOf(target=es2015).js @@ -0,0 +1,101 @@ +//// [tests/cases/conformance/statements/VariableStatements/usingDeclarations/usingDeclarationsInForAwaitOf.ts] //// + +//// [usingDeclarationsInForAwaitOf.ts] +async function main() { + for await (using d1 of [{ [Symbol.dispose]() {} }, null, undefined]) { + } +} + + +//// [usingDeclarationsInForAwaitOf.js] +var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { + function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } + return new (P || (P = Promise))(function (resolve, reject) { + function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } + function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } + function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } + step((generator = generator.apply(thisArg, _arguments || [])).next()); + }); +}; +var __addDisposableResource = (this && this.__addDisposableResource) || function (env, value, async) { + if (value !== null && value !== void 0) { + if (typeof value !== "object") throw new TypeError("Object expected."); + var dispose; + if (async) { + if (!Symbol.asyncDispose) throw new TypeError("Symbol.asyncDispose is not defined."); + dispose = value[Symbol.asyncDispose]; + } + if (dispose === void 0) { + if (!Symbol.dispose) throw new TypeError("Symbol.dispose is not defined."); + dispose = value[Symbol.dispose]; + } + if (typeof dispose !== "function") throw new TypeError("Object not disposable."); + env.stack.push({ value: value, dispose: dispose, async: async }); + } + else if (async) { + env.stack.push({ async: true }); + } + return value; +}; +var __disposeResources = (this && this.__disposeResources) || (function (SuppressedError) { + return function (env) { + function fail(e) { + env.error = env.hasError ? new SuppressedError(e, env.error, "An error was suppressed during disposal.") : e; + env.hasError = true; + } + function next() { + while (env.stack.length) { + var rec = env.stack.pop(); + try { + var result = rec.dispose && rec.dispose.call(rec.value); + if (rec.async) return Promise.resolve(result).then(next, function(e) { fail(e); return next(); }); + } + catch (e) { + fail(e); + } + } + if (env.hasError) throw env.error; + } + return next(); + }; +})(typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) { + var e = new Error(message); + return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e; +}); +var __asyncValues = (this && this.__asyncValues) || function (o) { + if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined."); + var m = o[Symbol.asyncIterator], i; + return m ? m.call(o) : (o = typeof __values === "function" ? __values(o) : o[Symbol.iterator](), i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i); + function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; } + function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); } +}; +function main() { + var _a, e_1, _b, _c; + return __awaiter(this, void 0, void 0, function* () { + try { + for (var _d = true, _e = __asyncValues([{ [Symbol.dispose]() { } }, null, undefined]), _f; _f = yield _e.next(), _a = _f.done, !_a; _d = true) { + _c = _f.value; + _d = false; + const d1_1 = _c; + const env_1 = { stack: [], error: void 0, hasError: false }; + try { + const d1 = __addDisposableResource(env_1, d1_1, false); + } + catch (e_2) { + env_1.error = e_2; + env_1.hasError = true; + } + finally { + __disposeResources(env_1); + } + } + } + catch (e_1_1) { e_1 = { error: e_1_1 }; } + finally { + try { + if (!_d && !_a && (_b = _e.return)) yield _b.call(_e); + } + finally { if (e_1) throw e_1.error; } + } + }); +} diff --git a/tests/baselines/reference/usingDeclarationsInForAwaitOf(target=es2017).js b/tests/baselines/reference/usingDeclarationsInForAwaitOf(target=es2017).js new file mode 100644 index 0000000000000..988c9fbea0be3 --- /dev/null +++ b/tests/baselines/reference/usingDeclarationsInForAwaitOf(target=es2017).js @@ -0,0 +1,90 @@ +//// [tests/cases/conformance/statements/VariableStatements/usingDeclarations/usingDeclarationsInForAwaitOf.ts] //// + +//// [usingDeclarationsInForAwaitOf.ts] +async function main() { + for await (using d1 of [{ [Symbol.dispose]() {} }, null, undefined]) { + } +} + + +//// [usingDeclarationsInForAwaitOf.js] +var __addDisposableResource = (this && this.__addDisposableResource) || function (env, value, async) { + if (value !== null && value !== void 0) { + if (typeof value !== "object") throw new TypeError("Object expected."); + var dispose; + if (async) { + if (!Symbol.asyncDispose) throw new TypeError("Symbol.asyncDispose is not defined."); + dispose = value[Symbol.asyncDispose]; + } + if (dispose === void 0) { + if (!Symbol.dispose) throw new TypeError("Symbol.dispose is not defined."); + dispose = value[Symbol.dispose]; + } + if (typeof dispose !== "function") throw new TypeError("Object not disposable."); + env.stack.push({ value: value, dispose: dispose, async: async }); + } + else if (async) { + env.stack.push({ async: true }); + } + return value; +}; +var __disposeResources = (this && this.__disposeResources) || (function (SuppressedError) { + return function (env) { + function fail(e) { + env.error = env.hasError ? new SuppressedError(e, env.error, "An error was suppressed during disposal.") : e; + env.hasError = true; + } + function next() { + while (env.stack.length) { + var rec = env.stack.pop(); + try { + var result = rec.dispose && rec.dispose.call(rec.value); + if (rec.async) return Promise.resolve(result).then(next, function(e) { fail(e); return next(); }); + } + catch (e) { + fail(e); + } + } + if (env.hasError) throw env.error; + } + return next(); + }; +})(typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) { + var e = new Error(message); + return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e; +}); +var __asyncValues = (this && this.__asyncValues) || function (o) { + if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined."); + var m = o[Symbol.asyncIterator], i; + return m ? m.call(o) : (o = typeof __values === "function" ? __values(o) : o[Symbol.iterator](), i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i); + function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; } + function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); } +}; +async function main() { + var _a, e_1, _b, _c; + try { + for (var _d = true, _e = __asyncValues([{ [Symbol.dispose]() { } }, null, undefined]), _f; _f = await _e.next(), _a = _f.done, !_a; _d = true) { + _c = _f.value; + _d = false; + const d1_1 = _c; + const env_1 = { stack: [], error: void 0, hasError: false }; + try { + const d1 = __addDisposableResource(env_1, d1_1, false); + } + catch (e_2) { + env_1.error = e_2; + env_1.hasError = true; + } + finally { + __disposeResources(env_1); + } + } + } + catch (e_1_1) { e_1 = { error: e_1_1 }; } + finally { + try { + if (!_d && !_a && (_b = _e.return)) await _b.call(_e); + } + finally { if (e_1) throw e_1.error; } + } +} diff --git a/tests/baselines/reference/usingDeclarationsInForAwaitOf(target=es2022).js b/tests/baselines/reference/usingDeclarationsInForAwaitOf(target=es2022).js new file mode 100644 index 0000000000000..00737468c933b --- /dev/null +++ b/tests/baselines/reference/usingDeclarationsInForAwaitOf(target=es2022).js @@ -0,0 +1,70 @@ +//// [tests/cases/conformance/statements/VariableStatements/usingDeclarations/usingDeclarationsInForAwaitOf.ts] //// + +//// [usingDeclarationsInForAwaitOf.ts] +async function main() { + for await (using d1 of [{ [Symbol.dispose]() {} }, null, undefined]) { + } +} + + +//// [usingDeclarationsInForAwaitOf.js] +var __addDisposableResource = (this && this.__addDisposableResource) || function (env, value, async) { + if (value !== null && value !== void 0) { + if (typeof value !== "object") throw new TypeError("Object expected."); + var dispose; + if (async) { + if (!Symbol.asyncDispose) throw new TypeError("Symbol.asyncDispose is not defined."); + dispose = value[Symbol.asyncDispose]; + } + if (dispose === void 0) { + if (!Symbol.dispose) throw new TypeError("Symbol.dispose is not defined."); + dispose = value[Symbol.dispose]; + } + if (typeof dispose !== "function") throw new TypeError("Object not disposable."); + env.stack.push({ value: value, dispose: dispose, async: async }); + } + else if (async) { + env.stack.push({ async: true }); + } + return value; +}; +var __disposeResources = (this && this.__disposeResources) || (function (SuppressedError) { + return function (env) { + function fail(e) { + env.error = env.hasError ? new SuppressedError(e, env.error, "An error was suppressed during disposal.") : e; + env.hasError = true; + } + function next() { + while (env.stack.length) { + var rec = env.stack.pop(); + try { + var result = rec.dispose && rec.dispose.call(rec.value); + if (rec.async) return Promise.resolve(result).then(next, function(e) { fail(e); return next(); }); + } + catch (e) { + fail(e); + } + } + if (env.hasError) throw env.error; + } + return next(); + }; +})(typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) { + var e = new Error(message); + return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e; +}); +async function main() { + for await (const d1_1 of [{ [Symbol.dispose]() { } }, null, undefined]) { + const env_1 = { stack: [], error: void 0, hasError: false }; + try { + const d1 = __addDisposableResource(env_1, d1_1, false); + } + catch (e_1) { + env_1.error = e_1; + env_1.hasError = true; + } + finally { + __disposeResources(env_1); + } + } +} diff --git a/tests/baselines/reference/usingDeclarationsInForAwaitOf(target=es5).js b/tests/baselines/reference/usingDeclarationsInForAwaitOf(target=es5).js new file mode 100644 index 0000000000000..0ad207f750744 --- /dev/null +++ b/tests/baselines/reference/usingDeclarationsInForAwaitOf(target=es5).js @@ -0,0 +1,152 @@ +//// [tests/cases/conformance/statements/VariableStatements/usingDeclarations/usingDeclarationsInForAwaitOf.ts] //// + +//// [usingDeclarationsInForAwaitOf.ts] +async function main() { + for await (using d1 of [{ [Symbol.dispose]() {} }, null, undefined]) { + } +} + + +//// [usingDeclarationsInForAwaitOf.js] +var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { + function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } + return new (P || (P = Promise))(function (resolve, reject) { + function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } + function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } + function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } + step((generator = generator.apply(thisArg, _arguments || [])).next()); + }); +}; +var __generator = (this && this.__generator) || function (thisArg, body) { + var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g; + return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g; + function verb(n) { return function (v) { return step([n, v]); }; } + function step(op) { + if (f) throw new TypeError("Generator is already executing."); + while (g && (g = 0, op[0] && (_ = 0)), _) try { + if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t; + if (y = 0, t) op = [op[0] & 2, t.value]; + switch (op[0]) { + case 0: case 1: t = op; break; + case 4: _.label++; return { value: op[1], done: false }; + case 5: _.label++; y = op[1]; op = [0]; continue; + case 7: op = _.ops.pop(); _.trys.pop(); continue; + default: + if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; } + if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; } + if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; } + if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; } + if (t[2]) _.ops.pop(); + _.trys.pop(); continue; + } + op = body.call(thisArg, _); + } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; } + if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true }; + } +}; +var __addDisposableResource = (this && this.__addDisposableResource) || function (env, value, async) { + if (value !== null && value !== void 0) { + if (typeof value !== "object") throw new TypeError("Object expected."); + var dispose; + if (async) { + if (!Symbol.asyncDispose) throw new TypeError("Symbol.asyncDispose is not defined."); + dispose = value[Symbol.asyncDispose]; + } + if (dispose === void 0) { + if (!Symbol.dispose) throw new TypeError("Symbol.dispose is not defined."); + dispose = value[Symbol.dispose]; + } + if (typeof dispose !== "function") throw new TypeError("Object not disposable."); + env.stack.push({ value: value, dispose: dispose, async: async }); + } + else if (async) { + env.stack.push({ async: true }); + } + return value; +}; +var __disposeResources = (this && this.__disposeResources) || (function (SuppressedError) { + return function (env) { + function fail(e) { + env.error = env.hasError ? new SuppressedError(e, env.error, "An error was suppressed during disposal.") : e; + env.hasError = true; + } + function next() { + while (env.stack.length) { + var rec = env.stack.pop(); + try { + var result = rec.dispose && rec.dispose.call(rec.value); + if (rec.async) return Promise.resolve(result).then(next, function(e) { fail(e); return next(); }); + } + catch (e) { + fail(e); + } + } + if (env.hasError) throw env.error; + } + return next(); + }; +})(typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) { + var e = new Error(message); + return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e; +}); +var __asyncValues = (this && this.__asyncValues) || function (o) { + if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined."); + var m = o[Symbol.asyncIterator], i; + return m ? m.call(o) : (o = typeof __values === "function" ? __values(o) : o[Symbol.iterator](), i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i); + function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; } + function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); } +}; +function main() { + var _a, e_1, _b, _c; + return __awaiter(this, void 0, void 0, function () { + var _d, _e, _f, d1_1, env_1, d1, e_1_1; + var _g; + return __generator(this, function (_h) { + switch (_h.label) { + case 0: + _h.trys.push([0, 5, 6, 11]); + _d = true, _e = __asyncValues([(_g = {}, _g[Symbol.dispose] = function () { }, _g), null, undefined]); + _h.label = 1; + case 1: return [4 /*yield*/, _e.next()]; + case 2: + if (!(_f = _h.sent(), _a = _f.done, !_a)) return [3 /*break*/, 4]; + _c = _f.value; + _d = false; + d1_1 = _c; + env_1 = { stack: [], error: void 0, hasError: false }; + try { + d1 = __addDisposableResource(env_1, d1_1, false); + } + catch (e_2) { + env_1.error = e_2; + env_1.hasError = true; + } + finally { + __disposeResources(env_1); + } + _h.label = 3; + case 3: + _d = true; + return [3 /*break*/, 1]; + case 4: return [3 /*break*/, 11]; + case 5: + e_1_1 = _h.sent(); + e_1 = { error: e_1_1 }; + return [3 /*break*/, 11]; + case 6: + _h.trys.push([6, , 9, 10]); + if (!(!_d && !_a && (_b = _e.return))) return [3 /*break*/, 8]; + return [4 /*yield*/, _b.call(_e)]; + case 7: + _h.sent(); + _h.label = 8; + case 8: return [3 /*break*/, 10]; + case 9: + if (e_1) throw e_1.error; + return [7 /*endfinally*/]; + case 10: return [7 /*endfinally*/]; + case 11: return [2 /*return*/]; + } + }); + }); +} diff --git a/tests/baselines/reference/usingDeclarationsInForAwaitOf(target=esnext).js b/tests/baselines/reference/usingDeclarationsInForAwaitOf(target=esnext).js new file mode 100644 index 0000000000000..c17e98d6a6732 --- /dev/null +++ b/tests/baselines/reference/usingDeclarationsInForAwaitOf(target=esnext).js @@ -0,0 +1,14 @@ +//// [tests/cases/conformance/statements/VariableStatements/usingDeclarations/usingDeclarationsInForAwaitOf.ts] //// + +//// [usingDeclarationsInForAwaitOf.ts] +async function main() { + for await (using d1 of [{ [Symbol.dispose]() {} }, null, undefined]) { + } +} + + +//// [usingDeclarationsInForAwaitOf.js] +async function main() { + for await (using d1 of [{ [Symbol.dispose]() { } }, null, undefined]) { + } +} diff --git a/tests/baselines/reference/usingDeclarationsInForIn.errors.txt b/tests/baselines/reference/usingDeclarationsInForIn.errors.txt new file mode 100644 index 0000000000000..123b337194841 --- /dev/null +++ b/tests/baselines/reference/usingDeclarationsInForIn.errors.txt @@ -0,0 +1,9 @@ +usingDeclarationsInForIn.ts(1,6): error TS1493: The left-hand side of a 'for...in' statement cannot be a 'using' declaration. + + +==== usingDeclarationsInForIn.ts (1 errors) ==== + for (using x in {}) { + ~~~~~~~ +!!! error TS1493: The left-hand side of a 'for...in' statement cannot be a 'using' declaration. + } + \ No newline at end of file diff --git a/tests/baselines/reference/usingDeclarationsInForIn.js b/tests/baselines/reference/usingDeclarationsInForIn.js new file mode 100644 index 0000000000000..fce8a93bb9d3c --- /dev/null +++ b/tests/baselines/reference/usingDeclarationsInForIn.js @@ -0,0 +1,10 @@ +//// [tests/cases/conformance/statements/VariableStatements/usingDeclarations/usingDeclarationsInForIn.ts] //// + +//// [usingDeclarationsInForIn.ts] +for (using x in {}) { +} + + +//// [usingDeclarationsInForIn.js] +for (using x in {}) { +} diff --git a/tests/baselines/reference/usingDeclarationsInForOf.1(target=es2015).js b/tests/baselines/reference/usingDeclarationsInForOf.1(target=es2015).js new file mode 100644 index 0000000000000..bf993d5fb624b --- /dev/null +++ b/tests/baselines/reference/usingDeclarationsInForOf.1(target=es2015).js @@ -0,0 +1,66 @@ +//// [tests/cases/conformance/statements/VariableStatements/usingDeclarations/usingDeclarationsInForOf.1.ts] //// + +//// [usingDeclarationsInForOf.1.ts] +for (using d1 of [{ [Symbol.dispose]() {} }, null, undefined]) { +} + + +//// [usingDeclarationsInForOf.1.js] +var __addDisposableResource = (this && this.__addDisposableResource) || function (env, value, async) { + if (value !== null && value !== void 0) { + if (typeof value !== "object") throw new TypeError("Object expected."); + var dispose; + if (async) { + if (!Symbol.asyncDispose) throw new TypeError("Symbol.asyncDispose is not defined."); + dispose = value[Symbol.asyncDispose]; + } + if (dispose === void 0) { + if (!Symbol.dispose) throw new TypeError("Symbol.dispose is not defined."); + dispose = value[Symbol.dispose]; + } + if (typeof dispose !== "function") throw new TypeError("Object not disposable."); + env.stack.push({ value: value, dispose: dispose, async: async }); + } + else if (async) { + env.stack.push({ async: true }); + } + return value; +}; +var __disposeResources = (this && this.__disposeResources) || (function (SuppressedError) { + return function (env) { + function fail(e) { + env.error = env.hasError ? new SuppressedError(e, env.error, "An error was suppressed during disposal.") : e; + env.hasError = true; + } + function next() { + while (env.stack.length) { + var rec = env.stack.pop(); + try { + var result = rec.dispose && rec.dispose.call(rec.value); + if (rec.async) return Promise.resolve(result).then(next, function(e) { fail(e); return next(); }); + } + catch (e) { + fail(e); + } + } + if (env.hasError) throw env.error; + } + return next(); + }; +})(typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) { + var e = new Error(message); + return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e; +}); +for (const d1_1 of [{ [Symbol.dispose]() { } }, null, undefined]) { + const env_1 = { stack: [], error: void 0, hasError: false }; + try { + const d1 = __addDisposableResource(env_1, d1_1, false); + } + catch (e_1) { + env_1.error = e_1; + env_1.hasError = true; + } + finally { + __disposeResources(env_1); + } +} diff --git a/tests/baselines/reference/usingDeclarationsInForOf.1(target=es2017).js b/tests/baselines/reference/usingDeclarationsInForOf.1(target=es2017).js new file mode 100644 index 0000000000000..bf993d5fb624b --- /dev/null +++ b/tests/baselines/reference/usingDeclarationsInForOf.1(target=es2017).js @@ -0,0 +1,66 @@ +//// [tests/cases/conformance/statements/VariableStatements/usingDeclarations/usingDeclarationsInForOf.1.ts] //// + +//// [usingDeclarationsInForOf.1.ts] +for (using d1 of [{ [Symbol.dispose]() {} }, null, undefined]) { +} + + +//// [usingDeclarationsInForOf.1.js] +var __addDisposableResource = (this && this.__addDisposableResource) || function (env, value, async) { + if (value !== null && value !== void 0) { + if (typeof value !== "object") throw new TypeError("Object expected."); + var dispose; + if (async) { + if (!Symbol.asyncDispose) throw new TypeError("Symbol.asyncDispose is not defined."); + dispose = value[Symbol.asyncDispose]; + } + if (dispose === void 0) { + if (!Symbol.dispose) throw new TypeError("Symbol.dispose is not defined."); + dispose = value[Symbol.dispose]; + } + if (typeof dispose !== "function") throw new TypeError("Object not disposable."); + env.stack.push({ value: value, dispose: dispose, async: async }); + } + else if (async) { + env.stack.push({ async: true }); + } + return value; +}; +var __disposeResources = (this && this.__disposeResources) || (function (SuppressedError) { + return function (env) { + function fail(e) { + env.error = env.hasError ? new SuppressedError(e, env.error, "An error was suppressed during disposal.") : e; + env.hasError = true; + } + function next() { + while (env.stack.length) { + var rec = env.stack.pop(); + try { + var result = rec.dispose && rec.dispose.call(rec.value); + if (rec.async) return Promise.resolve(result).then(next, function(e) { fail(e); return next(); }); + } + catch (e) { + fail(e); + } + } + if (env.hasError) throw env.error; + } + return next(); + }; +})(typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) { + var e = new Error(message); + return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e; +}); +for (const d1_1 of [{ [Symbol.dispose]() { } }, null, undefined]) { + const env_1 = { stack: [], error: void 0, hasError: false }; + try { + const d1 = __addDisposableResource(env_1, d1_1, false); + } + catch (e_1) { + env_1.error = e_1; + env_1.hasError = true; + } + finally { + __disposeResources(env_1); + } +} diff --git a/tests/baselines/reference/usingDeclarationsInForOf.1(target=es2022).js b/tests/baselines/reference/usingDeclarationsInForOf.1(target=es2022).js new file mode 100644 index 0000000000000..bf993d5fb624b --- /dev/null +++ b/tests/baselines/reference/usingDeclarationsInForOf.1(target=es2022).js @@ -0,0 +1,66 @@ +//// [tests/cases/conformance/statements/VariableStatements/usingDeclarations/usingDeclarationsInForOf.1.ts] //// + +//// [usingDeclarationsInForOf.1.ts] +for (using d1 of [{ [Symbol.dispose]() {} }, null, undefined]) { +} + + +//// [usingDeclarationsInForOf.1.js] +var __addDisposableResource = (this && this.__addDisposableResource) || function (env, value, async) { + if (value !== null && value !== void 0) { + if (typeof value !== "object") throw new TypeError("Object expected."); + var dispose; + if (async) { + if (!Symbol.asyncDispose) throw new TypeError("Symbol.asyncDispose is not defined."); + dispose = value[Symbol.asyncDispose]; + } + if (dispose === void 0) { + if (!Symbol.dispose) throw new TypeError("Symbol.dispose is not defined."); + dispose = value[Symbol.dispose]; + } + if (typeof dispose !== "function") throw new TypeError("Object not disposable."); + env.stack.push({ value: value, dispose: dispose, async: async }); + } + else if (async) { + env.stack.push({ async: true }); + } + return value; +}; +var __disposeResources = (this && this.__disposeResources) || (function (SuppressedError) { + return function (env) { + function fail(e) { + env.error = env.hasError ? new SuppressedError(e, env.error, "An error was suppressed during disposal.") : e; + env.hasError = true; + } + function next() { + while (env.stack.length) { + var rec = env.stack.pop(); + try { + var result = rec.dispose && rec.dispose.call(rec.value); + if (rec.async) return Promise.resolve(result).then(next, function(e) { fail(e); return next(); }); + } + catch (e) { + fail(e); + } + } + if (env.hasError) throw env.error; + } + return next(); + }; +})(typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) { + var e = new Error(message); + return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e; +}); +for (const d1_1 of [{ [Symbol.dispose]() { } }, null, undefined]) { + const env_1 = { stack: [], error: void 0, hasError: false }; + try { + const d1 = __addDisposableResource(env_1, d1_1, false); + } + catch (e_1) { + env_1.error = e_1; + env_1.hasError = true; + } + finally { + __disposeResources(env_1); + } +} diff --git a/tests/baselines/reference/usingDeclarationsInForOf.1(target=es5).js b/tests/baselines/reference/usingDeclarationsInForOf.1(target=es5).js new file mode 100644 index 0000000000000..f80303d1cfdcf --- /dev/null +++ b/tests/baselines/reference/usingDeclarationsInForOf.1(target=es5).js @@ -0,0 +1,68 @@ +//// [tests/cases/conformance/statements/VariableStatements/usingDeclarations/usingDeclarationsInForOf.1.ts] //// + +//// [usingDeclarationsInForOf.1.ts] +for (using d1 of [{ [Symbol.dispose]() {} }, null, undefined]) { +} + + +//// [usingDeclarationsInForOf.1.js] +var __addDisposableResource = (this && this.__addDisposableResource) || function (env, value, async) { + if (value !== null && value !== void 0) { + if (typeof value !== "object") throw new TypeError("Object expected."); + var dispose; + if (async) { + if (!Symbol.asyncDispose) throw new TypeError("Symbol.asyncDispose is not defined."); + dispose = value[Symbol.asyncDispose]; + } + if (dispose === void 0) { + if (!Symbol.dispose) throw new TypeError("Symbol.dispose is not defined."); + dispose = value[Symbol.dispose]; + } + if (typeof dispose !== "function") throw new TypeError("Object not disposable."); + env.stack.push({ value: value, dispose: dispose, async: async }); + } + else if (async) { + env.stack.push({ async: true }); + } + return value; +}; +var __disposeResources = (this && this.__disposeResources) || (function (SuppressedError) { + return function (env) { + function fail(e) { + env.error = env.hasError ? new SuppressedError(e, env.error, "An error was suppressed during disposal.") : e; + env.hasError = true; + } + function next() { + while (env.stack.length) { + var rec = env.stack.pop(); + try { + var result = rec.dispose && rec.dispose.call(rec.value); + if (rec.async) return Promise.resolve(result).then(next, function(e) { fail(e); return next(); }); + } + catch (e) { + fail(e); + } + } + if (env.hasError) throw env.error; + } + return next(); + }; +})(typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) { + var e = new Error(message); + return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e; +}); +var _a; +for (var _i = 0, _b = [(_a = {}, _a[Symbol.dispose] = function () { }, _a), null, undefined]; _i < _b.length; _i++) { + var d1_1 = _b[_i]; + var env_1 = { stack: [], error: void 0, hasError: false }; + try { + var d1 = __addDisposableResource(env_1, d1_1, false); + } + catch (e_1) { + env_1.error = e_1; + env_1.hasError = true; + } + finally { + __disposeResources(env_1); + } +} diff --git a/tests/baselines/reference/usingDeclarationsInForOf.1(target=esnext).js b/tests/baselines/reference/usingDeclarationsInForOf.1(target=esnext).js new file mode 100644 index 0000000000000..aaebb8948a2b6 --- /dev/null +++ b/tests/baselines/reference/usingDeclarationsInForOf.1(target=esnext).js @@ -0,0 +1,10 @@ +//// [tests/cases/conformance/statements/VariableStatements/usingDeclarations/usingDeclarationsInForOf.1.ts] //// + +//// [usingDeclarationsInForOf.1.ts] +for (using d1 of [{ [Symbol.dispose]() {} }, null, undefined]) { +} + + +//// [usingDeclarationsInForOf.1.js] +for (using d1 of [{ [Symbol.dispose]() { } }, null, undefined]) { +} diff --git a/tests/baselines/reference/usingDeclarationsInForOf.2.errors.txt b/tests/baselines/reference/usingDeclarationsInForOf.2.errors.txt new file mode 100644 index 0000000000000..2e5ee586ec13a --- /dev/null +++ b/tests/baselines/reference/usingDeclarationsInForOf.2.errors.txt @@ -0,0 +1,15 @@ +usingDeclarationsInForOf.2.ts(1,6): error TS2304: Cannot find name 'using'. +usingDeclarationsInForOf.2.ts(1,15): error TS2304: Cannot find name 'of'. +usingDeclarationsInForOf.2.ts(1,19): error TS1011: An element access expression should take an argument. + + +==== usingDeclarationsInForOf.2.ts (3 errors) ==== + for (using of of []) { + ~~~~~ +!!! error TS2304: Cannot find name 'using'. + ~~ +!!! error TS2304: Cannot find name 'of'. + +!!! error TS1011: An element access expression should take an argument. + } + \ No newline at end of file diff --git a/tests/baselines/reference/usingDeclarationsInForOf.2.js b/tests/baselines/reference/usingDeclarationsInForOf.2.js new file mode 100644 index 0000000000000..d965d7aa458dc --- /dev/null +++ b/tests/baselines/reference/usingDeclarationsInForOf.2.js @@ -0,0 +1,10 @@ +//// [tests/cases/conformance/statements/VariableStatements/usingDeclarations/usingDeclarationsInForOf.2.ts] //// + +//// [usingDeclarationsInForOf.2.ts] +for (using of of []) { +} + + +//// [usingDeclarationsInForOf.2.js] +for (using of of[]) { +} diff --git a/tests/baselines/reference/usingDeclarationsInForOf.3.errors.txt b/tests/baselines/reference/usingDeclarationsInForOf.3.errors.txt new file mode 100644 index 0000000000000..3af402cdc74d5 --- /dev/null +++ b/tests/baselines/reference/usingDeclarationsInForOf.3.errors.txt @@ -0,0 +1,9 @@ +usingDeclarationsInForOf.3.ts(1,12): error TS1492: 'using' declarations may not have binding patterns. + + +==== usingDeclarationsInForOf.3.ts (1 errors) ==== + for (using {} of []) { + ~~ +!!! error TS1492: 'using' declarations may not have binding patterns. + } + \ No newline at end of file diff --git a/tests/baselines/reference/usingDeclarationsInForOf.3.js b/tests/baselines/reference/usingDeclarationsInForOf.3.js new file mode 100644 index 0000000000000..877a260326521 --- /dev/null +++ b/tests/baselines/reference/usingDeclarationsInForOf.3.js @@ -0,0 +1,10 @@ +//// [tests/cases/conformance/statements/VariableStatements/usingDeclarations/usingDeclarationsInForOf.3.ts] //// + +//// [usingDeclarationsInForOf.3.ts] +for (using {} of []) { +} + + +//// [usingDeclarationsInForOf.3.js] +for (using {} of []) { +} diff --git a/tests/baselines/reference/usingDeclarationsNamedEvaluationDecoratorsAndClassFields.js b/tests/baselines/reference/usingDeclarationsNamedEvaluationDecoratorsAndClassFields.js new file mode 100644 index 0000000000000..a08e0c7f6c3f2 --- /dev/null +++ b/tests/baselines/reference/usingDeclarationsNamedEvaluationDecoratorsAndClassFields.js @@ -0,0 +1,171 @@ +//// [tests/cases/conformance/statements/VariableStatements/usingDeclarations/usingDeclarationsNamedEvaluationDecoratorsAndClassFields.ts] //// + +//// [usingDeclarationsNamedEvaluationDecoratorsAndClassFields.ts] +export {}; + +declare var dec: any; + +using C1 = class { + static [Symbol.dispose]() {} +}; + +using C2 = class { + static x = 1; + static [Symbol.dispose]() {} +}; + +using C3 = @dec class { + static [Symbol.dispose]() {} +}; + +using C4 = @dec class { + static x = 1; + static [Symbol.dispose]() {} +}; + + +//// [usingDeclarationsNamedEvaluationDecoratorsAndClassFields.js] +var __esDecorate = (this && this.__esDecorate) || function (ctor, descriptorIn, decorators, contextIn, initializers, extraInitializers) { + function accept(f) { if (f !== void 0 && typeof f !== "function") throw new TypeError("Function expected"); return f; } + var kind = contextIn.kind, key = kind === "getter" ? "get" : kind === "setter" ? "set" : "value"; + var target = !descriptorIn && ctor ? contextIn["static"] ? ctor : ctor.prototype : null; + var descriptor = descriptorIn || (target ? Object.getOwnPropertyDescriptor(target, contextIn.name) : {}); + var _, done = false; + for (var i = decorators.length - 1; i >= 0; i--) { + var context = {}; + for (var p in contextIn) context[p] = p === "access" ? {} : contextIn[p]; + for (var p in contextIn.access) context.access[p] = contextIn.access[p]; + context.addInitializer = function (f) { if (done) throw new TypeError("Cannot add initializers after decoration has completed"); extraInitializers.push(accept(f || null)); }; + var result = (0, decorators[i])(kind === "accessor" ? { get: descriptor.get, set: descriptor.set } : descriptor[key], context); + if (kind === "accessor") { + if (result === void 0) continue; + if (result === null || typeof result !== "object") throw new TypeError("Object expected"); + if (_ = accept(result.get)) descriptor.get = _; + if (_ = accept(result.set)) descriptor.set = _; + if (_ = accept(result.init)) initializers.unshift(_); + } + else if (_ = accept(result)) { + if (kind === "field") initializers.unshift(_); + else descriptor[key] = _; + } + } + if (target) Object.defineProperty(target, contextIn.name, descriptor); + done = true; +}; +var __runInitializers = (this && this.__runInitializers) || function (thisArg, initializers, value) { + var useValue = arguments.length > 2; + for (var i = 0; i < initializers.length; i++) { + value = useValue ? initializers[i].call(thisArg, value) : initializers[i].call(thisArg); + } + return useValue ? value : void 0; +}; +var __setFunctionName = (this && this.__setFunctionName) || function (f, name, prefix) { + if (typeof name === "symbol") name = name.description ? "[".concat(name.description, "]") : ""; + return Object.defineProperty(f, "name", { configurable: true, value: prefix ? "".concat(prefix, " ", name) : name }); +}; +var __addDisposableResource = (this && this.__addDisposableResource) || function (env, value, async) { + if (value !== null && value !== void 0) { + if (typeof value !== "object") throw new TypeError("Object expected."); + var dispose; + if (async) { + if (!Symbol.asyncDispose) throw new TypeError("Symbol.asyncDispose is not defined."); + dispose = value[Symbol.asyncDispose]; + } + if (dispose === void 0) { + if (!Symbol.dispose) throw new TypeError("Symbol.dispose is not defined."); + dispose = value[Symbol.dispose]; + } + if (typeof dispose !== "function") throw new TypeError("Object not disposable."); + env.stack.push({ value: value, dispose: dispose, async: async }); + } + else if (async) { + env.stack.push({ async: true }); + } + return value; +}; +var __disposeResources = (this && this.__disposeResources) || (function (SuppressedError) { + return function (env) { + function fail(e) { + env.error = env.hasError ? new SuppressedError(e, env.error, "An error was suppressed during disposal.") : e; + env.hasError = true; + } + function next() { + while (env.stack.length) { + var rec = env.stack.pop(); + try { + var result = rec.dispose && rec.dispose.call(rec.value); + if (rec.async) return Promise.resolve(result).then(next, function(e) { fail(e); return next(); }); + } + catch (e) { + fail(e); + } + } + if (env.hasError) throw env.error; + } + return next(); + }; +})(typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) { + var e = new Error(message); + return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e; +}); +var _a, _b; +var C1, C2, C3, C4; +const env_1 = { stack: [], error: void 0, hasError: false }; +try { + C1 = __addDisposableResource(env_1, (_a = class { + static [Symbol.dispose]() { } + }, + __setFunctionName(_a, "C1"), + _a), false); + C2 = __addDisposableResource(env_1, (_b = class { + static [Symbol.dispose]() { } + }, + __setFunctionName(_b, "C2"), + _b.x = 1, + _b), false); + C3 = __addDisposableResource(env_1, (() => { + let _classDecorators = [dec]; + let _classDescriptor; + let _classExtraInitializers = []; + let _classThis; + var class_1 = (_classThis = class { + static [Symbol.dispose]() { } + }, + __setFunctionName(_classThis, "C3"), + (() => { + __esDecorate(null, _classDescriptor = { value: _classThis }, _classDecorators, { kind: "class", name: _classThis.name }, null, _classExtraInitializers); + class_1 = _classThis = _classDescriptor.value; + __runInitializers(_classThis, _classExtraInitializers); + })(), + _classThis); + return class_1 = _classThis; + })(), false); + C4 = __addDisposableResource(env_1, (() => { + let _classDecorators = [dec]; + let _classDescriptor; + let _classExtraInitializers = []; + let _classThis; + var class_2 = (_classThis = class { + static [Symbol.dispose]() { } + }, + __setFunctionName(_classThis, "C4"), + (() => { + __esDecorate(null, _classDescriptor = { value: _classThis }, _classDecorators, { kind: "class", name: _classThis.name }, null, _classExtraInitializers); + class_2 = _classThis = _classDescriptor.value; + })(), + _classThis.x = 1, + (() => { + __runInitializers(_classThis, _classExtraInitializers); + })(), + _classThis); + return class_2 = _classThis; + })(), false); +} +catch (e_1) { + env_1.error = e_1; + env_1.hasError = true; +} +finally { + __disposeResources(env_1); +} +export {}; diff --git a/tests/baselines/reference/usingDeclarationsTopLevelOfModule.1(module=amd).js b/tests/baselines/reference/usingDeclarationsTopLevelOfModule.1(module=amd).js new file mode 100644 index 0000000000000..395532fcb8976 --- /dev/null +++ b/tests/baselines/reference/usingDeclarationsTopLevelOfModule.1(module=amd).js @@ -0,0 +1,40 @@ +//// [tests/cases/conformance/statements/VariableStatements/usingDeclarations/usingDeclarationsTopLevelOfModule.1.ts] //// + +//// [usingDeclarationsTopLevelOfModule.1.ts] +export const x = 1; +export { y }; + +using z = { [Symbol.dispose]() {} }; + +const y = 2; + +export const w = 3; + +export default 4; + +console.log(w, x, y, z); + + +//// [usingDeclarationsTopLevelOfModule.1.js] +define(["require", "exports"], function (require, exports) { + "use strict"; + Object.defineProperty(exports, "__esModule", { value: true }); + exports.w = exports.default = exports.y = exports.x = void 0; + exports.x = 1; + var z, y, _default; + const env_1 = { stack: [], error: void 0, hasError: false }; + try { + z = __addDisposableResource(env_1, { [Symbol.dispose]() { } }, false); + exports.y = y = 2; + exports.w = 3; + exports.default = _default = 4; + console.log(exports.w, exports.x, y, z); + } + catch (e_1) { + env_1.error = e_1; + env_1.hasError = true; + } + finally { + __disposeResources(env_1); + } +}); diff --git a/tests/baselines/reference/usingDeclarationsTopLevelOfModule.1(module=commonjs).js b/tests/baselines/reference/usingDeclarationsTopLevelOfModule.1(module=commonjs).js new file mode 100644 index 0000000000000..a5f84cfaff481 --- /dev/null +++ b/tests/baselines/reference/usingDeclarationsTopLevelOfModule.1(module=commonjs).js @@ -0,0 +1,38 @@ +//// [tests/cases/conformance/statements/VariableStatements/usingDeclarations/usingDeclarationsTopLevelOfModule.1.ts] //// + +//// [usingDeclarationsTopLevelOfModule.1.ts] +export const x = 1; +export { y }; + +using z = { [Symbol.dispose]() {} }; + +const y = 2; + +export const w = 3; + +export default 4; + +console.log(w, x, y, z); + + +//// [usingDeclarationsTopLevelOfModule.1.js] +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.w = exports.default = exports.y = exports.x = void 0; +exports.x = 1; +var z, y, _default; +const env_1 = { stack: [], error: void 0, hasError: false }; +try { + z = __addDisposableResource(env_1, { [Symbol.dispose]() { } }, false); + exports.y = y = 2; + exports.w = 3; + exports.default = _default = 4; + console.log(exports.w, exports.x, y, z); +} +catch (e_1) { + env_1.error = e_1; + env_1.hasError = true; +} +finally { + __disposeResources(env_1); +} diff --git a/tests/baselines/reference/usingDeclarationsTopLevelOfModule.1(module=esnext).js b/tests/baselines/reference/usingDeclarationsTopLevelOfModule.1(module=esnext).js new file mode 100644 index 0000000000000..7d293d96534ab --- /dev/null +++ b/tests/baselines/reference/usingDeclarationsTopLevelOfModule.1(module=esnext).js @@ -0,0 +1,38 @@ +//// [tests/cases/conformance/statements/VariableStatements/usingDeclarations/usingDeclarationsTopLevelOfModule.1.ts] //// + +//// [usingDeclarationsTopLevelOfModule.1.ts] +export const x = 1; +export { y }; + +using z = { [Symbol.dispose]() {} }; + +const y = 2; + +export const w = 3; + +export default 4; + +console.log(w, x, y, z); + + +//// [usingDeclarationsTopLevelOfModule.1.js] +export const x = 1; +export { y }; +export { _default as default }; +var z, y, _default; +export let w; +const env_1 = { stack: [], error: void 0, hasError: false }; +try { + z = __addDisposableResource(env_1, { [Symbol.dispose]() { } }, false); + y = 2; + w = 3; + _default = 4; + console.log(w, x, y, z); +} +catch (e_1) { + env_1.error = e_1; + env_1.hasError = true; +} +finally { + __disposeResources(env_1); +} diff --git a/tests/baselines/reference/usingDeclarationsTopLevelOfModule.1(module=system).js b/tests/baselines/reference/usingDeclarationsTopLevelOfModule.1(module=system).js new file mode 100644 index 0000000000000..27ac418009b49 --- /dev/null +++ b/tests/baselines/reference/usingDeclarationsTopLevelOfModule.1(module=system).js @@ -0,0 +1,44 @@ +//// [tests/cases/conformance/statements/VariableStatements/usingDeclarations/usingDeclarationsTopLevelOfModule.1.ts] //// + +//// [usingDeclarationsTopLevelOfModule.1.ts] +export const x = 1; +export { y }; + +using z = { [Symbol.dispose]() {} }; + +const y = 2; + +export const w = 3; + +export default 4; + +console.log(w, x, y, z); + + +//// [usingDeclarationsTopLevelOfModule.1.js] +System.register([], function (exports_1, context_1) { + "use strict"; + var x, z, y, _default, w, env_1; + var __moduleName = context_1 && context_1.id; + return { + setters: [], + execute: function () { + exports_1("x", x = 1); + env_1 = { stack: [], error: void 0, hasError: false }; + try { + z = __addDisposableResource(env_1, { [Symbol.dispose]() { } }, false); + exports_1("y", y = 2); + exports_1("w", w = 3); + exports_1("default", _default = 4); + console.log(w, x, y, z); + } + catch (e_1) { + env_1.error = e_1; + env_1.hasError = true; + } + finally { + __disposeResources(env_1); + } + } + }; +}); diff --git a/tests/baselines/reference/usingDeclarationsTopLevelOfModule.2(module=amd).js b/tests/baselines/reference/usingDeclarationsTopLevelOfModule.2(module=amd).js new file mode 100644 index 0000000000000..e93cbc963b3e8 --- /dev/null +++ b/tests/baselines/reference/usingDeclarationsTopLevelOfModule.2(module=amd).js @@ -0,0 +1,31 @@ +//// [tests/cases/conformance/statements/VariableStatements/usingDeclarations/usingDeclarationsTopLevelOfModule.2.ts] //// + +//// [usingDeclarationsTopLevelOfModule.2.ts] +using z = { [Symbol.dispose]() {} }; + +const y = 2; + +console.log(y, z); +export = 4; + + +//// [usingDeclarationsTopLevelOfModule.2.js] +define(["require", "exports"], function (require, exports) { + "use strict"; + var z, y, _default; + const env_1 = { stack: [], error: void 0, hasError: false }; + try { + z = __addDisposableResource(env_1, { [Symbol.dispose]() { } }, false); + y = 2; + console.log(y, z); + _default = 4; + } + catch (e_1) { + env_1.error = e_1; + env_1.hasError = true; + } + finally { + __disposeResources(env_1); + } + return _default; +}); diff --git a/tests/baselines/reference/usingDeclarationsTopLevelOfModule.2(module=commonjs).js b/tests/baselines/reference/usingDeclarationsTopLevelOfModule.2(module=commonjs).js new file mode 100644 index 0000000000000..f9e2147667d2e --- /dev/null +++ b/tests/baselines/reference/usingDeclarationsTopLevelOfModule.2(module=commonjs).js @@ -0,0 +1,29 @@ +//// [tests/cases/conformance/statements/VariableStatements/usingDeclarations/usingDeclarationsTopLevelOfModule.2.ts] //// + +//// [usingDeclarationsTopLevelOfModule.2.ts] +using z = { [Symbol.dispose]() {} }; + +const y = 2; + +console.log(y, z); +export = 4; + + +//// [usingDeclarationsTopLevelOfModule.2.js] +"use strict"; +var z, y, _default; +const env_1 = { stack: [], error: void 0, hasError: false }; +try { + z = __addDisposableResource(env_1, { [Symbol.dispose]() { } }, false); + y = 2; + console.log(y, z); + _default = 4; +} +catch (e_1) { + env_1.error = e_1; + env_1.hasError = true; +} +finally { + __disposeResources(env_1); +} +module.exports = _default; diff --git a/tests/baselines/reference/usingDeclarationsTopLevelOfModule.3(module=amd).js b/tests/baselines/reference/usingDeclarationsTopLevelOfModule.3(module=amd).js new file mode 100644 index 0000000000000..9d52c8edf8d64 --- /dev/null +++ b/tests/baselines/reference/usingDeclarationsTopLevelOfModule.3(module=amd).js @@ -0,0 +1,42 @@ +//// [tests/cases/conformance/statements/VariableStatements/usingDeclarations/usingDeclarationsTopLevelOfModule.3.ts] //// + +//// [usingDeclarationsTopLevelOfModule.3.ts] +export { y }; + +using z = { [Symbol.dispose]() {} }; + +if (false) { + var y = 1; +} + +function f() { + console.log(y, z); +} + + + +//// [usingDeclarationsTopLevelOfModule.3.js] +define(["require", "exports"], function (require, exports) { + "use strict"; + Object.defineProperty(exports, "__esModule", { value: true }); + exports.y = void 0; + function f() { + console.log(y, z); + } + var z; + const env_1 = { stack: [], error: void 0, hasError: false }; + try { + z = __addDisposableResource(env_1, { [Symbol.dispose]() { } }, false); + if (false) { + var y = 1; + exports.y = y; + } + } + catch (e_1) { + env_1.error = e_1; + env_1.hasError = true; + } + finally { + __disposeResources(env_1); + } +}); diff --git a/tests/baselines/reference/usingDeclarationsTopLevelOfModule.3(module=commonjs).js b/tests/baselines/reference/usingDeclarationsTopLevelOfModule.3(module=commonjs).js new file mode 100644 index 0000000000000..ac9dc368e1807 --- /dev/null +++ b/tests/baselines/reference/usingDeclarationsTopLevelOfModule.3(module=commonjs).js @@ -0,0 +1,40 @@ +//// [tests/cases/conformance/statements/VariableStatements/usingDeclarations/usingDeclarationsTopLevelOfModule.3.ts] //// + +//// [usingDeclarationsTopLevelOfModule.3.ts] +export { y }; + +using z = { [Symbol.dispose]() {} }; + +if (false) { + var y = 1; +} + +function f() { + console.log(y, z); +} + + + +//// [usingDeclarationsTopLevelOfModule.3.js] +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.y = void 0; +function f() { + console.log(y, z); +} +var z; +const env_1 = { stack: [], error: void 0, hasError: false }; +try { + z = __addDisposableResource(env_1, { [Symbol.dispose]() { } }, false); + if (false) { + var y = 1; + exports.y = y; + } +} +catch (e_1) { + env_1.error = e_1; + env_1.hasError = true; +} +finally { + __disposeResources(env_1); +} diff --git a/tests/baselines/reference/usingDeclarationsTopLevelOfModule.3(module=esnext).js b/tests/baselines/reference/usingDeclarationsTopLevelOfModule.3(module=esnext).js new file mode 100644 index 0000000000000..2e7482a371455 --- /dev/null +++ b/tests/baselines/reference/usingDeclarationsTopLevelOfModule.3(module=esnext).js @@ -0,0 +1,37 @@ +//// [tests/cases/conformance/statements/VariableStatements/usingDeclarations/usingDeclarationsTopLevelOfModule.3.ts] //// + +//// [usingDeclarationsTopLevelOfModule.3.ts] +export { y }; + +using z = { [Symbol.dispose]() {} }; + +if (false) { + var y = 1; +} + +function f() { + console.log(y, z); +} + + + +//// [usingDeclarationsTopLevelOfModule.3.js] +export { y }; +function f() { + console.log(y, z); +} +var z; +const env_1 = { stack: [], error: void 0, hasError: false }; +try { + z = __addDisposableResource(env_1, { [Symbol.dispose]() { } }, false); + if (false) { + var y = 1; + } +} +catch (e_1) { + env_1.error = e_1; + env_1.hasError = true; +} +finally { + __disposeResources(env_1); +} diff --git a/tests/baselines/reference/usingDeclarationsTopLevelOfModule.3(module=system).js b/tests/baselines/reference/usingDeclarationsTopLevelOfModule.3(module=system).js new file mode 100644 index 0000000000000..7cdecf655297d --- /dev/null +++ b/tests/baselines/reference/usingDeclarationsTopLevelOfModule.3(module=system).js @@ -0,0 +1,46 @@ +//// [tests/cases/conformance/statements/VariableStatements/usingDeclarations/usingDeclarationsTopLevelOfModule.3.ts] //// + +//// [usingDeclarationsTopLevelOfModule.3.ts] +export { y }; + +using z = { [Symbol.dispose]() {} }; + +if (false) { + var y = 1; +} + +function f() { + console.log(y, z); +} + + + +//// [usingDeclarationsTopLevelOfModule.3.js] +System.register([], function (exports_1, context_1) { + "use strict"; + var z, env_1, y; + var __moduleName = context_1 && context_1.id; + function f() { + console.log(y, z); + } + return { + setters: [], + execute: function () { + env_1 = { stack: [], error: void 0, hasError: false }; + try { + z = __addDisposableResource(env_1, { [Symbol.dispose]() { } }, false); + if (false) { + y = 1; + exports_1("y", y); + } + } + catch (e_1) { + env_1.error = e_1; + env_1.hasError = true; + } + finally { + __disposeResources(env_1); + } + } + }; +}); diff --git a/tests/baselines/reference/usingDeclarationsWithESClassDecorators.1(module=commonjs,target=es2015).js b/tests/baselines/reference/usingDeclarationsWithESClassDecorators.1(module=commonjs,target=es2015).js new file mode 100644 index 0000000000000..1e01f9ad89fba --- /dev/null +++ b/tests/baselines/reference/usingDeclarationsWithESClassDecorators.1(module=commonjs,target=es2015).js @@ -0,0 +1,44 @@ +//// [tests/cases/conformance/statements/VariableStatements/usingDeclarations/usingDeclarationsWithESClassDecorators.1.ts] //// + +//// [usingDeclarationsWithESClassDecorators.1.ts] +export {}; + +declare var dec: any; + +using before = null; + +@dec +class C { +} + + +//// [usingDeclarationsWithESClassDecorators.1.js] +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +var before, C; +const env_1 = { stack: [], error: void 0, hasError: false }; +try { + before = __addDisposableResource(env_1, null, false); + C = (() => { + let _classDecorators = [dec]; + let _classDescriptor; + let _classExtraInitializers = []; + let _classThis; + var C = _classThis = class { + }; + __setFunctionName(_classThis, "C"); + (() => { + __esDecorate(null, _classDescriptor = { value: _classThis }, _classDecorators, { kind: "class", name: _classThis.name }, null, _classExtraInitializers); + C = _classThis = _classDescriptor.value; + __runInitializers(_classThis, _classExtraInitializers); + })(); + return C = _classThis; + })(); +} +catch (e_1) { + env_1.error = e_1; + env_1.hasError = true; +} +finally { + __disposeResources(env_1); +} diff --git a/tests/baselines/reference/usingDeclarationsWithESClassDecorators.1(module=commonjs,target=es5).js b/tests/baselines/reference/usingDeclarationsWithESClassDecorators.1(module=commonjs,target=es5).js new file mode 100644 index 0000000000000..4bef68fef6bce --- /dev/null +++ b/tests/baselines/reference/usingDeclarationsWithESClassDecorators.1(module=commonjs,target=es5).js @@ -0,0 +1,47 @@ +//// [tests/cases/conformance/statements/VariableStatements/usingDeclarations/usingDeclarationsWithESClassDecorators.1.ts] //// + +//// [usingDeclarationsWithESClassDecorators.1.ts] +export {}; + +declare var dec: any; + +using before = null; + +@dec +class C { +} + + +//// [usingDeclarationsWithESClassDecorators.1.js] +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +var before, C; +var env_1 = { stack: [], error: void 0, hasError: false }; +try { + before = __addDisposableResource(env_1, null, false); + C = function () { + var _classDecorators = [dec]; + var _classDescriptor; + var _classExtraInitializers = []; + var _classThis; + var C = _classThis = /** @class */ (function () { + function C_1() { + } + return C_1; + }()); + __setFunctionName(_classThis, "C"); + (function () { + __esDecorate(null, _classDescriptor = { value: _classThis }, _classDecorators, { kind: "class", name: _classThis.name }, null, _classExtraInitializers); + C = _classThis = _classDescriptor.value; + __runInitializers(_classThis, _classExtraInitializers); + })(); + return C = _classThis; + }(); +} +catch (e_1) { + env_1.error = e_1; + env_1.hasError = true; +} +finally { + __disposeResources(env_1); +} diff --git a/tests/baselines/reference/usingDeclarationsWithESClassDecorators.1(module=commonjs,target=esnext).js b/tests/baselines/reference/usingDeclarationsWithESClassDecorators.1(module=commonjs,target=esnext).js new file mode 100644 index 0000000000000..f439d2535e81e --- /dev/null +++ b/tests/baselines/reference/usingDeclarationsWithESClassDecorators.1(module=commonjs,target=esnext).js @@ -0,0 +1,21 @@ +//// [tests/cases/conformance/statements/VariableStatements/usingDeclarations/usingDeclarationsWithESClassDecorators.1.ts] //// + +//// [usingDeclarationsWithESClassDecorators.1.ts] +export {}; + +declare var dec: any; + +using before = null; + +@dec +class C { +} + + +//// [usingDeclarationsWithESClassDecorators.1.js] +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +using before = null; +@dec +class C { +} diff --git a/tests/baselines/reference/usingDeclarationsWithESClassDecorators.1(module=esnext,target=es2015).js b/tests/baselines/reference/usingDeclarationsWithESClassDecorators.1(module=esnext,target=es2015).js new file mode 100644 index 0000000000000..159a293168c49 --- /dev/null +++ b/tests/baselines/reference/usingDeclarationsWithESClassDecorators.1(module=esnext,target=es2015).js @@ -0,0 +1,43 @@ +//// [tests/cases/conformance/statements/VariableStatements/usingDeclarations/usingDeclarationsWithESClassDecorators.1.ts] //// + +//// [usingDeclarationsWithESClassDecorators.1.ts] +export {}; + +declare var dec: any; + +using before = null; + +@dec +class C { +} + + +//// [usingDeclarationsWithESClassDecorators.1.js] +var before, C; +const env_1 = { stack: [], error: void 0, hasError: false }; +try { + before = __addDisposableResource(env_1, null, false); + C = (() => { + let _classDecorators = [dec]; + let _classDescriptor; + let _classExtraInitializers = []; + let _classThis; + var C = _classThis = class { + }; + __setFunctionName(_classThis, "C"); + (() => { + __esDecorate(null, _classDescriptor = { value: _classThis }, _classDecorators, { kind: "class", name: _classThis.name }, null, _classExtraInitializers); + C = _classThis = _classDescriptor.value; + __runInitializers(_classThis, _classExtraInitializers); + })(); + return C = _classThis; + })(); +} +catch (e_1) { + env_1.error = e_1; + env_1.hasError = true; +} +finally { + __disposeResources(env_1); +} +export {}; diff --git a/tests/baselines/reference/usingDeclarationsWithESClassDecorators.1(module=esnext,target=es5).js b/tests/baselines/reference/usingDeclarationsWithESClassDecorators.1(module=esnext,target=es5).js new file mode 100644 index 0000000000000..5d78d53be8f46 --- /dev/null +++ b/tests/baselines/reference/usingDeclarationsWithESClassDecorators.1(module=esnext,target=es5).js @@ -0,0 +1,46 @@ +//// [tests/cases/conformance/statements/VariableStatements/usingDeclarations/usingDeclarationsWithESClassDecorators.1.ts] //// + +//// [usingDeclarationsWithESClassDecorators.1.ts] +export {}; + +declare var dec: any; + +using before = null; + +@dec +class C { +} + + +//// [usingDeclarationsWithESClassDecorators.1.js] +var before, C; +var env_1 = { stack: [], error: void 0, hasError: false }; +try { + before = __addDisposableResource(env_1, null, false); + C = function () { + var _classDecorators = [dec]; + var _classDescriptor; + var _classExtraInitializers = []; + var _classThis; + var C = _classThis = /** @class */ (function () { + function C_1() { + } + return C_1; + }()); + __setFunctionName(_classThis, "C"); + (function () { + __esDecorate(null, _classDescriptor = { value: _classThis }, _classDecorators, { kind: "class", name: _classThis.name }, null, _classExtraInitializers); + C = _classThis = _classDescriptor.value; + __runInitializers(_classThis, _classExtraInitializers); + })(); + return C = _classThis; + }(); +} +catch (e_1) { + env_1.error = e_1; + env_1.hasError = true; +} +finally { + __disposeResources(env_1); +} +export {}; diff --git a/tests/baselines/reference/usingDeclarationsWithESClassDecorators.1(module=esnext,target=esnext).js b/tests/baselines/reference/usingDeclarationsWithESClassDecorators.1(module=esnext,target=esnext).js new file mode 100644 index 0000000000000..13d651149a6e7 --- /dev/null +++ b/tests/baselines/reference/usingDeclarationsWithESClassDecorators.1(module=esnext,target=esnext).js @@ -0,0 +1,20 @@ +//// [tests/cases/conformance/statements/VariableStatements/usingDeclarations/usingDeclarationsWithESClassDecorators.1.ts] //// + +//// [usingDeclarationsWithESClassDecorators.1.ts] +export {}; + +declare var dec: any; + +using before = null; + +@dec +class C { +} + + +//// [usingDeclarationsWithESClassDecorators.1.js] +using before = null; +@dec +class C { +} +export {}; diff --git a/tests/baselines/reference/usingDeclarationsWithESClassDecorators.1(module=system,target=es2015).js b/tests/baselines/reference/usingDeclarationsWithESClassDecorators.1(module=system,target=es2015).js new file mode 100644 index 0000000000000..0370cae3d87bd --- /dev/null +++ b/tests/baselines/reference/usingDeclarationsWithESClassDecorators.1(module=system,target=es2015).js @@ -0,0 +1,51 @@ +//// [tests/cases/conformance/statements/VariableStatements/usingDeclarations/usingDeclarationsWithESClassDecorators.1.ts] //// + +//// [usingDeclarationsWithESClassDecorators.1.ts] +export {}; + +declare var dec: any; + +using before = null; + +@dec +class C { +} + + +//// [usingDeclarationsWithESClassDecorators.1.js] +System.register([], function (exports_1, context_1) { + "use strict"; + var before, C, env_1; + var __moduleName = context_1 && context_1.id; + return { + setters: [], + execute: function () { + env_1 = { stack: [], error: void 0, hasError: false }; + try { + before = __addDisposableResource(env_1, null, false); + C = (() => { + let _classDecorators = [dec]; + let _classDescriptor; + let _classExtraInitializers = []; + let _classThis; + var C = _classThis = class { + }; + __setFunctionName(_classThis, "C"); + (() => { + __esDecorate(null, _classDescriptor = { value: _classThis }, _classDecorators, { kind: "class", name: _classThis.name }, null, _classExtraInitializers); + C = _classThis = _classDescriptor.value; + __runInitializers(_classThis, _classExtraInitializers); + })(); + return C = _classThis; + })(); + } + catch (e_1) { + env_1.error = e_1; + env_1.hasError = true; + } + finally { + __disposeResources(env_1); + } + } + }; +}); diff --git a/tests/baselines/reference/usingDeclarationsWithESClassDecorators.1(module=system,target=es5).js b/tests/baselines/reference/usingDeclarationsWithESClassDecorators.1(module=system,target=es5).js new file mode 100644 index 0000000000000..50be8899ca8ab --- /dev/null +++ b/tests/baselines/reference/usingDeclarationsWithESClassDecorators.1(module=system,target=es5).js @@ -0,0 +1,54 @@ +//// [tests/cases/conformance/statements/VariableStatements/usingDeclarations/usingDeclarationsWithESClassDecorators.1.ts] //// + +//// [usingDeclarationsWithESClassDecorators.1.ts] +export {}; + +declare var dec: any; + +using before = null; + +@dec +class C { +} + + +//// [usingDeclarationsWithESClassDecorators.1.js] +System.register([], function (exports_1, context_1) { + "use strict"; + var before, C, env_1; + var __moduleName = context_1 && context_1.id; + return { + setters: [], + execute: function () { + env_1 = { stack: [], error: void 0, hasError: false }; + try { + before = __addDisposableResource(env_1, null, false); + C = function () { + var _classDecorators = [dec]; + var _classDescriptor; + var _classExtraInitializers = []; + var _classThis; + var C = _classThis = /** @class */ (function () { + function C_1() { + } + return C_1; + }()); + __setFunctionName(_classThis, "C"); + (function () { + __esDecorate(null, _classDescriptor = { value: _classThis }, _classDecorators, { kind: "class", name: _classThis.name }, null, _classExtraInitializers); + C = _classThis = _classDescriptor.value; + __runInitializers(_classThis, _classExtraInitializers); + })(); + return C = _classThis; + }(); + } + catch (e_1) { + env_1.error = e_1; + env_1.hasError = true; + } + finally { + __disposeResources(env_1); + } + } + }; +}); diff --git a/tests/baselines/reference/usingDeclarationsWithESClassDecorators.1(module=system,target=esnext).js b/tests/baselines/reference/usingDeclarationsWithESClassDecorators.1(module=system,target=esnext).js new file mode 100644 index 0000000000000..2bcd0e780869b --- /dev/null +++ b/tests/baselines/reference/usingDeclarationsWithESClassDecorators.1(module=system,target=esnext).js @@ -0,0 +1,30 @@ +//// [tests/cases/conformance/statements/VariableStatements/usingDeclarations/usingDeclarationsWithESClassDecorators.1.ts] //// + +//// [usingDeclarationsWithESClassDecorators.1.ts] +export {}; + +declare var dec: any; + +using before = null; + +@dec +class C { +} + + +//// [usingDeclarationsWithESClassDecorators.1.js] +System.register([], function (exports_1, context_1) { + "use strict"; + var before, C; + var __moduleName = context_1 && context_1.id; + return { + setters: [], + execute: function () { + using before_1 = before = null; + C = + @dec + class C { + }; + } + }; +}); diff --git a/tests/baselines/reference/usingDeclarationsWithESClassDecorators.10(module=commonjs,target=es2015).js b/tests/baselines/reference/usingDeclarationsWithESClassDecorators.10(module=commonjs,target=es2015).js new file mode 100644 index 0000000000000..65a229c79d395 --- /dev/null +++ b/tests/baselines/reference/usingDeclarationsWithESClassDecorators.10(module=commonjs,target=es2015).js @@ -0,0 +1,44 @@ +//// [tests/cases/conformance/statements/VariableStatements/usingDeclarations/usingDeclarationsWithESClassDecorators.10.ts] //// + +//// [usingDeclarationsWithESClassDecorators.10.ts] +export {}; + +declare var dec: any; + +@dec +export default class { +} + +using after = null; + + +//// [usingDeclarationsWithESClassDecorators.10.js] +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.default = (() => { + let _classDecorators = [dec]; + let _classDescriptor; + let _classExtraInitializers = []; + let _classThis; + var default_1 = _classThis = class { + }; + __setFunctionName(_classThis, "default"); + (() => { + __esDecorate(null, _classDescriptor = { value: _classThis }, _classDecorators, { kind: "class", name: _classThis.name }, null, _classExtraInitializers); + default_1 = _classThis = _classDescriptor.value; + __runInitializers(_classThis, _classExtraInitializers); + })(); + return default_1 = _classThis; +})(); +var after; +const env_1 = { stack: [], error: void 0, hasError: false }; +try { + after = __addDisposableResource(env_1, null, false); +} +catch (e_1) { + env_1.error = e_1; + env_1.hasError = true; +} +finally { + __disposeResources(env_1); +} diff --git a/tests/baselines/reference/usingDeclarationsWithESClassDecorators.10(module=commonjs,target=es5).js b/tests/baselines/reference/usingDeclarationsWithESClassDecorators.10(module=commonjs,target=es5).js new file mode 100644 index 0000000000000..413a5784b33dc --- /dev/null +++ b/tests/baselines/reference/usingDeclarationsWithESClassDecorators.10(module=commonjs,target=es5).js @@ -0,0 +1,48 @@ +//// [tests/cases/conformance/statements/VariableStatements/usingDeclarations/usingDeclarationsWithESClassDecorators.10.ts] //// + +//// [usingDeclarationsWithESClassDecorators.10.ts] +export {}; + +declare var dec: any; + +@dec +export default class { +} + +using after = null; + + +//// [usingDeclarationsWithESClassDecorators.10.js] +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +var default_1 = function () { + var _classDecorators = [dec]; + var _classDescriptor; + var _classExtraInitializers = []; + var _classThis; + var default_1 = _classThis = /** @class */ (function () { + function default_1() { + } + return default_1; + }()); + __setFunctionName(_classThis, "default"); + (function () { + __esDecorate(null, _classDescriptor = { value: _classThis }, _classDecorators, { kind: "class", name: _classThis.name }, null, _classExtraInitializers); + default_1 = _classThis = _classDescriptor.value; + __runInitializers(_classThis, _classExtraInitializers); + })(); + return default_1 = _classThis; +}(); +exports.default = default_1; +var after; +var env_1 = { stack: [], error: void 0, hasError: false }; +try { + after = __addDisposableResource(env_1, null, false); +} +catch (e_1) { + env_1.error = e_1; + env_1.hasError = true; +} +finally { + __disposeResources(env_1); +} diff --git a/tests/baselines/reference/usingDeclarationsWithESClassDecorators.10(module=commonjs,target=esnext).js b/tests/baselines/reference/usingDeclarationsWithESClassDecorators.10(module=commonjs,target=esnext).js new file mode 100644 index 0000000000000..31ab02877e60d --- /dev/null +++ b/tests/baselines/reference/usingDeclarationsWithESClassDecorators.10(module=commonjs,target=esnext).js @@ -0,0 +1,22 @@ +//// [tests/cases/conformance/statements/VariableStatements/usingDeclarations/usingDeclarationsWithESClassDecorators.10.ts] //// + +//// [usingDeclarationsWithESClassDecorators.10.ts] +export {}; + +declare var dec: any; + +@dec +export default class { +} + +using after = null; + + +//// [usingDeclarationsWithESClassDecorators.10.js] +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +@dec +class default_1 { +} +exports.default = default_1; +using after = null; diff --git a/tests/baselines/reference/usingDeclarationsWithESClassDecorators.10(module=esnext,target=es2015).js b/tests/baselines/reference/usingDeclarationsWithESClassDecorators.10(module=esnext,target=es2015).js new file mode 100644 index 0000000000000..23f62a922b2fd --- /dev/null +++ b/tests/baselines/reference/usingDeclarationsWithESClassDecorators.10(module=esnext,target=es2015).js @@ -0,0 +1,42 @@ +//// [tests/cases/conformance/statements/VariableStatements/usingDeclarations/usingDeclarationsWithESClassDecorators.10.ts] //// + +//// [usingDeclarationsWithESClassDecorators.10.ts] +export {}; + +declare var dec: any; + +@dec +export default class { +} + +using after = null; + + +//// [usingDeclarationsWithESClassDecorators.10.js] +export default (() => { + let _classDecorators = [dec]; + let _classDescriptor; + let _classExtraInitializers = []; + let _classThis; + var default_1 = _classThis = class { + }; + __setFunctionName(_classThis, "default"); + (() => { + __esDecorate(null, _classDescriptor = { value: _classThis }, _classDecorators, { kind: "class", name: _classThis.name }, null, _classExtraInitializers); + default_1 = _classThis = _classDescriptor.value; + __runInitializers(_classThis, _classExtraInitializers); + })(); + return default_1 = _classThis; +})(); +var after; +const env_1 = { stack: [], error: void 0, hasError: false }; +try { + after = __addDisposableResource(env_1, null, false); +} +catch (e_1) { + env_1.error = e_1; + env_1.hasError = true; +} +finally { + __disposeResources(env_1); +} diff --git a/tests/baselines/reference/usingDeclarationsWithESClassDecorators.10(module=esnext,target=es5).js b/tests/baselines/reference/usingDeclarationsWithESClassDecorators.10(module=esnext,target=es5).js new file mode 100644 index 0000000000000..595556129dba3 --- /dev/null +++ b/tests/baselines/reference/usingDeclarationsWithESClassDecorators.10(module=esnext,target=es5).js @@ -0,0 +1,46 @@ +//// [tests/cases/conformance/statements/VariableStatements/usingDeclarations/usingDeclarationsWithESClassDecorators.10.ts] //// + +//// [usingDeclarationsWithESClassDecorators.10.ts] +export {}; + +declare var dec: any; + +@dec +export default class { +} + +using after = null; + + +//// [usingDeclarationsWithESClassDecorators.10.js] +var default_1 = function () { + var _classDecorators = [dec]; + var _classDescriptor; + var _classExtraInitializers = []; + var _classThis; + var default_1 = _classThis = /** @class */ (function () { + function default_1() { + } + return default_1; + }()); + __setFunctionName(_classThis, "default"); + (function () { + __esDecorate(null, _classDescriptor = { value: _classThis }, _classDecorators, { kind: "class", name: _classThis.name }, null, _classExtraInitializers); + default_1 = _classThis = _classDescriptor.value; + __runInitializers(_classThis, _classExtraInitializers); + })(); + return default_1 = _classThis; +}(); +export default default_1; +var after; +var env_1 = { stack: [], error: void 0, hasError: false }; +try { + after = __addDisposableResource(env_1, null, false); +} +catch (e_1) { + env_1.error = e_1; + env_1.hasError = true; +} +finally { + __disposeResources(env_1); +} diff --git a/tests/baselines/reference/usingDeclarationsWithESClassDecorators.10(module=esnext,target=esnext).js b/tests/baselines/reference/usingDeclarationsWithESClassDecorators.10(module=esnext,target=esnext).js new file mode 100644 index 0000000000000..bef146721585b --- /dev/null +++ b/tests/baselines/reference/usingDeclarationsWithESClassDecorators.10(module=esnext,target=esnext).js @@ -0,0 +1,19 @@ +//// [tests/cases/conformance/statements/VariableStatements/usingDeclarations/usingDeclarationsWithESClassDecorators.10.ts] //// + +//// [usingDeclarationsWithESClassDecorators.10.ts] +export {}; + +declare var dec: any; + +@dec +export default class { +} + +using after = null; + + +//// [usingDeclarationsWithESClassDecorators.10.js] +@dec +export default class { +} +using after = null; diff --git a/tests/baselines/reference/usingDeclarationsWithESClassDecorators.10(module=system,target=es2015).js b/tests/baselines/reference/usingDeclarationsWithESClassDecorators.10(module=system,target=es2015).js new file mode 100644 index 0000000000000..885c757f0484a --- /dev/null +++ b/tests/baselines/reference/usingDeclarationsWithESClassDecorators.10(module=system,target=es2015).js @@ -0,0 +1,51 @@ +//// [tests/cases/conformance/statements/VariableStatements/usingDeclarations/usingDeclarationsWithESClassDecorators.10.ts] //// + +//// [usingDeclarationsWithESClassDecorators.10.ts] +export {}; + +declare var dec: any; + +@dec +export default class { +} + +using after = null; + + +//// [usingDeclarationsWithESClassDecorators.10.js] +System.register([], function (exports_1, context_1) { + "use strict"; + var after, env_1; + var __moduleName = context_1 && context_1.id; + return { + setters: [], + execute: function () { + exports_1("default", (() => { + let _classDecorators = [dec]; + let _classDescriptor; + let _classExtraInitializers = []; + let _classThis; + var default_1 = _classThis = class { + }; + __setFunctionName(_classThis, "default"); + (() => { + __esDecorate(null, _classDescriptor = { value: _classThis }, _classDecorators, { kind: "class", name: _classThis.name }, null, _classExtraInitializers); + default_1 = _classThis = _classDescriptor.value; + __runInitializers(_classThis, _classExtraInitializers); + })(); + return default_1 = _classThis; + })()); + env_1 = { stack: [], error: void 0, hasError: false }; + try { + after = __addDisposableResource(env_1, null, false); + } + catch (e_1) { + env_1.error = e_1; + env_1.hasError = true; + } + finally { + __disposeResources(env_1); + } + } + }; +}); diff --git a/tests/baselines/reference/usingDeclarationsWithESClassDecorators.10(module=system,target=es5).js b/tests/baselines/reference/usingDeclarationsWithESClassDecorators.10(module=system,target=es5).js new file mode 100644 index 0000000000000..f6c7d850936c1 --- /dev/null +++ b/tests/baselines/reference/usingDeclarationsWithESClassDecorators.10(module=system,target=es5).js @@ -0,0 +1,55 @@ +//// [tests/cases/conformance/statements/VariableStatements/usingDeclarations/usingDeclarationsWithESClassDecorators.10.ts] //// + +//// [usingDeclarationsWithESClassDecorators.10.ts] +export {}; + +declare var dec: any; + +@dec +export default class { +} + +using after = null; + + +//// [usingDeclarationsWithESClassDecorators.10.js] +System.register([], function (exports_1, context_1) { + "use strict"; + var default_1, after, env_1; + var __moduleName = context_1 && context_1.id; + return { + setters: [], + execute: function () { + default_1 = function () { + var _classDecorators = [dec]; + var _classDescriptor; + var _classExtraInitializers = []; + var _classThis; + var default_1 = _classThis = /** @class */ (function () { + function default_1() { + } + return default_1; + }()); + __setFunctionName(_classThis, "default"); + (function () { + __esDecorate(null, _classDescriptor = { value: _classThis }, _classDecorators, { kind: "class", name: _classThis.name }, null, _classExtraInitializers); + default_1 = _classThis = _classDescriptor.value; + __runInitializers(_classThis, _classExtraInitializers); + })(); + return default_1 = _classThis; + }(); + exports_1("default", default_1); + env_1 = { stack: [], error: void 0, hasError: false }; + try { + after = __addDisposableResource(env_1, null, false); + } + catch (e_1) { + env_1.error = e_1; + env_1.hasError = true; + } + finally { + __disposeResources(env_1); + } + } + }; +}); diff --git a/tests/baselines/reference/usingDeclarationsWithESClassDecorators.10(module=system,target=esnext).js b/tests/baselines/reference/usingDeclarationsWithESClassDecorators.10(module=system,target=esnext).js new file mode 100644 index 0000000000000..e50d6155d678b --- /dev/null +++ b/tests/baselines/reference/usingDeclarationsWithESClassDecorators.10(module=system,target=esnext).js @@ -0,0 +1,31 @@ +//// [tests/cases/conformance/statements/VariableStatements/usingDeclarations/usingDeclarationsWithESClassDecorators.10.ts] //// + +//// [usingDeclarationsWithESClassDecorators.10.ts] +export {}; + +declare var dec: any; + +@dec +export default class { +} + +using after = null; + + +//// [usingDeclarationsWithESClassDecorators.10.js] +System.register([], function (exports_1, context_1) { + "use strict"; + var default_1, after; + var __moduleName = context_1 && context_1.id; + return { + setters: [], + execute: function () { + default_1 = + @dec + class { + }; + exports_1("default", default_1); + using after_1 = after = null; + } + }; +}); diff --git a/tests/baselines/reference/usingDeclarationsWithESClassDecorators.11(module=commonjs,target=es2015).js b/tests/baselines/reference/usingDeclarationsWithESClassDecorators.11(module=commonjs,target=es2015).js new file mode 100644 index 0000000000000..730ec08a45ec3 --- /dev/null +++ b/tests/baselines/reference/usingDeclarationsWithESClassDecorators.11(module=commonjs,target=es2015).js @@ -0,0 +1,48 @@ +//// [tests/cases/conformance/statements/VariableStatements/usingDeclarations/usingDeclarationsWithESClassDecorators.11.ts] //// + +//// [usingDeclarationsWithESClassDecorators.11.ts] +export {}; + +declare var dec: any; + +@dec +class C { +} + +export { C }; + +using after = null; + + +//// [usingDeclarationsWithESClassDecorators.11.js] +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.C = void 0; +let C = (() => { + let _classDecorators = [dec]; + let _classDescriptor; + let _classExtraInitializers = []; + let _classThis; + var C = _classThis = class { + }; + __setFunctionName(_classThis, "C"); + (() => { + __esDecorate(null, _classDescriptor = { value: _classThis }, _classDecorators, { kind: "class", name: _classThis.name }, null, _classExtraInitializers); + C = _classThis = _classDescriptor.value; + __runInitializers(_classThis, _classExtraInitializers); + })(); + return C = _classThis; +})(); +exports.C = C; +var after; +const env_1 = { stack: [], error: void 0, hasError: false }; +try { + after = __addDisposableResource(env_1, null, false); +} +catch (e_1) { + env_1.error = e_1; + env_1.hasError = true; +} +finally { + __disposeResources(env_1); +} diff --git a/tests/baselines/reference/usingDeclarationsWithESClassDecorators.11(module=commonjs,target=es5).js b/tests/baselines/reference/usingDeclarationsWithESClassDecorators.11(module=commonjs,target=es5).js new file mode 100644 index 0000000000000..46157431ff62b --- /dev/null +++ b/tests/baselines/reference/usingDeclarationsWithESClassDecorators.11(module=commonjs,target=es5).js @@ -0,0 +1,51 @@ +//// [tests/cases/conformance/statements/VariableStatements/usingDeclarations/usingDeclarationsWithESClassDecorators.11.ts] //// + +//// [usingDeclarationsWithESClassDecorators.11.ts] +export {}; + +declare var dec: any; + +@dec +class C { +} + +export { C }; + +using after = null; + + +//// [usingDeclarationsWithESClassDecorators.11.js] +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.C = void 0; +var C = function () { + var _classDecorators = [dec]; + var _classDescriptor; + var _classExtraInitializers = []; + var _classThis; + var C = _classThis = /** @class */ (function () { + function C_1() { + } + return C_1; + }()); + __setFunctionName(_classThis, "C"); + (function () { + __esDecorate(null, _classDescriptor = { value: _classThis }, _classDecorators, { kind: "class", name: _classThis.name }, null, _classExtraInitializers); + C = _classThis = _classDescriptor.value; + __runInitializers(_classThis, _classExtraInitializers); + })(); + return C = _classThis; +}(); +exports.C = C; +var after; +var env_1 = { stack: [], error: void 0, hasError: false }; +try { + after = __addDisposableResource(env_1, null, false); +} +catch (e_1) { + env_1.error = e_1; + env_1.hasError = true; +} +finally { + __disposeResources(env_1); +} diff --git a/tests/baselines/reference/usingDeclarationsWithESClassDecorators.11(module=commonjs,target=esnext).js b/tests/baselines/reference/usingDeclarationsWithESClassDecorators.11(module=commonjs,target=esnext).js new file mode 100644 index 0000000000000..afd994944e5f8 --- /dev/null +++ b/tests/baselines/reference/usingDeclarationsWithESClassDecorators.11(module=commonjs,target=esnext).js @@ -0,0 +1,25 @@ +//// [tests/cases/conformance/statements/VariableStatements/usingDeclarations/usingDeclarationsWithESClassDecorators.11.ts] //// + +//// [usingDeclarationsWithESClassDecorators.11.ts] +export {}; + +declare var dec: any; + +@dec +class C { +} + +export { C }; + +using after = null; + + +//// [usingDeclarationsWithESClassDecorators.11.js] +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.C = void 0; +@dec +class C { +} +exports.C = C; +using after = null; diff --git a/tests/baselines/reference/usingDeclarationsWithESClassDecorators.11(module=esnext,target=es2015).js b/tests/baselines/reference/usingDeclarationsWithESClassDecorators.11(module=esnext,target=es2015).js new file mode 100644 index 0000000000000..5624445959a12 --- /dev/null +++ b/tests/baselines/reference/usingDeclarationsWithESClassDecorators.11(module=esnext,target=es2015).js @@ -0,0 +1,45 @@ +//// [tests/cases/conformance/statements/VariableStatements/usingDeclarations/usingDeclarationsWithESClassDecorators.11.ts] //// + +//// [usingDeclarationsWithESClassDecorators.11.ts] +export {}; + +declare var dec: any; + +@dec +class C { +} + +export { C }; + +using after = null; + + +//// [usingDeclarationsWithESClassDecorators.11.js] +let C = (() => { + let _classDecorators = [dec]; + let _classDescriptor; + let _classExtraInitializers = []; + let _classThis; + var C = _classThis = class { + }; + __setFunctionName(_classThis, "C"); + (() => { + __esDecorate(null, _classDescriptor = { value: _classThis }, _classDecorators, { kind: "class", name: _classThis.name }, null, _classExtraInitializers); + C = _classThis = _classDescriptor.value; + __runInitializers(_classThis, _classExtraInitializers); + })(); + return C = _classThis; +})(); +export { C }; +var after; +const env_1 = { stack: [], error: void 0, hasError: false }; +try { + after = __addDisposableResource(env_1, null, false); +} +catch (e_1) { + env_1.error = e_1; + env_1.hasError = true; +} +finally { + __disposeResources(env_1); +} diff --git a/tests/baselines/reference/usingDeclarationsWithESClassDecorators.11(module=esnext,target=es5).js b/tests/baselines/reference/usingDeclarationsWithESClassDecorators.11(module=esnext,target=es5).js new file mode 100644 index 0000000000000..0f59cf19651bd --- /dev/null +++ b/tests/baselines/reference/usingDeclarationsWithESClassDecorators.11(module=esnext,target=es5).js @@ -0,0 +1,48 @@ +//// [tests/cases/conformance/statements/VariableStatements/usingDeclarations/usingDeclarationsWithESClassDecorators.11.ts] //// + +//// [usingDeclarationsWithESClassDecorators.11.ts] +export {}; + +declare var dec: any; + +@dec +class C { +} + +export { C }; + +using after = null; + + +//// [usingDeclarationsWithESClassDecorators.11.js] +var C = function () { + var _classDecorators = [dec]; + var _classDescriptor; + var _classExtraInitializers = []; + var _classThis; + var C = _classThis = /** @class */ (function () { + function C_1() { + } + return C_1; + }()); + __setFunctionName(_classThis, "C"); + (function () { + __esDecorate(null, _classDescriptor = { value: _classThis }, _classDecorators, { kind: "class", name: _classThis.name }, null, _classExtraInitializers); + C = _classThis = _classDescriptor.value; + __runInitializers(_classThis, _classExtraInitializers); + })(); + return C = _classThis; +}(); +export { C }; +var after; +var env_1 = { stack: [], error: void 0, hasError: false }; +try { + after = __addDisposableResource(env_1, null, false); +} +catch (e_1) { + env_1.error = e_1; + env_1.hasError = true; +} +finally { + __disposeResources(env_1); +} diff --git a/tests/baselines/reference/usingDeclarationsWithESClassDecorators.11(module=esnext,target=esnext).js b/tests/baselines/reference/usingDeclarationsWithESClassDecorators.11(module=esnext,target=esnext).js new file mode 100644 index 0000000000000..ae5cb9de7b9a9 --- /dev/null +++ b/tests/baselines/reference/usingDeclarationsWithESClassDecorators.11(module=esnext,target=esnext).js @@ -0,0 +1,22 @@ +//// [tests/cases/conformance/statements/VariableStatements/usingDeclarations/usingDeclarationsWithESClassDecorators.11.ts] //// + +//// [usingDeclarationsWithESClassDecorators.11.ts] +export {}; + +declare var dec: any; + +@dec +class C { +} + +export { C }; + +using after = null; + + +//// [usingDeclarationsWithESClassDecorators.11.js] +@dec +class C { +} +export { C }; +using after = null; diff --git a/tests/baselines/reference/usingDeclarationsWithESClassDecorators.11(module=system,target=es2015).js b/tests/baselines/reference/usingDeclarationsWithESClassDecorators.11(module=system,target=es2015).js new file mode 100644 index 0000000000000..c8f244ddabad1 --- /dev/null +++ b/tests/baselines/reference/usingDeclarationsWithESClassDecorators.11(module=system,target=es2015).js @@ -0,0 +1,54 @@ +//// [tests/cases/conformance/statements/VariableStatements/usingDeclarations/usingDeclarationsWithESClassDecorators.11.ts] //// + +//// [usingDeclarationsWithESClassDecorators.11.ts] +export {}; + +declare var dec: any; + +@dec +class C { +} + +export { C }; + +using after = null; + + +//// [usingDeclarationsWithESClassDecorators.11.js] +System.register([], function (exports_1, context_1) { + "use strict"; + var C, after, env_1; + var __moduleName = context_1 && context_1.id; + return { + setters: [], + execute: function () { + C = (() => { + let _classDecorators = [dec]; + let _classDescriptor; + let _classExtraInitializers = []; + let _classThis; + var C = _classThis = class { + }; + __setFunctionName(_classThis, "C"); + (() => { + __esDecorate(null, _classDescriptor = { value: _classThis }, _classDecorators, { kind: "class", name: _classThis.name }, null, _classExtraInitializers); + C = _classThis = _classDescriptor.value; + __runInitializers(_classThis, _classExtraInitializers); + })(); + return C = _classThis; + })(); + exports_1("C", C); + env_1 = { stack: [], error: void 0, hasError: false }; + try { + after = __addDisposableResource(env_1, null, false); + } + catch (e_1) { + env_1.error = e_1; + env_1.hasError = true; + } + finally { + __disposeResources(env_1); + } + } + }; +}); diff --git a/tests/baselines/reference/usingDeclarationsWithESClassDecorators.11(module=system,target=es5).js b/tests/baselines/reference/usingDeclarationsWithESClassDecorators.11(module=system,target=es5).js new file mode 100644 index 0000000000000..990cca5742048 --- /dev/null +++ b/tests/baselines/reference/usingDeclarationsWithESClassDecorators.11(module=system,target=es5).js @@ -0,0 +1,57 @@ +//// [tests/cases/conformance/statements/VariableStatements/usingDeclarations/usingDeclarationsWithESClassDecorators.11.ts] //// + +//// [usingDeclarationsWithESClassDecorators.11.ts] +export {}; + +declare var dec: any; + +@dec +class C { +} + +export { C }; + +using after = null; + + +//// [usingDeclarationsWithESClassDecorators.11.js] +System.register([], function (exports_1, context_1) { + "use strict"; + var C, after, env_1; + var __moduleName = context_1 && context_1.id; + return { + setters: [], + execute: function () { + C = function () { + var _classDecorators = [dec]; + var _classDescriptor; + var _classExtraInitializers = []; + var _classThis; + var C = _classThis = /** @class */ (function () { + function C_1() { + } + return C_1; + }()); + __setFunctionName(_classThis, "C"); + (function () { + __esDecorate(null, _classDescriptor = { value: _classThis }, _classDecorators, { kind: "class", name: _classThis.name }, null, _classExtraInitializers); + C = _classThis = _classDescriptor.value; + __runInitializers(_classThis, _classExtraInitializers); + })(); + return C = _classThis; + }(); + exports_1("C", C); + env_1 = { stack: [], error: void 0, hasError: false }; + try { + after = __addDisposableResource(env_1, null, false); + } + catch (e_1) { + env_1.error = e_1; + env_1.hasError = true; + } + finally { + __disposeResources(env_1); + } + } + }; +}); diff --git a/tests/baselines/reference/usingDeclarationsWithESClassDecorators.11(module=system,target=esnext).js b/tests/baselines/reference/usingDeclarationsWithESClassDecorators.11(module=system,target=esnext).js new file mode 100644 index 0000000000000..de982a12d2647 --- /dev/null +++ b/tests/baselines/reference/usingDeclarationsWithESClassDecorators.11(module=system,target=esnext).js @@ -0,0 +1,33 @@ +//// [tests/cases/conformance/statements/VariableStatements/usingDeclarations/usingDeclarationsWithESClassDecorators.11.ts] //// + +//// [usingDeclarationsWithESClassDecorators.11.ts] +export {}; + +declare var dec: any; + +@dec +class C { +} + +export { C }; + +using after = null; + + +//// [usingDeclarationsWithESClassDecorators.11.js] +System.register([], function (exports_1, context_1) { + "use strict"; + var C, after; + var __moduleName = context_1 && context_1.id; + return { + setters: [], + execute: function () { + C = + @dec + class C { + }; + exports_1("C", C); + using after_1 = after = null; + } + }; +}); diff --git a/tests/baselines/reference/usingDeclarationsWithESClassDecorators.12(module=commonjs,target=es2015).js b/tests/baselines/reference/usingDeclarationsWithESClassDecorators.12(module=commonjs,target=es2015).js new file mode 100644 index 0000000000000..700b49c59088e --- /dev/null +++ b/tests/baselines/reference/usingDeclarationsWithESClassDecorators.12(module=commonjs,target=es2015).js @@ -0,0 +1,48 @@ +//// [tests/cases/conformance/statements/VariableStatements/usingDeclarations/usingDeclarationsWithESClassDecorators.12.ts] //// + +//// [usingDeclarationsWithESClassDecorators.12.ts] +export {}; + +declare var dec: any; + +@dec +class C { +} + +export { C as D }; + +using after = null; + + +//// [usingDeclarationsWithESClassDecorators.12.js] +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.D = void 0; +let C = (() => { + let _classDecorators = [dec]; + let _classDescriptor; + let _classExtraInitializers = []; + let _classThis; + var C = _classThis = class { + }; + __setFunctionName(_classThis, "C"); + (() => { + __esDecorate(null, _classDescriptor = { value: _classThis }, _classDecorators, { kind: "class", name: _classThis.name }, null, _classExtraInitializers); + C = _classThis = _classDescriptor.value; + __runInitializers(_classThis, _classExtraInitializers); + })(); + return C = _classThis; +})(); +exports.D = C; +var after; +const env_1 = { stack: [], error: void 0, hasError: false }; +try { + after = __addDisposableResource(env_1, null, false); +} +catch (e_1) { + env_1.error = e_1; + env_1.hasError = true; +} +finally { + __disposeResources(env_1); +} diff --git a/tests/baselines/reference/usingDeclarationsWithESClassDecorators.12(module=commonjs,target=es5).js b/tests/baselines/reference/usingDeclarationsWithESClassDecorators.12(module=commonjs,target=es5).js new file mode 100644 index 0000000000000..2f420f06e1e7e --- /dev/null +++ b/tests/baselines/reference/usingDeclarationsWithESClassDecorators.12(module=commonjs,target=es5).js @@ -0,0 +1,51 @@ +//// [tests/cases/conformance/statements/VariableStatements/usingDeclarations/usingDeclarationsWithESClassDecorators.12.ts] //// + +//// [usingDeclarationsWithESClassDecorators.12.ts] +export {}; + +declare var dec: any; + +@dec +class C { +} + +export { C as D }; + +using after = null; + + +//// [usingDeclarationsWithESClassDecorators.12.js] +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.D = void 0; +var C = function () { + var _classDecorators = [dec]; + var _classDescriptor; + var _classExtraInitializers = []; + var _classThis; + var C = _classThis = /** @class */ (function () { + function C_1() { + } + return C_1; + }()); + __setFunctionName(_classThis, "C"); + (function () { + __esDecorate(null, _classDescriptor = { value: _classThis }, _classDecorators, { kind: "class", name: _classThis.name }, null, _classExtraInitializers); + C = _classThis = _classDescriptor.value; + __runInitializers(_classThis, _classExtraInitializers); + })(); + return C = _classThis; +}(); +exports.D = C; +var after; +var env_1 = { stack: [], error: void 0, hasError: false }; +try { + after = __addDisposableResource(env_1, null, false); +} +catch (e_1) { + env_1.error = e_1; + env_1.hasError = true; +} +finally { + __disposeResources(env_1); +} diff --git a/tests/baselines/reference/usingDeclarationsWithESClassDecorators.12(module=commonjs,target=esnext).js b/tests/baselines/reference/usingDeclarationsWithESClassDecorators.12(module=commonjs,target=esnext).js new file mode 100644 index 0000000000000..264a0b9e63bc0 --- /dev/null +++ b/tests/baselines/reference/usingDeclarationsWithESClassDecorators.12(module=commonjs,target=esnext).js @@ -0,0 +1,25 @@ +//// [tests/cases/conformance/statements/VariableStatements/usingDeclarations/usingDeclarationsWithESClassDecorators.12.ts] //// + +//// [usingDeclarationsWithESClassDecorators.12.ts] +export {}; + +declare var dec: any; + +@dec +class C { +} + +export { C as D }; + +using after = null; + + +//// [usingDeclarationsWithESClassDecorators.12.js] +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.D = void 0; +@dec +class C { +} +exports.D = C; +using after = null; diff --git a/tests/baselines/reference/usingDeclarationsWithESClassDecorators.12(module=esnext,target=es2015).js b/tests/baselines/reference/usingDeclarationsWithESClassDecorators.12(module=esnext,target=es2015).js new file mode 100644 index 0000000000000..5f654d1d5aa6a --- /dev/null +++ b/tests/baselines/reference/usingDeclarationsWithESClassDecorators.12(module=esnext,target=es2015).js @@ -0,0 +1,45 @@ +//// [tests/cases/conformance/statements/VariableStatements/usingDeclarations/usingDeclarationsWithESClassDecorators.12.ts] //// + +//// [usingDeclarationsWithESClassDecorators.12.ts] +export {}; + +declare var dec: any; + +@dec +class C { +} + +export { C as D }; + +using after = null; + + +//// [usingDeclarationsWithESClassDecorators.12.js] +let C = (() => { + let _classDecorators = [dec]; + let _classDescriptor; + let _classExtraInitializers = []; + let _classThis; + var C = _classThis = class { + }; + __setFunctionName(_classThis, "C"); + (() => { + __esDecorate(null, _classDescriptor = { value: _classThis }, _classDecorators, { kind: "class", name: _classThis.name }, null, _classExtraInitializers); + C = _classThis = _classDescriptor.value; + __runInitializers(_classThis, _classExtraInitializers); + })(); + return C = _classThis; +})(); +export { C as D }; +var after; +const env_1 = { stack: [], error: void 0, hasError: false }; +try { + after = __addDisposableResource(env_1, null, false); +} +catch (e_1) { + env_1.error = e_1; + env_1.hasError = true; +} +finally { + __disposeResources(env_1); +} diff --git a/tests/baselines/reference/usingDeclarationsWithESClassDecorators.12(module=esnext,target=es5).js b/tests/baselines/reference/usingDeclarationsWithESClassDecorators.12(module=esnext,target=es5).js new file mode 100644 index 0000000000000..c16abc97793e4 --- /dev/null +++ b/tests/baselines/reference/usingDeclarationsWithESClassDecorators.12(module=esnext,target=es5).js @@ -0,0 +1,48 @@ +//// [tests/cases/conformance/statements/VariableStatements/usingDeclarations/usingDeclarationsWithESClassDecorators.12.ts] //// + +//// [usingDeclarationsWithESClassDecorators.12.ts] +export {}; + +declare var dec: any; + +@dec +class C { +} + +export { C as D }; + +using after = null; + + +//// [usingDeclarationsWithESClassDecorators.12.js] +var C = function () { + var _classDecorators = [dec]; + var _classDescriptor; + var _classExtraInitializers = []; + var _classThis; + var C = _classThis = /** @class */ (function () { + function C_1() { + } + return C_1; + }()); + __setFunctionName(_classThis, "C"); + (function () { + __esDecorate(null, _classDescriptor = { value: _classThis }, _classDecorators, { kind: "class", name: _classThis.name }, null, _classExtraInitializers); + C = _classThis = _classDescriptor.value; + __runInitializers(_classThis, _classExtraInitializers); + })(); + return C = _classThis; +}(); +export { C as D }; +var after; +var env_1 = { stack: [], error: void 0, hasError: false }; +try { + after = __addDisposableResource(env_1, null, false); +} +catch (e_1) { + env_1.error = e_1; + env_1.hasError = true; +} +finally { + __disposeResources(env_1); +} diff --git a/tests/baselines/reference/usingDeclarationsWithESClassDecorators.12(module=esnext,target=esnext).js b/tests/baselines/reference/usingDeclarationsWithESClassDecorators.12(module=esnext,target=esnext).js new file mode 100644 index 0000000000000..88e96a557ff40 --- /dev/null +++ b/tests/baselines/reference/usingDeclarationsWithESClassDecorators.12(module=esnext,target=esnext).js @@ -0,0 +1,22 @@ +//// [tests/cases/conformance/statements/VariableStatements/usingDeclarations/usingDeclarationsWithESClassDecorators.12.ts] //// + +//// [usingDeclarationsWithESClassDecorators.12.ts] +export {}; + +declare var dec: any; + +@dec +class C { +} + +export { C as D }; + +using after = null; + + +//// [usingDeclarationsWithESClassDecorators.12.js] +@dec +class C { +} +export { C as D }; +using after = null; diff --git a/tests/baselines/reference/usingDeclarationsWithESClassDecorators.12(module=system,target=es2015).js b/tests/baselines/reference/usingDeclarationsWithESClassDecorators.12(module=system,target=es2015).js new file mode 100644 index 0000000000000..703dbd4a0afe3 --- /dev/null +++ b/tests/baselines/reference/usingDeclarationsWithESClassDecorators.12(module=system,target=es2015).js @@ -0,0 +1,54 @@ +//// [tests/cases/conformance/statements/VariableStatements/usingDeclarations/usingDeclarationsWithESClassDecorators.12.ts] //// + +//// [usingDeclarationsWithESClassDecorators.12.ts] +export {}; + +declare var dec: any; + +@dec +class C { +} + +export { C as D }; + +using after = null; + + +//// [usingDeclarationsWithESClassDecorators.12.js] +System.register([], function (exports_1, context_1) { + "use strict"; + var C, after, env_1; + var __moduleName = context_1 && context_1.id; + return { + setters: [], + execute: function () { + C = (() => { + let _classDecorators = [dec]; + let _classDescriptor; + let _classExtraInitializers = []; + let _classThis; + var C = _classThis = class { + }; + __setFunctionName(_classThis, "C"); + (() => { + __esDecorate(null, _classDescriptor = { value: _classThis }, _classDecorators, { kind: "class", name: _classThis.name }, null, _classExtraInitializers); + C = _classThis = _classDescriptor.value; + __runInitializers(_classThis, _classExtraInitializers); + })(); + return C = _classThis; + })(); + exports_1("D", C); + env_1 = { stack: [], error: void 0, hasError: false }; + try { + after = __addDisposableResource(env_1, null, false); + } + catch (e_1) { + env_1.error = e_1; + env_1.hasError = true; + } + finally { + __disposeResources(env_1); + } + } + }; +}); diff --git a/tests/baselines/reference/usingDeclarationsWithESClassDecorators.12(module=system,target=es5).js b/tests/baselines/reference/usingDeclarationsWithESClassDecorators.12(module=system,target=es5).js new file mode 100644 index 0000000000000..47721a55f78aa --- /dev/null +++ b/tests/baselines/reference/usingDeclarationsWithESClassDecorators.12(module=system,target=es5).js @@ -0,0 +1,57 @@ +//// [tests/cases/conformance/statements/VariableStatements/usingDeclarations/usingDeclarationsWithESClassDecorators.12.ts] //// + +//// [usingDeclarationsWithESClassDecorators.12.ts] +export {}; + +declare var dec: any; + +@dec +class C { +} + +export { C as D }; + +using after = null; + + +//// [usingDeclarationsWithESClassDecorators.12.js] +System.register([], function (exports_1, context_1) { + "use strict"; + var C, after, env_1; + var __moduleName = context_1 && context_1.id; + return { + setters: [], + execute: function () { + C = function () { + var _classDecorators = [dec]; + var _classDescriptor; + var _classExtraInitializers = []; + var _classThis; + var C = _classThis = /** @class */ (function () { + function C_1() { + } + return C_1; + }()); + __setFunctionName(_classThis, "C"); + (function () { + __esDecorate(null, _classDescriptor = { value: _classThis }, _classDecorators, { kind: "class", name: _classThis.name }, null, _classExtraInitializers); + C = _classThis = _classDescriptor.value; + __runInitializers(_classThis, _classExtraInitializers); + })(); + return C = _classThis; + }(); + exports_1("D", C); + env_1 = { stack: [], error: void 0, hasError: false }; + try { + after = __addDisposableResource(env_1, null, false); + } + catch (e_1) { + env_1.error = e_1; + env_1.hasError = true; + } + finally { + __disposeResources(env_1); + } + } + }; +}); diff --git a/tests/baselines/reference/usingDeclarationsWithESClassDecorators.12(module=system,target=esnext).js b/tests/baselines/reference/usingDeclarationsWithESClassDecorators.12(module=system,target=esnext).js new file mode 100644 index 0000000000000..3469e409b7722 --- /dev/null +++ b/tests/baselines/reference/usingDeclarationsWithESClassDecorators.12(module=system,target=esnext).js @@ -0,0 +1,33 @@ +//// [tests/cases/conformance/statements/VariableStatements/usingDeclarations/usingDeclarationsWithESClassDecorators.12.ts] //// + +//// [usingDeclarationsWithESClassDecorators.12.ts] +export {}; + +declare var dec: any; + +@dec +class C { +} + +export { C as D }; + +using after = null; + + +//// [usingDeclarationsWithESClassDecorators.12.js] +System.register([], function (exports_1, context_1) { + "use strict"; + var C, after; + var __moduleName = context_1 && context_1.id; + return { + setters: [], + execute: function () { + C = + @dec + class C { + }; + exports_1("D", C); + using after_1 = after = null; + } + }; +}); diff --git a/tests/baselines/reference/usingDeclarationsWithESClassDecorators.2(module=commonjs,target=es2015).js b/tests/baselines/reference/usingDeclarationsWithESClassDecorators.2(module=commonjs,target=es2015).js new file mode 100644 index 0000000000000..2118bb61db641 --- /dev/null +++ b/tests/baselines/reference/usingDeclarationsWithESClassDecorators.2(module=commonjs,target=es2015).js @@ -0,0 +1,45 @@ +//// [tests/cases/conformance/statements/VariableStatements/usingDeclarations/usingDeclarationsWithESClassDecorators.2.ts] //// + +//// [usingDeclarationsWithESClassDecorators.2.ts] +export {}; + +declare var dec: any; + +using before = null; + +@dec +export class C { +} + + +//// [usingDeclarationsWithESClassDecorators.2.js] +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.C = void 0; +var before, C; +const env_1 = { stack: [], error: void 0, hasError: false }; +try { + before = __addDisposableResource(env_1, null, false); + exports.C = C = (() => { + let _classDecorators = [dec]; + let _classDescriptor; + let _classExtraInitializers = []; + let _classThis; + var C = _classThis = class { + }; + __setFunctionName(_classThis, "C"); + (() => { + __esDecorate(null, _classDescriptor = { value: _classThis }, _classDecorators, { kind: "class", name: _classThis.name }, null, _classExtraInitializers); + C = _classThis = _classDescriptor.value; + __runInitializers(_classThis, _classExtraInitializers); + })(); + return C = _classThis; + })(); +} +catch (e_1) { + env_1.error = e_1; + env_1.hasError = true; +} +finally { + __disposeResources(env_1); +} diff --git a/tests/baselines/reference/usingDeclarationsWithESClassDecorators.2(module=commonjs,target=es5).js b/tests/baselines/reference/usingDeclarationsWithESClassDecorators.2(module=commonjs,target=es5).js new file mode 100644 index 0000000000000..7a770d3618266 --- /dev/null +++ b/tests/baselines/reference/usingDeclarationsWithESClassDecorators.2(module=commonjs,target=es5).js @@ -0,0 +1,48 @@ +//// [tests/cases/conformance/statements/VariableStatements/usingDeclarations/usingDeclarationsWithESClassDecorators.2.ts] //// + +//// [usingDeclarationsWithESClassDecorators.2.ts] +export {}; + +declare var dec: any; + +using before = null; + +@dec +export class C { +} + + +//// [usingDeclarationsWithESClassDecorators.2.js] +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.C = void 0; +var before, C; +var env_1 = { stack: [], error: void 0, hasError: false }; +try { + before = __addDisposableResource(env_1, null, false); + exports.C = C = function () { + var _classDecorators = [dec]; + var _classDescriptor; + var _classExtraInitializers = []; + var _classThis; + var C = _classThis = /** @class */ (function () { + function C_1() { + } + return C_1; + }()); + __setFunctionName(_classThis, "C"); + (function () { + __esDecorate(null, _classDescriptor = { value: _classThis }, _classDecorators, { kind: "class", name: _classThis.name }, null, _classExtraInitializers); + C = _classThis = _classDescriptor.value; + __runInitializers(_classThis, _classExtraInitializers); + })(); + return C = _classThis; + }(); +} +catch (e_1) { + env_1.error = e_1; + env_1.hasError = true; +} +finally { + __disposeResources(env_1); +} diff --git a/tests/baselines/reference/usingDeclarationsWithESClassDecorators.2(module=commonjs,target=esnext).js b/tests/baselines/reference/usingDeclarationsWithESClassDecorators.2(module=commonjs,target=esnext).js new file mode 100644 index 0000000000000..938b226e096e7 --- /dev/null +++ b/tests/baselines/reference/usingDeclarationsWithESClassDecorators.2(module=commonjs,target=esnext).js @@ -0,0 +1,23 @@ +//// [tests/cases/conformance/statements/VariableStatements/usingDeclarations/usingDeclarationsWithESClassDecorators.2.ts] //// + +//// [usingDeclarationsWithESClassDecorators.2.ts] +export {}; + +declare var dec: any; + +using before = null; + +@dec +export class C { +} + + +//// [usingDeclarationsWithESClassDecorators.2.js] +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.C = void 0; +using before = null; +@dec +class C { +} +exports.C = C; diff --git a/tests/baselines/reference/usingDeclarationsWithESClassDecorators.2(module=esnext,target=es2015).js b/tests/baselines/reference/usingDeclarationsWithESClassDecorators.2(module=esnext,target=es2015).js new file mode 100644 index 0000000000000..447e4016d22a5 --- /dev/null +++ b/tests/baselines/reference/usingDeclarationsWithESClassDecorators.2(module=esnext,target=es2015).js @@ -0,0 +1,43 @@ +//// [tests/cases/conformance/statements/VariableStatements/usingDeclarations/usingDeclarationsWithESClassDecorators.2.ts] //// + +//// [usingDeclarationsWithESClassDecorators.2.ts] +export {}; + +declare var dec: any; + +using before = null; + +@dec +export class C { +} + + +//// [usingDeclarationsWithESClassDecorators.2.js] +export { C }; +var before, C; +const env_1 = { stack: [], error: void 0, hasError: false }; +try { + before = __addDisposableResource(env_1, null, false); + C = (() => { + let _classDecorators = [dec]; + let _classDescriptor; + let _classExtraInitializers = []; + let _classThis; + var C = _classThis = class { + }; + __setFunctionName(_classThis, "C"); + (() => { + __esDecorate(null, _classDescriptor = { value: _classThis }, _classDecorators, { kind: "class", name: _classThis.name }, null, _classExtraInitializers); + C = _classThis = _classDescriptor.value; + __runInitializers(_classThis, _classExtraInitializers); + })(); + return C = _classThis; + })(); +} +catch (e_1) { + env_1.error = e_1; + env_1.hasError = true; +} +finally { + __disposeResources(env_1); +} diff --git a/tests/baselines/reference/usingDeclarationsWithESClassDecorators.2(module=esnext,target=es5).js b/tests/baselines/reference/usingDeclarationsWithESClassDecorators.2(module=esnext,target=es5).js new file mode 100644 index 0000000000000..d53fe23c73a2f --- /dev/null +++ b/tests/baselines/reference/usingDeclarationsWithESClassDecorators.2(module=esnext,target=es5).js @@ -0,0 +1,46 @@ +//// [tests/cases/conformance/statements/VariableStatements/usingDeclarations/usingDeclarationsWithESClassDecorators.2.ts] //// + +//// [usingDeclarationsWithESClassDecorators.2.ts] +export {}; + +declare var dec: any; + +using before = null; + +@dec +export class C { +} + + +//// [usingDeclarationsWithESClassDecorators.2.js] +export { C }; +var before, C; +var env_1 = { stack: [], error: void 0, hasError: false }; +try { + before = __addDisposableResource(env_1, null, false); + C = function () { + var _classDecorators = [dec]; + var _classDescriptor; + var _classExtraInitializers = []; + var _classThis; + var C = _classThis = /** @class */ (function () { + function C_1() { + } + return C_1; + }()); + __setFunctionName(_classThis, "C"); + (function () { + __esDecorate(null, _classDescriptor = { value: _classThis }, _classDecorators, { kind: "class", name: _classThis.name }, null, _classExtraInitializers); + C = _classThis = _classDescriptor.value; + __runInitializers(_classThis, _classExtraInitializers); + })(); + return C = _classThis; + }(); +} +catch (e_1) { + env_1.error = e_1; + env_1.hasError = true; +} +finally { + __disposeResources(env_1); +} diff --git a/tests/baselines/reference/usingDeclarationsWithESClassDecorators.2(module=esnext,target=esnext).js b/tests/baselines/reference/usingDeclarationsWithESClassDecorators.2(module=esnext,target=esnext).js new file mode 100644 index 0000000000000..a410a3d05998a --- /dev/null +++ b/tests/baselines/reference/usingDeclarationsWithESClassDecorators.2(module=esnext,target=esnext).js @@ -0,0 +1,19 @@ +//// [tests/cases/conformance/statements/VariableStatements/usingDeclarations/usingDeclarationsWithESClassDecorators.2.ts] //// + +//// [usingDeclarationsWithESClassDecorators.2.ts] +export {}; + +declare var dec: any; + +using before = null; + +@dec +export class C { +} + + +//// [usingDeclarationsWithESClassDecorators.2.js] +using before = null; +@dec +export class C { +} diff --git a/tests/baselines/reference/usingDeclarationsWithESClassDecorators.2(module=system,target=es2015).js b/tests/baselines/reference/usingDeclarationsWithESClassDecorators.2(module=system,target=es2015).js new file mode 100644 index 0000000000000..c220e494b2c2e --- /dev/null +++ b/tests/baselines/reference/usingDeclarationsWithESClassDecorators.2(module=system,target=es2015).js @@ -0,0 +1,51 @@ +//// [tests/cases/conformance/statements/VariableStatements/usingDeclarations/usingDeclarationsWithESClassDecorators.2.ts] //// + +//// [usingDeclarationsWithESClassDecorators.2.ts] +export {}; + +declare var dec: any; + +using before = null; + +@dec +export class C { +} + + +//// [usingDeclarationsWithESClassDecorators.2.js] +System.register([], function (exports_1, context_1) { + "use strict"; + var before, C, env_1; + var __moduleName = context_1 && context_1.id; + return { + setters: [], + execute: function () { + env_1 = { stack: [], error: void 0, hasError: false }; + try { + before = __addDisposableResource(env_1, null, false); + exports_1("C", C = (() => { + let _classDecorators = [dec]; + let _classDescriptor; + let _classExtraInitializers = []; + let _classThis; + var C = _classThis = class { + }; + __setFunctionName(_classThis, "C"); + (() => { + __esDecorate(null, _classDescriptor = { value: _classThis }, _classDecorators, { kind: "class", name: _classThis.name }, null, _classExtraInitializers); + C = _classThis = _classDescriptor.value; + __runInitializers(_classThis, _classExtraInitializers); + })(); + return C = _classThis; + })()); + } + catch (e_1) { + env_1.error = e_1; + env_1.hasError = true; + } + finally { + __disposeResources(env_1); + } + } + }; +}); diff --git a/tests/baselines/reference/usingDeclarationsWithESClassDecorators.2(module=system,target=es5).js b/tests/baselines/reference/usingDeclarationsWithESClassDecorators.2(module=system,target=es5).js new file mode 100644 index 0000000000000..7d4c0543a6dfd --- /dev/null +++ b/tests/baselines/reference/usingDeclarationsWithESClassDecorators.2(module=system,target=es5).js @@ -0,0 +1,54 @@ +//// [tests/cases/conformance/statements/VariableStatements/usingDeclarations/usingDeclarationsWithESClassDecorators.2.ts] //// + +//// [usingDeclarationsWithESClassDecorators.2.ts] +export {}; + +declare var dec: any; + +using before = null; + +@dec +export class C { +} + + +//// [usingDeclarationsWithESClassDecorators.2.js] +System.register([], function (exports_1, context_1) { + "use strict"; + var before, C, env_1; + var __moduleName = context_1 && context_1.id; + return { + setters: [], + execute: function () { + env_1 = { stack: [], error: void 0, hasError: false }; + try { + before = __addDisposableResource(env_1, null, false); + exports_1("C", C = function () { + var _classDecorators = [dec]; + var _classDescriptor; + var _classExtraInitializers = []; + var _classThis; + var C = _classThis = /** @class */ (function () { + function C_1() { + } + return C_1; + }()); + __setFunctionName(_classThis, "C"); + (function () { + __esDecorate(null, _classDescriptor = { value: _classThis }, _classDecorators, { kind: "class", name: _classThis.name }, null, _classExtraInitializers); + C = _classThis = _classDescriptor.value; + __runInitializers(_classThis, _classExtraInitializers); + })(); + return C = _classThis; + }()); + } + catch (e_1) { + env_1.error = e_1; + env_1.hasError = true; + } + finally { + __disposeResources(env_1); + } + } + }; +}); diff --git a/tests/baselines/reference/usingDeclarationsWithESClassDecorators.2(module=system,target=esnext).js b/tests/baselines/reference/usingDeclarationsWithESClassDecorators.2(module=system,target=esnext).js new file mode 100644 index 0000000000000..99beb51906161 --- /dev/null +++ b/tests/baselines/reference/usingDeclarationsWithESClassDecorators.2(module=system,target=esnext).js @@ -0,0 +1,31 @@ +//// [tests/cases/conformance/statements/VariableStatements/usingDeclarations/usingDeclarationsWithESClassDecorators.2.ts] //// + +//// [usingDeclarationsWithESClassDecorators.2.ts] +export {}; + +declare var dec: any; + +using before = null; + +@dec +export class C { +} + + +//// [usingDeclarationsWithESClassDecorators.2.js] +System.register([], function (exports_1, context_1) { + "use strict"; + var before, C; + var __moduleName = context_1 && context_1.id; + return { + setters: [], + execute: function () { + using before_1 = before = null; + C = + @dec + class C { + }; + exports_1("C", C); + } + }; +}); diff --git a/tests/baselines/reference/usingDeclarationsWithESClassDecorators.3(module=commonjs,target=es2015).js b/tests/baselines/reference/usingDeclarationsWithESClassDecorators.3(module=commonjs,target=es2015).js new file mode 100644 index 0000000000000..3370d3f118a30 --- /dev/null +++ b/tests/baselines/reference/usingDeclarationsWithESClassDecorators.3(module=commonjs,target=es2015).js @@ -0,0 +1,47 @@ +//// [tests/cases/conformance/statements/VariableStatements/usingDeclarations/usingDeclarationsWithESClassDecorators.3.ts] //// + +//// [usingDeclarationsWithESClassDecorators.3.ts] +export {}; + +declare var dec: any; + +using before = null; + +@dec +export default class C { +} + +void C; + +//// [usingDeclarationsWithESClassDecorators.3.js] +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.default = void 0; +var before, C, _default; +const env_1 = { stack: [], error: void 0, hasError: false }; +try { + before = __addDisposableResource(env_1, null, false); + exports.default = _default = C = (() => { + let _classDecorators = [dec]; + let _classDescriptor; + let _classExtraInitializers = []; + let _classThis; + var C = _classThis = class { + }; + __setFunctionName(_classThis, "C"); + (() => { + __esDecorate(null, _classDescriptor = { value: _classThis }, _classDecorators, { kind: "class", name: _classThis.name }, null, _classExtraInitializers); + C = _classThis = _classDescriptor.value; + __runInitializers(_classThis, _classExtraInitializers); + })(); + return C = _classThis; + })(); + void C; +} +catch (e_1) { + env_1.error = e_1; + env_1.hasError = true; +} +finally { + __disposeResources(env_1); +} diff --git a/tests/baselines/reference/usingDeclarationsWithESClassDecorators.3(module=commonjs,target=es5).js b/tests/baselines/reference/usingDeclarationsWithESClassDecorators.3(module=commonjs,target=es5).js new file mode 100644 index 0000000000000..d3c27dd438cc2 --- /dev/null +++ b/tests/baselines/reference/usingDeclarationsWithESClassDecorators.3(module=commonjs,target=es5).js @@ -0,0 +1,51 @@ +//// [tests/cases/conformance/statements/VariableStatements/usingDeclarations/usingDeclarationsWithESClassDecorators.3.ts] //// + +//// [usingDeclarationsWithESClassDecorators.3.ts] +export {}; + +declare var dec: any; + +using before = null; + +@dec +export default class C { +} + +void C; + +//// [usingDeclarationsWithESClassDecorators.3.js] +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.default = void 0; +var before, C, _default; +var env_1 = { stack: [], error: void 0, hasError: false }; +try { + before = __addDisposableResource(env_1, null, false); + C = function () { + var _classDecorators = [dec]; + var _classDescriptor; + var _classExtraInitializers = []; + var _classThis; + var C = _classThis = /** @class */ (function () { + function C_1() { + } + return C_1; + }()); + __setFunctionName(_classThis, "C"); + (function () { + __esDecorate(null, _classDescriptor = { value: _classThis }, _classDecorators, { kind: "class", name: _classThis.name }, null, _classExtraInitializers); + C = _classThis = _classDescriptor.value; + __runInitializers(_classThis, _classExtraInitializers); + })(); + return C = _classThis; + }(); + exports.default = _default = C; + void C; +} +catch (e_1) { + env_1.error = e_1; + env_1.hasError = true; +} +finally { + __disposeResources(env_1); +} diff --git a/tests/baselines/reference/usingDeclarationsWithESClassDecorators.3(module=commonjs,target=esnext).js b/tests/baselines/reference/usingDeclarationsWithESClassDecorators.3(module=commonjs,target=esnext).js new file mode 100644 index 0000000000000..a2152534410a6 --- /dev/null +++ b/tests/baselines/reference/usingDeclarationsWithESClassDecorators.3(module=commonjs,target=esnext).js @@ -0,0 +1,24 @@ +//// [tests/cases/conformance/statements/VariableStatements/usingDeclarations/usingDeclarationsWithESClassDecorators.3.ts] //// + +//// [usingDeclarationsWithESClassDecorators.3.ts] +export {}; + +declare var dec: any; + +using before = null; + +@dec +export default class C { +} + +void C; + +//// [usingDeclarationsWithESClassDecorators.3.js] +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +using before = null; +@dec +class C { +} +exports.default = C; +void C; diff --git a/tests/baselines/reference/usingDeclarationsWithESClassDecorators.3(module=esnext,target=es2015).js b/tests/baselines/reference/usingDeclarationsWithESClassDecorators.3(module=esnext,target=es2015).js new file mode 100644 index 0000000000000..a44858f1d1fdf --- /dev/null +++ b/tests/baselines/reference/usingDeclarationsWithESClassDecorators.3(module=esnext,target=es2015).js @@ -0,0 +1,45 @@ +//// [tests/cases/conformance/statements/VariableStatements/usingDeclarations/usingDeclarationsWithESClassDecorators.3.ts] //// + +//// [usingDeclarationsWithESClassDecorators.3.ts] +export {}; + +declare var dec: any; + +using before = null; + +@dec +export default class C { +} + +void C; + +//// [usingDeclarationsWithESClassDecorators.3.js] +export { _default as default }; +var before, C, _default; +const env_1 = { stack: [], error: void 0, hasError: false }; +try { + before = __addDisposableResource(env_1, null, false); + _default = C = (() => { + let _classDecorators = [dec]; + let _classDescriptor; + let _classExtraInitializers = []; + let _classThis; + var C = _classThis = class { + }; + __setFunctionName(_classThis, "C"); + (() => { + __esDecorate(null, _classDescriptor = { value: _classThis }, _classDecorators, { kind: "class", name: _classThis.name }, null, _classExtraInitializers); + C = _classThis = _classDescriptor.value; + __runInitializers(_classThis, _classExtraInitializers); + })(); + return C = _classThis; + })(); + void C; +} +catch (e_1) { + env_1.error = e_1; + env_1.hasError = true; +} +finally { + __disposeResources(env_1); +} diff --git a/tests/baselines/reference/usingDeclarationsWithESClassDecorators.3(module=esnext,target=es5).js b/tests/baselines/reference/usingDeclarationsWithESClassDecorators.3(module=esnext,target=es5).js new file mode 100644 index 0000000000000..b7d521c92cff5 --- /dev/null +++ b/tests/baselines/reference/usingDeclarationsWithESClassDecorators.3(module=esnext,target=es5).js @@ -0,0 +1,49 @@ +//// [tests/cases/conformance/statements/VariableStatements/usingDeclarations/usingDeclarationsWithESClassDecorators.3.ts] //// + +//// [usingDeclarationsWithESClassDecorators.3.ts] +export {}; + +declare var dec: any; + +using before = null; + +@dec +export default class C { +} + +void C; + +//// [usingDeclarationsWithESClassDecorators.3.js] +export { _default as default }; +var before, C, _default; +var env_1 = { stack: [], error: void 0, hasError: false }; +try { + before = __addDisposableResource(env_1, null, false); + C = function () { + var _classDecorators = [dec]; + var _classDescriptor; + var _classExtraInitializers = []; + var _classThis; + var C = _classThis = /** @class */ (function () { + function C_1() { + } + return C_1; + }()); + __setFunctionName(_classThis, "C"); + (function () { + __esDecorate(null, _classDescriptor = { value: _classThis }, _classDecorators, { kind: "class", name: _classThis.name }, null, _classExtraInitializers); + C = _classThis = _classDescriptor.value; + __runInitializers(_classThis, _classExtraInitializers); + })(); + return C = _classThis; + }(); + _default = C; + void C; +} +catch (e_1) { + env_1.error = e_1; + env_1.hasError = true; +} +finally { + __disposeResources(env_1); +} diff --git a/tests/baselines/reference/usingDeclarationsWithESClassDecorators.3(module=esnext,target=esnext).js b/tests/baselines/reference/usingDeclarationsWithESClassDecorators.3(module=esnext,target=esnext).js new file mode 100644 index 0000000000000..03c4b9ce3ae40 --- /dev/null +++ b/tests/baselines/reference/usingDeclarationsWithESClassDecorators.3(module=esnext,target=esnext).js @@ -0,0 +1,21 @@ +//// [tests/cases/conformance/statements/VariableStatements/usingDeclarations/usingDeclarationsWithESClassDecorators.3.ts] //// + +//// [usingDeclarationsWithESClassDecorators.3.ts] +export {}; + +declare var dec: any; + +using before = null; + +@dec +export default class C { +} + +void C; + +//// [usingDeclarationsWithESClassDecorators.3.js] +using before = null; +@dec +export default class C { +} +void C; diff --git a/tests/baselines/reference/usingDeclarationsWithESClassDecorators.3(module=system,target=es2015).js b/tests/baselines/reference/usingDeclarationsWithESClassDecorators.3(module=system,target=es2015).js new file mode 100644 index 0000000000000..dafe5eadea43d --- /dev/null +++ b/tests/baselines/reference/usingDeclarationsWithESClassDecorators.3(module=system,target=es2015).js @@ -0,0 +1,53 @@ +//// [tests/cases/conformance/statements/VariableStatements/usingDeclarations/usingDeclarationsWithESClassDecorators.3.ts] //// + +//// [usingDeclarationsWithESClassDecorators.3.ts] +export {}; + +declare var dec: any; + +using before = null; + +@dec +export default class C { +} + +void C; + +//// [usingDeclarationsWithESClassDecorators.3.js] +System.register([], function (exports_1, context_1) { + "use strict"; + var before, C, _default, env_1; + var __moduleName = context_1 && context_1.id; + return { + setters: [], + execute: function () { + env_1 = { stack: [], error: void 0, hasError: false }; + try { + before = __addDisposableResource(env_1, null, false); + exports_1("default", _default = C = (() => { + let _classDecorators = [dec]; + let _classDescriptor; + let _classExtraInitializers = []; + let _classThis; + var C = _classThis = class { + }; + __setFunctionName(_classThis, "C"); + (() => { + __esDecorate(null, _classDescriptor = { value: _classThis }, _classDecorators, { kind: "class", name: _classThis.name }, null, _classExtraInitializers); + C = _classThis = _classDescriptor.value; + __runInitializers(_classThis, _classExtraInitializers); + })(); + return C = _classThis; + })()); + void C; + } + catch (e_1) { + env_1.error = e_1; + env_1.hasError = true; + } + finally { + __disposeResources(env_1); + } + } + }; +}); diff --git a/tests/baselines/reference/usingDeclarationsWithESClassDecorators.3(module=system,target=es5).js b/tests/baselines/reference/usingDeclarationsWithESClassDecorators.3(module=system,target=es5).js new file mode 100644 index 0000000000000..b30c4565cc50b --- /dev/null +++ b/tests/baselines/reference/usingDeclarationsWithESClassDecorators.3(module=system,target=es5).js @@ -0,0 +1,57 @@ +//// [tests/cases/conformance/statements/VariableStatements/usingDeclarations/usingDeclarationsWithESClassDecorators.3.ts] //// + +//// [usingDeclarationsWithESClassDecorators.3.ts] +export {}; + +declare var dec: any; + +using before = null; + +@dec +export default class C { +} + +void C; + +//// [usingDeclarationsWithESClassDecorators.3.js] +System.register([], function (exports_1, context_1) { + "use strict"; + var before, C, _default, env_1; + var __moduleName = context_1 && context_1.id; + return { + setters: [], + execute: function () { + env_1 = { stack: [], error: void 0, hasError: false }; + try { + before = __addDisposableResource(env_1, null, false); + C = function () { + var _classDecorators = [dec]; + var _classDescriptor; + var _classExtraInitializers = []; + var _classThis; + var C = _classThis = /** @class */ (function () { + function C_1() { + } + return C_1; + }()); + __setFunctionName(_classThis, "C"); + (function () { + __esDecorate(null, _classDescriptor = { value: _classThis }, _classDecorators, { kind: "class", name: _classThis.name }, null, _classExtraInitializers); + C = _classThis = _classDescriptor.value; + __runInitializers(_classThis, _classExtraInitializers); + })(); + return C = _classThis; + }(); + exports_1("default", _default = C); + void C; + } + catch (e_1) { + env_1.error = e_1; + env_1.hasError = true; + } + finally { + __disposeResources(env_1); + } + } + }; +}); diff --git a/tests/baselines/reference/usingDeclarationsWithESClassDecorators.3(module=system,target=esnext).js b/tests/baselines/reference/usingDeclarationsWithESClassDecorators.3(module=system,target=esnext).js new file mode 100644 index 0000000000000..d15eef891aa98 --- /dev/null +++ b/tests/baselines/reference/usingDeclarationsWithESClassDecorators.3(module=system,target=esnext).js @@ -0,0 +1,33 @@ +//// [tests/cases/conformance/statements/VariableStatements/usingDeclarations/usingDeclarationsWithESClassDecorators.3.ts] //// + +//// [usingDeclarationsWithESClassDecorators.3.ts] +export {}; + +declare var dec: any; + +using before = null; + +@dec +export default class C { +} + +void C; + +//// [usingDeclarationsWithESClassDecorators.3.js] +System.register([], function (exports_1, context_1) { + "use strict"; + var before, C; + var __moduleName = context_1 && context_1.id; + return { + setters: [], + execute: function () { + using before_1 = before = null; + C = + @dec + class C { + }; + exports_1("default", C); + void C; + } + }; +}); diff --git a/tests/baselines/reference/usingDeclarationsWithESClassDecorators.4(module=commonjs,target=es2015).js b/tests/baselines/reference/usingDeclarationsWithESClassDecorators.4(module=commonjs,target=es2015).js new file mode 100644 index 0000000000000..58f36d54b3be0 --- /dev/null +++ b/tests/baselines/reference/usingDeclarationsWithESClassDecorators.4(module=commonjs,target=es2015).js @@ -0,0 +1,45 @@ +//// [tests/cases/conformance/statements/VariableStatements/usingDeclarations/usingDeclarationsWithESClassDecorators.4.ts] //// + +//// [usingDeclarationsWithESClassDecorators.4.ts] +export {}; + +declare var dec: any; + +using before = null; + +@dec +export default class { +} + + +//// [usingDeclarationsWithESClassDecorators.4.js] +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.default = void 0; +var before, _default; +const env_1 = { stack: [], error: void 0, hasError: false }; +try { + before = __addDisposableResource(env_1, null, false); + exports.default = _default = (() => { + let _classDecorators = [dec]; + let _classDescriptor; + let _classExtraInitializers = []; + let _classThis; + var default_1 = _classThis = class { + }; + __setFunctionName(_classThis, "default"); + (() => { + __esDecorate(null, _classDescriptor = { value: _classThis }, _classDecorators, { kind: "class", name: _classThis.name }, null, _classExtraInitializers); + default_1 = _classThis = _classDescriptor.value; + __runInitializers(_classThis, _classExtraInitializers); + })(); + return default_1 = _classThis; + })(); +} +catch (e_1) { + env_1.error = e_1; + env_1.hasError = true; +} +finally { + __disposeResources(env_1); +} diff --git a/tests/baselines/reference/usingDeclarationsWithESClassDecorators.4(module=commonjs,target=es5).js b/tests/baselines/reference/usingDeclarationsWithESClassDecorators.4(module=commonjs,target=es5).js new file mode 100644 index 0000000000000..c7937553b5ead --- /dev/null +++ b/tests/baselines/reference/usingDeclarationsWithESClassDecorators.4(module=commonjs,target=es5).js @@ -0,0 +1,49 @@ +//// [tests/cases/conformance/statements/VariableStatements/usingDeclarations/usingDeclarationsWithESClassDecorators.4.ts] //// + +//// [usingDeclarationsWithESClassDecorators.4.ts] +export {}; + +declare var dec: any; + +using before = null; + +@dec +export default class { +} + + +//// [usingDeclarationsWithESClassDecorators.4.js] +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.default = void 0; +var before, default_1, _default; +var env_1 = { stack: [], error: void 0, hasError: false }; +try { + before = __addDisposableResource(env_1, null, false); + default_1 = function () { + var _classDecorators = [dec]; + var _classDescriptor; + var _classExtraInitializers = []; + var _classThis; + var default_1 = _classThis = /** @class */ (function () { + function default_1() { + } + return default_1; + }()); + __setFunctionName(_classThis, "default"); + (function () { + __esDecorate(null, _classDescriptor = { value: _classThis }, _classDecorators, { kind: "class", name: _classThis.name }, null, _classExtraInitializers); + default_1 = _classThis = _classDescriptor.value; + __runInitializers(_classThis, _classExtraInitializers); + })(); + return default_1 = _classThis; + }(); + exports.default = _default = default_1; +} +catch (e_1) { + env_1.error = e_1; + env_1.hasError = true; +} +finally { + __disposeResources(env_1); +} diff --git a/tests/baselines/reference/usingDeclarationsWithESClassDecorators.4(module=commonjs,target=esnext).js b/tests/baselines/reference/usingDeclarationsWithESClassDecorators.4(module=commonjs,target=esnext).js new file mode 100644 index 0000000000000..a30e9b1a11705 --- /dev/null +++ b/tests/baselines/reference/usingDeclarationsWithESClassDecorators.4(module=commonjs,target=esnext).js @@ -0,0 +1,22 @@ +//// [tests/cases/conformance/statements/VariableStatements/usingDeclarations/usingDeclarationsWithESClassDecorators.4.ts] //// + +//// [usingDeclarationsWithESClassDecorators.4.ts] +export {}; + +declare var dec: any; + +using before = null; + +@dec +export default class { +} + + +//// [usingDeclarationsWithESClassDecorators.4.js] +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +using before = null; +@dec +class default_1 { +} +exports.default = default_1; diff --git a/tests/baselines/reference/usingDeclarationsWithESClassDecorators.4(module=esnext,target=es2015).js b/tests/baselines/reference/usingDeclarationsWithESClassDecorators.4(module=esnext,target=es2015).js new file mode 100644 index 0000000000000..aa3057d8ab39e --- /dev/null +++ b/tests/baselines/reference/usingDeclarationsWithESClassDecorators.4(module=esnext,target=es2015).js @@ -0,0 +1,43 @@ +//// [tests/cases/conformance/statements/VariableStatements/usingDeclarations/usingDeclarationsWithESClassDecorators.4.ts] //// + +//// [usingDeclarationsWithESClassDecorators.4.ts] +export {}; + +declare var dec: any; + +using before = null; + +@dec +export default class { +} + + +//// [usingDeclarationsWithESClassDecorators.4.js] +export { _default as default }; +var before, _default; +const env_1 = { stack: [], error: void 0, hasError: false }; +try { + before = __addDisposableResource(env_1, null, false); + _default = (() => { + let _classDecorators = [dec]; + let _classDescriptor; + let _classExtraInitializers = []; + let _classThis; + var default_1 = _classThis = class { + }; + __setFunctionName(_classThis, "default"); + (() => { + __esDecorate(null, _classDescriptor = { value: _classThis }, _classDecorators, { kind: "class", name: _classThis.name }, null, _classExtraInitializers); + default_1 = _classThis = _classDescriptor.value; + __runInitializers(_classThis, _classExtraInitializers); + })(); + return default_1 = _classThis; + })(); +} +catch (e_1) { + env_1.error = e_1; + env_1.hasError = true; +} +finally { + __disposeResources(env_1); +} diff --git a/tests/baselines/reference/usingDeclarationsWithESClassDecorators.4(module=esnext,target=es5).js b/tests/baselines/reference/usingDeclarationsWithESClassDecorators.4(module=esnext,target=es5).js new file mode 100644 index 0000000000000..27216ba8063e9 --- /dev/null +++ b/tests/baselines/reference/usingDeclarationsWithESClassDecorators.4(module=esnext,target=es5).js @@ -0,0 +1,47 @@ +//// [tests/cases/conformance/statements/VariableStatements/usingDeclarations/usingDeclarationsWithESClassDecorators.4.ts] //// + +//// [usingDeclarationsWithESClassDecorators.4.ts] +export {}; + +declare var dec: any; + +using before = null; + +@dec +export default class { +} + + +//// [usingDeclarationsWithESClassDecorators.4.js] +export { _default as default }; +var before, default_1, _default; +var env_1 = { stack: [], error: void 0, hasError: false }; +try { + before = __addDisposableResource(env_1, null, false); + default_1 = function () { + var _classDecorators = [dec]; + var _classDescriptor; + var _classExtraInitializers = []; + var _classThis; + var default_1 = _classThis = /** @class */ (function () { + function default_1() { + } + return default_1; + }()); + __setFunctionName(_classThis, "default"); + (function () { + __esDecorate(null, _classDescriptor = { value: _classThis }, _classDecorators, { kind: "class", name: _classThis.name }, null, _classExtraInitializers); + default_1 = _classThis = _classDescriptor.value; + __runInitializers(_classThis, _classExtraInitializers); + })(); + return default_1 = _classThis; + }(); + _default = default_1; +} +catch (e_1) { + env_1.error = e_1; + env_1.hasError = true; +} +finally { + __disposeResources(env_1); +} diff --git a/tests/baselines/reference/usingDeclarationsWithESClassDecorators.4(module=esnext,target=esnext).js b/tests/baselines/reference/usingDeclarationsWithESClassDecorators.4(module=esnext,target=esnext).js new file mode 100644 index 0000000000000..274e1083354b4 --- /dev/null +++ b/tests/baselines/reference/usingDeclarationsWithESClassDecorators.4(module=esnext,target=esnext).js @@ -0,0 +1,19 @@ +//// [tests/cases/conformance/statements/VariableStatements/usingDeclarations/usingDeclarationsWithESClassDecorators.4.ts] //// + +//// [usingDeclarationsWithESClassDecorators.4.ts] +export {}; + +declare var dec: any; + +using before = null; + +@dec +export default class { +} + + +//// [usingDeclarationsWithESClassDecorators.4.js] +using before = null; +@dec +export default class { +} diff --git a/tests/baselines/reference/usingDeclarationsWithESClassDecorators.4(module=system,target=es2015).js b/tests/baselines/reference/usingDeclarationsWithESClassDecorators.4(module=system,target=es2015).js new file mode 100644 index 0000000000000..10c0557cd12d2 --- /dev/null +++ b/tests/baselines/reference/usingDeclarationsWithESClassDecorators.4(module=system,target=es2015).js @@ -0,0 +1,51 @@ +//// [tests/cases/conformance/statements/VariableStatements/usingDeclarations/usingDeclarationsWithESClassDecorators.4.ts] //// + +//// [usingDeclarationsWithESClassDecorators.4.ts] +export {}; + +declare var dec: any; + +using before = null; + +@dec +export default class { +} + + +//// [usingDeclarationsWithESClassDecorators.4.js] +System.register([], function (exports_1, context_1) { + "use strict"; + var before, _default, env_1; + var __moduleName = context_1 && context_1.id; + return { + setters: [], + execute: function () { + env_1 = { stack: [], error: void 0, hasError: false }; + try { + before = __addDisposableResource(env_1, null, false); + exports_1("default", _default = (() => { + let _classDecorators = [dec]; + let _classDescriptor; + let _classExtraInitializers = []; + let _classThis; + var default_1 = _classThis = class { + }; + __setFunctionName(_classThis, "default"); + (() => { + __esDecorate(null, _classDescriptor = { value: _classThis }, _classDecorators, { kind: "class", name: _classThis.name }, null, _classExtraInitializers); + default_1 = _classThis = _classDescriptor.value; + __runInitializers(_classThis, _classExtraInitializers); + })(); + return default_1 = _classThis; + })()); + } + catch (e_1) { + env_1.error = e_1; + env_1.hasError = true; + } + finally { + __disposeResources(env_1); + } + } + }; +}); diff --git a/tests/baselines/reference/usingDeclarationsWithESClassDecorators.4(module=system,target=es5).js b/tests/baselines/reference/usingDeclarationsWithESClassDecorators.4(module=system,target=es5).js new file mode 100644 index 0000000000000..6bbc3b09ea042 --- /dev/null +++ b/tests/baselines/reference/usingDeclarationsWithESClassDecorators.4(module=system,target=es5).js @@ -0,0 +1,55 @@ +//// [tests/cases/conformance/statements/VariableStatements/usingDeclarations/usingDeclarationsWithESClassDecorators.4.ts] //// + +//// [usingDeclarationsWithESClassDecorators.4.ts] +export {}; + +declare var dec: any; + +using before = null; + +@dec +export default class { +} + + +//// [usingDeclarationsWithESClassDecorators.4.js] +System.register([], function (exports_1, context_1) { + "use strict"; + var before, default_1, _default, env_1; + var __moduleName = context_1 && context_1.id; + return { + setters: [], + execute: function () { + env_1 = { stack: [], error: void 0, hasError: false }; + try { + before = __addDisposableResource(env_1, null, false); + default_1 = function () { + var _classDecorators = [dec]; + var _classDescriptor; + var _classExtraInitializers = []; + var _classThis; + var default_1 = _classThis = /** @class */ (function () { + function default_1() { + } + return default_1; + }()); + __setFunctionName(_classThis, "default"); + (function () { + __esDecorate(null, _classDescriptor = { value: _classThis }, _classDecorators, { kind: "class", name: _classThis.name }, null, _classExtraInitializers); + default_1 = _classThis = _classDescriptor.value; + __runInitializers(_classThis, _classExtraInitializers); + })(); + return default_1 = _classThis; + }(); + exports_1("default", _default = default_1); + } + catch (e_1) { + env_1.error = e_1; + env_1.hasError = true; + } + finally { + __disposeResources(env_1); + } + } + }; +}); diff --git a/tests/baselines/reference/usingDeclarationsWithESClassDecorators.4(module=system,target=esnext).js b/tests/baselines/reference/usingDeclarationsWithESClassDecorators.4(module=system,target=esnext).js new file mode 100644 index 0000000000000..e1a2db0a6eb24 --- /dev/null +++ b/tests/baselines/reference/usingDeclarationsWithESClassDecorators.4(module=system,target=esnext).js @@ -0,0 +1,31 @@ +//// [tests/cases/conformance/statements/VariableStatements/usingDeclarations/usingDeclarationsWithESClassDecorators.4.ts] //// + +//// [usingDeclarationsWithESClassDecorators.4.ts] +export {}; + +declare var dec: any; + +using before = null; + +@dec +export default class { +} + + +//// [usingDeclarationsWithESClassDecorators.4.js] +System.register([], function (exports_1, context_1) { + "use strict"; + var before, default_1; + var __moduleName = context_1 && context_1.id; + return { + setters: [], + execute: function () { + using before_1 = before = null; + default_1 = + @dec + class { + }; + exports_1("default", default_1); + } + }; +}); diff --git a/tests/baselines/reference/usingDeclarationsWithESClassDecorators.5(module=commonjs,target=es2015).js b/tests/baselines/reference/usingDeclarationsWithESClassDecorators.5(module=commonjs,target=es2015).js new file mode 100644 index 0000000000000..69ad55ba72ccf --- /dev/null +++ b/tests/baselines/reference/usingDeclarationsWithESClassDecorators.5(module=commonjs,target=es2015).js @@ -0,0 +1,46 @@ +//// [tests/cases/conformance/statements/VariableStatements/usingDeclarations/usingDeclarationsWithESClassDecorators.5.ts] //// + +//// [usingDeclarationsWithESClassDecorators.5.ts] +export {}; + +declare var dec: any; + +using before = null; + +@dec +class C { +} + +export { C }; + +//// [usingDeclarationsWithESClassDecorators.5.js] +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.C = void 0; +var before, C; +const env_1 = { stack: [], error: void 0, hasError: false }; +try { + before = __addDisposableResource(env_1, null, false); + exports.C = C = (() => { + let _classDecorators = [dec]; + let _classDescriptor; + let _classExtraInitializers = []; + let _classThis; + var C = _classThis = class { + }; + __setFunctionName(_classThis, "C"); + (() => { + __esDecorate(null, _classDescriptor = { value: _classThis }, _classDecorators, { kind: "class", name: _classThis.name }, null, _classExtraInitializers); + C = _classThis = _classDescriptor.value; + __runInitializers(_classThis, _classExtraInitializers); + })(); + return C = _classThis; + })(); +} +catch (e_1) { + env_1.error = e_1; + env_1.hasError = true; +} +finally { + __disposeResources(env_1); +} diff --git a/tests/baselines/reference/usingDeclarationsWithESClassDecorators.5(module=commonjs,target=es5).js b/tests/baselines/reference/usingDeclarationsWithESClassDecorators.5(module=commonjs,target=es5).js new file mode 100644 index 0000000000000..426fa87fc2a25 --- /dev/null +++ b/tests/baselines/reference/usingDeclarationsWithESClassDecorators.5(module=commonjs,target=es5).js @@ -0,0 +1,49 @@ +//// [tests/cases/conformance/statements/VariableStatements/usingDeclarations/usingDeclarationsWithESClassDecorators.5.ts] //// + +//// [usingDeclarationsWithESClassDecorators.5.ts] +export {}; + +declare var dec: any; + +using before = null; + +@dec +class C { +} + +export { C }; + +//// [usingDeclarationsWithESClassDecorators.5.js] +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.C = void 0; +var before, C; +var env_1 = { stack: [], error: void 0, hasError: false }; +try { + before = __addDisposableResource(env_1, null, false); + exports.C = C = function () { + var _classDecorators = [dec]; + var _classDescriptor; + var _classExtraInitializers = []; + var _classThis; + var C = _classThis = /** @class */ (function () { + function C_1() { + } + return C_1; + }()); + __setFunctionName(_classThis, "C"); + (function () { + __esDecorate(null, _classDescriptor = { value: _classThis }, _classDecorators, { kind: "class", name: _classThis.name }, null, _classExtraInitializers); + C = _classThis = _classDescriptor.value; + __runInitializers(_classThis, _classExtraInitializers); + })(); + return C = _classThis; + }(); +} +catch (e_1) { + env_1.error = e_1; + env_1.hasError = true; +} +finally { + __disposeResources(env_1); +} diff --git a/tests/baselines/reference/usingDeclarationsWithESClassDecorators.5(module=commonjs,target=esnext).js b/tests/baselines/reference/usingDeclarationsWithESClassDecorators.5(module=commonjs,target=esnext).js new file mode 100644 index 0000000000000..0f139aa395686 --- /dev/null +++ b/tests/baselines/reference/usingDeclarationsWithESClassDecorators.5(module=commonjs,target=esnext).js @@ -0,0 +1,24 @@ +//// [tests/cases/conformance/statements/VariableStatements/usingDeclarations/usingDeclarationsWithESClassDecorators.5.ts] //// + +//// [usingDeclarationsWithESClassDecorators.5.ts] +export {}; + +declare var dec: any; + +using before = null; + +@dec +class C { +} + +export { C }; + +//// [usingDeclarationsWithESClassDecorators.5.js] +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.C = void 0; +using before = null; +@dec +class C { +} +exports.C = C; diff --git a/tests/baselines/reference/usingDeclarationsWithESClassDecorators.5(module=esnext,target=es2015).js b/tests/baselines/reference/usingDeclarationsWithESClassDecorators.5(module=esnext,target=es2015).js new file mode 100644 index 0000000000000..18733b5de767c --- /dev/null +++ b/tests/baselines/reference/usingDeclarationsWithESClassDecorators.5(module=esnext,target=es2015).js @@ -0,0 +1,44 @@ +//// [tests/cases/conformance/statements/VariableStatements/usingDeclarations/usingDeclarationsWithESClassDecorators.5.ts] //// + +//// [usingDeclarationsWithESClassDecorators.5.ts] +export {}; + +declare var dec: any; + +using before = null; + +@dec +class C { +} + +export { C }; + +//// [usingDeclarationsWithESClassDecorators.5.js] +export { C }; +var before, C; +const env_1 = { stack: [], error: void 0, hasError: false }; +try { + before = __addDisposableResource(env_1, null, false); + C = (() => { + let _classDecorators = [dec]; + let _classDescriptor; + let _classExtraInitializers = []; + let _classThis; + var C = _classThis = class { + }; + __setFunctionName(_classThis, "C"); + (() => { + __esDecorate(null, _classDescriptor = { value: _classThis }, _classDecorators, { kind: "class", name: _classThis.name }, null, _classExtraInitializers); + C = _classThis = _classDescriptor.value; + __runInitializers(_classThis, _classExtraInitializers); + })(); + return C = _classThis; + })(); +} +catch (e_1) { + env_1.error = e_1; + env_1.hasError = true; +} +finally { + __disposeResources(env_1); +} diff --git a/tests/baselines/reference/usingDeclarationsWithESClassDecorators.5(module=esnext,target=es5).js b/tests/baselines/reference/usingDeclarationsWithESClassDecorators.5(module=esnext,target=es5).js new file mode 100644 index 0000000000000..67fd4a4eda108 --- /dev/null +++ b/tests/baselines/reference/usingDeclarationsWithESClassDecorators.5(module=esnext,target=es5).js @@ -0,0 +1,47 @@ +//// [tests/cases/conformance/statements/VariableStatements/usingDeclarations/usingDeclarationsWithESClassDecorators.5.ts] //// + +//// [usingDeclarationsWithESClassDecorators.5.ts] +export {}; + +declare var dec: any; + +using before = null; + +@dec +class C { +} + +export { C }; + +//// [usingDeclarationsWithESClassDecorators.5.js] +export { C }; +var before, C; +var env_1 = { stack: [], error: void 0, hasError: false }; +try { + before = __addDisposableResource(env_1, null, false); + C = function () { + var _classDecorators = [dec]; + var _classDescriptor; + var _classExtraInitializers = []; + var _classThis; + var C = _classThis = /** @class */ (function () { + function C_1() { + } + return C_1; + }()); + __setFunctionName(_classThis, "C"); + (function () { + __esDecorate(null, _classDescriptor = { value: _classThis }, _classDecorators, { kind: "class", name: _classThis.name }, null, _classExtraInitializers); + C = _classThis = _classDescriptor.value; + __runInitializers(_classThis, _classExtraInitializers); + })(); + return C = _classThis; + }(); +} +catch (e_1) { + env_1.error = e_1; + env_1.hasError = true; +} +finally { + __disposeResources(env_1); +} diff --git a/tests/baselines/reference/usingDeclarationsWithESClassDecorators.5(module=esnext,target=esnext).js b/tests/baselines/reference/usingDeclarationsWithESClassDecorators.5(module=esnext,target=esnext).js new file mode 100644 index 0000000000000..10a24f2f754db --- /dev/null +++ b/tests/baselines/reference/usingDeclarationsWithESClassDecorators.5(module=esnext,target=esnext).js @@ -0,0 +1,21 @@ +//// [tests/cases/conformance/statements/VariableStatements/usingDeclarations/usingDeclarationsWithESClassDecorators.5.ts] //// + +//// [usingDeclarationsWithESClassDecorators.5.ts] +export {}; + +declare var dec: any; + +using before = null; + +@dec +class C { +} + +export { C }; + +//// [usingDeclarationsWithESClassDecorators.5.js] +using before = null; +@dec +class C { +} +export { C }; diff --git a/tests/baselines/reference/usingDeclarationsWithESClassDecorators.5(module=system,target=es2015).js b/tests/baselines/reference/usingDeclarationsWithESClassDecorators.5(module=system,target=es2015).js new file mode 100644 index 0000000000000..bf9770ac33c0e --- /dev/null +++ b/tests/baselines/reference/usingDeclarationsWithESClassDecorators.5(module=system,target=es2015).js @@ -0,0 +1,52 @@ +//// [tests/cases/conformance/statements/VariableStatements/usingDeclarations/usingDeclarationsWithESClassDecorators.5.ts] //// + +//// [usingDeclarationsWithESClassDecorators.5.ts] +export {}; + +declare var dec: any; + +using before = null; + +@dec +class C { +} + +export { C }; + +//// [usingDeclarationsWithESClassDecorators.5.js] +System.register([], function (exports_1, context_1) { + "use strict"; + var before, C, env_1; + var __moduleName = context_1 && context_1.id; + return { + setters: [], + execute: function () { + env_1 = { stack: [], error: void 0, hasError: false }; + try { + before = __addDisposableResource(env_1, null, false); + exports_1("C", C = (() => { + let _classDecorators = [dec]; + let _classDescriptor; + let _classExtraInitializers = []; + let _classThis; + var C = _classThis = class { + }; + __setFunctionName(_classThis, "C"); + (() => { + __esDecorate(null, _classDescriptor = { value: _classThis }, _classDecorators, { kind: "class", name: _classThis.name }, null, _classExtraInitializers); + C = _classThis = _classDescriptor.value; + __runInitializers(_classThis, _classExtraInitializers); + })(); + return C = _classThis; + })()); + } + catch (e_1) { + env_1.error = e_1; + env_1.hasError = true; + } + finally { + __disposeResources(env_1); + } + } + }; +}); diff --git a/tests/baselines/reference/usingDeclarationsWithESClassDecorators.5(module=system,target=es5).js b/tests/baselines/reference/usingDeclarationsWithESClassDecorators.5(module=system,target=es5).js new file mode 100644 index 0000000000000..c90bf63c6837f --- /dev/null +++ b/tests/baselines/reference/usingDeclarationsWithESClassDecorators.5(module=system,target=es5).js @@ -0,0 +1,55 @@ +//// [tests/cases/conformance/statements/VariableStatements/usingDeclarations/usingDeclarationsWithESClassDecorators.5.ts] //// + +//// [usingDeclarationsWithESClassDecorators.5.ts] +export {}; + +declare var dec: any; + +using before = null; + +@dec +class C { +} + +export { C }; + +//// [usingDeclarationsWithESClassDecorators.5.js] +System.register([], function (exports_1, context_1) { + "use strict"; + var before, C, env_1; + var __moduleName = context_1 && context_1.id; + return { + setters: [], + execute: function () { + env_1 = { stack: [], error: void 0, hasError: false }; + try { + before = __addDisposableResource(env_1, null, false); + exports_1("C", C = function () { + var _classDecorators = [dec]; + var _classDescriptor; + var _classExtraInitializers = []; + var _classThis; + var C = _classThis = /** @class */ (function () { + function C_1() { + } + return C_1; + }()); + __setFunctionName(_classThis, "C"); + (function () { + __esDecorate(null, _classDescriptor = { value: _classThis }, _classDecorators, { kind: "class", name: _classThis.name }, null, _classExtraInitializers); + C = _classThis = _classDescriptor.value; + __runInitializers(_classThis, _classExtraInitializers); + })(); + return C = _classThis; + }()); + } + catch (e_1) { + env_1.error = e_1; + env_1.hasError = true; + } + finally { + __disposeResources(env_1); + } + } + }; +}); diff --git a/tests/baselines/reference/usingDeclarationsWithESClassDecorators.5(module=system,target=esnext).js b/tests/baselines/reference/usingDeclarationsWithESClassDecorators.5(module=system,target=esnext).js new file mode 100644 index 0000000000000..bd6e0ecf0e3fb --- /dev/null +++ b/tests/baselines/reference/usingDeclarationsWithESClassDecorators.5(module=system,target=esnext).js @@ -0,0 +1,32 @@ +//// [tests/cases/conformance/statements/VariableStatements/usingDeclarations/usingDeclarationsWithESClassDecorators.5.ts] //// + +//// [usingDeclarationsWithESClassDecorators.5.ts] +export {}; + +declare var dec: any; + +using before = null; + +@dec +class C { +} + +export { C }; + +//// [usingDeclarationsWithESClassDecorators.5.js] +System.register([], function (exports_1, context_1) { + "use strict"; + var before, C; + var __moduleName = context_1 && context_1.id; + return { + setters: [], + execute: function () { + using before_1 = before = null; + C = + @dec + class C { + }; + exports_1("C", C); + } + }; +}); diff --git a/tests/baselines/reference/usingDeclarationsWithESClassDecorators.6(module=commonjs,target=es2015).js b/tests/baselines/reference/usingDeclarationsWithESClassDecorators.6(module=commonjs,target=es2015).js new file mode 100644 index 0000000000000..76192f102439b --- /dev/null +++ b/tests/baselines/reference/usingDeclarationsWithESClassDecorators.6(module=commonjs,target=es2015).js @@ -0,0 +1,46 @@ +//// [tests/cases/conformance/statements/VariableStatements/usingDeclarations/usingDeclarationsWithESClassDecorators.6.ts] //// + +//// [usingDeclarationsWithESClassDecorators.6.ts] +export {}; + +declare var dec: any; + +using before = null; + +@dec +class C { +} + +export { C as D }; + +//// [usingDeclarationsWithESClassDecorators.6.js] +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.D = void 0; +var before, C; +const env_1 = { stack: [], error: void 0, hasError: false }; +try { + before = __addDisposableResource(env_1, null, false); + exports.D = C = (() => { + let _classDecorators = [dec]; + let _classDescriptor; + let _classExtraInitializers = []; + let _classThis; + var C = _classThis = class { + }; + __setFunctionName(_classThis, "C"); + (() => { + __esDecorate(null, _classDescriptor = { value: _classThis }, _classDecorators, { kind: "class", name: _classThis.name }, null, _classExtraInitializers); + C = _classThis = _classDescriptor.value; + __runInitializers(_classThis, _classExtraInitializers); + })(); + return C = _classThis; + })(); +} +catch (e_1) { + env_1.error = e_1; + env_1.hasError = true; +} +finally { + __disposeResources(env_1); +} diff --git a/tests/baselines/reference/usingDeclarationsWithESClassDecorators.6(module=commonjs,target=es5).js b/tests/baselines/reference/usingDeclarationsWithESClassDecorators.6(module=commonjs,target=es5).js new file mode 100644 index 0000000000000..f2cf7297b2e94 --- /dev/null +++ b/tests/baselines/reference/usingDeclarationsWithESClassDecorators.6(module=commonjs,target=es5).js @@ -0,0 +1,49 @@ +//// [tests/cases/conformance/statements/VariableStatements/usingDeclarations/usingDeclarationsWithESClassDecorators.6.ts] //// + +//// [usingDeclarationsWithESClassDecorators.6.ts] +export {}; + +declare var dec: any; + +using before = null; + +@dec +class C { +} + +export { C as D }; + +//// [usingDeclarationsWithESClassDecorators.6.js] +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.D = void 0; +var before, C; +var env_1 = { stack: [], error: void 0, hasError: false }; +try { + before = __addDisposableResource(env_1, null, false); + exports.D = C = function () { + var _classDecorators = [dec]; + var _classDescriptor; + var _classExtraInitializers = []; + var _classThis; + var C = _classThis = /** @class */ (function () { + function C_1() { + } + return C_1; + }()); + __setFunctionName(_classThis, "C"); + (function () { + __esDecorate(null, _classDescriptor = { value: _classThis }, _classDecorators, { kind: "class", name: _classThis.name }, null, _classExtraInitializers); + C = _classThis = _classDescriptor.value; + __runInitializers(_classThis, _classExtraInitializers); + })(); + return C = _classThis; + }(); +} +catch (e_1) { + env_1.error = e_1; + env_1.hasError = true; +} +finally { + __disposeResources(env_1); +} diff --git a/tests/baselines/reference/usingDeclarationsWithESClassDecorators.6(module=commonjs,target=esnext).js b/tests/baselines/reference/usingDeclarationsWithESClassDecorators.6(module=commonjs,target=esnext).js new file mode 100644 index 0000000000000..71d7f1e7d5447 --- /dev/null +++ b/tests/baselines/reference/usingDeclarationsWithESClassDecorators.6(module=commonjs,target=esnext).js @@ -0,0 +1,24 @@ +//// [tests/cases/conformance/statements/VariableStatements/usingDeclarations/usingDeclarationsWithESClassDecorators.6.ts] //// + +//// [usingDeclarationsWithESClassDecorators.6.ts] +export {}; + +declare var dec: any; + +using before = null; + +@dec +class C { +} + +export { C as D }; + +//// [usingDeclarationsWithESClassDecorators.6.js] +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.D = void 0; +using before = null; +@dec +class C { +} +exports.D = C; diff --git a/tests/baselines/reference/usingDeclarationsWithESClassDecorators.6(module=esnext,target=es2015).js b/tests/baselines/reference/usingDeclarationsWithESClassDecorators.6(module=esnext,target=es2015).js new file mode 100644 index 0000000000000..45e9ae25ab00d --- /dev/null +++ b/tests/baselines/reference/usingDeclarationsWithESClassDecorators.6(module=esnext,target=es2015).js @@ -0,0 +1,44 @@ +//// [tests/cases/conformance/statements/VariableStatements/usingDeclarations/usingDeclarationsWithESClassDecorators.6.ts] //// + +//// [usingDeclarationsWithESClassDecorators.6.ts] +export {}; + +declare var dec: any; + +using before = null; + +@dec +class C { +} + +export { C as D }; + +//// [usingDeclarationsWithESClassDecorators.6.js] +export { C as D }; +var before, C; +const env_1 = { stack: [], error: void 0, hasError: false }; +try { + before = __addDisposableResource(env_1, null, false); + C = (() => { + let _classDecorators = [dec]; + let _classDescriptor; + let _classExtraInitializers = []; + let _classThis; + var C = _classThis = class { + }; + __setFunctionName(_classThis, "C"); + (() => { + __esDecorate(null, _classDescriptor = { value: _classThis }, _classDecorators, { kind: "class", name: _classThis.name }, null, _classExtraInitializers); + C = _classThis = _classDescriptor.value; + __runInitializers(_classThis, _classExtraInitializers); + })(); + return C = _classThis; + })(); +} +catch (e_1) { + env_1.error = e_1; + env_1.hasError = true; +} +finally { + __disposeResources(env_1); +} diff --git a/tests/baselines/reference/usingDeclarationsWithESClassDecorators.6(module=esnext,target=es5).js b/tests/baselines/reference/usingDeclarationsWithESClassDecorators.6(module=esnext,target=es5).js new file mode 100644 index 0000000000000..2ec9c11a8a668 --- /dev/null +++ b/tests/baselines/reference/usingDeclarationsWithESClassDecorators.6(module=esnext,target=es5).js @@ -0,0 +1,47 @@ +//// [tests/cases/conformance/statements/VariableStatements/usingDeclarations/usingDeclarationsWithESClassDecorators.6.ts] //// + +//// [usingDeclarationsWithESClassDecorators.6.ts] +export {}; + +declare var dec: any; + +using before = null; + +@dec +class C { +} + +export { C as D }; + +//// [usingDeclarationsWithESClassDecorators.6.js] +export { C as D }; +var before, C; +var env_1 = { stack: [], error: void 0, hasError: false }; +try { + before = __addDisposableResource(env_1, null, false); + C = function () { + var _classDecorators = [dec]; + var _classDescriptor; + var _classExtraInitializers = []; + var _classThis; + var C = _classThis = /** @class */ (function () { + function C_1() { + } + return C_1; + }()); + __setFunctionName(_classThis, "C"); + (function () { + __esDecorate(null, _classDescriptor = { value: _classThis }, _classDecorators, { kind: "class", name: _classThis.name }, null, _classExtraInitializers); + C = _classThis = _classDescriptor.value; + __runInitializers(_classThis, _classExtraInitializers); + })(); + return C = _classThis; + }(); +} +catch (e_1) { + env_1.error = e_1; + env_1.hasError = true; +} +finally { + __disposeResources(env_1); +} diff --git a/tests/baselines/reference/usingDeclarationsWithESClassDecorators.6(module=esnext,target=esnext).js b/tests/baselines/reference/usingDeclarationsWithESClassDecorators.6(module=esnext,target=esnext).js new file mode 100644 index 0000000000000..641f53fd98e43 --- /dev/null +++ b/tests/baselines/reference/usingDeclarationsWithESClassDecorators.6(module=esnext,target=esnext).js @@ -0,0 +1,21 @@ +//// [tests/cases/conformance/statements/VariableStatements/usingDeclarations/usingDeclarationsWithESClassDecorators.6.ts] //// + +//// [usingDeclarationsWithESClassDecorators.6.ts] +export {}; + +declare var dec: any; + +using before = null; + +@dec +class C { +} + +export { C as D }; + +//// [usingDeclarationsWithESClassDecorators.6.js] +using before = null; +@dec +class C { +} +export { C as D }; diff --git a/tests/baselines/reference/usingDeclarationsWithESClassDecorators.6(module=system,target=es2015).js b/tests/baselines/reference/usingDeclarationsWithESClassDecorators.6(module=system,target=es2015).js new file mode 100644 index 0000000000000..166ea0b809173 --- /dev/null +++ b/tests/baselines/reference/usingDeclarationsWithESClassDecorators.6(module=system,target=es2015).js @@ -0,0 +1,52 @@ +//// [tests/cases/conformance/statements/VariableStatements/usingDeclarations/usingDeclarationsWithESClassDecorators.6.ts] //// + +//// [usingDeclarationsWithESClassDecorators.6.ts] +export {}; + +declare var dec: any; + +using before = null; + +@dec +class C { +} + +export { C as D }; + +//// [usingDeclarationsWithESClassDecorators.6.js] +System.register([], function (exports_1, context_1) { + "use strict"; + var before, C, env_1; + var __moduleName = context_1 && context_1.id; + return { + setters: [], + execute: function () { + env_1 = { stack: [], error: void 0, hasError: false }; + try { + before = __addDisposableResource(env_1, null, false); + exports_1("D", C = (() => { + let _classDecorators = [dec]; + let _classDescriptor; + let _classExtraInitializers = []; + let _classThis; + var C = _classThis = class { + }; + __setFunctionName(_classThis, "C"); + (() => { + __esDecorate(null, _classDescriptor = { value: _classThis }, _classDecorators, { kind: "class", name: _classThis.name }, null, _classExtraInitializers); + C = _classThis = _classDescriptor.value; + __runInitializers(_classThis, _classExtraInitializers); + })(); + return C = _classThis; + })()); + } + catch (e_1) { + env_1.error = e_1; + env_1.hasError = true; + } + finally { + __disposeResources(env_1); + } + } + }; +}); diff --git a/tests/baselines/reference/usingDeclarationsWithESClassDecorators.6(module=system,target=es5).js b/tests/baselines/reference/usingDeclarationsWithESClassDecorators.6(module=system,target=es5).js new file mode 100644 index 0000000000000..78f5826eb33e0 --- /dev/null +++ b/tests/baselines/reference/usingDeclarationsWithESClassDecorators.6(module=system,target=es5).js @@ -0,0 +1,55 @@ +//// [tests/cases/conformance/statements/VariableStatements/usingDeclarations/usingDeclarationsWithESClassDecorators.6.ts] //// + +//// [usingDeclarationsWithESClassDecorators.6.ts] +export {}; + +declare var dec: any; + +using before = null; + +@dec +class C { +} + +export { C as D }; + +//// [usingDeclarationsWithESClassDecorators.6.js] +System.register([], function (exports_1, context_1) { + "use strict"; + var before, C, env_1; + var __moduleName = context_1 && context_1.id; + return { + setters: [], + execute: function () { + env_1 = { stack: [], error: void 0, hasError: false }; + try { + before = __addDisposableResource(env_1, null, false); + exports_1("D", C = function () { + var _classDecorators = [dec]; + var _classDescriptor; + var _classExtraInitializers = []; + var _classThis; + var C = _classThis = /** @class */ (function () { + function C_1() { + } + return C_1; + }()); + __setFunctionName(_classThis, "C"); + (function () { + __esDecorate(null, _classDescriptor = { value: _classThis }, _classDecorators, { kind: "class", name: _classThis.name }, null, _classExtraInitializers); + C = _classThis = _classDescriptor.value; + __runInitializers(_classThis, _classExtraInitializers); + })(); + return C = _classThis; + }()); + } + catch (e_1) { + env_1.error = e_1; + env_1.hasError = true; + } + finally { + __disposeResources(env_1); + } + } + }; +}); diff --git a/tests/baselines/reference/usingDeclarationsWithESClassDecorators.6(module=system,target=esnext).js b/tests/baselines/reference/usingDeclarationsWithESClassDecorators.6(module=system,target=esnext).js new file mode 100644 index 0000000000000..b350dd05b3cee --- /dev/null +++ b/tests/baselines/reference/usingDeclarationsWithESClassDecorators.6(module=system,target=esnext).js @@ -0,0 +1,32 @@ +//// [tests/cases/conformance/statements/VariableStatements/usingDeclarations/usingDeclarationsWithESClassDecorators.6.ts] //// + +//// [usingDeclarationsWithESClassDecorators.6.ts] +export {}; + +declare var dec: any; + +using before = null; + +@dec +class C { +} + +export { C as D }; + +//// [usingDeclarationsWithESClassDecorators.6.js] +System.register([], function (exports_1, context_1) { + "use strict"; + var before, C; + var __moduleName = context_1 && context_1.id; + return { + setters: [], + execute: function () { + using before_1 = before = null; + C = + @dec + class C { + }; + exports_1("D", C); + } + }; +}); diff --git a/tests/baselines/reference/usingDeclarationsWithESClassDecorators.7(module=commonjs,target=es2015).js b/tests/baselines/reference/usingDeclarationsWithESClassDecorators.7(module=commonjs,target=es2015).js new file mode 100644 index 0000000000000..3c4b4dda56e79 --- /dev/null +++ b/tests/baselines/reference/usingDeclarationsWithESClassDecorators.7(module=commonjs,target=es2015).js @@ -0,0 +1,45 @@ +//// [tests/cases/conformance/statements/VariableStatements/usingDeclarations/usingDeclarationsWithESClassDecorators.7.ts] //// + +//// [usingDeclarationsWithESClassDecorators.7.ts] +export {}; + +declare var dec: any; + +@dec +class C { +} + +using after = null; + + + +//// [usingDeclarationsWithESClassDecorators.7.js] +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +let C = (() => { + let _classDecorators = [dec]; + let _classDescriptor; + let _classExtraInitializers = []; + let _classThis; + var C = _classThis = class { + }; + __setFunctionName(_classThis, "C"); + (() => { + __esDecorate(null, _classDescriptor = { value: _classThis }, _classDecorators, { kind: "class", name: _classThis.name }, null, _classExtraInitializers); + C = _classThis = _classDescriptor.value; + __runInitializers(_classThis, _classExtraInitializers); + })(); + return C = _classThis; +})(); +var after; +const env_1 = { stack: [], error: void 0, hasError: false }; +try { + after = __addDisposableResource(env_1, null, false); +} +catch (e_1) { + env_1.error = e_1; + env_1.hasError = true; +} +finally { + __disposeResources(env_1); +} diff --git a/tests/baselines/reference/usingDeclarationsWithESClassDecorators.7(module=commonjs,target=es5).js b/tests/baselines/reference/usingDeclarationsWithESClassDecorators.7(module=commonjs,target=es5).js new file mode 100644 index 0000000000000..08af55964ca6e --- /dev/null +++ b/tests/baselines/reference/usingDeclarationsWithESClassDecorators.7(module=commonjs,target=es5).js @@ -0,0 +1,48 @@ +//// [tests/cases/conformance/statements/VariableStatements/usingDeclarations/usingDeclarationsWithESClassDecorators.7.ts] //// + +//// [usingDeclarationsWithESClassDecorators.7.ts] +export {}; + +declare var dec: any; + +@dec +class C { +} + +using after = null; + + + +//// [usingDeclarationsWithESClassDecorators.7.js] +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +var C = function () { + var _classDecorators = [dec]; + var _classDescriptor; + var _classExtraInitializers = []; + var _classThis; + var C = _classThis = /** @class */ (function () { + function C_1() { + } + return C_1; + }()); + __setFunctionName(_classThis, "C"); + (function () { + __esDecorate(null, _classDescriptor = { value: _classThis }, _classDecorators, { kind: "class", name: _classThis.name }, null, _classExtraInitializers); + C = _classThis = _classDescriptor.value; + __runInitializers(_classThis, _classExtraInitializers); + })(); + return C = _classThis; +}(); +var after; +var env_1 = { stack: [], error: void 0, hasError: false }; +try { + after = __addDisposableResource(env_1, null, false); +} +catch (e_1) { + env_1.error = e_1; + env_1.hasError = true; +} +finally { + __disposeResources(env_1); +} diff --git a/tests/baselines/reference/usingDeclarationsWithESClassDecorators.7(module=commonjs,target=esnext).js b/tests/baselines/reference/usingDeclarationsWithESClassDecorators.7(module=commonjs,target=esnext).js new file mode 100644 index 0000000000000..007c1012fd93e --- /dev/null +++ b/tests/baselines/reference/usingDeclarationsWithESClassDecorators.7(module=commonjs,target=esnext).js @@ -0,0 +1,22 @@ +//// [tests/cases/conformance/statements/VariableStatements/usingDeclarations/usingDeclarationsWithESClassDecorators.7.ts] //// + +//// [usingDeclarationsWithESClassDecorators.7.ts] +export {}; + +declare var dec: any; + +@dec +class C { +} + +using after = null; + + + +//// [usingDeclarationsWithESClassDecorators.7.js] +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +@dec +class C { +} +using after = null; diff --git a/tests/baselines/reference/usingDeclarationsWithESClassDecorators.7(module=esnext,target=es2015).js b/tests/baselines/reference/usingDeclarationsWithESClassDecorators.7(module=esnext,target=es2015).js new file mode 100644 index 0000000000000..1968891ff9048 --- /dev/null +++ b/tests/baselines/reference/usingDeclarationsWithESClassDecorators.7(module=esnext,target=es2015).js @@ -0,0 +1,44 @@ +//// [tests/cases/conformance/statements/VariableStatements/usingDeclarations/usingDeclarationsWithESClassDecorators.7.ts] //// + +//// [usingDeclarationsWithESClassDecorators.7.ts] +export {}; + +declare var dec: any; + +@dec +class C { +} + +using after = null; + + + +//// [usingDeclarationsWithESClassDecorators.7.js] +let C = (() => { + let _classDecorators = [dec]; + let _classDescriptor; + let _classExtraInitializers = []; + let _classThis; + var C = _classThis = class { + }; + __setFunctionName(_classThis, "C"); + (() => { + __esDecorate(null, _classDescriptor = { value: _classThis }, _classDecorators, { kind: "class", name: _classThis.name }, null, _classExtraInitializers); + C = _classThis = _classDescriptor.value; + __runInitializers(_classThis, _classExtraInitializers); + })(); + return C = _classThis; +})(); +var after; +const env_1 = { stack: [], error: void 0, hasError: false }; +try { + after = __addDisposableResource(env_1, null, false); +} +catch (e_1) { + env_1.error = e_1; + env_1.hasError = true; +} +finally { + __disposeResources(env_1); +} +export {}; diff --git a/tests/baselines/reference/usingDeclarationsWithESClassDecorators.7(module=esnext,target=es5).js b/tests/baselines/reference/usingDeclarationsWithESClassDecorators.7(module=esnext,target=es5).js new file mode 100644 index 0000000000000..41f9acca18328 --- /dev/null +++ b/tests/baselines/reference/usingDeclarationsWithESClassDecorators.7(module=esnext,target=es5).js @@ -0,0 +1,47 @@ +//// [tests/cases/conformance/statements/VariableStatements/usingDeclarations/usingDeclarationsWithESClassDecorators.7.ts] //// + +//// [usingDeclarationsWithESClassDecorators.7.ts] +export {}; + +declare var dec: any; + +@dec +class C { +} + +using after = null; + + + +//// [usingDeclarationsWithESClassDecorators.7.js] +var C = function () { + var _classDecorators = [dec]; + var _classDescriptor; + var _classExtraInitializers = []; + var _classThis; + var C = _classThis = /** @class */ (function () { + function C_1() { + } + return C_1; + }()); + __setFunctionName(_classThis, "C"); + (function () { + __esDecorate(null, _classDescriptor = { value: _classThis }, _classDecorators, { kind: "class", name: _classThis.name }, null, _classExtraInitializers); + C = _classThis = _classDescriptor.value; + __runInitializers(_classThis, _classExtraInitializers); + })(); + return C = _classThis; +}(); +var after; +var env_1 = { stack: [], error: void 0, hasError: false }; +try { + after = __addDisposableResource(env_1, null, false); +} +catch (e_1) { + env_1.error = e_1; + env_1.hasError = true; +} +finally { + __disposeResources(env_1); +} +export {}; diff --git a/tests/baselines/reference/usingDeclarationsWithESClassDecorators.7(module=esnext,target=esnext).js b/tests/baselines/reference/usingDeclarationsWithESClassDecorators.7(module=esnext,target=esnext).js new file mode 100644 index 0000000000000..aa6ea6c8327dd --- /dev/null +++ b/tests/baselines/reference/usingDeclarationsWithESClassDecorators.7(module=esnext,target=esnext).js @@ -0,0 +1,21 @@ +//// [tests/cases/conformance/statements/VariableStatements/usingDeclarations/usingDeclarationsWithESClassDecorators.7.ts] //// + +//// [usingDeclarationsWithESClassDecorators.7.ts] +export {}; + +declare var dec: any; + +@dec +class C { +} + +using after = null; + + + +//// [usingDeclarationsWithESClassDecorators.7.js] +@dec +class C { +} +using after = null; +export {}; diff --git a/tests/baselines/reference/usingDeclarationsWithESClassDecorators.7(module=system,target=es2015).js b/tests/baselines/reference/usingDeclarationsWithESClassDecorators.7(module=system,target=es2015).js new file mode 100644 index 0000000000000..d0dc61887edf5 --- /dev/null +++ b/tests/baselines/reference/usingDeclarationsWithESClassDecorators.7(module=system,target=es2015).js @@ -0,0 +1,52 @@ +//// [tests/cases/conformance/statements/VariableStatements/usingDeclarations/usingDeclarationsWithESClassDecorators.7.ts] //// + +//// [usingDeclarationsWithESClassDecorators.7.ts] +export {}; + +declare var dec: any; + +@dec +class C { +} + +using after = null; + + + +//// [usingDeclarationsWithESClassDecorators.7.js] +System.register([], function (exports_1, context_1) { + "use strict"; + var C, after, env_1; + var __moduleName = context_1 && context_1.id; + return { + setters: [], + execute: function () { + C = (() => { + let _classDecorators = [dec]; + let _classDescriptor; + let _classExtraInitializers = []; + let _classThis; + var C = _classThis = class { + }; + __setFunctionName(_classThis, "C"); + (() => { + __esDecorate(null, _classDescriptor = { value: _classThis }, _classDecorators, { kind: "class", name: _classThis.name }, null, _classExtraInitializers); + C = _classThis = _classDescriptor.value; + __runInitializers(_classThis, _classExtraInitializers); + })(); + return C = _classThis; + })(); + env_1 = { stack: [], error: void 0, hasError: false }; + try { + after = __addDisposableResource(env_1, null, false); + } + catch (e_1) { + env_1.error = e_1; + env_1.hasError = true; + } + finally { + __disposeResources(env_1); + } + } + }; +}); diff --git a/tests/baselines/reference/usingDeclarationsWithESClassDecorators.7(module=system,target=es5).js b/tests/baselines/reference/usingDeclarationsWithESClassDecorators.7(module=system,target=es5).js new file mode 100644 index 0000000000000..34ddb575c0eb9 --- /dev/null +++ b/tests/baselines/reference/usingDeclarationsWithESClassDecorators.7(module=system,target=es5).js @@ -0,0 +1,55 @@ +//// [tests/cases/conformance/statements/VariableStatements/usingDeclarations/usingDeclarationsWithESClassDecorators.7.ts] //// + +//// [usingDeclarationsWithESClassDecorators.7.ts] +export {}; + +declare var dec: any; + +@dec +class C { +} + +using after = null; + + + +//// [usingDeclarationsWithESClassDecorators.7.js] +System.register([], function (exports_1, context_1) { + "use strict"; + var C, after, env_1; + var __moduleName = context_1 && context_1.id; + return { + setters: [], + execute: function () { + C = function () { + var _classDecorators = [dec]; + var _classDescriptor; + var _classExtraInitializers = []; + var _classThis; + var C = _classThis = /** @class */ (function () { + function C_1() { + } + return C_1; + }()); + __setFunctionName(_classThis, "C"); + (function () { + __esDecorate(null, _classDescriptor = { value: _classThis }, _classDecorators, { kind: "class", name: _classThis.name }, null, _classExtraInitializers); + C = _classThis = _classDescriptor.value; + __runInitializers(_classThis, _classExtraInitializers); + })(); + return C = _classThis; + }(); + env_1 = { stack: [], error: void 0, hasError: false }; + try { + after = __addDisposableResource(env_1, null, false); + } + catch (e_1) { + env_1.error = e_1; + env_1.hasError = true; + } + finally { + __disposeResources(env_1); + } + } + }; +}); diff --git a/tests/baselines/reference/usingDeclarationsWithESClassDecorators.7(module=system,target=esnext).js b/tests/baselines/reference/usingDeclarationsWithESClassDecorators.7(module=system,target=esnext).js new file mode 100644 index 0000000000000..6ee74dea872ed --- /dev/null +++ b/tests/baselines/reference/usingDeclarationsWithESClassDecorators.7(module=system,target=esnext).js @@ -0,0 +1,31 @@ +//// [tests/cases/conformance/statements/VariableStatements/usingDeclarations/usingDeclarationsWithESClassDecorators.7.ts] //// + +//// [usingDeclarationsWithESClassDecorators.7.ts] +export {}; + +declare var dec: any; + +@dec +class C { +} + +using after = null; + + + +//// [usingDeclarationsWithESClassDecorators.7.js] +System.register([], function (exports_1, context_1) { + "use strict"; + var C, after; + var __moduleName = context_1 && context_1.id; + return { + setters: [], + execute: function () { + C = + @dec + class C { + }; + using after_1 = after = null; + } + }; +}); diff --git a/tests/baselines/reference/usingDeclarationsWithESClassDecorators.8(module=commonjs,target=es2015).js b/tests/baselines/reference/usingDeclarationsWithESClassDecorators.8(module=commonjs,target=es2015).js new file mode 100644 index 0000000000000..6f89e98a525a5 --- /dev/null +++ b/tests/baselines/reference/usingDeclarationsWithESClassDecorators.8(module=commonjs,target=es2015).js @@ -0,0 +1,46 @@ +//// [tests/cases/conformance/statements/VariableStatements/usingDeclarations/usingDeclarationsWithESClassDecorators.8.ts] //// + +//// [usingDeclarationsWithESClassDecorators.8.ts] +export {}; + +declare var dec: any; + +@dec +export class C { +} + +using after = null; + + +//// [usingDeclarationsWithESClassDecorators.8.js] +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.C = void 0; +let C = (() => { + let _classDecorators = [dec]; + let _classDescriptor; + let _classExtraInitializers = []; + let _classThis; + var C = _classThis = class { + }; + __setFunctionName(_classThis, "C"); + (() => { + __esDecorate(null, _classDescriptor = { value: _classThis }, _classDecorators, { kind: "class", name: _classThis.name }, null, _classExtraInitializers); + C = _classThis = _classDescriptor.value; + __runInitializers(_classThis, _classExtraInitializers); + })(); + return C = _classThis; +})(); +exports.C = C; +var after; +const env_1 = { stack: [], error: void 0, hasError: false }; +try { + after = __addDisposableResource(env_1, null, false); +} +catch (e_1) { + env_1.error = e_1; + env_1.hasError = true; +} +finally { + __disposeResources(env_1); +} diff --git a/tests/baselines/reference/usingDeclarationsWithESClassDecorators.8(module=commonjs,target=es5).js b/tests/baselines/reference/usingDeclarationsWithESClassDecorators.8(module=commonjs,target=es5).js new file mode 100644 index 0000000000000..7a6ea5d919e22 --- /dev/null +++ b/tests/baselines/reference/usingDeclarationsWithESClassDecorators.8(module=commonjs,target=es5).js @@ -0,0 +1,49 @@ +//// [tests/cases/conformance/statements/VariableStatements/usingDeclarations/usingDeclarationsWithESClassDecorators.8.ts] //// + +//// [usingDeclarationsWithESClassDecorators.8.ts] +export {}; + +declare var dec: any; + +@dec +export class C { +} + +using after = null; + + +//// [usingDeclarationsWithESClassDecorators.8.js] +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.C = void 0; +var C = function () { + var _classDecorators = [dec]; + var _classDescriptor; + var _classExtraInitializers = []; + var _classThis; + var C = _classThis = /** @class */ (function () { + function C_1() { + } + return C_1; + }()); + __setFunctionName(_classThis, "C"); + (function () { + __esDecorate(null, _classDescriptor = { value: _classThis }, _classDecorators, { kind: "class", name: _classThis.name }, null, _classExtraInitializers); + C = _classThis = _classDescriptor.value; + __runInitializers(_classThis, _classExtraInitializers); + })(); + return C = _classThis; +}(); +exports.C = C; +var after; +var env_1 = { stack: [], error: void 0, hasError: false }; +try { + after = __addDisposableResource(env_1, null, false); +} +catch (e_1) { + env_1.error = e_1; + env_1.hasError = true; +} +finally { + __disposeResources(env_1); +} diff --git a/tests/baselines/reference/usingDeclarationsWithESClassDecorators.8(module=commonjs,target=esnext).js b/tests/baselines/reference/usingDeclarationsWithESClassDecorators.8(module=commonjs,target=esnext).js new file mode 100644 index 0000000000000..89ecf5ebce7c3 --- /dev/null +++ b/tests/baselines/reference/usingDeclarationsWithESClassDecorators.8(module=commonjs,target=esnext).js @@ -0,0 +1,23 @@ +//// [tests/cases/conformance/statements/VariableStatements/usingDeclarations/usingDeclarationsWithESClassDecorators.8.ts] //// + +//// [usingDeclarationsWithESClassDecorators.8.ts] +export {}; + +declare var dec: any; + +@dec +export class C { +} + +using after = null; + + +//// [usingDeclarationsWithESClassDecorators.8.js] +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.C = void 0; +@dec +class C { +} +exports.C = C; +using after = null; diff --git a/tests/baselines/reference/usingDeclarationsWithESClassDecorators.8(module=esnext,target=es2015).js b/tests/baselines/reference/usingDeclarationsWithESClassDecorators.8(module=esnext,target=es2015).js new file mode 100644 index 0000000000000..3d9f656481604 --- /dev/null +++ b/tests/baselines/reference/usingDeclarationsWithESClassDecorators.8(module=esnext,target=es2015).js @@ -0,0 +1,43 @@ +//// [tests/cases/conformance/statements/VariableStatements/usingDeclarations/usingDeclarationsWithESClassDecorators.8.ts] //// + +//// [usingDeclarationsWithESClassDecorators.8.ts] +export {}; + +declare var dec: any; + +@dec +export class C { +} + +using after = null; + + +//// [usingDeclarationsWithESClassDecorators.8.js] +let C = (() => { + let _classDecorators = [dec]; + let _classDescriptor; + let _classExtraInitializers = []; + let _classThis; + var C = _classThis = class { + }; + __setFunctionName(_classThis, "C"); + (() => { + __esDecorate(null, _classDescriptor = { value: _classThis }, _classDecorators, { kind: "class", name: _classThis.name }, null, _classExtraInitializers); + C = _classThis = _classDescriptor.value; + __runInitializers(_classThis, _classExtraInitializers); + })(); + return C = _classThis; +})(); +export { C }; +var after; +const env_1 = { stack: [], error: void 0, hasError: false }; +try { + after = __addDisposableResource(env_1, null, false); +} +catch (e_1) { + env_1.error = e_1; + env_1.hasError = true; +} +finally { + __disposeResources(env_1); +} diff --git a/tests/baselines/reference/usingDeclarationsWithESClassDecorators.8(module=esnext,target=es5).js b/tests/baselines/reference/usingDeclarationsWithESClassDecorators.8(module=esnext,target=es5).js new file mode 100644 index 0000000000000..4d2d866f26388 --- /dev/null +++ b/tests/baselines/reference/usingDeclarationsWithESClassDecorators.8(module=esnext,target=es5).js @@ -0,0 +1,46 @@ +//// [tests/cases/conformance/statements/VariableStatements/usingDeclarations/usingDeclarationsWithESClassDecorators.8.ts] //// + +//// [usingDeclarationsWithESClassDecorators.8.ts] +export {}; + +declare var dec: any; + +@dec +export class C { +} + +using after = null; + + +//// [usingDeclarationsWithESClassDecorators.8.js] +var C = function () { + var _classDecorators = [dec]; + var _classDescriptor; + var _classExtraInitializers = []; + var _classThis; + var C = _classThis = /** @class */ (function () { + function C_1() { + } + return C_1; + }()); + __setFunctionName(_classThis, "C"); + (function () { + __esDecorate(null, _classDescriptor = { value: _classThis }, _classDecorators, { kind: "class", name: _classThis.name }, null, _classExtraInitializers); + C = _classThis = _classDescriptor.value; + __runInitializers(_classThis, _classExtraInitializers); + })(); + return C = _classThis; +}(); +export { C }; +var after; +var env_1 = { stack: [], error: void 0, hasError: false }; +try { + after = __addDisposableResource(env_1, null, false); +} +catch (e_1) { + env_1.error = e_1; + env_1.hasError = true; +} +finally { + __disposeResources(env_1); +} diff --git a/tests/baselines/reference/usingDeclarationsWithESClassDecorators.8(module=esnext,target=esnext).js b/tests/baselines/reference/usingDeclarationsWithESClassDecorators.8(module=esnext,target=esnext).js new file mode 100644 index 0000000000000..7233732ecfd32 --- /dev/null +++ b/tests/baselines/reference/usingDeclarationsWithESClassDecorators.8(module=esnext,target=esnext).js @@ -0,0 +1,19 @@ +//// [tests/cases/conformance/statements/VariableStatements/usingDeclarations/usingDeclarationsWithESClassDecorators.8.ts] //// + +//// [usingDeclarationsWithESClassDecorators.8.ts] +export {}; + +declare var dec: any; + +@dec +export class C { +} + +using after = null; + + +//// [usingDeclarationsWithESClassDecorators.8.js] +@dec +export class C { +} +using after = null; diff --git a/tests/baselines/reference/usingDeclarationsWithESClassDecorators.8(module=system,target=es2015).js b/tests/baselines/reference/usingDeclarationsWithESClassDecorators.8(module=system,target=es2015).js new file mode 100644 index 0000000000000..881531f70a5a8 --- /dev/null +++ b/tests/baselines/reference/usingDeclarationsWithESClassDecorators.8(module=system,target=es2015).js @@ -0,0 +1,52 @@ +//// [tests/cases/conformance/statements/VariableStatements/usingDeclarations/usingDeclarationsWithESClassDecorators.8.ts] //// + +//// [usingDeclarationsWithESClassDecorators.8.ts] +export {}; + +declare var dec: any; + +@dec +export class C { +} + +using after = null; + + +//// [usingDeclarationsWithESClassDecorators.8.js] +System.register([], function (exports_1, context_1) { + "use strict"; + var C, after, env_1; + var __moduleName = context_1 && context_1.id; + return { + setters: [], + execute: function () { + C = (() => { + let _classDecorators = [dec]; + let _classDescriptor; + let _classExtraInitializers = []; + let _classThis; + var C = _classThis = class { + }; + __setFunctionName(_classThis, "C"); + (() => { + __esDecorate(null, _classDescriptor = { value: _classThis }, _classDecorators, { kind: "class", name: _classThis.name }, null, _classExtraInitializers); + C = _classThis = _classDescriptor.value; + __runInitializers(_classThis, _classExtraInitializers); + })(); + return C = _classThis; + })(); + exports_1("C", C); + env_1 = { stack: [], error: void 0, hasError: false }; + try { + after = __addDisposableResource(env_1, null, false); + } + catch (e_1) { + env_1.error = e_1; + env_1.hasError = true; + } + finally { + __disposeResources(env_1); + } + } + }; +}); diff --git a/tests/baselines/reference/usingDeclarationsWithESClassDecorators.8(module=system,target=es5).js b/tests/baselines/reference/usingDeclarationsWithESClassDecorators.8(module=system,target=es5).js new file mode 100644 index 0000000000000..e1bacdb082a54 --- /dev/null +++ b/tests/baselines/reference/usingDeclarationsWithESClassDecorators.8(module=system,target=es5).js @@ -0,0 +1,55 @@ +//// [tests/cases/conformance/statements/VariableStatements/usingDeclarations/usingDeclarationsWithESClassDecorators.8.ts] //// + +//// [usingDeclarationsWithESClassDecorators.8.ts] +export {}; + +declare var dec: any; + +@dec +export class C { +} + +using after = null; + + +//// [usingDeclarationsWithESClassDecorators.8.js] +System.register([], function (exports_1, context_1) { + "use strict"; + var C, after, env_1; + var __moduleName = context_1 && context_1.id; + return { + setters: [], + execute: function () { + C = function () { + var _classDecorators = [dec]; + var _classDescriptor; + var _classExtraInitializers = []; + var _classThis; + var C = _classThis = /** @class */ (function () { + function C_1() { + } + return C_1; + }()); + __setFunctionName(_classThis, "C"); + (function () { + __esDecorate(null, _classDescriptor = { value: _classThis }, _classDecorators, { kind: "class", name: _classThis.name }, null, _classExtraInitializers); + C = _classThis = _classDescriptor.value; + __runInitializers(_classThis, _classExtraInitializers); + })(); + return C = _classThis; + }(); + exports_1("C", C); + env_1 = { stack: [], error: void 0, hasError: false }; + try { + after = __addDisposableResource(env_1, null, false); + } + catch (e_1) { + env_1.error = e_1; + env_1.hasError = true; + } + finally { + __disposeResources(env_1); + } + } + }; +}); diff --git a/tests/baselines/reference/usingDeclarationsWithESClassDecorators.8(module=system,target=esnext).js b/tests/baselines/reference/usingDeclarationsWithESClassDecorators.8(module=system,target=esnext).js new file mode 100644 index 0000000000000..53b7f9f06f41c --- /dev/null +++ b/tests/baselines/reference/usingDeclarationsWithESClassDecorators.8(module=system,target=esnext).js @@ -0,0 +1,31 @@ +//// [tests/cases/conformance/statements/VariableStatements/usingDeclarations/usingDeclarationsWithESClassDecorators.8.ts] //// + +//// [usingDeclarationsWithESClassDecorators.8.ts] +export {}; + +declare var dec: any; + +@dec +export class C { +} + +using after = null; + + +//// [usingDeclarationsWithESClassDecorators.8.js] +System.register([], function (exports_1, context_1) { + "use strict"; + var C, after; + var __moduleName = context_1 && context_1.id; + return { + setters: [], + execute: function () { + C = + @dec + class C { + }; + exports_1("C", C); + using after_1 = after = null; + } + }; +}); diff --git a/tests/baselines/reference/usingDeclarationsWithESClassDecorators.9(module=commonjs,target=es2015).js b/tests/baselines/reference/usingDeclarationsWithESClassDecorators.9(module=commonjs,target=es2015).js new file mode 100644 index 0000000000000..04799ef6c6165 --- /dev/null +++ b/tests/baselines/reference/usingDeclarationsWithESClassDecorators.9(module=commonjs,target=es2015).js @@ -0,0 +1,49 @@ +//// [tests/cases/conformance/statements/VariableStatements/usingDeclarations/usingDeclarationsWithESClassDecorators.9.ts] //// + +//// [usingDeclarationsWithESClassDecorators.9.ts] +export {}; + +declare var dec: any; + +@dec +export default class C { +} + +void C; + +using after = null; + + + +//// [usingDeclarationsWithESClassDecorators.9.js] +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +let C = (() => { + let _classDecorators = [dec]; + let _classDescriptor; + let _classExtraInitializers = []; + let _classThis; + var C = _classThis = class { + }; + __setFunctionName(_classThis, "C"); + (() => { + __esDecorate(null, _classDescriptor = { value: _classThis }, _classDecorators, { kind: "class", name: _classThis.name }, null, _classExtraInitializers); + C = _classThis = _classDescriptor.value; + __runInitializers(_classThis, _classExtraInitializers); + })(); + return C = _classThis; +})(); +exports.default = C; +void C; +var after; +const env_1 = { stack: [], error: void 0, hasError: false }; +try { + after = __addDisposableResource(env_1, null, false); +} +catch (e_1) { + env_1.error = e_1; + env_1.hasError = true; +} +finally { + __disposeResources(env_1); +} diff --git a/tests/baselines/reference/usingDeclarationsWithESClassDecorators.9(module=commonjs,target=es5).js b/tests/baselines/reference/usingDeclarationsWithESClassDecorators.9(module=commonjs,target=es5).js new file mode 100644 index 0000000000000..93d3fcaa6315d --- /dev/null +++ b/tests/baselines/reference/usingDeclarationsWithESClassDecorators.9(module=commonjs,target=es5).js @@ -0,0 +1,52 @@ +//// [tests/cases/conformance/statements/VariableStatements/usingDeclarations/usingDeclarationsWithESClassDecorators.9.ts] //// + +//// [usingDeclarationsWithESClassDecorators.9.ts] +export {}; + +declare var dec: any; + +@dec +export default class C { +} + +void C; + +using after = null; + + + +//// [usingDeclarationsWithESClassDecorators.9.js] +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +var C = function () { + var _classDecorators = [dec]; + var _classDescriptor; + var _classExtraInitializers = []; + var _classThis; + var C = _classThis = /** @class */ (function () { + function C_1() { + } + return C_1; + }()); + __setFunctionName(_classThis, "C"); + (function () { + __esDecorate(null, _classDescriptor = { value: _classThis }, _classDecorators, { kind: "class", name: _classThis.name }, null, _classExtraInitializers); + C = _classThis = _classDescriptor.value; + __runInitializers(_classThis, _classExtraInitializers); + })(); + return C = _classThis; +}(); +exports.default = C; +void C; +var after; +var env_1 = { stack: [], error: void 0, hasError: false }; +try { + after = __addDisposableResource(env_1, null, false); +} +catch (e_1) { + env_1.error = e_1; + env_1.hasError = true; +} +finally { + __disposeResources(env_1); +} diff --git a/tests/baselines/reference/usingDeclarationsWithESClassDecorators.9(module=commonjs,target=esnext).js b/tests/baselines/reference/usingDeclarationsWithESClassDecorators.9(module=commonjs,target=esnext).js new file mode 100644 index 0000000000000..adff298cfc0ef --- /dev/null +++ b/tests/baselines/reference/usingDeclarationsWithESClassDecorators.9(module=commonjs,target=esnext).js @@ -0,0 +1,26 @@ +//// [tests/cases/conformance/statements/VariableStatements/usingDeclarations/usingDeclarationsWithESClassDecorators.9.ts] //// + +//// [usingDeclarationsWithESClassDecorators.9.ts] +export {}; + +declare var dec: any; + +@dec +export default class C { +} + +void C; + +using after = null; + + + +//// [usingDeclarationsWithESClassDecorators.9.js] +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +@dec +class C { +} +exports.default = C; +void C; +using after = null; diff --git a/tests/baselines/reference/usingDeclarationsWithESClassDecorators.9(module=esnext,target=es2015).js b/tests/baselines/reference/usingDeclarationsWithESClassDecorators.9(module=esnext,target=es2015).js new file mode 100644 index 0000000000000..8318eba18a191 --- /dev/null +++ b/tests/baselines/reference/usingDeclarationsWithESClassDecorators.9(module=esnext,target=es2015).js @@ -0,0 +1,47 @@ +//// [tests/cases/conformance/statements/VariableStatements/usingDeclarations/usingDeclarationsWithESClassDecorators.9.ts] //// + +//// [usingDeclarationsWithESClassDecorators.9.ts] +export {}; + +declare var dec: any; + +@dec +export default class C { +} + +void C; + +using after = null; + + + +//// [usingDeclarationsWithESClassDecorators.9.js] +let C = (() => { + let _classDecorators = [dec]; + let _classDescriptor; + let _classExtraInitializers = []; + let _classThis; + var C = _classThis = class { + }; + __setFunctionName(_classThis, "C"); + (() => { + __esDecorate(null, _classDescriptor = { value: _classThis }, _classDecorators, { kind: "class", name: _classThis.name }, null, _classExtraInitializers); + C = _classThis = _classDescriptor.value; + __runInitializers(_classThis, _classExtraInitializers); + })(); + return C = _classThis; +})(); +export default C; +void C; +var after; +const env_1 = { stack: [], error: void 0, hasError: false }; +try { + after = __addDisposableResource(env_1, null, false); +} +catch (e_1) { + env_1.error = e_1; + env_1.hasError = true; +} +finally { + __disposeResources(env_1); +} diff --git a/tests/baselines/reference/usingDeclarationsWithESClassDecorators.9(module=esnext,target=es5).js b/tests/baselines/reference/usingDeclarationsWithESClassDecorators.9(module=esnext,target=es5).js new file mode 100644 index 0000000000000..693c3ed7a6a26 --- /dev/null +++ b/tests/baselines/reference/usingDeclarationsWithESClassDecorators.9(module=esnext,target=es5).js @@ -0,0 +1,50 @@ +//// [tests/cases/conformance/statements/VariableStatements/usingDeclarations/usingDeclarationsWithESClassDecorators.9.ts] //// + +//// [usingDeclarationsWithESClassDecorators.9.ts] +export {}; + +declare var dec: any; + +@dec +export default class C { +} + +void C; + +using after = null; + + + +//// [usingDeclarationsWithESClassDecorators.9.js] +var C = function () { + var _classDecorators = [dec]; + var _classDescriptor; + var _classExtraInitializers = []; + var _classThis; + var C = _classThis = /** @class */ (function () { + function C_1() { + } + return C_1; + }()); + __setFunctionName(_classThis, "C"); + (function () { + __esDecorate(null, _classDescriptor = { value: _classThis }, _classDecorators, { kind: "class", name: _classThis.name }, null, _classExtraInitializers); + C = _classThis = _classDescriptor.value; + __runInitializers(_classThis, _classExtraInitializers); + })(); + return C = _classThis; +}(); +export default C; +void C; +var after; +var env_1 = { stack: [], error: void 0, hasError: false }; +try { + after = __addDisposableResource(env_1, null, false); +} +catch (e_1) { + env_1.error = e_1; + env_1.hasError = true; +} +finally { + __disposeResources(env_1); +} diff --git a/tests/baselines/reference/usingDeclarationsWithESClassDecorators.9(module=esnext,target=esnext).js b/tests/baselines/reference/usingDeclarationsWithESClassDecorators.9(module=esnext,target=esnext).js new file mode 100644 index 0000000000000..1ae172c17ede7 --- /dev/null +++ b/tests/baselines/reference/usingDeclarationsWithESClassDecorators.9(module=esnext,target=esnext).js @@ -0,0 +1,23 @@ +//// [tests/cases/conformance/statements/VariableStatements/usingDeclarations/usingDeclarationsWithESClassDecorators.9.ts] //// + +//// [usingDeclarationsWithESClassDecorators.9.ts] +export {}; + +declare var dec: any; + +@dec +export default class C { +} + +void C; + +using after = null; + + + +//// [usingDeclarationsWithESClassDecorators.9.js] +@dec +export default class C { +} +void C; +using after = null; diff --git a/tests/baselines/reference/usingDeclarationsWithESClassDecorators.9(module=system,target=es2015).js b/tests/baselines/reference/usingDeclarationsWithESClassDecorators.9(module=system,target=es2015).js new file mode 100644 index 0000000000000..5f149929b43dc --- /dev/null +++ b/tests/baselines/reference/usingDeclarationsWithESClassDecorators.9(module=system,target=es2015).js @@ -0,0 +1,56 @@ +//// [tests/cases/conformance/statements/VariableStatements/usingDeclarations/usingDeclarationsWithESClassDecorators.9.ts] //// + +//// [usingDeclarationsWithESClassDecorators.9.ts] +export {}; + +declare var dec: any; + +@dec +export default class C { +} + +void C; + +using after = null; + + + +//// [usingDeclarationsWithESClassDecorators.9.js] +System.register([], function (exports_1, context_1) { + "use strict"; + var C, after, env_1; + var __moduleName = context_1 && context_1.id; + return { + setters: [], + execute: function () { + C = (() => { + let _classDecorators = [dec]; + let _classDescriptor; + let _classExtraInitializers = []; + let _classThis; + var C = _classThis = class { + }; + __setFunctionName(_classThis, "C"); + (() => { + __esDecorate(null, _classDescriptor = { value: _classThis }, _classDecorators, { kind: "class", name: _classThis.name }, null, _classExtraInitializers); + C = _classThis = _classDescriptor.value; + __runInitializers(_classThis, _classExtraInitializers); + })(); + return C = _classThis; + })(); + exports_1("default", C); + void C; + env_1 = { stack: [], error: void 0, hasError: false }; + try { + after = __addDisposableResource(env_1, null, false); + } + catch (e_1) { + env_1.error = e_1; + env_1.hasError = true; + } + finally { + __disposeResources(env_1); + } + } + }; +}); diff --git a/tests/baselines/reference/usingDeclarationsWithESClassDecorators.9(module=system,target=es5).js b/tests/baselines/reference/usingDeclarationsWithESClassDecorators.9(module=system,target=es5).js new file mode 100644 index 0000000000000..f5d7a58ef5ef4 --- /dev/null +++ b/tests/baselines/reference/usingDeclarationsWithESClassDecorators.9(module=system,target=es5).js @@ -0,0 +1,59 @@ +//// [tests/cases/conformance/statements/VariableStatements/usingDeclarations/usingDeclarationsWithESClassDecorators.9.ts] //// + +//// [usingDeclarationsWithESClassDecorators.9.ts] +export {}; + +declare var dec: any; + +@dec +export default class C { +} + +void C; + +using after = null; + + + +//// [usingDeclarationsWithESClassDecorators.9.js] +System.register([], function (exports_1, context_1) { + "use strict"; + var C, after, env_1; + var __moduleName = context_1 && context_1.id; + return { + setters: [], + execute: function () { + C = function () { + var _classDecorators = [dec]; + var _classDescriptor; + var _classExtraInitializers = []; + var _classThis; + var C = _classThis = /** @class */ (function () { + function C_1() { + } + return C_1; + }()); + __setFunctionName(_classThis, "C"); + (function () { + __esDecorate(null, _classDescriptor = { value: _classThis }, _classDecorators, { kind: "class", name: _classThis.name }, null, _classExtraInitializers); + C = _classThis = _classDescriptor.value; + __runInitializers(_classThis, _classExtraInitializers); + })(); + return C = _classThis; + }(); + exports_1("default", C); + void C; + env_1 = { stack: [], error: void 0, hasError: false }; + try { + after = __addDisposableResource(env_1, null, false); + } + catch (e_1) { + env_1.error = e_1; + env_1.hasError = true; + } + finally { + __disposeResources(env_1); + } + } + }; +}); diff --git a/tests/baselines/reference/usingDeclarationsWithESClassDecorators.9(module=system,target=esnext).js b/tests/baselines/reference/usingDeclarationsWithESClassDecorators.9(module=system,target=esnext).js new file mode 100644 index 0000000000000..1b832deaf7ab3 --- /dev/null +++ b/tests/baselines/reference/usingDeclarationsWithESClassDecorators.9(module=system,target=esnext).js @@ -0,0 +1,35 @@ +//// [tests/cases/conformance/statements/VariableStatements/usingDeclarations/usingDeclarationsWithESClassDecorators.9.ts] //// + +//// [usingDeclarationsWithESClassDecorators.9.ts] +export {}; + +declare var dec: any; + +@dec +export default class C { +} + +void C; + +using after = null; + + + +//// [usingDeclarationsWithESClassDecorators.9.js] +System.register([], function (exports_1, context_1) { + "use strict"; + var C, after; + var __moduleName = context_1 && context_1.id; + return { + setters: [], + execute: function () { + C = + @dec + class C { + }; + exports_1("default", C); + void C; + using after_1 = after = null; + } + }; +}); diff --git a/tests/baselines/reference/usingDeclarationsWithImportHelpers.errors.txt b/tests/baselines/reference/usingDeclarationsWithImportHelpers.errors.txt new file mode 100644 index 0000000000000..e1ba1e5086491 --- /dev/null +++ b/tests/baselines/reference/usingDeclarationsWithImportHelpers.errors.txt @@ -0,0 +1,11 @@ +usingDeclarationsWithImportHelpers.ts(4,5): error TS2354: This syntax requires an imported helper but module 'tslib' cannot be found. + + +==== usingDeclarationsWithImportHelpers.ts (1 errors) ==== + export {}; + + { + using a = null; + ~~~~~~~~~~~~~~ +!!! error TS2354: This syntax requires an imported helper but module 'tslib' cannot be found. + } \ No newline at end of file diff --git a/tests/baselines/reference/usingDeclarationsWithImportHelpers.js b/tests/baselines/reference/usingDeclarationsWithImportHelpers.js new file mode 100644 index 0000000000000..19985bb812053 --- /dev/null +++ b/tests/baselines/reference/usingDeclarationsWithImportHelpers.js @@ -0,0 +1,14 @@ +//// [tests/cases/conformance/statements/VariableStatements/usingDeclarations/usingDeclarationsWithImportHelpers.ts] //// + +//// [usingDeclarationsWithImportHelpers.ts] +export {}; + +{ + using a = null; +} + +//// [usingDeclarationsWithImportHelpers.js] +{ + using a = null; +} +export {}; diff --git a/tests/baselines/reference/usingDeclarationsWithLegacyClassDecorators.1(module=commonjs,target=es2015).js b/tests/baselines/reference/usingDeclarationsWithLegacyClassDecorators.1(module=commonjs,target=es2015).js new file mode 100644 index 0000000000000..b7056ebea45f6 --- /dev/null +++ b/tests/baselines/reference/usingDeclarationsWithLegacyClassDecorators.1(module=commonjs,target=es2015).js @@ -0,0 +1,34 @@ +//// [tests/cases/conformance/statements/VariableStatements/usingDeclarations/usingDeclarationsWithLegacyClassDecorators.1.ts] //// + +//// [usingDeclarationsWithLegacyClassDecorators.1.ts] +export {}; + +declare var dec: any; + +using before = null; + +@dec +class C { +} + + +//// [usingDeclarationsWithLegacyClassDecorators.1.js] +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +var before, C; +const env_1 = { stack: [], error: void 0, hasError: false }; +try { + before = __addDisposableResource(env_1, null, false); + C = class C { + }; + C = __decorate([ + dec + ], C); +} +catch (e_1) { + env_1.error = e_1; + env_1.hasError = true; +} +finally { + __disposeResources(env_1); +} diff --git a/tests/baselines/reference/usingDeclarationsWithLegacyClassDecorators.1(module=commonjs,target=es5).js b/tests/baselines/reference/usingDeclarationsWithLegacyClassDecorators.1(module=commonjs,target=es5).js new file mode 100644 index 0000000000000..4fdd4f97855a4 --- /dev/null +++ b/tests/baselines/reference/usingDeclarationsWithLegacyClassDecorators.1(module=commonjs,target=es5).js @@ -0,0 +1,37 @@ +//// [tests/cases/conformance/statements/VariableStatements/usingDeclarations/usingDeclarationsWithLegacyClassDecorators.1.ts] //// + +//// [usingDeclarationsWithLegacyClassDecorators.1.ts] +export {}; + +declare var dec: any; + +using before = null; + +@dec +class C { +} + + +//// [usingDeclarationsWithLegacyClassDecorators.1.js] +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +var before, C; +var env_1 = { stack: [], error: void 0, hasError: false }; +try { + before = __addDisposableResource(env_1, null, false); + C = /** @class */ (function () { + function C() { + } + C = __decorate([ + dec + ], C); + return C; + }()); +} +catch (e_1) { + env_1.error = e_1; + env_1.hasError = true; +} +finally { + __disposeResources(env_1); +} diff --git a/tests/baselines/reference/usingDeclarationsWithLegacyClassDecorators.1(module=commonjs,target=esnext).js b/tests/baselines/reference/usingDeclarationsWithLegacyClassDecorators.1(module=commonjs,target=esnext).js new file mode 100644 index 0000000000000..1d134f939c555 --- /dev/null +++ b/tests/baselines/reference/usingDeclarationsWithLegacyClassDecorators.1(module=commonjs,target=esnext).js @@ -0,0 +1,23 @@ +//// [tests/cases/conformance/statements/VariableStatements/usingDeclarations/usingDeclarationsWithLegacyClassDecorators.1.ts] //// + +//// [usingDeclarationsWithLegacyClassDecorators.1.ts] +export {}; + +declare var dec: any; + +using before = null; + +@dec +class C { +} + + +//// [usingDeclarationsWithLegacyClassDecorators.1.js] +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +using before = null; +let C = class C { +}; +C = __decorate([ + dec +], C); diff --git a/tests/baselines/reference/usingDeclarationsWithLegacyClassDecorators.1(module=esnext,target=es2015).js b/tests/baselines/reference/usingDeclarationsWithLegacyClassDecorators.1(module=esnext,target=es2015).js new file mode 100644 index 0000000000000..b0cfcf2065e10 --- /dev/null +++ b/tests/baselines/reference/usingDeclarationsWithLegacyClassDecorators.1(module=esnext,target=es2015).js @@ -0,0 +1,33 @@ +//// [tests/cases/conformance/statements/VariableStatements/usingDeclarations/usingDeclarationsWithLegacyClassDecorators.1.ts] //// + +//// [usingDeclarationsWithLegacyClassDecorators.1.ts] +export {}; + +declare var dec: any; + +using before = null; + +@dec +class C { +} + + +//// [usingDeclarationsWithLegacyClassDecorators.1.js] +var before, C; +const env_1 = { stack: [], error: void 0, hasError: false }; +try { + before = __addDisposableResource(env_1, null, false); + C = class C { + }; + C = __decorate([ + dec + ], C); +} +catch (e_1) { + env_1.error = e_1; + env_1.hasError = true; +} +finally { + __disposeResources(env_1); +} +export {}; diff --git a/tests/baselines/reference/usingDeclarationsWithLegacyClassDecorators.1(module=esnext,target=es5).js b/tests/baselines/reference/usingDeclarationsWithLegacyClassDecorators.1(module=esnext,target=es5).js new file mode 100644 index 0000000000000..c2ac948b229eb --- /dev/null +++ b/tests/baselines/reference/usingDeclarationsWithLegacyClassDecorators.1(module=esnext,target=es5).js @@ -0,0 +1,36 @@ +//// [tests/cases/conformance/statements/VariableStatements/usingDeclarations/usingDeclarationsWithLegacyClassDecorators.1.ts] //// + +//// [usingDeclarationsWithLegacyClassDecorators.1.ts] +export {}; + +declare var dec: any; + +using before = null; + +@dec +class C { +} + + +//// [usingDeclarationsWithLegacyClassDecorators.1.js] +var before, C; +var env_1 = { stack: [], error: void 0, hasError: false }; +try { + before = __addDisposableResource(env_1, null, false); + C = /** @class */ (function () { + function C() { + } + C = __decorate([ + dec + ], C); + return C; + }()); +} +catch (e_1) { + env_1.error = e_1; + env_1.hasError = true; +} +finally { + __disposeResources(env_1); +} +export {}; diff --git a/tests/baselines/reference/usingDeclarationsWithLegacyClassDecorators.1(module=esnext,target=esnext).js b/tests/baselines/reference/usingDeclarationsWithLegacyClassDecorators.1(module=esnext,target=esnext).js new file mode 100644 index 0000000000000..bcd661c593ba5 --- /dev/null +++ b/tests/baselines/reference/usingDeclarationsWithLegacyClassDecorators.1(module=esnext,target=esnext).js @@ -0,0 +1,22 @@ +//// [tests/cases/conformance/statements/VariableStatements/usingDeclarations/usingDeclarationsWithLegacyClassDecorators.1.ts] //// + +//// [usingDeclarationsWithLegacyClassDecorators.1.ts] +export {}; + +declare var dec: any; + +using before = null; + +@dec +class C { +} + + +//// [usingDeclarationsWithLegacyClassDecorators.1.js] +using before = null; +let C = class C { +}; +C = __decorate([ + dec +], C); +export {}; diff --git a/tests/baselines/reference/usingDeclarationsWithLegacyClassDecorators.1(module=system,target=es2015).js b/tests/baselines/reference/usingDeclarationsWithLegacyClassDecorators.1(module=system,target=es2015).js new file mode 100644 index 0000000000000..e38f4368dd2b1 --- /dev/null +++ b/tests/baselines/reference/usingDeclarationsWithLegacyClassDecorators.1(module=system,target=es2015).js @@ -0,0 +1,41 @@ +//// [tests/cases/conformance/statements/VariableStatements/usingDeclarations/usingDeclarationsWithLegacyClassDecorators.1.ts] //// + +//// [usingDeclarationsWithLegacyClassDecorators.1.ts] +export {}; + +declare var dec: any; + +using before = null; + +@dec +class C { +} + + +//// [usingDeclarationsWithLegacyClassDecorators.1.js] +System.register([], function (exports_1, context_1) { + "use strict"; + var before, C, env_1; + var __moduleName = context_1 && context_1.id; + return { + setters: [], + execute: function () { + env_1 = { stack: [], error: void 0, hasError: false }; + try { + before = __addDisposableResource(env_1, null, false); + C = class C { + }; + C = __decorate([ + dec + ], C); + } + catch (e_1) { + env_1.error = e_1; + env_1.hasError = true; + } + finally { + __disposeResources(env_1); + } + } + }; +}); diff --git a/tests/baselines/reference/usingDeclarationsWithLegacyClassDecorators.1(module=system,target=es5).js b/tests/baselines/reference/usingDeclarationsWithLegacyClassDecorators.1(module=system,target=es5).js new file mode 100644 index 0000000000000..01b2a8ac3469d --- /dev/null +++ b/tests/baselines/reference/usingDeclarationsWithLegacyClassDecorators.1(module=system,target=es5).js @@ -0,0 +1,44 @@ +//// [tests/cases/conformance/statements/VariableStatements/usingDeclarations/usingDeclarationsWithLegacyClassDecorators.1.ts] //// + +//// [usingDeclarationsWithLegacyClassDecorators.1.ts] +export {}; + +declare var dec: any; + +using before = null; + +@dec +class C { +} + + +//// [usingDeclarationsWithLegacyClassDecorators.1.js] +System.register([], function (exports_1, context_1) { + "use strict"; + var before, C, env_1; + var __moduleName = context_1 && context_1.id; + return { + setters: [], + execute: function () { + env_1 = { stack: [], error: void 0, hasError: false }; + try { + before = __addDisposableResource(env_1, null, false); + C = /** @class */ (function () { + function C() { + } + C = __decorate([ + dec + ], C); + return C; + }()); + } + catch (e_1) { + env_1.error = e_1; + env_1.hasError = true; + } + finally { + __disposeResources(env_1); + } + } + }; +}); diff --git a/tests/baselines/reference/usingDeclarationsWithLegacyClassDecorators.1(module=system,target=esnext).js b/tests/baselines/reference/usingDeclarationsWithLegacyClassDecorators.1(module=system,target=esnext).js new file mode 100644 index 0000000000000..9acdfb05936c2 --- /dev/null +++ b/tests/baselines/reference/usingDeclarationsWithLegacyClassDecorators.1(module=system,target=esnext).js @@ -0,0 +1,31 @@ +//// [tests/cases/conformance/statements/VariableStatements/usingDeclarations/usingDeclarationsWithLegacyClassDecorators.1.ts] //// + +//// [usingDeclarationsWithLegacyClassDecorators.1.ts] +export {}; + +declare var dec: any; + +using before = null; + +@dec +class C { +} + + +//// [usingDeclarationsWithLegacyClassDecorators.1.js] +System.register([], function (exports_1, context_1) { + "use strict"; + var before, C; + var __moduleName = context_1 && context_1.id; + return { + setters: [], + execute: function () { + using before_1 = before = null; + C = class C { + }; + C = __decorate([ + dec + ], C); + } + }; +}); diff --git a/tests/baselines/reference/usingDeclarationsWithLegacyClassDecorators.10(module=commonjs,target=es2015).js b/tests/baselines/reference/usingDeclarationsWithLegacyClassDecorators.10(module=commonjs,target=es2015).js new file mode 100644 index 0000000000000..7d88c087818b4 --- /dev/null +++ b/tests/baselines/reference/usingDeclarationsWithLegacyClassDecorators.10(module=commonjs,target=es2015).js @@ -0,0 +1,35 @@ +//// [tests/cases/conformance/statements/VariableStatements/usingDeclarations/usingDeclarationsWithLegacyClassDecorators.10.ts] //// + +//// [usingDeclarationsWithLegacyClassDecorators.10.ts] +export {}; + +declare var dec: any; + +@dec +export default class { +} + +using after = null; + + +//// [usingDeclarationsWithLegacyClassDecorators.10.js] +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +let default_1 = class { +}; +default_1 = __decorate([ + dec +], default_1); +exports.default = default_1; +var after; +const env_1 = { stack: [], error: void 0, hasError: false }; +try { + after = __addDisposableResource(env_1, null, false); +} +catch (e_1) { + env_1.error = e_1; + env_1.hasError = true; +} +finally { + __disposeResources(env_1); +} diff --git a/tests/baselines/reference/usingDeclarationsWithLegacyClassDecorators.10(module=commonjs,target=es5).js b/tests/baselines/reference/usingDeclarationsWithLegacyClassDecorators.10(module=commonjs,target=es5).js new file mode 100644 index 0000000000000..58df20063749d --- /dev/null +++ b/tests/baselines/reference/usingDeclarationsWithLegacyClassDecorators.10(module=commonjs,target=es5).js @@ -0,0 +1,38 @@ +//// [tests/cases/conformance/statements/VariableStatements/usingDeclarations/usingDeclarationsWithLegacyClassDecorators.10.ts] //// + +//// [usingDeclarationsWithLegacyClassDecorators.10.ts] +export {}; + +declare var dec: any; + +@dec +export default class { +} + +using after = null; + + +//// [usingDeclarationsWithLegacyClassDecorators.10.js] +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +var default_1 = /** @class */ (function () { + function default_1() { + } + default_1 = __decorate([ + dec + ], default_1); + return default_1; +}()); +exports.default = default_1; +var after; +var env_1 = { stack: [], error: void 0, hasError: false }; +try { + after = __addDisposableResource(env_1, null, false); +} +catch (e_1) { + env_1.error = e_1; + env_1.hasError = true; +} +finally { + __disposeResources(env_1); +} diff --git a/tests/baselines/reference/usingDeclarationsWithLegacyClassDecorators.10(module=commonjs,target=esnext).js b/tests/baselines/reference/usingDeclarationsWithLegacyClassDecorators.10(module=commonjs,target=esnext).js new file mode 100644 index 0000000000000..1300e8055a9f2 --- /dev/null +++ b/tests/baselines/reference/usingDeclarationsWithLegacyClassDecorators.10(module=commonjs,target=esnext).js @@ -0,0 +1,24 @@ +//// [tests/cases/conformance/statements/VariableStatements/usingDeclarations/usingDeclarationsWithLegacyClassDecorators.10.ts] //// + +//// [usingDeclarationsWithLegacyClassDecorators.10.ts] +export {}; + +declare var dec: any; + +@dec +export default class { +} + +using after = null; + + +//// [usingDeclarationsWithLegacyClassDecorators.10.js] +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +let default_1 = class { +}; +default_1 = __decorate([ + dec +], default_1); +exports.default = default_1; +using after = null; diff --git a/tests/baselines/reference/usingDeclarationsWithLegacyClassDecorators.10(module=esnext,target=es2015).js b/tests/baselines/reference/usingDeclarationsWithLegacyClassDecorators.10(module=esnext,target=es2015).js new file mode 100644 index 0000000000000..0d6a670510e88 --- /dev/null +++ b/tests/baselines/reference/usingDeclarationsWithLegacyClassDecorators.10(module=esnext,target=es2015).js @@ -0,0 +1,33 @@ +//// [tests/cases/conformance/statements/VariableStatements/usingDeclarations/usingDeclarationsWithLegacyClassDecorators.10.ts] //// + +//// [usingDeclarationsWithLegacyClassDecorators.10.ts] +export {}; + +declare var dec: any; + +@dec +export default class { +} + +using after = null; + + +//// [usingDeclarationsWithLegacyClassDecorators.10.js] +let default_1 = class { +}; +default_1 = __decorate([ + dec +], default_1); +export default default_1; +var after; +const env_1 = { stack: [], error: void 0, hasError: false }; +try { + after = __addDisposableResource(env_1, null, false); +} +catch (e_1) { + env_1.error = e_1; + env_1.hasError = true; +} +finally { + __disposeResources(env_1); +} diff --git a/tests/baselines/reference/usingDeclarationsWithLegacyClassDecorators.10(module=esnext,target=es5).js b/tests/baselines/reference/usingDeclarationsWithLegacyClassDecorators.10(module=esnext,target=es5).js new file mode 100644 index 0000000000000..af906874802a6 --- /dev/null +++ b/tests/baselines/reference/usingDeclarationsWithLegacyClassDecorators.10(module=esnext,target=es5).js @@ -0,0 +1,36 @@ +//// [tests/cases/conformance/statements/VariableStatements/usingDeclarations/usingDeclarationsWithLegacyClassDecorators.10.ts] //// + +//// [usingDeclarationsWithLegacyClassDecorators.10.ts] +export {}; + +declare var dec: any; + +@dec +export default class { +} + +using after = null; + + +//// [usingDeclarationsWithLegacyClassDecorators.10.js] +var default_1 = /** @class */ (function () { + function default_1() { + } + default_1 = __decorate([ + dec + ], default_1); + return default_1; +}()); +export default default_1; +var after; +var env_1 = { stack: [], error: void 0, hasError: false }; +try { + after = __addDisposableResource(env_1, null, false); +} +catch (e_1) { + env_1.error = e_1; + env_1.hasError = true; +} +finally { + __disposeResources(env_1); +} diff --git a/tests/baselines/reference/usingDeclarationsWithLegacyClassDecorators.10(module=esnext,target=esnext).js b/tests/baselines/reference/usingDeclarationsWithLegacyClassDecorators.10(module=esnext,target=esnext).js new file mode 100644 index 0000000000000..50db75c3f74e7 --- /dev/null +++ b/tests/baselines/reference/usingDeclarationsWithLegacyClassDecorators.10(module=esnext,target=esnext).js @@ -0,0 +1,22 @@ +//// [tests/cases/conformance/statements/VariableStatements/usingDeclarations/usingDeclarationsWithLegacyClassDecorators.10.ts] //// + +//// [usingDeclarationsWithLegacyClassDecorators.10.ts] +export {}; + +declare var dec: any; + +@dec +export default class { +} + +using after = null; + + +//// [usingDeclarationsWithLegacyClassDecorators.10.js] +let default_1 = class { +}; +default_1 = __decorate([ + dec +], default_1); +export default default_1; +using after = null; diff --git a/tests/baselines/reference/usingDeclarationsWithLegacyClassDecorators.10(module=system,target=es2015).js b/tests/baselines/reference/usingDeclarationsWithLegacyClassDecorators.10(module=system,target=es2015).js new file mode 100644 index 0000000000000..f42cafc020f48 --- /dev/null +++ b/tests/baselines/reference/usingDeclarationsWithLegacyClassDecorators.10(module=system,target=es2015).js @@ -0,0 +1,42 @@ +//// [tests/cases/conformance/statements/VariableStatements/usingDeclarations/usingDeclarationsWithLegacyClassDecorators.10.ts] //// + +//// [usingDeclarationsWithLegacyClassDecorators.10.ts] +export {}; + +declare var dec: any; + +@dec +export default class { +} + +using after = null; + + +//// [usingDeclarationsWithLegacyClassDecorators.10.js] +System.register([], function (exports_1, context_1) { + "use strict"; + var default_1, after, env_1; + var __moduleName = context_1 && context_1.id; + return { + setters: [], + execute: function () { + default_1 = class { + }; + default_1 = __decorate([ + dec + ], default_1); + exports_1("default", default_1); + env_1 = { stack: [], error: void 0, hasError: false }; + try { + after = __addDisposableResource(env_1, null, false); + } + catch (e_1) { + env_1.error = e_1; + env_1.hasError = true; + } + finally { + __disposeResources(env_1); + } + } + }; +}); diff --git a/tests/baselines/reference/usingDeclarationsWithLegacyClassDecorators.10(module=system,target=es5).js b/tests/baselines/reference/usingDeclarationsWithLegacyClassDecorators.10(module=system,target=es5).js new file mode 100644 index 0000000000000..6d93aa6896b4e --- /dev/null +++ b/tests/baselines/reference/usingDeclarationsWithLegacyClassDecorators.10(module=system,target=es5).js @@ -0,0 +1,45 @@ +//// [tests/cases/conformance/statements/VariableStatements/usingDeclarations/usingDeclarationsWithLegacyClassDecorators.10.ts] //// + +//// [usingDeclarationsWithLegacyClassDecorators.10.ts] +export {}; + +declare var dec: any; + +@dec +export default class { +} + +using after = null; + + +//// [usingDeclarationsWithLegacyClassDecorators.10.js] +System.register([], function (exports_1, context_1) { + "use strict"; + var default_1, after, env_1; + var __moduleName = context_1 && context_1.id; + return { + setters: [], + execute: function () { + default_1 = /** @class */ (function () { + function default_1() { + } + default_1 = __decorate([ + dec + ], default_1); + return default_1; + }()); + exports_1("default", default_1); + env_1 = { stack: [], error: void 0, hasError: false }; + try { + after = __addDisposableResource(env_1, null, false); + } + catch (e_1) { + env_1.error = e_1; + env_1.hasError = true; + } + finally { + __disposeResources(env_1); + } + } + }; +}); diff --git a/tests/baselines/reference/usingDeclarationsWithLegacyClassDecorators.10(module=system,target=esnext).js b/tests/baselines/reference/usingDeclarationsWithLegacyClassDecorators.10(module=system,target=esnext).js new file mode 100644 index 0000000000000..80d52ac8a0917 --- /dev/null +++ b/tests/baselines/reference/usingDeclarationsWithLegacyClassDecorators.10(module=system,target=esnext).js @@ -0,0 +1,32 @@ +//// [tests/cases/conformance/statements/VariableStatements/usingDeclarations/usingDeclarationsWithLegacyClassDecorators.10.ts] //// + +//// [usingDeclarationsWithLegacyClassDecorators.10.ts] +export {}; + +declare var dec: any; + +@dec +export default class { +} + +using after = null; + + +//// [usingDeclarationsWithLegacyClassDecorators.10.js] +System.register([], function (exports_1, context_1) { + "use strict"; + var default_1, after; + var __moduleName = context_1 && context_1.id; + return { + setters: [], + execute: function () { + default_1 = class { + }; + default_1 = __decorate([ + dec + ], default_1); + exports_1("default", default_1); + using after_1 = after = null; + } + }; +}); diff --git a/tests/baselines/reference/usingDeclarationsWithLegacyClassDecorators.11(module=commonjs,target=es2015).js b/tests/baselines/reference/usingDeclarationsWithLegacyClassDecorators.11(module=commonjs,target=es2015).js new file mode 100644 index 0000000000000..f8dd7ad608931 --- /dev/null +++ b/tests/baselines/reference/usingDeclarationsWithLegacyClassDecorators.11(module=commonjs,target=es2015).js @@ -0,0 +1,38 @@ +//// [tests/cases/conformance/statements/VariableStatements/usingDeclarations/usingDeclarationsWithLegacyClassDecorators.11.ts] //// + +//// [usingDeclarationsWithLegacyClassDecorators.11.ts] +export {}; + +declare var dec: any; + +@dec +class C { +} + +export { C }; + +using after = null; + + +//// [usingDeclarationsWithLegacyClassDecorators.11.js] +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.C = void 0; +let C = class C { +}; +exports.C = C; +exports.C = C = __decorate([ + dec +], C); +var after; +const env_1 = { stack: [], error: void 0, hasError: false }; +try { + after = __addDisposableResource(env_1, null, false); +} +catch (e_1) { + env_1.error = e_1; + env_1.hasError = true; +} +finally { + __disposeResources(env_1); +} diff --git a/tests/baselines/reference/usingDeclarationsWithLegacyClassDecorators.11(module=commonjs,target=es5).js b/tests/baselines/reference/usingDeclarationsWithLegacyClassDecorators.11(module=commonjs,target=es5).js new file mode 100644 index 0000000000000..5b6952769bff6 --- /dev/null +++ b/tests/baselines/reference/usingDeclarationsWithLegacyClassDecorators.11(module=commonjs,target=es5).js @@ -0,0 +1,41 @@ +//// [tests/cases/conformance/statements/VariableStatements/usingDeclarations/usingDeclarationsWithLegacyClassDecorators.11.ts] //// + +//// [usingDeclarationsWithLegacyClassDecorators.11.ts] +export {}; + +declare var dec: any; + +@dec +class C { +} + +export { C }; + +using after = null; + + +//// [usingDeclarationsWithLegacyClassDecorators.11.js] +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.C = void 0; +var C = /** @class */ (function () { + function C() { + } + C = __decorate([ + dec + ], C); + return C; +}()); +exports.C = C; +var after; +var env_1 = { stack: [], error: void 0, hasError: false }; +try { + after = __addDisposableResource(env_1, null, false); +} +catch (e_1) { + env_1.error = e_1; + env_1.hasError = true; +} +finally { + __disposeResources(env_1); +} diff --git a/tests/baselines/reference/usingDeclarationsWithLegacyClassDecorators.11(module=commonjs,target=esnext).js b/tests/baselines/reference/usingDeclarationsWithLegacyClassDecorators.11(module=commonjs,target=esnext).js new file mode 100644 index 0000000000000..b278c51655307 --- /dev/null +++ b/tests/baselines/reference/usingDeclarationsWithLegacyClassDecorators.11(module=commonjs,target=esnext).js @@ -0,0 +1,27 @@ +//// [tests/cases/conformance/statements/VariableStatements/usingDeclarations/usingDeclarationsWithLegacyClassDecorators.11.ts] //// + +//// [usingDeclarationsWithLegacyClassDecorators.11.ts] +export {}; + +declare var dec: any; + +@dec +class C { +} + +export { C }; + +using after = null; + + +//// [usingDeclarationsWithLegacyClassDecorators.11.js] +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.C = void 0; +let C = class C { +}; +exports.C = C; +exports.C = C = __decorate([ + dec +], C); +using after = null; diff --git a/tests/baselines/reference/usingDeclarationsWithLegacyClassDecorators.11(module=esnext,target=es2015).js b/tests/baselines/reference/usingDeclarationsWithLegacyClassDecorators.11(module=esnext,target=es2015).js new file mode 100644 index 0000000000000..9093751af8570 --- /dev/null +++ b/tests/baselines/reference/usingDeclarationsWithLegacyClassDecorators.11(module=esnext,target=es2015).js @@ -0,0 +1,35 @@ +//// [tests/cases/conformance/statements/VariableStatements/usingDeclarations/usingDeclarationsWithLegacyClassDecorators.11.ts] //// + +//// [usingDeclarationsWithLegacyClassDecorators.11.ts] +export {}; + +declare var dec: any; + +@dec +class C { +} + +export { C }; + +using after = null; + + +//// [usingDeclarationsWithLegacyClassDecorators.11.js] +let C = class C { +}; +C = __decorate([ + dec +], C); +export { C }; +var after; +const env_1 = { stack: [], error: void 0, hasError: false }; +try { + after = __addDisposableResource(env_1, null, false); +} +catch (e_1) { + env_1.error = e_1; + env_1.hasError = true; +} +finally { + __disposeResources(env_1); +} diff --git a/tests/baselines/reference/usingDeclarationsWithLegacyClassDecorators.11(module=esnext,target=es5).js b/tests/baselines/reference/usingDeclarationsWithLegacyClassDecorators.11(module=esnext,target=es5).js new file mode 100644 index 0000000000000..231f35d7fb147 --- /dev/null +++ b/tests/baselines/reference/usingDeclarationsWithLegacyClassDecorators.11(module=esnext,target=es5).js @@ -0,0 +1,38 @@ +//// [tests/cases/conformance/statements/VariableStatements/usingDeclarations/usingDeclarationsWithLegacyClassDecorators.11.ts] //// + +//// [usingDeclarationsWithLegacyClassDecorators.11.ts] +export {}; + +declare var dec: any; + +@dec +class C { +} + +export { C }; + +using after = null; + + +//// [usingDeclarationsWithLegacyClassDecorators.11.js] +var C = /** @class */ (function () { + function C() { + } + C = __decorate([ + dec + ], C); + return C; +}()); +export { C }; +var after; +var env_1 = { stack: [], error: void 0, hasError: false }; +try { + after = __addDisposableResource(env_1, null, false); +} +catch (e_1) { + env_1.error = e_1; + env_1.hasError = true; +} +finally { + __disposeResources(env_1); +} diff --git a/tests/baselines/reference/usingDeclarationsWithLegacyClassDecorators.11(module=esnext,target=esnext).js b/tests/baselines/reference/usingDeclarationsWithLegacyClassDecorators.11(module=esnext,target=esnext).js new file mode 100644 index 0000000000000..9082a184d621a --- /dev/null +++ b/tests/baselines/reference/usingDeclarationsWithLegacyClassDecorators.11(module=esnext,target=esnext).js @@ -0,0 +1,24 @@ +//// [tests/cases/conformance/statements/VariableStatements/usingDeclarations/usingDeclarationsWithLegacyClassDecorators.11.ts] //// + +//// [usingDeclarationsWithLegacyClassDecorators.11.ts] +export {}; + +declare var dec: any; + +@dec +class C { +} + +export { C }; + +using after = null; + + +//// [usingDeclarationsWithLegacyClassDecorators.11.js] +let C = class C { +}; +C = __decorate([ + dec +], C); +export { C }; +using after = null; diff --git a/tests/baselines/reference/usingDeclarationsWithLegacyClassDecorators.11(module=system,target=es2015).js b/tests/baselines/reference/usingDeclarationsWithLegacyClassDecorators.11(module=system,target=es2015).js new file mode 100644 index 0000000000000..d43c78d6fd206 --- /dev/null +++ b/tests/baselines/reference/usingDeclarationsWithLegacyClassDecorators.11(module=system,target=es2015).js @@ -0,0 +1,44 @@ +//// [tests/cases/conformance/statements/VariableStatements/usingDeclarations/usingDeclarationsWithLegacyClassDecorators.11.ts] //// + +//// [usingDeclarationsWithLegacyClassDecorators.11.ts] +export {}; + +declare var dec: any; + +@dec +class C { +} + +export { C }; + +using after = null; + + +//// [usingDeclarationsWithLegacyClassDecorators.11.js] +System.register([], function (exports_1, context_1) { + "use strict"; + var C, after, env_1; + var __moduleName = context_1 && context_1.id; + return { + setters: [], + execute: function () { + C = class C { + }; + exports_1("C", C); + exports_1("C", C = __decorate([ + dec + ], C)); + env_1 = { stack: [], error: void 0, hasError: false }; + try { + after = __addDisposableResource(env_1, null, false); + } + catch (e_1) { + env_1.error = e_1; + env_1.hasError = true; + } + finally { + __disposeResources(env_1); + } + } + }; +}); diff --git a/tests/baselines/reference/usingDeclarationsWithLegacyClassDecorators.11(module=system,target=es5).js b/tests/baselines/reference/usingDeclarationsWithLegacyClassDecorators.11(module=system,target=es5).js new file mode 100644 index 0000000000000..4052e27a1af44 --- /dev/null +++ b/tests/baselines/reference/usingDeclarationsWithLegacyClassDecorators.11(module=system,target=es5).js @@ -0,0 +1,47 @@ +//// [tests/cases/conformance/statements/VariableStatements/usingDeclarations/usingDeclarationsWithLegacyClassDecorators.11.ts] //// + +//// [usingDeclarationsWithLegacyClassDecorators.11.ts] +export {}; + +declare var dec: any; + +@dec +class C { +} + +export { C }; + +using after = null; + + +//// [usingDeclarationsWithLegacyClassDecorators.11.js] +System.register([], function (exports_1, context_1) { + "use strict"; + var C, after, env_1; + var __moduleName = context_1 && context_1.id; + return { + setters: [], + execute: function () { + C = /** @class */ (function () { + function C() { + } + C = __decorate([ + dec + ], C); + return C; + }()); + exports_1("C", C); + env_1 = { stack: [], error: void 0, hasError: false }; + try { + after = __addDisposableResource(env_1, null, false); + } + catch (e_1) { + env_1.error = e_1; + env_1.hasError = true; + } + finally { + __disposeResources(env_1); + } + } + }; +}); diff --git a/tests/baselines/reference/usingDeclarationsWithLegacyClassDecorators.11(module=system,target=esnext).js b/tests/baselines/reference/usingDeclarationsWithLegacyClassDecorators.11(module=system,target=esnext).js new file mode 100644 index 0000000000000..a4bb104e394a9 --- /dev/null +++ b/tests/baselines/reference/usingDeclarationsWithLegacyClassDecorators.11(module=system,target=esnext).js @@ -0,0 +1,34 @@ +//// [tests/cases/conformance/statements/VariableStatements/usingDeclarations/usingDeclarationsWithLegacyClassDecorators.11.ts] //// + +//// [usingDeclarationsWithLegacyClassDecorators.11.ts] +export {}; + +declare var dec: any; + +@dec +class C { +} + +export { C }; + +using after = null; + + +//// [usingDeclarationsWithLegacyClassDecorators.11.js] +System.register([], function (exports_1, context_1) { + "use strict"; + var C, after; + var __moduleName = context_1 && context_1.id; + return { + setters: [], + execute: function () { + C = class C { + }; + exports_1("C", C); + exports_1("C", C = __decorate([ + dec + ], C)); + using after_1 = after = null; + } + }; +}); diff --git a/tests/baselines/reference/usingDeclarationsWithLegacyClassDecorators.12(module=commonjs,target=es2015).js b/tests/baselines/reference/usingDeclarationsWithLegacyClassDecorators.12(module=commonjs,target=es2015).js new file mode 100644 index 0000000000000..ab54db5b65d06 --- /dev/null +++ b/tests/baselines/reference/usingDeclarationsWithLegacyClassDecorators.12(module=commonjs,target=es2015).js @@ -0,0 +1,38 @@ +//// [tests/cases/conformance/statements/VariableStatements/usingDeclarations/usingDeclarationsWithLegacyClassDecorators.12.ts] //// + +//// [usingDeclarationsWithLegacyClassDecorators.12.ts] +export {}; + +declare var dec: any; + +@dec +class C { +} + +export { C as D }; + +using after = null; + + +//// [usingDeclarationsWithLegacyClassDecorators.12.js] +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.D = void 0; +let C = class C { +}; +exports.D = C; +exports.D = C = __decorate([ + dec +], C); +var after; +const env_1 = { stack: [], error: void 0, hasError: false }; +try { + after = __addDisposableResource(env_1, null, false); +} +catch (e_1) { + env_1.error = e_1; + env_1.hasError = true; +} +finally { + __disposeResources(env_1); +} diff --git a/tests/baselines/reference/usingDeclarationsWithLegacyClassDecorators.12(module=commonjs,target=es5).js b/tests/baselines/reference/usingDeclarationsWithLegacyClassDecorators.12(module=commonjs,target=es5).js new file mode 100644 index 0000000000000..e33447c0bcafa --- /dev/null +++ b/tests/baselines/reference/usingDeclarationsWithLegacyClassDecorators.12(module=commonjs,target=es5).js @@ -0,0 +1,41 @@ +//// [tests/cases/conformance/statements/VariableStatements/usingDeclarations/usingDeclarationsWithLegacyClassDecorators.12.ts] //// + +//// [usingDeclarationsWithLegacyClassDecorators.12.ts] +export {}; + +declare var dec: any; + +@dec +class C { +} + +export { C as D }; + +using after = null; + + +//// [usingDeclarationsWithLegacyClassDecorators.12.js] +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.D = void 0; +var C = /** @class */ (function () { + function C() { + } + C = __decorate([ + dec + ], C); + return C; +}()); +exports.D = C; +var after; +var env_1 = { stack: [], error: void 0, hasError: false }; +try { + after = __addDisposableResource(env_1, null, false); +} +catch (e_1) { + env_1.error = e_1; + env_1.hasError = true; +} +finally { + __disposeResources(env_1); +} diff --git a/tests/baselines/reference/usingDeclarationsWithLegacyClassDecorators.12(module=commonjs,target=esnext).js b/tests/baselines/reference/usingDeclarationsWithLegacyClassDecorators.12(module=commonjs,target=esnext).js new file mode 100644 index 0000000000000..75dce8b79c8d0 --- /dev/null +++ b/tests/baselines/reference/usingDeclarationsWithLegacyClassDecorators.12(module=commonjs,target=esnext).js @@ -0,0 +1,27 @@ +//// [tests/cases/conformance/statements/VariableStatements/usingDeclarations/usingDeclarationsWithLegacyClassDecorators.12.ts] //// + +//// [usingDeclarationsWithLegacyClassDecorators.12.ts] +export {}; + +declare var dec: any; + +@dec +class C { +} + +export { C as D }; + +using after = null; + + +//// [usingDeclarationsWithLegacyClassDecorators.12.js] +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.D = void 0; +let C = class C { +}; +exports.D = C; +exports.D = C = __decorate([ + dec +], C); +using after = null; diff --git a/tests/baselines/reference/usingDeclarationsWithLegacyClassDecorators.12(module=esnext,target=es2015).js b/tests/baselines/reference/usingDeclarationsWithLegacyClassDecorators.12(module=esnext,target=es2015).js new file mode 100644 index 0000000000000..6a0dc99507452 --- /dev/null +++ b/tests/baselines/reference/usingDeclarationsWithLegacyClassDecorators.12(module=esnext,target=es2015).js @@ -0,0 +1,35 @@ +//// [tests/cases/conformance/statements/VariableStatements/usingDeclarations/usingDeclarationsWithLegacyClassDecorators.12.ts] //// + +//// [usingDeclarationsWithLegacyClassDecorators.12.ts] +export {}; + +declare var dec: any; + +@dec +class C { +} + +export { C as D }; + +using after = null; + + +//// [usingDeclarationsWithLegacyClassDecorators.12.js] +let C = class C { +}; +C = __decorate([ + dec +], C); +export { C as D }; +var after; +const env_1 = { stack: [], error: void 0, hasError: false }; +try { + after = __addDisposableResource(env_1, null, false); +} +catch (e_1) { + env_1.error = e_1; + env_1.hasError = true; +} +finally { + __disposeResources(env_1); +} diff --git a/tests/baselines/reference/usingDeclarationsWithLegacyClassDecorators.12(module=esnext,target=es5).js b/tests/baselines/reference/usingDeclarationsWithLegacyClassDecorators.12(module=esnext,target=es5).js new file mode 100644 index 0000000000000..d9638676cd11a --- /dev/null +++ b/tests/baselines/reference/usingDeclarationsWithLegacyClassDecorators.12(module=esnext,target=es5).js @@ -0,0 +1,38 @@ +//// [tests/cases/conformance/statements/VariableStatements/usingDeclarations/usingDeclarationsWithLegacyClassDecorators.12.ts] //// + +//// [usingDeclarationsWithLegacyClassDecorators.12.ts] +export {}; + +declare var dec: any; + +@dec +class C { +} + +export { C as D }; + +using after = null; + + +//// [usingDeclarationsWithLegacyClassDecorators.12.js] +var C = /** @class */ (function () { + function C() { + } + C = __decorate([ + dec + ], C); + return C; +}()); +export { C as D }; +var after; +var env_1 = { stack: [], error: void 0, hasError: false }; +try { + after = __addDisposableResource(env_1, null, false); +} +catch (e_1) { + env_1.error = e_1; + env_1.hasError = true; +} +finally { + __disposeResources(env_1); +} diff --git a/tests/baselines/reference/usingDeclarationsWithLegacyClassDecorators.12(module=esnext,target=esnext).js b/tests/baselines/reference/usingDeclarationsWithLegacyClassDecorators.12(module=esnext,target=esnext).js new file mode 100644 index 0000000000000..0cd3ea7c8163d --- /dev/null +++ b/tests/baselines/reference/usingDeclarationsWithLegacyClassDecorators.12(module=esnext,target=esnext).js @@ -0,0 +1,24 @@ +//// [tests/cases/conformance/statements/VariableStatements/usingDeclarations/usingDeclarationsWithLegacyClassDecorators.12.ts] //// + +//// [usingDeclarationsWithLegacyClassDecorators.12.ts] +export {}; + +declare var dec: any; + +@dec +class C { +} + +export { C as D }; + +using after = null; + + +//// [usingDeclarationsWithLegacyClassDecorators.12.js] +let C = class C { +}; +C = __decorate([ + dec +], C); +export { C as D }; +using after = null; diff --git a/tests/baselines/reference/usingDeclarationsWithLegacyClassDecorators.12(module=system,target=es2015).js b/tests/baselines/reference/usingDeclarationsWithLegacyClassDecorators.12(module=system,target=es2015).js new file mode 100644 index 0000000000000..ef4e15941152e --- /dev/null +++ b/tests/baselines/reference/usingDeclarationsWithLegacyClassDecorators.12(module=system,target=es2015).js @@ -0,0 +1,44 @@ +//// [tests/cases/conformance/statements/VariableStatements/usingDeclarations/usingDeclarationsWithLegacyClassDecorators.12.ts] //// + +//// [usingDeclarationsWithLegacyClassDecorators.12.ts] +export {}; + +declare var dec: any; + +@dec +class C { +} + +export { C as D }; + +using after = null; + + +//// [usingDeclarationsWithLegacyClassDecorators.12.js] +System.register([], function (exports_1, context_1) { + "use strict"; + var C, after, env_1; + var __moduleName = context_1 && context_1.id; + return { + setters: [], + execute: function () { + C = class C { + }; + exports_1("D", C); + exports_1("D", C = __decorate([ + dec + ], C)); + env_1 = { stack: [], error: void 0, hasError: false }; + try { + after = __addDisposableResource(env_1, null, false); + } + catch (e_1) { + env_1.error = e_1; + env_1.hasError = true; + } + finally { + __disposeResources(env_1); + } + } + }; +}); diff --git a/tests/baselines/reference/usingDeclarationsWithLegacyClassDecorators.12(module=system,target=es5).js b/tests/baselines/reference/usingDeclarationsWithLegacyClassDecorators.12(module=system,target=es5).js new file mode 100644 index 0000000000000..11bc49f8098b3 --- /dev/null +++ b/tests/baselines/reference/usingDeclarationsWithLegacyClassDecorators.12(module=system,target=es5).js @@ -0,0 +1,47 @@ +//// [tests/cases/conformance/statements/VariableStatements/usingDeclarations/usingDeclarationsWithLegacyClassDecorators.12.ts] //// + +//// [usingDeclarationsWithLegacyClassDecorators.12.ts] +export {}; + +declare var dec: any; + +@dec +class C { +} + +export { C as D }; + +using after = null; + + +//// [usingDeclarationsWithLegacyClassDecorators.12.js] +System.register([], function (exports_1, context_1) { + "use strict"; + var C, after, env_1; + var __moduleName = context_1 && context_1.id; + return { + setters: [], + execute: function () { + C = /** @class */ (function () { + function C() { + } + C = __decorate([ + dec + ], C); + return C; + }()); + exports_1("D", C); + env_1 = { stack: [], error: void 0, hasError: false }; + try { + after = __addDisposableResource(env_1, null, false); + } + catch (e_1) { + env_1.error = e_1; + env_1.hasError = true; + } + finally { + __disposeResources(env_1); + } + } + }; +}); diff --git a/tests/baselines/reference/usingDeclarationsWithLegacyClassDecorators.12(module=system,target=esnext).js b/tests/baselines/reference/usingDeclarationsWithLegacyClassDecorators.12(module=system,target=esnext).js new file mode 100644 index 0000000000000..1ca8cc0ad3995 --- /dev/null +++ b/tests/baselines/reference/usingDeclarationsWithLegacyClassDecorators.12(module=system,target=esnext).js @@ -0,0 +1,34 @@ +//// [tests/cases/conformance/statements/VariableStatements/usingDeclarations/usingDeclarationsWithLegacyClassDecorators.12.ts] //// + +//// [usingDeclarationsWithLegacyClassDecorators.12.ts] +export {}; + +declare var dec: any; + +@dec +class C { +} + +export { C as D }; + +using after = null; + + +//// [usingDeclarationsWithLegacyClassDecorators.12.js] +System.register([], function (exports_1, context_1) { + "use strict"; + var C, after; + var __moduleName = context_1 && context_1.id; + return { + setters: [], + execute: function () { + C = class C { + }; + exports_1("D", C); + exports_1("D", C = __decorate([ + dec + ], C)); + using after_1 = after = null; + } + }; +}); diff --git a/tests/baselines/reference/usingDeclarationsWithLegacyClassDecorators.2(module=commonjs,target=es2015).js b/tests/baselines/reference/usingDeclarationsWithLegacyClassDecorators.2(module=commonjs,target=es2015).js new file mode 100644 index 0000000000000..110e2d0686a68 --- /dev/null +++ b/tests/baselines/reference/usingDeclarationsWithLegacyClassDecorators.2(module=commonjs,target=es2015).js @@ -0,0 +1,35 @@ +//// [tests/cases/conformance/statements/VariableStatements/usingDeclarations/usingDeclarationsWithLegacyClassDecorators.2.ts] //// + +//// [usingDeclarationsWithLegacyClassDecorators.2.ts] +export {}; + +declare var dec: any; + +using before = null; + +@dec +export class C { +} + + +//// [usingDeclarationsWithLegacyClassDecorators.2.js] +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.C = void 0; +var before, C; +const env_1 = { stack: [], error: void 0, hasError: false }; +try { + before = __addDisposableResource(env_1, null, false); + exports.C = C = class C { + }; + exports.C = C = __decorate([ + dec + ], C); +} +catch (e_1) { + env_1.error = e_1; + env_1.hasError = true; +} +finally { + __disposeResources(env_1); +} diff --git a/tests/baselines/reference/usingDeclarationsWithLegacyClassDecorators.2(module=commonjs,target=es5).js b/tests/baselines/reference/usingDeclarationsWithLegacyClassDecorators.2(module=commonjs,target=es5).js new file mode 100644 index 0000000000000..dac6a5c993b52 --- /dev/null +++ b/tests/baselines/reference/usingDeclarationsWithLegacyClassDecorators.2(module=commonjs,target=es5).js @@ -0,0 +1,38 @@ +//// [tests/cases/conformance/statements/VariableStatements/usingDeclarations/usingDeclarationsWithLegacyClassDecorators.2.ts] //// + +//// [usingDeclarationsWithLegacyClassDecorators.2.ts] +export {}; + +declare var dec: any; + +using before = null; + +@dec +export class C { +} + + +//// [usingDeclarationsWithLegacyClassDecorators.2.js] +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.C = void 0; +var before, C; +var env_1 = { stack: [], error: void 0, hasError: false }; +try { + before = __addDisposableResource(env_1, null, false); + exports.C = C = /** @class */ (function () { + function C() { + } + C = __decorate([ + dec + ], C); + return C; + }()); +} +catch (e_1) { + env_1.error = e_1; + env_1.hasError = true; +} +finally { + __disposeResources(env_1); +} diff --git a/tests/baselines/reference/usingDeclarationsWithLegacyClassDecorators.2(module=commonjs,target=esnext).js b/tests/baselines/reference/usingDeclarationsWithLegacyClassDecorators.2(module=commonjs,target=esnext).js new file mode 100644 index 0000000000000..f0cbe114e2257 --- /dev/null +++ b/tests/baselines/reference/usingDeclarationsWithLegacyClassDecorators.2(module=commonjs,target=esnext).js @@ -0,0 +1,25 @@ +//// [tests/cases/conformance/statements/VariableStatements/usingDeclarations/usingDeclarationsWithLegacyClassDecorators.2.ts] //// + +//// [usingDeclarationsWithLegacyClassDecorators.2.ts] +export {}; + +declare var dec: any; + +using before = null; + +@dec +export class C { +} + + +//// [usingDeclarationsWithLegacyClassDecorators.2.js] +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.C = void 0; +using before = null; +let C = class C { +}; +exports.C = C; +exports.C = C = __decorate([ + dec +], C); diff --git a/tests/baselines/reference/usingDeclarationsWithLegacyClassDecorators.2(module=esnext,target=es2015).js b/tests/baselines/reference/usingDeclarationsWithLegacyClassDecorators.2(module=esnext,target=es2015).js new file mode 100644 index 0000000000000..8643cb7216193 --- /dev/null +++ b/tests/baselines/reference/usingDeclarationsWithLegacyClassDecorators.2(module=esnext,target=es2015).js @@ -0,0 +1,33 @@ +//// [tests/cases/conformance/statements/VariableStatements/usingDeclarations/usingDeclarationsWithLegacyClassDecorators.2.ts] //// + +//// [usingDeclarationsWithLegacyClassDecorators.2.ts] +export {}; + +declare var dec: any; + +using before = null; + +@dec +export class C { +} + + +//// [usingDeclarationsWithLegacyClassDecorators.2.js] +export { C }; +var before, C; +const env_1 = { stack: [], error: void 0, hasError: false }; +try { + before = __addDisposableResource(env_1, null, false); + C = class C { + }; + C = __decorate([ + dec + ], C); +} +catch (e_1) { + env_1.error = e_1; + env_1.hasError = true; +} +finally { + __disposeResources(env_1); +} diff --git a/tests/baselines/reference/usingDeclarationsWithLegacyClassDecorators.2(module=esnext,target=es5).js b/tests/baselines/reference/usingDeclarationsWithLegacyClassDecorators.2(module=esnext,target=es5).js new file mode 100644 index 0000000000000..8521f3d0516da --- /dev/null +++ b/tests/baselines/reference/usingDeclarationsWithLegacyClassDecorators.2(module=esnext,target=es5).js @@ -0,0 +1,36 @@ +//// [tests/cases/conformance/statements/VariableStatements/usingDeclarations/usingDeclarationsWithLegacyClassDecorators.2.ts] //// + +//// [usingDeclarationsWithLegacyClassDecorators.2.ts] +export {}; + +declare var dec: any; + +using before = null; + +@dec +export class C { +} + + +//// [usingDeclarationsWithLegacyClassDecorators.2.js] +export { C }; +var before, C; +var env_1 = { stack: [], error: void 0, hasError: false }; +try { + before = __addDisposableResource(env_1, null, false); + C = /** @class */ (function () { + function C() { + } + C = __decorate([ + dec + ], C); + return C; + }()); +} +catch (e_1) { + env_1.error = e_1; + env_1.hasError = true; +} +finally { + __disposeResources(env_1); +} diff --git a/tests/baselines/reference/usingDeclarationsWithLegacyClassDecorators.2(module=esnext,target=esnext).js b/tests/baselines/reference/usingDeclarationsWithLegacyClassDecorators.2(module=esnext,target=esnext).js new file mode 100644 index 0000000000000..8d3fe7c206312 --- /dev/null +++ b/tests/baselines/reference/usingDeclarationsWithLegacyClassDecorators.2(module=esnext,target=esnext).js @@ -0,0 +1,22 @@ +//// [tests/cases/conformance/statements/VariableStatements/usingDeclarations/usingDeclarationsWithLegacyClassDecorators.2.ts] //// + +//// [usingDeclarationsWithLegacyClassDecorators.2.ts] +export {}; + +declare var dec: any; + +using before = null; + +@dec +export class C { +} + + +//// [usingDeclarationsWithLegacyClassDecorators.2.js] +using before = null; +let C = class C { +}; +C = __decorate([ + dec +], C); +export { C }; diff --git a/tests/baselines/reference/usingDeclarationsWithLegacyClassDecorators.2(module=system,target=es2015).js b/tests/baselines/reference/usingDeclarationsWithLegacyClassDecorators.2(module=system,target=es2015).js new file mode 100644 index 0000000000000..e32aea12a16c7 --- /dev/null +++ b/tests/baselines/reference/usingDeclarationsWithLegacyClassDecorators.2(module=system,target=es2015).js @@ -0,0 +1,41 @@ +//// [tests/cases/conformance/statements/VariableStatements/usingDeclarations/usingDeclarationsWithLegacyClassDecorators.2.ts] //// + +//// [usingDeclarationsWithLegacyClassDecorators.2.ts] +export {}; + +declare var dec: any; + +using before = null; + +@dec +export class C { +} + + +//// [usingDeclarationsWithLegacyClassDecorators.2.js] +System.register([], function (exports_1, context_1) { + "use strict"; + var before, C, env_1; + var __moduleName = context_1 && context_1.id; + return { + setters: [], + execute: function () { + env_1 = { stack: [], error: void 0, hasError: false }; + try { + before = __addDisposableResource(env_1, null, false); + exports_1("C", C = class C { + }); + exports_1("C", C = __decorate([ + dec + ], C)); + } + catch (e_1) { + env_1.error = e_1; + env_1.hasError = true; + } + finally { + __disposeResources(env_1); + } + } + }; +}); diff --git a/tests/baselines/reference/usingDeclarationsWithLegacyClassDecorators.2(module=system,target=es5).js b/tests/baselines/reference/usingDeclarationsWithLegacyClassDecorators.2(module=system,target=es5).js new file mode 100644 index 0000000000000..3564d393247f0 --- /dev/null +++ b/tests/baselines/reference/usingDeclarationsWithLegacyClassDecorators.2(module=system,target=es5).js @@ -0,0 +1,44 @@ +//// [tests/cases/conformance/statements/VariableStatements/usingDeclarations/usingDeclarationsWithLegacyClassDecorators.2.ts] //// + +//// [usingDeclarationsWithLegacyClassDecorators.2.ts] +export {}; + +declare var dec: any; + +using before = null; + +@dec +export class C { +} + + +//// [usingDeclarationsWithLegacyClassDecorators.2.js] +System.register([], function (exports_1, context_1) { + "use strict"; + var before, C, env_1; + var __moduleName = context_1 && context_1.id; + return { + setters: [], + execute: function () { + env_1 = { stack: [], error: void 0, hasError: false }; + try { + before = __addDisposableResource(env_1, null, false); + exports_1("C", C = /** @class */ (function () { + function C() { + } + C = __decorate([ + dec + ], C); + return C; + }())); + } + catch (e_1) { + env_1.error = e_1; + env_1.hasError = true; + } + finally { + __disposeResources(env_1); + } + } + }; +}); diff --git a/tests/baselines/reference/usingDeclarationsWithLegacyClassDecorators.2(module=system,target=esnext).js b/tests/baselines/reference/usingDeclarationsWithLegacyClassDecorators.2(module=system,target=esnext).js new file mode 100644 index 0000000000000..2832750c6b9ff --- /dev/null +++ b/tests/baselines/reference/usingDeclarationsWithLegacyClassDecorators.2(module=system,target=esnext).js @@ -0,0 +1,32 @@ +//// [tests/cases/conformance/statements/VariableStatements/usingDeclarations/usingDeclarationsWithLegacyClassDecorators.2.ts] //// + +//// [usingDeclarationsWithLegacyClassDecorators.2.ts] +export {}; + +declare var dec: any; + +using before = null; + +@dec +export class C { +} + + +//// [usingDeclarationsWithLegacyClassDecorators.2.js] +System.register([], function (exports_1, context_1) { + "use strict"; + var before, C; + var __moduleName = context_1 && context_1.id; + return { + setters: [], + execute: function () { + using before_1 = before = null; + C = class C { + }; + exports_1("C", C); + exports_1("C", C = __decorate([ + dec + ], C)); + } + }; +}); diff --git a/tests/baselines/reference/usingDeclarationsWithLegacyClassDecorators.3(module=commonjs,target=es2015).js b/tests/baselines/reference/usingDeclarationsWithLegacyClassDecorators.3(module=commonjs,target=es2015).js new file mode 100644 index 0000000000000..24b99f7ec2921 --- /dev/null +++ b/tests/baselines/reference/usingDeclarationsWithLegacyClassDecorators.3(module=commonjs,target=es2015).js @@ -0,0 +1,36 @@ +//// [tests/cases/conformance/statements/VariableStatements/usingDeclarations/usingDeclarationsWithLegacyClassDecorators.3.ts] //// + +//// [usingDeclarationsWithLegacyClassDecorators.3.ts] +export {}; + +declare var dec: any; + +using before = null; + +@dec +export default class C { +} + + +//// [usingDeclarationsWithLegacyClassDecorators.3.js] +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.default = void 0; +var before, C, _default; +const env_1 = { stack: [], error: void 0, hasError: false }; +try { + before = __addDisposableResource(env_1, null, false); + C = class C { + }; + C = __decorate([ + dec + ], C); + exports.default = _default = C; +} +catch (e_1) { + env_1.error = e_1; + env_1.hasError = true; +} +finally { + __disposeResources(env_1); +} diff --git a/tests/baselines/reference/usingDeclarationsWithLegacyClassDecorators.3(module=commonjs,target=es5).js b/tests/baselines/reference/usingDeclarationsWithLegacyClassDecorators.3(module=commonjs,target=es5).js new file mode 100644 index 0000000000000..1ad2385ac991c --- /dev/null +++ b/tests/baselines/reference/usingDeclarationsWithLegacyClassDecorators.3(module=commonjs,target=es5).js @@ -0,0 +1,39 @@ +//// [tests/cases/conformance/statements/VariableStatements/usingDeclarations/usingDeclarationsWithLegacyClassDecorators.3.ts] //// + +//// [usingDeclarationsWithLegacyClassDecorators.3.ts] +export {}; + +declare var dec: any; + +using before = null; + +@dec +export default class C { +} + + +//// [usingDeclarationsWithLegacyClassDecorators.3.js] +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.default = void 0; +var before, C, _default; +var env_1 = { stack: [], error: void 0, hasError: false }; +try { + before = __addDisposableResource(env_1, null, false); + C = /** @class */ (function () { + function C() { + } + C = __decorate([ + dec + ], C); + return C; + }()); + exports.default = _default = C; +} +catch (e_1) { + env_1.error = e_1; + env_1.hasError = true; +} +finally { + __disposeResources(env_1); +} diff --git a/tests/baselines/reference/usingDeclarationsWithLegacyClassDecorators.3(module=commonjs,target=esnext).js b/tests/baselines/reference/usingDeclarationsWithLegacyClassDecorators.3(module=commonjs,target=esnext).js new file mode 100644 index 0000000000000..8f18c7d48e1a4 --- /dev/null +++ b/tests/baselines/reference/usingDeclarationsWithLegacyClassDecorators.3(module=commonjs,target=esnext).js @@ -0,0 +1,24 @@ +//// [tests/cases/conformance/statements/VariableStatements/usingDeclarations/usingDeclarationsWithLegacyClassDecorators.3.ts] //// + +//// [usingDeclarationsWithLegacyClassDecorators.3.ts] +export {}; + +declare var dec: any; + +using before = null; + +@dec +export default class C { +} + + +//// [usingDeclarationsWithLegacyClassDecorators.3.js] +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +using before = null; +let C = class C { +}; +C = __decorate([ + dec +], C); +exports.default = C; diff --git a/tests/baselines/reference/usingDeclarationsWithLegacyClassDecorators.3(module=esnext,target=es2015).js b/tests/baselines/reference/usingDeclarationsWithLegacyClassDecorators.3(module=esnext,target=es2015).js new file mode 100644 index 0000000000000..dc4b8a751a1db --- /dev/null +++ b/tests/baselines/reference/usingDeclarationsWithLegacyClassDecorators.3(module=esnext,target=es2015).js @@ -0,0 +1,34 @@ +//// [tests/cases/conformance/statements/VariableStatements/usingDeclarations/usingDeclarationsWithLegacyClassDecorators.3.ts] //// + +//// [usingDeclarationsWithLegacyClassDecorators.3.ts] +export {}; + +declare var dec: any; + +using before = null; + +@dec +export default class C { +} + + +//// [usingDeclarationsWithLegacyClassDecorators.3.js] +export { _default as default }; +var before, C, _default; +const env_1 = { stack: [], error: void 0, hasError: false }; +try { + before = __addDisposableResource(env_1, null, false); + C = class C { + }; + C = __decorate([ + dec + ], C); + _default = C; +} +catch (e_1) { + env_1.error = e_1; + env_1.hasError = true; +} +finally { + __disposeResources(env_1); +} diff --git a/tests/baselines/reference/usingDeclarationsWithLegacyClassDecorators.3(module=esnext,target=es5).js b/tests/baselines/reference/usingDeclarationsWithLegacyClassDecorators.3(module=esnext,target=es5).js new file mode 100644 index 0000000000000..ea0edcd57ae68 --- /dev/null +++ b/tests/baselines/reference/usingDeclarationsWithLegacyClassDecorators.3(module=esnext,target=es5).js @@ -0,0 +1,37 @@ +//// [tests/cases/conformance/statements/VariableStatements/usingDeclarations/usingDeclarationsWithLegacyClassDecorators.3.ts] //// + +//// [usingDeclarationsWithLegacyClassDecorators.3.ts] +export {}; + +declare var dec: any; + +using before = null; + +@dec +export default class C { +} + + +//// [usingDeclarationsWithLegacyClassDecorators.3.js] +export { _default as default }; +var before, C, _default; +var env_1 = { stack: [], error: void 0, hasError: false }; +try { + before = __addDisposableResource(env_1, null, false); + C = /** @class */ (function () { + function C() { + } + C = __decorate([ + dec + ], C); + return C; + }()); + _default = C; +} +catch (e_1) { + env_1.error = e_1; + env_1.hasError = true; +} +finally { + __disposeResources(env_1); +} diff --git a/tests/baselines/reference/usingDeclarationsWithLegacyClassDecorators.3(module=esnext,target=esnext).js b/tests/baselines/reference/usingDeclarationsWithLegacyClassDecorators.3(module=esnext,target=esnext).js new file mode 100644 index 0000000000000..3d51ccac1bfd2 --- /dev/null +++ b/tests/baselines/reference/usingDeclarationsWithLegacyClassDecorators.3(module=esnext,target=esnext).js @@ -0,0 +1,22 @@ +//// [tests/cases/conformance/statements/VariableStatements/usingDeclarations/usingDeclarationsWithLegacyClassDecorators.3.ts] //// + +//// [usingDeclarationsWithLegacyClassDecorators.3.ts] +export {}; + +declare var dec: any; + +using before = null; + +@dec +export default class C { +} + + +//// [usingDeclarationsWithLegacyClassDecorators.3.js] +using before = null; +let C = class C { +}; +C = __decorate([ + dec +], C); +export default C; diff --git a/tests/baselines/reference/usingDeclarationsWithLegacyClassDecorators.3(module=system,target=es2015).js b/tests/baselines/reference/usingDeclarationsWithLegacyClassDecorators.3(module=system,target=es2015).js new file mode 100644 index 0000000000000..7dc57efd1ae8a --- /dev/null +++ b/tests/baselines/reference/usingDeclarationsWithLegacyClassDecorators.3(module=system,target=es2015).js @@ -0,0 +1,42 @@ +//// [tests/cases/conformance/statements/VariableStatements/usingDeclarations/usingDeclarationsWithLegacyClassDecorators.3.ts] //// + +//// [usingDeclarationsWithLegacyClassDecorators.3.ts] +export {}; + +declare var dec: any; + +using before = null; + +@dec +export default class C { +} + + +//// [usingDeclarationsWithLegacyClassDecorators.3.js] +System.register([], function (exports_1, context_1) { + "use strict"; + var before, C, _default, env_1; + var __moduleName = context_1 && context_1.id; + return { + setters: [], + execute: function () { + env_1 = { stack: [], error: void 0, hasError: false }; + try { + before = __addDisposableResource(env_1, null, false); + C = class C { + }; + C = __decorate([ + dec + ], C); + exports_1("default", _default = C); + } + catch (e_1) { + env_1.error = e_1; + env_1.hasError = true; + } + finally { + __disposeResources(env_1); + } + } + }; +}); diff --git a/tests/baselines/reference/usingDeclarationsWithLegacyClassDecorators.3(module=system,target=es5).js b/tests/baselines/reference/usingDeclarationsWithLegacyClassDecorators.3(module=system,target=es5).js new file mode 100644 index 0000000000000..bf8059e196205 --- /dev/null +++ b/tests/baselines/reference/usingDeclarationsWithLegacyClassDecorators.3(module=system,target=es5).js @@ -0,0 +1,45 @@ +//// [tests/cases/conformance/statements/VariableStatements/usingDeclarations/usingDeclarationsWithLegacyClassDecorators.3.ts] //// + +//// [usingDeclarationsWithLegacyClassDecorators.3.ts] +export {}; + +declare var dec: any; + +using before = null; + +@dec +export default class C { +} + + +//// [usingDeclarationsWithLegacyClassDecorators.3.js] +System.register([], function (exports_1, context_1) { + "use strict"; + var before, C, _default, env_1; + var __moduleName = context_1 && context_1.id; + return { + setters: [], + execute: function () { + env_1 = { stack: [], error: void 0, hasError: false }; + try { + before = __addDisposableResource(env_1, null, false); + C = /** @class */ (function () { + function C() { + } + C = __decorate([ + dec + ], C); + return C; + }()); + exports_1("default", _default = C); + } + catch (e_1) { + env_1.error = e_1; + env_1.hasError = true; + } + finally { + __disposeResources(env_1); + } + } + }; +}); diff --git a/tests/baselines/reference/usingDeclarationsWithLegacyClassDecorators.3(module=system,target=esnext).js b/tests/baselines/reference/usingDeclarationsWithLegacyClassDecorators.3(module=system,target=esnext).js new file mode 100644 index 0000000000000..88f54ce2d6057 --- /dev/null +++ b/tests/baselines/reference/usingDeclarationsWithLegacyClassDecorators.3(module=system,target=esnext).js @@ -0,0 +1,32 @@ +//// [tests/cases/conformance/statements/VariableStatements/usingDeclarations/usingDeclarationsWithLegacyClassDecorators.3.ts] //// + +//// [usingDeclarationsWithLegacyClassDecorators.3.ts] +export {}; + +declare var dec: any; + +using before = null; + +@dec +export default class C { +} + + +//// [usingDeclarationsWithLegacyClassDecorators.3.js] +System.register([], function (exports_1, context_1) { + "use strict"; + var before, C; + var __moduleName = context_1 && context_1.id; + return { + setters: [], + execute: function () { + using before_1 = before = null; + C = class C { + }; + C = __decorate([ + dec + ], C); + exports_1("default", C); + } + }; +}); diff --git a/tests/baselines/reference/usingDeclarationsWithLegacyClassDecorators.4(module=commonjs,target=es2015).js b/tests/baselines/reference/usingDeclarationsWithLegacyClassDecorators.4(module=commonjs,target=es2015).js new file mode 100644 index 0000000000000..f5304502626a8 --- /dev/null +++ b/tests/baselines/reference/usingDeclarationsWithLegacyClassDecorators.4(module=commonjs,target=es2015).js @@ -0,0 +1,36 @@ +//// [tests/cases/conformance/statements/VariableStatements/usingDeclarations/usingDeclarationsWithLegacyClassDecorators.4.ts] //// + +//// [usingDeclarationsWithLegacyClassDecorators.4.ts] +export {}; + +declare var dec: any; + +using before = null; + +@dec +export default class { +} + + +//// [usingDeclarationsWithLegacyClassDecorators.4.js] +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.default = void 0; +var before, default_1, _default; +const env_1 = { stack: [], error: void 0, hasError: false }; +try { + before = __addDisposableResource(env_1, null, false); + default_1 = class { + }; + default_1 = __decorate([ + dec + ], default_1); + exports.default = _default = default_1; +} +catch (e_1) { + env_1.error = e_1; + env_1.hasError = true; +} +finally { + __disposeResources(env_1); +} diff --git a/tests/baselines/reference/usingDeclarationsWithLegacyClassDecorators.4(module=commonjs,target=es5).js b/tests/baselines/reference/usingDeclarationsWithLegacyClassDecorators.4(module=commonjs,target=es5).js new file mode 100644 index 0000000000000..ea32db068b14a --- /dev/null +++ b/tests/baselines/reference/usingDeclarationsWithLegacyClassDecorators.4(module=commonjs,target=es5).js @@ -0,0 +1,39 @@ +//// [tests/cases/conformance/statements/VariableStatements/usingDeclarations/usingDeclarationsWithLegacyClassDecorators.4.ts] //// + +//// [usingDeclarationsWithLegacyClassDecorators.4.ts] +export {}; + +declare var dec: any; + +using before = null; + +@dec +export default class { +} + + +//// [usingDeclarationsWithLegacyClassDecorators.4.js] +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.default = void 0; +var before, default_1, _default; +var env_1 = { stack: [], error: void 0, hasError: false }; +try { + before = __addDisposableResource(env_1, null, false); + default_1 = /** @class */ (function () { + function default_1() { + } + default_1 = __decorate([ + dec + ], default_1); + return default_1; + }()); + exports.default = _default = default_1; +} +catch (e_1) { + env_1.error = e_1; + env_1.hasError = true; +} +finally { + __disposeResources(env_1); +} diff --git a/tests/baselines/reference/usingDeclarationsWithLegacyClassDecorators.4(module=commonjs,target=esnext).js b/tests/baselines/reference/usingDeclarationsWithLegacyClassDecorators.4(module=commonjs,target=esnext).js new file mode 100644 index 0000000000000..09e23b6ac07cc --- /dev/null +++ b/tests/baselines/reference/usingDeclarationsWithLegacyClassDecorators.4(module=commonjs,target=esnext).js @@ -0,0 +1,24 @@ +//// [tests/cases/conformance/statements/VariableStatements/usingDeclarations/usingDeclarationsWithLegacyClassDecorators.4.ts] //// + +//// [usingDeclarationsWithLegacyClassDecorators.4.ts] +export {}; + +declare var dec: any; + +using before = null; + +@dec +export default class { +} + + +//// [usingDeclarationsWithLegacyClassDecorators.4.js] +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +using before = null; +let default_1 = class { +}; +default_1 = __decorate([ + dec +], default_1); +exports.default = default_1; diff --git a/tests/baselines/reference/usingDeclarationsWithLegacyClassDecorators.4(module=esnext,target=es2015).js b/tests/baselines/reference/usingDeclarationsWithLegacyClassDecorators.4(module=esnext,target=es2015).js new file mode 100644 index 0000000000000..78d86eeb20599 --- /dev/null +++ b/tests/baselines/reference/usingDeclarationsWithLegacyClassDecorators.4(module=esnext,target=es2015).js @@ -0,0 +1,34 @@ +//// [tests/cases/conformance/statements/VariableStatements/usingDeclarations/usingDeclarationsWithLegacyClassDecorators.4.ts] //// + +//// [usingDeclarationsWithLegacyClassDecorators.4.ts] +export {}; + +declare var dec: any; + +using before = null; + +@dec +export default class { +} + + +//// [usingDeclarationsWithLegacyClassDecorators.4.js] +export { _default as default }; +var before, default_1, _default; +const env_1 = { stack: [], error: void 0, hasError: false }; +try { + before = __addDisposableResource(env_1, null, false); + default_1 = class { + }; + default_1 = __decorate([ + dec + ], default_1); + _default = default_1; +} +catch (e_1) { + env_1.error = e_1; + env_1.hasError = true; +} +finally { + __disposeResources(env_1); +} diff --git a/tests/baselines/reference/usingDeclarationsWithLegacyClassDecorators.4(module=esnext,target=es5).js b/tests/baselines/reference/usingDeclarationsWithLegacyClassDecorators.4(module=esnext,target=es5).js new file mode 100644 index 0000000000000..65fd9bcfdf166 --- /dev/null +++ b/tests/baselines/reference/usingDeclarationsWithLegacyClassDecorators.4(module=esnext,target=es5).js @@ -0,0 +1,37 @@ +//// [tests/cases/conformance/statements/VariableStatements/usingDeclarations/usingDeclarationsWithLegacyClassDecorators.4.ts] //// + +//// [usingDeclarationsWithLegacyClassDecorators.4.ts] +export {}; + +declare var dec: any; + +using before = null; + +@dec +export default class { +} + + +//// [usingDeclarationsWithLegacyClassDecorators.4.js] +export { _default as default }; +var before, default_1, _default; +var env_1 = { stack: [], error: void 0, hasError: false }; +try { + before = __addDisposableResource(env_1, null, false); + default_1 = /** @class */ (function () { + function default_1() { + } + default_1 = __decorate([ + dec + ], default_1); + return default_1; + }()); + _default = default_1; +} +catch (e_1) { + env_1.error = e_1; + env_1.hasError = true; +} +finally { + __disposeResources(env_1); +} diff --git a/tests/baselines/reference/usingDeclarationsWithLegacyClassDecorators.4(module=esnext,target=esnext).js b/tests/baselines/reference/usingDeclarationsWithLegacyClassDecorators.4(module=esnext,target=esnext).js new file mode 100644 index 0000000000000..4aa174e2f6b0b --- /dev/null +++ b/tests/baselines/reference/usingDeclarationsWithLegacyClassDecorators.4(module=esnext,target=esnext).js @@ -0,0 +1,22 @@ +//// [tests/cases/conformance/statements/VariableStatements/usingDeclarations/usingDeclarationsWithLegacyClassDecorators.4.ts] //// + +//// [usingDeclarationsWithLegacyClassDecorators.4.ts] +export {}; + +declare var dec: any; + +using before = null; + +@dec +export default class { +} + + +//// [usingDeclarationsWithLegacyClassDecorators.4.js] +using before = null; +let default_1 = class { +}; +default_1 = __decorate([ + dec +], default_1); +export default default_1; diff --git a/tests/baselines/reference/usingDeclarationsWithLegacyClassDecorators.4(module=system,target=es2015).js b/tests/baselines/reference/usingDeclarationsWithLegacyClassDecorators.4(module=system,target=es2015).js new file mode 100644 index 0000000000000..44c3493d3312e --- /dev/null +++ b/tests/baselines/reference/usingDeclarationsWithLegacyClassDecorators.4(module=system,target=es2015).js @@ -0,0 +1,42 @@ +//// [tests/cases/conformance/statements/VariableStatements/usingDeclarations/usingDeclarationsWithLegacyClassDecorators.4.ts] //// + +//// [usingDeclarationsWithLegacyClassDecorators.4.ts] +export {}; + +declare var dec: any; + +using before = null; + +@dec +export default class { +} + + +//// [usingDeclarationsWithLegacyClassDecorators.4.js] +System.register([], function (exports_1, context_1) { + "use strict"; + var before, default_1, _default, env_1; + var __moduleName = context_1 && context_1.id; + return { + setters: [], + execute: function () { + env_1 = { stack: [], error: void 0, hasError: false }; + try { + before = __addDisposableResource(env_1, null, false); + default_1 = class { + }; + default_1 = __decorate([ + dec + ], default_1); + exports_1("default", _default = default_1); + } + catch (e_1) { + env_1.error = e_1; + env_1.hasError = true; + } + finally { + __disposeResources(env_1); + } + } + }; +}); diff --git a/tests/baselines/reference/usingDeclarationsWithLegacyClassDecorators.4(module=system,target=es5).js b/tests/baselines/reference/usingDeclarationsWithLegacyClassDecorators.4(module=system,target=es5).js new file mode 100644 index 0000000000000..e1eac33213cd9 --- /dev/null +++ b/tests/baselines/reference/usingDeclarationsWithLegacyClassDecorators.4(module=system,target=es5).js @@ -0,0 +1,45 @@ +//// [tests/cases/conformance/statements/VariableStatements/usingDeclarations/usingDeclarationsWithLegacyClassDecorators.4.ts] //// + +//// [usingDeclarationsWithLegacyClassDecorators.4.ts] +export {}; + +declare var dec: any; + +using before = null; + +@dec +export default class { +} + + +//// [usingDeclarationsWithLegacyClassDecorators.4.js] +System.register([], function (exports_1, context_1) { + "use strict"; + var before, default_1, _default, env_1; + var __moduleName = context_1 && context_1.id; + return { + setters: [], + execute: function () { + env_1 = { stack: [], error: void 0, hasError: false }; + try { + before = __addDisposableResource(env_1, null, false); + default_1 = /** @class */ (function () { + function default_1() { + } + default_1 = __decorate([ + dec + ], default_1); + return default_1; + }()); + exports_1("default", _default = default_1); + } + catch (e_1) { + env_1.error = e_1; + env_1.hasError = true; + } + finally { + __disposeResources(env_1); + } + } + }; +}); diff --git a/tests/baselines/reference/usingDeclarationsWithLegacyClassDecorators.4(module=system,target=esnext).js b/tests/baselines/reference/usingDeclarationsWithLegacyClassDecorators.4(module=system,target=esnext).js new file mode 100644 index 0000000000000..494d32651c8fa --- /dev/null +++ b/tests/baselines/reference/usingDeclarationsWithLegacyClassDecorators.4(module=system,target=esnext).js @@ -0,0 +1,32 @@ +//// [tests/cases/conformance/statements/VariableStatements/usingDeclarations/usingDeclarationsWithLegacyClassDecorators.4.ts] //// + +//// [usingDeclarationsWithLegacyClassDecorators.4.ts] +export {}; + +declare var dec: any; + +using before = null; + +@dec +export default class { +} + + +//// [usingDeclarationsWithLegacyClassDecorators.4.js] +System.register([], function (exports_1, context_1) { + "use strict"; + var before, default_1; + var __moduleName = context_1 && context_1.id; + return { + setters: [], + execute: function () { + using before_1 = before = null; + default_1 = class { + }; + default_1 = __decorate([ + dec + ], default_1); + exports_1("default", default_1); + } + }; +}); diff --git a/tests/baselines/reference/usingDeclarationsWithLegacyClassDecorators.5(module=commonjs,target=es2015).js b/tests/baselines/reference/usingDeclarationsWithLegacyClassDecorators.5(module=commonjs,target=es2015).js new file mode 100644 index 0000000000000..c5eaee6126599 --- /dev/null +++ b/tests/baselines/reference/usingDeclarationsWithLegacyClassDecorators.5(module=commonjs,target=es2015).js @@ -0,0 +1,36 @@ +//// [tests/cases/conformance/statements/VariableStatements/usingDeclarations/usingDeclarationsWithLegacyClassDecorators.5.ts] //// + +//// [usingDeclarationsWithLegacyClassDecorators.5.ts] +export {}; + +declare var dec: any; + +using before = null; + +@dec +class C { +} + +export { C }; + +//// [usingDeclarationsWithLegacyClassDecorators.5.js] +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.C = void 0; +var before, C; +const env_1 = { stack: [], error: void 0, hasError: false }; +try { + before = __addDisposableResource(env_1, null, false); + exports.C = C = class C { + }; + exports.C = C = __decorate([ + dec + ], C); +} +catch (e_1) { + env_1.error = e_1; + env_1.hasError = true; +} +finally { + __disposeResources(env_1); +} diff --git a/tests/baselines/reference/usingDeclarationsWithLegacyClassDecorators.5(module=commonjs,target=es5).js b/tests/baselines/reference/usingDeclarationsWithLegacyClassDecorators.5(module=commonjs,target=es5).js new file mode 100644 index 0000000000000..12feede6b52d6 --- /dev/null +++ b/tests/baselines/reference/usingDeclarationsWithLegacyClassDecorators.5(module=commonjs,target=es5).js @@ -0,0 +1,39 @@ +//// [tests/cases/conformance/statements/VariableStatements/usingDeclarations/usingDeclarationsWithLegacyClassDecorators.5.ts] //// + +//// [usingDeclarationsWithLegacyClassDecorators.5.ts] +export {}; + +declare var dec: any; + +using before = null; + +@dec +class C { +} + +export { C }; + +//// [usingDeclarationsWithLegacyClassDecorators.5.js] +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.C = void 0; +var before, C; +var env_1 = { stack: [], error: void 0, hasError: false }; +try { + before = __addDisposableResource(env_1, null, false); + exports.C = C = /** @class */ (function () { + function C() { + } + C = __decorate([ + dec + ], C); + return C; + }()); +} +catch (e_1) { + env_1.error = e_1; + env_1.hasError = true; +} +finally { + __disposeResources(env_1); +} diff --git a/tests/baselines/reference/usingDeclarationsWithLegacyClassDecorators.5(module=commonjs,target=esnext).js b/tests/baselines/reference/usingDeclarationsWithLegacyClassDecorators.5(module=commonjs,target=esnext).js new file mode 100644 index 0000000000000..3199317d1e09f --- /dev/null +++ b/tests/baselines/reference/usingDeclarationsWithLegacyClassDecorators.5(module=commonjs,target=esnext).js @@ -0,0 +1,26 @@ +//// [tests/cases/conformance/statements/VariableStatements/usingDeclarations/usingDeclarationsWithLegacyClassDecorators.5.ts] //// + +//// [usingDeclarationsWithLegacyClassDecorators.5.ts] +export {}; + +declare var dec: any; + +using before = null; + +@dec +class C { +} + +export { C }; + +//// [usingDeclarationsWithLegacyClassDecorators.5.js] +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.C = void 0; +using before = null; +let C = class C { +}; +exports.C = C; +exports.C = C = __decorate([ + dec +], C); diff --git a/tests/baselines/reference/usingDeclarationsWithLegacyClassDecorators.5(module=esnext,target=es2015).js b/tests/baselines/reference/usingDeclarationsWithLegacyClassDecorators.5(module=esnext,target=es2015).js new file mode 100644 index 0000000000000..0d0242609312c --- /dev/null +++ b/tests/baselines/reference/usingDeclarationsWithLegacyClassDecorators.5(module=esnext,target=es2015).js @@ -0,0 +1,34 @@ +//// [tests/cases/conformance/statements/VariableStatements/usingDeclarations/usingDeclarationsWithLegacyClassDecorators.5.ts] //// + +//// [usingDeclarationsWithLegacyClassDecorators.5.ts] +export {}; + +declare var dec: any; + +using before = null; + +@dec +class C { +} + +export { C }; + +//// [usingDeclarationsWithLegacyClassDecorators.5.js] +export { C }; +var before, C; +const env_1 = { stack: [], error: void 0, hasError: false }; +try { + before = __addDisposableResource(env_1, null, false); + C = class C { + }; + C = __decorate([ + dec + ], C); +} +catch (e_1) { + env_1.error = e_1; + env_1.hasError = true; +} +finally { + __disposeResources(env_1); +} diff --git a/tests/baselines/reference/usingDeclarationsWithLegacyClassDecorators.5(module=esnext,target=es5).js b/tests/baselines/reference/usingDeclarationsWithLegacyClassDecorators.5(module=esnext,target=es5).js new file mode 100644 index 0000000000000..999bdcc43dbb2 --- /dev/null +++ b/tests/baselines/reference/usingDeclarationsWithLegacyClassDecorators.5(module=esnext,target=es5).js @@ -0,0 +1,37 @@ +//// [tests/cases/conformance/statements/VariableStatements/usingDeclarations/usingDeclarationsWithLegacyClassDecorators.5.ts] //// + +//// [usingDeclarationsWithLegacyClassDecorators.5.ts] +export {}; + +declare var dec: any; + +using before = null; + +@dec +class C { +} + +export { C }; + +//// [usingDeclarationsWithLegacyClassDecorators.5.js] +export { C }; +var before, C; +var env_1 = { stack: [], error: void 0, hasError: false }; +try { + before = __addDisposableResource(env_1, null, false); + C = /** @class */ (function () { + function C() { + } + C = __decorate([ + dec + ], C); + return C; + }()); +} +catch (e_1) { + env_1.error = e_1; + env_1.hasError = true; +} +finally { + __disposeResources(env_1); +} diff --git a/tests/baselines/reference/usingDeclarationsWithLegacyClassDecorators.5(module=esnext,target=esnext).js b/tests/baselines/reference/usingDeclarationsWithLegacyClassDecorators.5(module=esnext,target=esnext).js new file mode 100644 index 0000000000000..f490f0b613aa7 --- /dev/null +++ b/tests/baselines/reference/usingDeclarationsWithLegacyClassDecorators.5(module=esnext,target=esnext).js @@ -0,0 +1,23 @@ +//// [tests/cases/conformance/statements/VariableStatements/usingDeclarations/usingDeclarationsWithLegacyClassDecorators.5.ts] //// + +//// [usingDeclarationsWithLegacyClassDecorators.5.ts] +export {}; + +declare var dec: any; + +using before = null; + +@dec +class C { +} + +export { C }; + +//// [usingDeclarationsWithLegacyClassDecorators.5.js] +using before = null; +let C = class C { +}; +C = __decorate([ + dec +], C); +export { C }; diff --git a/tests/baselines/reference/usingDeclarationsWithLegacyClassDecorators.5(module=system,target=es2015).js b/tests/baselines/reference/usingDeclarationsWithLegacyClassDecorators.5(module=system,target=es2015).js new file mode 100644 index 0000000000000..6b859f60e6a3d --- /dev/null +++ b/tests/baselines/reference/usingDeclarationsWithLegacyClassDecorators.5(module=system,target=es2015).js @@ -0,0 +1,42 @@ +//// [tests/cases/conformance/statements/VariableStatements/usingDeclarations/usingDeclarationsWithLegacyClassDecorators.5.ts] //// + +//// [usingDeclarationsWithLegacyClassDecorators.5.ts] +export {}; + +declare var dec: any; + +using before = null; + +@dec +class C { +} + +export { C }; + +//// [usingDeclarationsWithLegacyClassDecorators.5.js] +System.register([], function (exports_1, context_1) { + "use strict"; + var before, C, env_1; + var __moduleName = context_1 && context_1.id; + return { + setters: [], + execute: function () { + env_1 = { stack: [], error: void 0, hasError: false }; + try { + before = __addDisposableResource(env_1, null, false); + exports_1("C", C = class C { + }); + exports_1("C", C = __decorate([ + dec + ], C)); + } + catch (e_1) { + env_1.error = e_1; + env_1.hasError = true; + } + finally { + __disposeResources(env_1); + } + } + }; +}); diff --git a/tests/baselines/reference/usingDeclarationsWithLegacyClassDecorators.5(module=system,target=es5).js b/tests/baselines/reference/usingDeclarationsWithLegacyClassDecorators.5(module=system,target=es5).js new file mode 100644 index 0000000000000..1a7c63879a804 --- /dev/null +++ b/tests/baselines/reference/usingDeclarationsWithLegacyClassDecorators.5(module=system,target=es5).js @@ -0,0 +1,45 @@ +//// [tests/cases/conformance/statements/VariableStatements/usingDeclarations/usingDeclarationsWithLegacyClassDecorators.5.ts] //// + +//// [usingDeclarationsWithLegacyClassDecorators.5.ts] +export {}; + +declare var dec: any; + +using before = null; + +@dec +class C { +} + +export { C }; + +//// [usingDeclarationsWithLegacyClassDecorators.5.js] +System.register([], function (exports_1, context_1) { + "use strict"; + var before, C, env_1; + var __moduleName = context_1 && context_1.id; + return { + setters: [], + execute: function () { + env_1 = { stack: [], error: void 0, hasError: false }; + try { + before = __addDisposableResource(env_1, null, false); + exports_1("C", C = /** @class */ (function () { + function C() { + } + C = __decorate([ + dec + ], C); + return C; + }())); + } + catch (e_1) { + env_1.error = e_1; + env_1.hasError = true; + } + finally { + __disposeResources(env_1); + } + } + }; +}); diff --git a/tests/baselines/reference/usingDeclarationsWithLegacyClassDecorators.5(module=system,target=esnext).js b/tests/baselines/reference/usingDeclarationsWithLegacyClassDecorators.5(module=system,target=esnext).js new file mode 100644 index 0000000000000..5aac5f3cf27af --- /dev/null +++ b/tests/baselines/reference/usingDeclarationsWithLegacyClassDecorators.5(module=system,target=esnext).js @@ -0,0 +1,33 @@ +//// [tests/cases/conformance/statements/VariableStatements/usingDeclarations/usingDeclarationsWithLegacyClassDecorators.5.ts] //// + +//// [usingDeclarationsWithLegacyClassDecorators.5.ts] +export {}; + +declare var dec: any; + +using before = null; + +@dec +class C { +} + +export { C }; + +//// [usingDeclarationsWithLegacyClassDecorators.5.js] +System.register([], function (exports_1, context_1) { + "use strict"; + var before, C; + var __moduleName = context_1 && context_1.id; + return { + setters: [], + execute: function () { + using before_1 = before = null; + C = class C { + }; + exports_1("C", C); + exports_1("C", C = __decorate([ + dec + ], C)); + } + }; +}); diff --git a/tests/baselines/reference/usingDeclarationsWithLegacyClassDecorators.6(module=commonjs,target=es2015).js b/tests/baselines/reference/usingDeclarationsWithLegacyClassDecorators.6(module=commonjs,target=es2015).js new file mode 100644 index 0000000000000..e6d605175bedc --- /dev/null +++ b/tests/baselines/reference/usingDeclarationsWithLegacyClassDecorators.6(module=commonjs,target=es2015).js @@ -0,0 +1,36 @@ +//// [tests/cases/conformance/statements/VariableStatements/usingDeclarations/usingDeclarationsWithLegacyClassDecorators.6.ts] //// + +//// [usingDeclarationsWithLegacyClassDecorators.6.ts] +export {}; + +declare var dec: any; + +using before = null; + +@dec +class C { +} + +export { C as D }; + +//// [usingDeclarationsWithLegacyClassDecorators.6.js] +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.D = void 0; +var before, C; +const env_1 = { stack: [], error: void 0, hasError: false }; +try { + before = __addDisposableResource(env_1, null, false); + exports.D = C = class C { + }; + exports.D = C = __decorate([ + dec + ], C); +} +catch (e_1) { + env_1.error = e_1; + env_1.hasError = true; +} +finally { + __disposeResources(env_1); +} diff --git a/tests/baselines/reference/usingDeclarationsWithLegacyClassDecorators.6(module=commonjs,target=es5).js b/tests/baselines/reference/usingDeclarationsWithLegacyClassDecorators.6(module=commonjs,target=es5).js new file mode 100644 index 0000000000000..87d338f480208 --- /dev/null +++ b/tests/baselines/reference/usingDeclarationsWithLegacyClassDecorators.6(module=commonjs,target=es5).js @@ -0,0 +1,39 @@ +//// [tests/cases/conformance/statements/VariableStatements/usingDeclarations/usingDeclarationsWithLegacyClassDecorators.6.ts] //// + +//// [usingDeclarationsWithLegacyClassDecorators.6.ts] +export {}; + +declare var dec: any; + +using before = null; + +@dec +class C { +} + +export { C as D }; + +//// [usingDeclarationsWithLegacyClassDecorators.6.js] +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.D = void 0; +var before, C; +var env_1 = { stack: [], error: void 0, hasError: false }; +try { + before = __addDisposableResource(env_1, null, false); + exports.D = C = /** @class */ (function () { + function C() { + } + C = __decorate([ + dec + ], C); + return C; + }()); +} +catch (e_1) { + env_1.error = e_1; + env_1.hasError = true; +} +finally { + __disposeResources(env_1); +} diff --git a/tests/baselines/reference/usingDeclarationsWithLegacyClassDecorators.6(module=commonjs,target=esnext).js b/tests/baselines/reference/usingDeclarationsWithLegacyClassDecorators.6(module=commonjs,target=esnext).js new file mode 100644 index 0000000000000..f16c4772a13c1 --- /dev/null +++ b/tests/baselines/reference/usingDeclarationsWithLegacyClassDecorators.6(module=commonjs,target=esnext).js @@ -0,0 +1,26 @@ +//// [tests/cases/conformance/statements/VariableStatements/usingDeclarations/usingDeclarationsWithLegacyClassDecorators.6.ts] //// + +//// [usingDeclarationsWithLegacyClassDecorators.6.ts] +export {}; + +declare var dec: any; + +using before = null; + +@dec +class C { +} + +export { C as D }; + +//// [usingDeclarationsWithLegacyClassDecorators.6.js] +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.D = void 0; +using before = null; +let C = class C { +}; +exports.D = C; +exports.D = C = __decorate([ + dec +], C); diff --git a/tests/baselines/reference/usingDeclarationsWithLegacyClassDecorators.6(module=esnext,target=es2015).js b/tests/baselines/reference/usingDeclarationsWithLegacyClassDecorators.6(module=esnext,target=es2015).js new file mode 100644 index 0000000000000..f3762ca32533e --- /dev/null +++ b/tests/baselines/reference/usingDeclarationsWithLegacyClassDecorators.6(module=esnext,target=es2015).js @@ -0,0 +1,34 @@ +//// [tests/cases/conformance/statements/VariableStatements/usingDeclarations/usingDeclarationsWithLegacyClassDecorators.6.ts] //// + +//// [usingDeclarationsWithLegacyClassDecorators.6.ts] +export {}; + +declare var dec: any; + +using before = null; + +@dec +class C { +} + +export { C as D }; + +//// [usingDeclarationsWithLegacyClassDecorators.6.js] +export { C as D }; +var before, C; +const env_1 = { stack: [], error: void 0, hasError: false }; +try { + before = __addDisposableResource(env_1, null, false); + C = class C { + }; + C = __decorate([ + dec + ], C); +} +catch (e_1) { + env_1.error = e_1; + env_1.hasError = true; +} +finally { + __disposeResources(env_1); +} diff --git a/tests/baselines/reference/usingDeclarationsWithLegacyClassDecorators.6(module=esnext,target=es5).js b/tests/baselines/reference/usingDeclarationsWithLegacyClassDecorators.6(module=esnext,target=es5).js new file mode 100644 index 0000000000000..7c1a58cd4e25d --- /dev/null +++ b/tests/baselines/reference/usingDeclarationsWithLegacyClassDecorators.6(module=esnext,target=es5).js @@ -0,0 +1,37 @@ +//// [tests/cases/conformance/statements/VariableStatements/usingDeclarations/usingDeclarationsWithLegacyClassDecorators.6.ts] //// + +//// [usingDeclarationsWithLegacyClassDecorators.6.ts] +export {}; + +declare var dec: any; + +using before = null; + +@dec +class C { +} + +export { C as D }; + +//// [usingDeclarationsWithLegacyClassDecorators.6.js] +export { C as D }; +var before, C; +var env_1 = { stack: [], error: void 0, hasError: false }; +try { + before = __addDisposableResource(env_1, null, false); + C = /** @class */ (function () { + function C() { + } + C = __decorate([ + dec + ], C); + return C; + }()); +} +catch (e_1) { + env_1.error = e_1; + env_1.hasError = true; +} +finally { + __disposeResources(env_1); +} diff --git a/tests/baselines/reference/usingDeclarationsWithLegacyClassDecorators.6(module=esnext,target=esnext).js b/tests/baselines/reference/usingDeclarationsWithLegacyClassDecorators.6(module=esnext,target=esnext).js new file mode 100644 index 0000000000000..ed1f2c80d9796 --- /dev/null +++ b/tests/baselines/reference/usingDeclarationsWithLegacyClassDecorators.6(module=esnext,target=esnext).js @@ -0,0 +1,23 @@ +//// [tests/cases/conformance/statements/VariableStatements/usingDeclarations/usingDeclarationsWithLegacyClassDecorators.6.ts] //// + +//// [usingDeclarationsWithLegacyClassDecorators.6.ts] +export {}; + +declare var dec: any; + +using before = null; + +@dec +class C { +} + +export { C as D }; + +//// [usingDeclarationsWithLegacyClassDecorators.6.js] +using before = null; +let C = class C { +}; +C = __decorate([ + dec +], C); +export { C as D }; diff --git a/tests/baselines/reference/usingDeclarationsWithLegacyClassDecorators.6(module=system,target=es2015).js b/tests/baselines/reference/usingDeclarationsWithLegacyClassDecorators.6(module=system,target=es2015).js new file mode 100644 index 0000000000000..c49f186a62b8a --- /dev/null +++ b/tests/baselines/reference/usingDeclarationsWithLegacyClassDecorators.6(module=system,target=es2015).js @@ -0,0 +1,42 @@ +//// [tests/cases/conformance/statements/VariableStatements/usingDeclarations/usingDeclarationsWithLegacyClassDecorators.6.ts] //// + +//// [usingDeclarationsWithLegacyClassDecorators.6.ts] +export {}; + +declare var dec: any; + +using before = null; + +@dec +class C { +} + +export { C as D }; + +//// [usingDeclarationsWithLegacyClassDecorators.6.js] +System.register([], function (exports_1, context_1) { + "use strict"; + var before, C, env_1; + var __moduleName = context_1 && context_1.id; + return { + setters: [], + execute: function () { + env_1 = { stack: [], error: void 0, hasError: false }; + try { + before = __addDisposableResource(env_1, null, false); + exports_1("D", C = class C { + }); + exports_1("D", C = __decorate([ + dec + ], C)); + } + catch (e_1) { + env_1.error = e_1; + env_1.hasError = true; + } + finally { + __disposeResources(env_1); + } + } + }; +}); diff --git a/tests/baselines/reference/usingDeclarationsWithLegacyClassDecorators.6(module=system,target=es5).js b/tests/baselines/reference/usingDeclarationsWithLegacyClassDecorators.6(module=system,target=es5).js new file mode 100644 index 0000000000000..5a258248b7841 --- /dev/null +++ b/tests/baselines/reference/usingDeclarationsWithLegacyClassDecorators.6(module=system,target=es5).js @@ -0,0 +1,45 @@ +//// [tests/cases/conformance/statements/VariableStatements/usingDeclarations/usingDeclarationsWithLegacyClassDecorators.6.ts] //// + +//// [usingDeclarationsWithLegacyClassDecorators.6.ts] +export {}; + +declare var dec: any; + +using before = null; + +@dec +class C { +} + +export { C as D }; + +//// [usingDeclarationsWithLegacyClassDecorators.6.js] +System.register([], function (exports_1, context_1) { + "use strict"; + var before, C, env_1; + var __moduleName = context_1 && context_1.id; + return { + setters: [], + execute: function () { + env_1 = { stack: [], error: void 0, hasError: false }; + try { + before = __addDisposableResource(env_1, null, false); + exports_1("D", C = /** @class */ (function () { + function C() { + } + C = __decorate([ + dec + ], C); + return C; + }())); + } + catch (e_1) { + env_1.error = e_1; + env_1.hasError = true; + } + finally { + __disposeResources(env_1); + } + } + }; +}); diff --git a/tests/baselines/reference/usingDeclarationsWithLegacyClassDecorators.6(module=system,target=esnext).js b/tests/baselines/reference/usingDeclarationsWithLegacyClassDecorators.6(module=system,target=esnext).js new file mode 100644 index 0000000000000..15f5addcbffb2 --- /dev/null +++ b/tests/baselines/reference/usingDeclarationsWithLegacyClassDecorators.6(module=system,target=esnext).js @@ -0,0 +1,33 @@ +//// [tests/cases/conformance/statements/VariableStatements/usingDeclarations/usingDeclarationsWithLegacyClassDecorators.6.ts] //// + +//// [usingDeclarationsWithLegacyClassDecorators.6.ts] +export {}; + +declare var dec: any; + +using before = null; + +@dec +class C { +} + +export { C as D }; + +//// [usingDeclarationsWithLegacyClassDecorators.6.js] +System.register([], function (exports_1, context_1) { + "use strict"; + var before, C; + var __moduleName = context_1 && context_1.id; + return { + setters: [], + execute: function () { + using before_1 = before = null; + C = class C { + }; + exports_1("D", C); + exports_1("D", C = __decorate([ + dec + ], C)); + } + }; +}); diff --git a/tests/baselines/reference/usingDeclarationsWithLegacyClassDecorators.7(module=commonjs,target=es2015).js b/tests/baselines/reference/usingDeclarationsWithLegacyClassDecorators.7(module=commonjs,target=es2015).js new file mode 100644 index 0000000000000..c2103047fb56e --- /dev/null +++ b/tests/baselines/reference/usingDeclarationsWithLegacyClassDecorators.7(module=commonjs,target=es2015).js @@ -0,0 +1,34 @@ +//// [tests/cases/conformance/statements/VariableStatements/usingDeclarations/usingDeclarationsWithLegacyClassDecorators.7.ts] //// + +//// [usingDeclarationsWithLegacyClassDecorators.7.ts] +export {}; + +declare var dec: any; + +@dec +class C { +} + +using after = null; + + +//// [usingDeclarationsWithLegacyClassDecorators.7.js] +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +let C = class C { +}; +C = __decorate([ + dec +], C); +var after; +const env_1 = { stack: [], error: void 0, hasError: false }; +try { + after = __addDisposableResource(env_1, null, false); +} +catch (e_1) { + env_1.error = e_1; + env_1.hasError = true; +} +finally { + __disposeResources(env_1); +} diff --git a/tests/baselines/reference/usingDeclarationsWithLegacyClassDecorators.7(module=commonjs,target=es5).js b/tests/baselines/reference/usingDeclarationsWithLegacyClassDecorators.7(module=commonjs,target=es5).js new file mode 100644 index 0000000000000..96e605fb89d0e --- /dev/null +++ b/tests/baselines/reference/usingDeclarationsWithLegacyClassDecorators.7(module=commonjs,target=es5).js @@ -0,0 +1,37 @@ +//// [tests/cases/conformance/statements/VariableStatements/usingDeclarations/usingDeclarationsWithLegacyClassDecorators.7.ts] //// + +//// [usingDeclarationsWithLegacyClassDecorators.7.ts] +export {}; + +declare var dec: any; + +@dec +class C { +} + +using after = null; + + +//// [usingDeclarationsWithLegacyClassDecorators.7.js] +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +var C = /** @class */ (function () { + function C() { + } + C = __decorate([ + dec + ], C); + return C; +}()); +var after; +var env_1 = { stack: [], error: void 0, hasError: false }; +try { + after = __addDisposableResource(env_1, null, false); +} +catch (e_1) { + env_1.error = e_1; + env_1.hasError = true; +} +finally { + __disposeResources(env_1); +} diff --git a/tests/baselines/reference/usingDeclarationsWithLegacyClassDecorators.7(module=commonjs,target=esnext).js b/tests/baselines/reference/usingDeclarationsWithLegacyClassDecorators.7(module=commonjs,target=esnext).js new file mode 100644 index 0000000000000..1acfe3baf31b3 --- /dev/null +++ b/tests/baselines/reference/usingDeclarationsWithLegacyClassDecorators.7(module=commonjs,target=esnext).js @@ -0,0 +1,23 @@ +//// [tests/cases/conformance/statements/VariableStatements/usingDeclarations/usingDeclarationsWithLegacyClassDecorators.7.ts] //// + +//// [usingDeclarationsWithLegacyClassDecorators.7.ts] +export {}; + +declare var dec: any; + +@dec +class C { +} + +using after = null; + + +//// [usingDeclarationsWithLegacyClassDecorators.7.js] +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +let C = class C { +}; +C = __decorate([ + dec +], C); +using after = null; diff --git a/tests/baselines/reference/usingDeclarationsWithLegacyClassDecorators.7(module=esnext,target=es2015).js b/tests/baselines/reference/usingDeclarationsWithLegacyClassDecorators.7(module=esnext,target=es2015).js new file mode 100644 index 0000000000000..9b8ec66516f8e --- /dev/null +++ b/tests/baselines/reference/usingDeclarationsWithLegacyClassDecorators.7(module=esnext,target=es2015).js @@ -0,0 +1,33 @@ +//// [tests/cases/conformance/statements/VariableStatements/usingDeclarations/usingDeclarationsWithLegacyClassDecorators.7.ts] //// + +//// [usingDeclarationsWithLegacyClassDecorators.7.ts] +export {}; + +declare var dec: any; + +@dec +class C { +} + +using after = null; + + +//// [usingDeclarationsWithLegacyClassDecorators.7.js] +let C = class C { +}; +C = __decorate([ + dec +], C); +var after; +const env_1 = { stack: [], error: void 0, hasError: false }; +try { + after = __addDisposableResource(env_1, null, false); +} +catch (e_1) { + env_1.error = e_1; + env_1.hasError = true; +} +finally { + __disposeResources(env_1); +} +export {}; diff --git a/tests/baselines/reference/usingDeclarationsWithLegacyClassDecorators.7(module=esnext,target=es5).js b/tests/baselines/reference/usingDeclarationsWithLegacyClassDecorators.7(module=esnext,target=es5).js new file mode 100644 index 0000000000000..4578e2373c062 --- /dev/null +++ b/tests/baselines/reference/usingDeclarationsWithLegacyClassDecorators.7(module=esnext,target=es5).js @@ -0,0 +1,36 @@ +//// [tests/cases/conformance/statements/VariableStatements/usingDeclarations/usingDeclarationsWithLegacyClassDecorators.7.ts] //// + +//// [usingDeclarationsWithLegacyClassDecorators.7.ts] +export {}; + +declare var dec: any; + +@dec +class C { +} + +using after = null; + + +//// [usingDeclarationsWithLegacyClassDecorators.7.js] +var C = /** @class */ (function () { + function C() { + } + C = __decorate([ + dec + ], C); + return C; +}()); +var after; +var env_1 = { stack: [], error: void 0, hasError: false }; +try { + after = __addDisposableResource(env_1, null, false); +} +catch (e_1) { + env_1.error = e_1; + env_1.hasError = true; +} +finally { + __disposeResources(env_1); +} +export {}; diff --git a/tests/baselines/reference/usingDeclarationsWithLegacyClassDecorators.7(module=esnext,target=esnext).js b/tests/baselines/reference/usingDeclarationsWithLegacyClassDecorators.7(module=esnext,target=esnext).js new file mode 100644 index 0000000000000..0456f1ea706c0 --- /dev/null +++ b/tests/baselines/reference/usingDeclarationsWithLegacyClassDecorators.7(module=esnext,target=esnext).js @@ -0,0 +1,22 @@ +//// [tests/cases/conformance/statements/VariableStatements/usingDeclarations/usingDeclarationsWithLegacyClassDecorators.7.ts] //// + +//// [usingDeclarationsWithLegacyClassDecorators.7.ts] +export {}; + +declare var dec: any; + +@dec +class C { +} + +using after = null; + + +//// [usingDeclarationsWithLegacyClassDecorators.7.js] +let C = class C { +}; +C = __decorate([ + dec +], C); +using after = null; +export {}; diff --git a/tests/baselines/reference/usingDeclarationsWithLegacyClassDecorators.7(module=system,target=es2015).js b/tests/baselines/reference/usingDeclarationsWithLegacyClassDecorators.7(module=system,target=es2015).js new file mode 100644 index 0000000000000..7e32ca24eb2d9 --- /dev/null +++ b/tests/baselines/reference/usingDeclarationsWithLegacyClassDecorators.7(module=system,target=es2015).js @@ -0,0 +1,41 @@ +//// [tests/cases/conformance/statements/VariableStatements/usingDeclarations/usingDeclarationsWithLegacyClassDecorators.7.ts] //// + +//// [usingDeclarationsWithLegacyClassDecorators.7.ts] +export {}; + +declare var dec: any; + +@dec +class C { +} + +using after = null; + + +//// [usingDeclarationsWithLegacyClassDecorators.7.js] +System.register([], function (exports_1, context_1) { + "use strict"; + var C, after, env_1; + var __moduleName = context_1 && context_1.id; + return { + setters: [], + execute: function () { + C = class C { + }; + C = __decorate([ + dec + ], C); + env_1 = { stack: [], error: void 0, hasError: false }; + try { + after = __addDisposableResource(env_1, null, false); + } + catch (e_1) { + env_1.error = e_1; + env_1.hasError = true; + } + finally { + __disposeResources(env_1); + } + } + }; +}); diff --git a/tests/baselines/reference/usingDeclarationsWithLegacyClassDecorators.7(module=system,target=es5).js b/tests/baselines/reference/usingDeclarationsWithLegacyClassDecorators.7(module=system,target=es5).js new file mode 100644 index 0000000000000..af832ee965587 --- /dev/null +++ b/tests/baselines/reference/usingDeclarationsWithLegacyClassDecorators.7(module=system,target=es5).js @@ -0,0 +1,44 @@ +//// [tests/cases/conformance/statements/VariableStatements/usingDeclarations/usingDeclarationsWithLegacyClassDecorators.7.ts] //// + +//// [usingDeclarationsWithLegacyClassDecorators.7.ts] +export {}; + +declare var dec: any; + +@dec +class C { +} + +using after = null; + + +//// [usingDeclarationsWithLegacyClassDecorators.7.js] +System.register([], function (exports_1, context_1) { + "use strict"; + var C, after, env_1; + var __moduleName = context_1 && context_1.id; + return { + setters: [], + execute: function () { + C = /** @class */ (function () { + function C() { + } + C = __decorate([ + dec + ], C); + return C; + }()); + env_1 = { stack: [], error: void 0, hasError: false }; + try { + after = __addDisposableResource(env_1, null, false); + } + catch (e_1) { + env_1.error = e_1; + env_1.hasError = true; + } + finally { + __disposeResources(env_1); + } + } + }; +}); diff --git a/tests/baselines/reference/usingDeclarationsWithLegacyClassDecorators.7(module=system,target=esnext).js b/tests/baselines/reference/usingDeclarationsWithLegacyClassDecorators.7(module=system,target=esnext).js new file mode 100644 index 0000000000000..7072d117365ed --- /dev/null +++ b/tests/baselines/reference/usingDeclarationsWithLegacyClassDecorators.7(module=system,target=esnext).js @@ -0,0 +1,31 @@ +//// [tests/cases/conformance/statements/VariableStatements/usingDeclarations/usingDeclarationsWithLegacyClassDecorators.7.ts] //// + +//// [usingDeclarationsWithLegacyClassDecorators.7.ts] +export {}; + +declare var dec: any; + +@dec +class C { +} + +using after = null; + + +//// [usingDeclarationsWithLegacyClassDecorators.7.js] +System.register([], function (exports_1, context_1) { + "use strict"; + var C, after; + var __moduleName = context_1 && context_1.id; + return { + setters: [], + execute: function () { + C = class C { + }; + C = __decorate([ + dec + ], C); + using after_1 = after = null; + } + }; +}); diff --git a/tests/baselines/reference/usingDeclarationsWithLegacyClassDecorators.8(module=commonjs,target=es2015).js b/tests/baselines/reference/usingDeclarationsWithLegacyClassDecorators.8(module=commonjs,target=es2015).js new file mode 100644 index 0000000000000..d3f6f053686b2 --- /dev/null +++ b/tests/baselines/reference/usingDeclarationsWithLegacyClassDecorators.8(module=commonjs,target=es2015).js @@ -0,0 +1,36 @@ +//// [tests/cases/conformance/statements/VariableStatements/usingDeclarations/usingDeclarationsWithLegacyClassDecorators.8.ts] //// + +//// [usingDeclarationsWithLegacyClassDecorators.8.ts] +export {}; + +declare var dec: any; + +@dec +export class C { +} + +using after = null; + + +//// [usingDeclarationsWithLegacyClassDecorators.8.js] +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.C = void 0; +let C = class C { +}; +exports.C = C; +exports.C = C = __decorate([ + dec +], C); +var after; +const env_1 = { stack: [], error: void 0, hasError: false }; +try { + after = __addDisposableResource(env_1, null, false); +} +catch (e_1) { + env_1.error = e_1; + env_1.hasError = true; +} +finally { + __disposeResources(env_1); +} diff --git a/tests/baselines/reference/usingDeclarationsWithLegacyClassDecorators.8(module=commonjs,target=es5).js b/tests/baselines/reference/usingDeclarationsWithLegacyClassDecorators.8(module=commonjs,target=es5).js new file mode 100644 index 0000000000000..b3083338b24c0 --- /dev/null +++ b/tests/baselines/reference/usingDeclarationsWithLegacyClassDecorators.8(module=commonjs,target=es5).js @@ -0,0 +1,39 @@ +//// [tests/cases/conformance/statements/VariableStatements/usingDeclarations/usingDeclarationsWithLegacyClassDecorators.8.ts] //// + +//// [usingDeclarationsWithLegacyClassDecorators.8.ts] +export {}; + +declare var dec: any; + +@dec +export class C { +} + +using after = null; + + +//// [usingDeclarationsWithLegacyClassDecorators.8.js] +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.C = void 0; +var C = /** @class */ (function () { + function C() { + } + C = __decorate([ + dec + ], C); + return C; +}()); +exports.C = C; +var after; +var env_1 = { stack: [], error: void 0, hasError: false }; +try { + after = __addDisposableResource(env_1, null, false); +} +catch (e_1) { + env_1.error = e_1; + env_1.hasError = true; +} +finally { + __disposeResources(env_1); +} diff --git a/tests/baselines/reference/usingDeclarationsWithLegacyClassDecorators.8(module=commonjs,target=esnext).js b/tests/baselines/reference/usingDeclarationsWithLegacyClassDecorators.8(module=commonjs,target=esnext).js new file mode 100644 index 0000000000000..516301c4c8ff8 --- /dev/null +++ b/tests/baselines/reference/usingDeclarationsWithLegacyClassDecorators.8(module=commonjs,target=esnext).js @@ -0,0 +1,25 @@ +//// [tests/cases/conformance/statements/VariableStatements/usingDeclarations/usingDeclarationsWithLegacyClassDecorators.8.ts] //// + +//// [usingDeclarationsWithLegacyClassDecorators.8.ts] +export {}; + +declare var dec: any; + +@dec +export class C { +} + +using after = null; + + +//// [usingDeclarationsWithLegacyClassDecorators.8.js] +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.C = void 0; +let C = class C { +}; +exports.C = C; +exports.C = C = __decorate([ + dec +], C); +using after = null; diff --git a/tests/baselines/reference/usingDeclarationsWithLegacyClassDecorators.8(module=esnext,target=es2015).js b/tests/baselines/reference/usingDeclarationsWithLegacyClassDecorators.8(module=esnext,target=es2015).js new file mode 100644 index 0000000000000..b87aac7bf4f42 --- /dev/null +++ b/tests/baselines/reference/usingDeclarationsWithLegacyClassDecorators.8(module=esnext,target=es2015).js @@ -0,0 +1,33 @@ +//// [tests/cases/conformance/statements/VariableStatements/usingDeclarations/usingDeclarationsWithLegacyClassDecorators.8.ts] //// + +//// [usingDeclarationsWithLegacyClassDecorators.8.ts] +export {}; + +declare var dec: any; + +@dec +export class C { +} + +using after = null; + + +//// [usingDeclarationsWithLegacyClassDecorators.8.js] +let C = class C { +}; +C = __decorate([ + dec +], C); +export { C }; +var after; +const env_1 = { stack: [], error: void 0, hasError: false }; +try { + after = __addDisposableResource(env_1, null, false); +} +catch (e_1) { + env_1.error = e_1; + env_1.hasError = true; +} +finally { + __disposeResources(env_1); +} diff --git a/tests/baselines/reference/usingDeclarationsWithLegacyClassDecorators.8(module=esnext,target=es5).js b/tests/baselines/reference/usingDeclarationsWithLegacyClassDecorators.8(module=esnext,target=es5).js new file mode 100644 index 0000000000000..ce5acfb5adc8b --- /dev/null +++ b/tests/baselines/reference/usingDeclarationsWithLegacyClassDecorators.8(module=esnext,target=es5).js @@ -0,0 +1,36 @@ +//// [tests/cases/conformance/statements/VariableStatements/usingDeclarations/usingDeclarationsWithLegacyClassDecorators.8.ts] //// + +//// [usingDeclarationsWithLegacyClassDecorators.8.ts] +export {}; + +declare var dec: any; + +@dec +export class C { +} + +using after = null; + + +//// [usingDeclarationsWithLegacyClassDecorators.8.js] +var C = /** @class */ (function () { + function C() { + } + C = __decorate([ + dec + ], C); + return C; +}()); +export { C }; +var after; +var env_1 = { stack: [], error: void 0, hasError: false }; +try { + after = __addDisposableResource(env_1, null, false); +} +catch (e_1) { + env_1.error = e_1; + env_1.hasError = true; +} +finally { + __disposeResources(env_1); +} diff --git a/tests/baselines/reference/usingDeclarationsWithLegacyClassDecorators.8(module=esnext,target=esnext).js b/tests/baselines/reference/usingDeclarationsWithLegacyClassDecorators.8(module=esnext,target=esnext).js new file mode 100644 index 0000000000000..aee33622d8b7f --- /dev/null +++ b/tests/baselines/reference/usingDeclarationsWithLegacyClassDecorators.8(module=esnext,target=esnext).js @@ -0,0 +1,22 @@ +//// [tests/cases/conformance/statements/VariableStatements/usingDeclarations/usingDeclarationsWithLegacyClassDecorators.8.ts] //// + +//// [usingDeclarationsWithLegacyClassDecorators.8.ts] +export {}; + +declare var dec: any; + +@dec +export class C { +} + +using after = null; + + +//// [usingDeclarationsWithLegacyClassDecorators.8.js] +let C = class C { +}; +C = __decorate([ + dec +], C); +export { C }; +using after = null; diff --git a/tests/baselines/reference/usingDeclarationsWithLegacyClassDecorators.8(module=system,target=es2015).js b/tests/baselines/reference/usingDeclarationsWithLegacyClassDecorators.8(module=system,target=es2015).js new file mode 100644 index 0000000000000..aa595d326bc71 --- /dev/null +++ b/tests/baselines/reference/usingDeclarationsWithLegacyClassDecorators.8(module=system,target=es2015).js @@ -0,0 +1,42 @@ +//// [tests/cases/conformance/statements/VariableStatements/usingDeclarations/usingDeclarationsWithLegacyClassDecorators.8.ts] //// + +//// [usingDeclarationsWithLegacyClassDecorators.8.ts] +export {}; + +declare var dec: any; + +@dec +export class C { +} + +using after = null; + + +//// [usingDeclarationsWithLegacyClassDecorators.8.js] +System.register([], function (exports_1, context_1) { + "use strict"; + var C, after, env_1; + var __moduleName = context_1 && context_1.id; + return { + setters: [], + execute: function () { + C = class C { + }; + exports_1("C", C); + exports_1("C", C = __decorate([ + dec + ], C)); + env_1 = { stack: [], error: void 0, hasError: false }; + try { + after = __addDisposableResource(env_1, null, false); + } + catch (e_1) { + env_1.error = e_1; + env_1.hasError = true; + } + finally { + __disposeResources(env_1); + } + } + }; +}); diff --git a/tests/baselines/reference/usingDeclarationsWithLegacyClassDecorators.8(module=system,target=es5).js b/tests/baselines/reference/usingDeclarationsWithLegacyClassDecorators.8(module=system,target=es5).js new file mode 100644 index 0000000000000..117049660d22a --- /dev/null +++ b/tests/baselines/reference/usingDeclarationsWithLegacyClassDecorators.8(module=system,target=es5).js @@ -0,0 +1,45 @@ +//// [tests/cases/conformance/statements/VariableStatements/usingDeclarations/usingDeclarationsWithLegacyClassDecorators.8.ts] //// + +//// [usingDeclarationsWithLegacyClassDecorators.8.ts] +export {}; + +declare var dec: any; + +@dec +export class C { +} + +using after = null; + + +//// [usingDeclarationsWithLegacyClassDecorators.8.js] +System.register([], function (exports_1, context_1) { + "use strict"; + var C, after, env_1; + var __moduleName = context_1 && context_1.id; + return { + setters: [], + execute: function () { + C = /** @class */ (function () { + function C() { + } + C = __decorate([ + dec + ], C); + return C; + }()); + exports_1("C", C); + env_1 = { stack: [], error: void 0, hasError: false }; + try { + after = __addDisposableResource(env_1, null, false); + } + catch (e_1) { + env_1.error = e_1; + env_1.hasError = true; + } + finally { + __disposeResources(env_1); + } + } + }; +}); diff --git a/tests/baselines/reference/usingDeclarationsWithLegacyClassDecorators.8(module=system,target=esnext).js b/tests/baselines/reference/usingDeclarationsWithLegacyClassDecorators.8(module=system,target=esnext).js new file mode 100644 index 0000000000000..a015e9020dd14 --- /dev/null +++ b/tests/baselines/reference/usingDeclarationsWithLegacyClassDecorators.8(module=system,target=esnext).js @@ -0,0 +1,32 @@ +//// [tests/cases/conformance/statements/VariableStatements/usingDeclarations/usingDeclarationsWithLegacyClassDecorators.8.ts] //// + +//// [usingDeclarationsWithLegacyClassDecorators.8.ts] +export {}; + +declare var dec: any; + +@dec +export class C { +} + +using after = null; + + +//// [usingDeclarationsWithLegacyClassDecorators.8.js] +System.register([], function (exports_1, context_1) { + "use strict"; + var C, after; + var __moduleName = context_1 && context_1.id; + return { + setters: [], + execute: function () { + C = class C { + }; + exports_1("C", C); + exports_1("C", C = __decorate([ + dec + ], C)); + using after_1 = after = null; + } + }; +}); diff --git a/tests/baselines/reference/usingDeclarationsWithLegacyClassDecorators.9(module=commonjs,target=es2015).js b/tests/baselines/reference/usingDeclarationsWithLegacyClassDecorators.9(module=commonjs,target=es2015).js new file mode 100644 index 0000000000000..80064a1921b7b --- /dev/null +++ b/tests/baselines/reference/usingDeclarationsWithLegacyClassDecorators.9(module=commonjs,target=es2015).js @@ -0,0 +1,35 @@ +//// [tests/cases/conformance/statements/VariableStatements/usingDeclarations/usingDeclarationsWithLegacyClassDecorators.9.ts] //// + +//// [usingDeclarationsWithLegacyClassDecorators.9.ts] +export {}; + +declare var dec: any; + +@dec +export default class C { +} + +using after = null; + + +//// [usingDeclarationsWithLegacyClassDecorators.9.js] +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +let C = class C { +}; +C = __decorate([ + dec +], C); +exports.default = C; +var after; +const env_1 = { stack: [], error: void 0, hasError: false }; +try { + after = __addDisposableResource(env_1, null, false); +} +catch (e_1) { + env_1.error = e_1; + env_1.hasError = true; +} +finally { + __disposeResources(env_1); +} diff --git a/tests/baselines/reference/usingDeclarationsWithLegacyClassDecorators.9(module=commonjs,target=es5).js b/tests/baselines/reference/usingDeclarationsWithLegacyClassDecorators.9(module=commonjs,target=es5).js new file mode 100644 index 0000000000000..742f3a153c7f6 --- /dev/null +++ b/tests/baselines/reference/usingDeclarationsWithLegacyClassDecorators.9(module=commonjs,target=es5).js @@ -0,0 +1,38 @@ +//// [tests/cases/conformance/statements/VariableStatements/usingDeclarations/usingDeclarationsWithLegacyClassDecorators.9.ts] //// + +//// [usingDeclarationsWithLegacyClassDecorators.9.ts] +export {}; + +declare var dec: any; + +@dec +export default class C { +} + +using after = null; + + +//// [usingDeclarationsWithLegacyClassDecorators.9.js] +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +var C = /** @class */ (function () { + function C() { + } + C = __decorate([ + dec + ], C); + return C; +}()); +exports.default = C; +var after; +var env_1 = { stack: [], error: void 0, hasError: false }; +try { + after = __addDisposableResource(env_1, null, false); +} +catch (e_1) { + env_1.error = e_1; + env_1.hasError = true; +} +finally { + __disposeResources(env_1); +} diff --git a/tests/baselines/reference/usingDeclarationsWithLegacyClassDecorators.9(module=commonjs,target=esnext).js b/tests/baselines/reference/usingDeclarationsWithLegacyClassDecorators.9(module=commonjs,target=esnext).js new file mode 100644 index 0000000000000..17855fd9c7444 --- /dev/null +++ b/tests/baselines/reference/usingDeclarationsWithLegacyClassDecorators.9(module=commonjs,target=esnext).js @@ -0,0 +1,24 @@ +//// [tests/cases/conformance/statements/VariableStatements/usingDeclarations/usingDeclarationsWithLegacyClassDecorators.9.ts] //// + +//// [usingDeclarationsWithLegacyClassDecorators.9.ts] +export {}; + +declare var dec: any; + +@dec +export default class C { +} + +using after = null; + + +//// [usingDeclarationsWithLegacyClassDecorators.9.js] +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +let C = class C { +}; +C = __decorate([ + dec +], C); +exports.default = C; +using after = null; diff --git a/tests/baselines/reference/usingDeclarationsWithLegacyClassDecorators.9(module=esnext,target=es2015).js b/tests/baselines/reference/usingDeclarationsWithLegacyClassDecorators.9(module=esnext,target=es2015).js new file mode 100644 index 0000000000000..aa0f6687345e9 --- /dev/null +++ b/tests/baselines/reference/usingDeclarationsWithLegacyClassDecorators.9(module=esnext,target=es2015).js @@ -0,0 +1,33 @@ +//// [tests/cases/conformance/statements/VariableStatements/usingDeclarations/usingDeclarationsWithLegacyClassDecorators.9.ts] //// + +//// [usingDeclarationsWithLegacyClassDecorators.9.ts] +export {}; + +declare var dec: any; + +@dec +export default class C { +} + +using after = null; + + +//// [usingDeclarationsWithLegacyClassDecorators.9.js] +let C = class C { +}; +C = __decorate([ + dec +], C); +export default C; +var after; +const env_1 = { stack: [], error: void 0, hasError: false }; +try { + after = __addDisposableResource(env_1, null, false); +} +catch (e_1) { + env_1.error = e_1; + env_1.hasError = true; +} +finally { + __disposeResources(env_1); +} diff --git a/tests/baselines/reference/usingDeclarationsWithLegacyClassDecorators.9(module=esnext,target=es5).js b/tests/baselines/reference/usingDeclarationsWithLegacyClassDecorators.9(module=esnext,target=es5).js new file mode 100644 index 0000000000000..32a30f161ebe2 --- /dev/null +++ b/tests/baselines/reference/usingDeclarationsWithLegacyClassDecorators.9(module=esnext,target=es5).js @@ -0,0 +1,36 @@ +//// [tests/cases/conformance/statements/VariableStatements/usingDeclarations/usingDeclarationsWithLegacyClassDecorators.9.ts] //// + +//// [usingDeclarationsWithLegacyClassDecorators.9.ts] +export {}; + +declare var dec: any; + +@dec +export default class C { +} + +using after = null; + + +//// [usingDeclarationsWithLegacyClassDecorators.9.js] +var C = /** @class */ (function () { + function C() { + } + C = __decorate([ + dec + ], C); + return C; +}()); +export default C; +var after; +var env_1 = { stack: [], error: void 0, hasError: false }; +try { + after = __addDisposableResource(env_1, null, false); +} +catch (e_1) { + env_1.error = e_1; + env_1.hasError = true; +} +finally { + __disposeResources(env_1); +} diff --git a/tests/baselines/reference/usingDeclarationsWithLegacyClassDecorators.9(module=esnext,target=esnext).js b/tests/baselines/reference/usingDeclarationsWithLegacyClassDecorators.9(module=esnext,target=esnext).js new file mode 100644 index 0000000000000..53806f180d9eb --- /dev/null +++ b/tests/baselines/reference/usingDeclarationsWithLegacyClassDecorators.9(module=esnext,target=esnext).js @@ -0,0 +1,22 @@ +//// [tests/cases/conformance/statements/VariableStatements/usingDeclarations/usingDeclarationsWithLegacyClassDecorators.9.ts] //// + +//// [usingDeclarationsWithLegacyClassDecorators.9.ts] +export {}; + +declare var dec: any; + +@dec +export default class C { +} + +using after = null; + + +//// [usingDeclarationsWithLegacyClassDecorators.9.js] +let C = class C { +}; +C = __decorate([ + dec +], C); +export default C; +using after = null; diff --git a/tests/baselines/reference/usingDeclarationsWithLegacyClassDecorators.9(module=system,target=es2015).js b/tests/baselines/reference/usingDeclarationsWithLegacyClassDecorators.9(module=system,target=es2015).js new file mode 100644 index 0000000000000..bcac7ec03c1d1 --- /dev/null +++ b/tests/baselines/reference/usingDeclarationsWithLegacyClassDecorators.9(module=system,target=es2015).js @@ -0,0 +1,42 @@ +//// [tests/cases/conformance/statements/VariableStatements/usingDeclarations/usingDeclarationsWithLegacyClassDecorators.9.ts] //// + +//// [usingDeclarationsWithLegacyClassDecorators.9.ts] +export {}; + +declare var dec: any; + +@dec +export default class C { +} + +using after = null; + + +//// [usingDeclarationsWithLegacyClassDecorators.9.js] +System.register([], function (exports_1, context_1) { + "use strict"; + var C, after, env_1; + var __moduleName = context_1 && context_1.id; + return { + setters: [], + execute: function () { + C = class C { + }; + C = __decorate([ + dec + ], C); + exports_1("default", C); + env_1 = { stack: [], error: void 0, hasError: false }; + try { + after = __addDisposableResource(env_1, null, false); + } + catch (e_1) { + env_1.error = e_1; + env_1.hasError = true; + } + finally { + __disposeResources(env_1); + } + } + }; +}); diff --git a/tests/baselines/reference/usingDeclarationsWithLegacyClassDecorators.9(module=system,target=es5).js b/tests/baselines/reference/usingDeclarationsWithLegacyClassDecorators.9(module=system,target=es5).js new file mode 100644 index 0000000000000..e283f12e5e6b0 --- /dev/null +++ b/tests/baselines/reference/usingDeclarationsWithLegacyClassDecorators.9(module=system,target=es5).js @@ -0,0 +1,45 @@ +//// [tests/cases/conformance/statements/VariableStatements/usingDeclarations/usingDeclarationsWithLegacyClassDecorators.9.ts] //// + +//// [usingDeclarationsWithLegacyClassDecorators.9.ts] +export {}; + +declare var dec: any; + +@dec +export default class C { +} + +using after = null; + + +//// [usingDeclarationsWithLegacyClassDecorators.9.js] +System.register([], function (exports_1, context_1) { + "use strict"; + var C, after, env_1; + var __moduleName = context_1 && context_1.id; + return { + setters: [], + execute: function () { + C = /** @class */ (function () { + function C() { + } + C = __decorate([ + dec + ], C); + return C; + }()); + exports_1("default", C); + env_1 = { stack: [], error: void 0, hasError: false }; + try { + after = __addDisposableResource(env_1, null, false); + } + catch (e_1) { + env_1.error = e_1; + env_1.hasError = true; + } + finally { + __disposeResources(env_1); + } + } + }; +}); diff --git a/tests/baselines/reference/usingDeclarationsWithLegacyClassDecorators.9(module=system,target=esnext).js b/tests/baselines/reference/usingDeclarationsWithLegacyClassDecorators.9(module=system,target=esnext).js new file mode 100644 index 0000000000000..4529090ab9985 --- /dev/null +++ b/tests/baselines/reference/usingDeclarationsWithLegacyClassDecorators.9(module=system,target=esnext).js @@ -0,0 +1,32 @@ +//// [tests/cases/conformance/statements/VariableStatements/usingDeclarations/usingDeclarationsWithLegacyClassDecorators.9.ts] //// + +//// [usingDeclarationsWithLegacyClassDecorators.9.ts] +export {}; + +declare var dec: any; + +@dec +export default class C { +} + +using after = null; + + +//// [usingDeclarationsWithLegacyClassDecorators.9.js] +System.register([], function (exports_1, context_1) { + "use strict"; + var C, after; + var __moduleName = context_1 && context_1.id; + return { + setters: [], + execute: function () { + C = class C { + }; + C = __decorate([ + dec + ], C); + exports_1("default", C); + using after_1 = after = null; + } + }; +}); diff --git a/tests/cases/conformance/es6/for-ofStatements/for-of-excess-declarations.ts b/tests/cases/conformance/es6/for-ofStatements/for-of-excess-declarations.ts new file mode 100644 index 0000000000000..df9b63475d96b --- /dev/null +++ b/tests/cases/conformance/es6/for-ofStatements/for-of-excess-declarations.ts @@ -0,0 +1,4 @@ +// @target: esnext +for (const a, { [b]: c} of [1]) { + +} \ No newline at end of file diff --git a/tests/cases/conformance/statements/VariableStatements/usingDeclarations/awaitUsingDeclarations.1.ts b/tests/cases/conformance/statements/VariableStatements/usingDeclarations/awaitUsingDeclarations.1.ts new file mode 100644 index 0000000000000..7f7f86bd4410f --- /dev/null +++ b/tests/cases/conformance/statements/VariableStatements/usingDeclarations/awaitUsingDeclarations.1.ts @@ -0,0 +1,102 @@ +// @target: esnext,es2022,es2017,es2015,es5 +// @module: esnext +// @lib: esnext +// @noTypesAndSymbols: true + +await using d1 = { async [Symbol.asyncDispose]() {} }; + +async function af() { + await using d3 = { async [Symbol.asyncDispose]() {} }; + await null; +} + +async function * ag() { + await using d5 = { async [Symbol.asyncDispose]() {} }; + yield; + await null; +} + +const a = async () => { + await using d6 = { async [Symbol.asyncDispose]() {} }; +}; + +class C1 { + a = async () => { + await using d7 = { async [Symbol.asyncDispose]() {} }; + }; + + async am() { + await using d13 = { async [Symbol.asyncDispose]() {} }; + await null; + } + + async * ag() { + await using d15 = { async [Symbol.asyncDispose]() {} }; + yield; + await null; + } +} + +{ + await using d19 = { async [Symbol.asyncDispose]() {} }; +} + +switch (Math.random()) { + case 0: + await using d20 = { async [Symbol.asyncDispose]() {} }; + break; + + case 1: + await using d21 = { async [Symbol.asyncDispose]() {} }; + break; +} + +if (true) + switch (0) { + case 0: + await using d22 = { async [Symbol.asyncDispose]() {} }; + break; + } + +try { + await using d23 = { async [Symbol.asyncDispose]() {} }; +} +catch { + await using d24 = { async [Symbol.asyncDispose]() {} }; +} +finally { + await using d25 = { async [Symbol.asyncDispose]() {} }; +} + +if (true) { + await using d26 = { async [Symbol.asyncDispose]() {} }; +} +else { + await using d27 = { async [Symbol.asyncDispose]() {} }; +} + +while (true) { + await using d28 = { async [Symbol.asyncDispose]() {} }; + break; +} + +do { + await using d29 = { async [Symbol.asyncDispose]() {} }; + break; +} +while (true); + +for (;;) { + await using d30 = { async [Symbol.asyncDispose]() {} }; + break; +} + +for (const x in {}) { + await using d31 = { async [Symbol.asyncDispose]() {} }; +} + +for (const x of []) { + await using d32 = { async [Symbol.asyncDispose]() {} }; +} + +export {}; \ No newline at end of file diff --git a/tests/cases/conformance/statements/VariableStatements/usingDeclarations/awaitUsingDeclarations.10.ts b/tests/cases/conformance/statements/VariableStatements/usingDeclarations/awaitUsingDeclarations.10.ts new file mode 100644 index 0000000000000..1f132c396407c --- /dev/null +++ b/tests/cases/conformance/statements/VariableStatements/usingDeclarations/awaitUsingDeclarations.10.ts @@ -0,0 +1,11 @@ +// @target: esnext +// @module: esnext +// @lib: esnext +// @noTypesAndSymbols: true + +export {}; + +declare var x: any; +async function f() { + if (x) await using a = null; +} \ No newline at end of file diff --git a/tests/cases/conformance/statements/VariableStatements/usingDeclarations/awaitUsingDeclarations.11.ts b/tests/cases/conformance/statements/VariableStatements/usingDeclarations/awaitUsingDeclarations.11.ts new file mode 100644 index 0000000000000..d22e7abcc7086 --- /dev/null +++ b/tests/cases/conformance/statements/VariableStatements/usingDeclarations/awaitUsingDeclarations.11.ts @@ -0,0 +1,7 @@ +// @target: esnext +// @module: esnext +// @lib: esnext +// @noTypesAndSymbols: true + +export await using x = null; +declare await using y: null; diff --git a/tests/cases/conformance/statements/VariableStatements/usingDeclarations/awaitUsingDeclarations.12.ts b/tests/cases/conformance/statements/VariableStatements/usingDeclarations/awaitUsingDeclarations.12.ts new file mode 100644 index 0000000000000..6013970105c30 --- /dev/null +++ b/tests/cases/conformance/statements/VariableStatements/usingDeclarations/awaitUsingDeclarations.12.ts @@ -0,0 +1,8 @@ +// @target: esnext +// @module: esnext +// @lib: esnext +// @noTypesAndSymbols: true + +async function f() { + await using x = {}; +} \ No newline at end of file diff --git a/tests/cases/conformance/statements/VariableStatements/usingDeclarations/awaitUsingDeclarations.13.ts b/tests/cases/conformance/statements/VariableStatements/usingDeclarations/awaitUsingDeclarations.13.ts new file mode 100644 index 0000000000000..c1a88f304148d --- /dev/null +++ b/tests/cases/conformance/statements/VariableStatements/usingDeclarations/awaitUsingDeclarations.13.ts @@ -0,0 +1,10 @@ +// @target: esnext +// @module: esnext +// @lib: esnext +// @noTypesAndSymbols: true + +await using x = null; + +function f() { + await using x = null; +} \ No newline at end of file diff --git a/tests/cases/conformance/statements/VariableStatements/usingDeclarations/awaitUsingDeclarations.14.ts b/tests/cases/conformance/statements/VariableStatements/usingDeclarations/awaitUsingDeclarations.14.ts new file mode 100644 index 0000000000000..9a32c0614ee45 --- /dev/null +++ b/tests/cases/conformance/statements/VariableStatements/usingDeclarations/awaitUsingDeclarations.14.ts @@ -0,0 +1,13 @@ +// @target: esnext +// @module: esnext +// @lib: esnext +// @noTypesAndSymbols: true + +class C { + static { + await using x = null; + { + await using y = null; + } + } +} diff --git a/tests/cases/conformance/statements/VariableStatements/usingDeclarations/awaitUsingDeclarations.15.ts b/tests/cases/conformance/statements/VariableStatements/usingDeclarations/awaitUsingDeclarations.15.ts new file mode 100644 index 0000000000000..f92136565435d --- /dev/null +++ b/tests/cases/conformance/statements/VariableStatements/usingDeclarations/awaitUsingDeclarations.15.ts @@ -0,0 +1,9 @@ +// @target: esnext +// @module: esnext +// @lib: esnext +// @noTypesAndSymbols: true +// @noUnusedLocals: true + +async function f() { + await using _ = { async [Symbol.asyncDispose]() {} }; +} \ No newline at end of file diff --git a/tests/cases/conformance/statements/VariableStatements/usingDeclarations/awaitUsingDeclarations.2.ts b/tests/cases/conformance/statements/VariableStatements/usingDeclarations/awaitUsingDeclarations.2.ts new file mode 100644 index 0000000000000..b93a8648308cf --- /dev/null +++ b/tests/cases/conformance/statements/VariableStatements/usingDeclarations/awaitUsingDeclarations.2.ts @@ -0,0 +1,11 @@ +// @target: esnext,es2022,es2017,es2015,es5 +// @module: esnext +// @lib: esnext +// @noTypesAndSymbols: true + +{ + await using d1 = { async [Symbol.asyncDispose]() {} }, + d2 = { async [Symbol.asyncDispose]() {} }; +} + +export {}; \ No newline at end of file diff --git a/tests/cases/conformance/statements/VariableStatements/usingDeclarations/awaitUsingDeclarations.3.ts b/tests/cases/conformance/statements/VariableStatements/usingDeclarations/awaitUsingDeclarations.3.ts new file mode 100644 index 0000000000000..cf1eee443b6bc --- /dev/null +++ b/tests/cases/conformance/statements/VariableStatements/usingDeclarations/awaitUsingDeclarations.3.ts @@ -0,0 +1,13 @@ +// @target: esnext,es2022,es2017,es2015,es5 +// @module: esnext +// @lib: esnext +// @noTypesAndSymbols: true + +{ + await using d1 = { async [Symbol.asyncDispose]() {} }, + d2 = null, + d3 = undefined, + d4 = { [Symbol.dispose]() {} }; +} + +export {}; \ No newline at end of file diff --git a/tests/cases/conformance/statements/VariableStatements/usingDeclarations/awaitUsingDeclarations.4.ts b/tests/cases/conformance/statements/VariableStatements/usingDeclarations/awaitUsingDeclarations.4.ts new file mode 100644 index 0000000000000..251cba55fe695 --- /dev/null +++ b/tests/cases/conformance/statements/VariableStatements/usingDeclarations/awaitUsingDeclarations.4.ts @@ -0,0 +1,10 @@ +// @target: esnext +// @module: esnext +// @lib: esnext +// @noTypesAndSymbols: true + +{ + await using [a] = null; +} + +export {}; \ No newline at end of file diff --git a/tests/cases/conformance/statements/VariableStatements/usingDeclarations/awaitUsingDeclarations.5.ts b/tests/cases/conformance/statements/VariableStatements/usingDeclarations/awaitUsingDeclarations.5.ts new file mode 100644 index 0000000000000..b172bdab826f5 --- /dev/null +++ b/tests/cases/conformance/statements/VariableStatements/usingDeclarations/awaitUsingDeclarations.5.ts @@ -0,0 +1,12 @@ +// @target: esnext +// @module: esnext +// @lib: esnext +// @noTypesAndSymbols: true + +{ + await using a = null, + [b] = null, + c = null; +} + +export {}; \ No newline at end of file diff --git a/tests/cases/conformance/statements/VariableStatements/usingDeclarations/awaitUsingDeclarations.6.ts b/tests/cases/conformance/statements/VariableStatements/usingDeclarations/awaitUsingDeclarations.6.ts new file mode 100644 index 0000000000000..9a5d109f2235d --- /dev/null +++ b/tests/cases/conformance/statements/VariableStatements/usingDeclarations/awaitUsingDeclarations.6.ts @@ -0,0 +1,11 @@ +// @target: esnext +// @module: esnext +// @lib: esnext +// @noTypesAndSymbols: true + +{ + await using {a} = null; +} + + +export {}; \ No newline at end of file diff --git a/tests/cases/conformance/statements/VariableStatements/usingDeclarations/awaitUsingDeclarations.7.ts b/tests/cases/conformance/statements/VariableStatements/usingDeclarations/awaitUsingDeclarations.7.ts new file mode 100644 index 0000000000000..f246cd1aaab41 --- /dev/null +++ b/tests/cases/conformance/statements/VariableStatements/usingDeclarations/awaitUsingDeclarations.7.ts @@ -0,0 +1,10 @@ +// @target: esnext +// @module: esnext +// @lib: esnext +// @noTypesAndSymbols: true + +{ + await using a = null, + {b} = null, + c = null; +} \ No newline at end of file diff --git a/tests/cases/conformance/statements/VariableStatements/usingDeclarations/awaitUsingDeclarations.8.ts b/tests/cases/conformance/statements/VariableStatements/usingDeclarations/awaitUsingDeclarations.8.ts new file mode 100644 index 0000000000000..1dfa88ce88b6f --- /dev/null +++ b/tests/cases/conformance/statements/VariableStatements/usingDeclarations/awaitUsingDeclarations.8.ts @@ -0,0 +1,10 @@ +// @target: esnext +// @module: esnext +// @lib: esnext +// @noTypesAndSymbols: true + +{ + await using a; +} + +export {}; \ No newline at end of file diff --git a/tests/cases/conformance/statements/VariableStatements/usingDeclarations/awaitUsingDeclarations.9.ts b/tests/cases/conformance/statements/VariableStatements/usingDeclarations/awaitUsingDeclarations.9.ts new file mode 100644 index 0000000000000..b9fba2635669e --- /dev/null +++ b/tests/cases/conformance/statements/VariableStatements/usingDeclarations/awaitUsingDeclarations.9.ts @@ -0,0 +1,10 @@ +// @target: esnext +// @module: esnext +// @lib: es2022 +// @noTypesAndSymbols: true + +{ + await using a = null; +} + +export {}; \ No newline at end of file diff --git a/tests/cases/conformance/statements/VariableStatements/usingDeclarations/awaitUsingDeclarationsInFor.ts b/tests/cases/conformance/statements/VariableStatements/usingDeclarations/awaitUsingDeclarationsInFor.ts new file mode 100644 index 0000000000000..0f075d4a752b8 --- /dev/null +++ b/tests/cases/conformance/statements/VariableStatements/usingDeclarations/awaitUsingDeclarationsInFor.ts @@ -0,0 +1,11 @@ +// @target: esnext,es2022,es2017,es2015,es5 +// @module: esnext +// @lib: esnext +// @noTypesAndSymbols: true +async function main() { + for (await using d1 = { [Symbol.dispose]() {} }, + d2 = { async [Symbol.asyncDispose]() {} }, + d3 = null, + d4 = undefined;;) { + } +} \ No newline at end of file diff --git a/tests/cases/conformance/statements/VariableStatements/usingDeclarations/awaitUsingDeclarationsInForAwaitOf.ts b/tests/cases/conformance/statements/VariableStatements/usingDeclarations/awaitUsingDeclarationsInForAwaitOf.ts new file mode 100644 index 0000000000000..8f488313a91d9 --- /dev/null +++ b/tests/cases/conformance/statements/VariableStatements/usingDeclarations/awaitUsingDeclarationsInForAwaitOf.ts @@ -0,0 +1,8 @@ +// @target: esnext,es2022,es2017,es2015,es5 +// @module: esnext +// @lib: esnext +// @noTypesAndSymbols: true +async function main() { + for await (await using d1 of [{ async [Symbol.asyncDispose]() {} }, { [Symbol.dispose]() {} }, null, undefined]) { + } +} \ No newline at end of file diff --git a/tests/cases/conformance/statements/VariableStatements/usingDeclarations/awaitUsingDeclarationsInForIn.ts b/tests/cases/conformance/statements/VariableStatements/usingDeclarations/awaitUsingDeclarationsInForIn.ts new file mode 100644 index 0000000000000..12621f830853e --- /dev/null +++ b/tests/cases/conformance/statements/VariableStatements/usingDeclarations/awaitUsingDeclarationsInForIn.ts @@ -0,0 +1,9 @@ +// @target: esnext +// @module: esnext +// @lib: esnext +// @noTypesAndSymbols: true + +async function main() { + for (await using x in {}) { + } +} diff --git a/tests/cases/conformance/statements/VariableStatements/usingDeclarations/awaitUsingDeclarationsInForOf.1.ts b/tests/cases/conformance/statements/VariableStatements/usingDeclarations/awaitUsingDeclarationsInForOf.1.ts new file mode 100644 index 0000000000000..cd26c931d2acd --- /dev/null +++ b/tests/cases/conformance/statements/VariableStatements/usingDeclarations/awaitUsingDeclarationsInForOf.1.ts @@ -0,0 +1,9 @@ +// @target: esnext,es2022,es2017,es2015,es5 +// @module: esnext +// @lib: esnext +// @noTypesAndSymbols: true + +async function main() { + for (await using d1 of [{ async [Symbol.asyncDispose]() {} }, { [Symbol.dispose]() {} }, null, undefined]) { + } +} diff --git a/tests/cases/conformance/statements/VariableStatements/usingDeclarations/awaitUsingDeclarationsInForOf.2.ts b/tests/cases/conformance/statements/VariableStatements/usingDeclarations/awaitUsingDeclarationsInForOf.2.ts new file mode 100644 index 0000000000000..4d6ac155a9c46 --- /dev/null +++ b/tests/cases/conformance/statements/VariableStatements/usingDeclarations/awaitUsingDeclarationsInForOf.2.ts @@ -0,0 +1,9 @@ +// @target: esnext +// @module: esnext +// @lib: esnext +// @noTypesAndSymbols: true + +async function main() { + for (await using of of []) { + } +} diff --git a/tests/cases/conformance/statements/VariableStatements/usingDeclarations/awaitUsingDeclarationsInForOf.3.ts b/tests/cases/conformance/statements/VariableStatements/usingDeclarations/awaitUsingDeclarationsInForOf.3.ts new file mode 100644 index 0000000000000..e686baa1120c7 --- /dev/null +++ b/tests/cases/conformance/statements/VariableStatements/usingDeclarations/awaitUsingDeclarationsInForOf.3.ts @@ -0,0 +1,9 @@ +// @target: esnext +// @module: esnext +// @lib: esnext +// @noTypesAndSymbols: true + +async function main() { + for (await using {} of []) { + } +} diff --git a/tests/cases/conformance/statements/VariableStatements/usingDeclarations/awaitUsingDeclarationsTopLevelOfModule.1.ts b/tests/cases/conformance/statements/VariableStatements/usingDeclarations/awaitUsingDeclarationsTopLevelOfModule.1.ts new file mode 100644 index 0000000000000..4daedf413bb4c --- /dev/null +++ b/tests/cases/conformance/statements/VariableStatements/usingDeclarations/awaitUsingDeclarationsTopLevelOfModule.1.ts @@ -0,0 +1,18 @@ +// @target: es2022 +// @lib: esnext,dom +// @module: system,esnext +// @noTypesAndSymbols: true +// @noEmitHelpers: true + +export const x = 1; +export { y }; + +await using z = { async [Symbol.asyncDispose]() {} }; + +const y = 2; + +export const w = 3; + +export default 4; + +console.log(w, x, y, z); diff --git a/tests/cases/conformance/statements/VariableStatements/usingDeclarations/awaitUsingDeclarationsWithImportHelpers.ts b/tests/cases/conformance/statements/VariableStatements/usingDeclarations/awaitUsingDeclarationsWithImportHelpers.ts new file mode 100644 index 0000000000000..28fbc0b65a309 --- /dev/null +++ b/tests/cases/conformance/statements/VariableStatements/usingDeclarations/awaitUsingDeclarationsWithImportHelpers.ts @@ -0,0 +1,11 @@ +// @target: esnext +// @module: esnext +// @lib: esnext +// @importHelpers: true +// @noTypesAndSymbols: true + +export {}; + +async function f() { + await using a = null; +} \ No newline at end of file diff --git a/tests/cases/conformance/statements/VariableStatements/usingDeclarations/usingDeclarations.1.ts b/tests/cases/conformance/statements/VariableStatements/usingDeclarations/usingDeclarations.1.ts new file mode 100644 index 0000000000000..48339bbdd072b --- /dev/null +++ b/tests/cases/conformance/statements/VariableStatements/usingDeclarations/usingDeclarations.1.ts @@ -0,0 +1,156 @@ +// @target: esnext,es2022,es2017,es2015,es5 +// @module: esnext +// @lib: esnext +// @noTypesAndSymbols: true + +using d1 = { [Symbol.dispose]() {} }; + +function f() { + using d2 = { [Symbol.dispose]() {} }; +} + +async function af() { + using d3 = { [Symbol.dispose]() {} }; + await null; +} + +function * g() { + using d4 = { [Symbol.dispose]() {} }; + yield; +} + +async function * ag() { + using d5 = { [Symbol.dispose]() {} }; + yield; + await null; +} + +const a = () => { + using d6 = { [Symbol.dispose]() {} }; +} + +class C1 { + a = () => { + using d7 = { [Symbol.dispose]() {} }; + } + + constructor() { + using d8 = { [Symbol.dispose]() {} }; + } + + static { + using d9 = { [Symbol.dispose]() {} }; + } + + m() { + using d10 = { [Symbol.dispose]() {} }; + } + + get x() { + using d11 = { [Symbol.dispose]() {} }; + return 0; + } + + set x(v) { + using d12 = { [Symbol.dispose]() {} }; + } + + async am() { + using d13 = { [Symbol.dispose]() {} }; + await null; + } + + * g() { + using d14 = { [Symbol.dispose]() {} }; + yield; + } + + async * ag() { + using d15 = { [Symbol.dispose]() {} }; + yield; + await null; + } +} + +class C2 extends C1 { + constructor() { + using d16 = { [Symbol.dispose]() {} }; + super(); + } +} + +class C3 extends C1 { + y = 1; + constructor() { + using d17 = { [Symbol.dispose]() {} }; + super(); + } +} + +namespace N { + using d18 = { [Symbol.dispose]() {} }; +} + +{ + using d19 = { [Symbol.dispose]() {} }; +} + +switch (Math.random()) { + case 0: + using d20 = { [Symbol.dispose]() {} }; + break; + + case 1: + using d21 = { [Symbol.dispose]() {} }; + break; +} + +if (true) + switch (0) { + case 0: + using d22 = { [Symbol.dispose]() {} }; + break; + } + +try { + using d23 = { [Symbol.dispose]() {} }; +} +catch { + using d24 = { [Symbol.dispose]() {} }; +} +finally { + using d25 = { [Symbol.dispose]() {} }; +} + +if (true) { + using d26 = { [Symbol.dispose]() {} }; +} +else { + using d27 = { [Symbol.dispose]() {} }; +} + +while (true) { + using d28 = { [Symbol.dispose]() {} }; + break; +} + +do { + using d29 = { [Symbol.dispose]() {} }; + break; +} +while (true); + +for (;;) { + using d30 = { [Symbol.dispose]() {} }; + break; +} + +for (const x in {}) { + using d31 = { [Symbol.dispose]() {} }; +} + +for (const x of []) { + using d32 = { [Symbol.dispose]() {} }; +} + +export {}; \ No newline at end of file diff --git a/tests/cases/conformance/statements/VariableStatements/usingDeclarations/usingDeclarations.10.ts b/tests/cases/conformance/statements/VariableStatements/usingDeclarations/usingDeclarations.10.ts new file mode 100644 index 0000000000000..13a77b4379a94 --- /dev/null +++ b/tests/cases/conformance/statements/VariableStatements/usingDeclarations/usingDeclarations.10.ts @@ -0,0 +1,7 @@ +// @target: esnext +// @module: esnext +// @lib: esnext +// @noTypesAndSymbols: true + +declare var x: any; +if (x) using a = null; diff --git a/tests/cases/conformance/statements/VariableStatements/usingDeclarations/usingDeclarations.11.ts b/tests/cases/conformance/statements/VariableStatements/usingDeclarations/usingDeclarations.11.ts new file mode 100644 index 0000000000000..603e25901b9bd --- /dev/null +++ b/tests/cases/conformance/statements/VariableStatements/usingDeclarations/usingDeclarations.11.ts @@ -0,0 +1,38 @@ +// @target: es5 +// @module: esnext +// @lib: esnext +// @noTypesAndSymbols: true + +class A {} +class C1 extends A { + constructor() { + using x = null; + super(); + } +} +class C2 extends A { + constructor() { + super(); + using x = null; + } +} +class C3 extends A { + y = 1; + constructor() { + using x = null; + super(); + } +} +class C4 extends A { + constructor(public y: number) { + using x = null; + super(); + } +} +class C5 extends A { + z = 1; + constructor(public y: number) { + using x = null; + super(); + } +} diff --git a/tests/cases/conformance/statements/VariableStatements/usingDeclarations/usingDeclarations.12.ts b/tests/cases/conformance/statements/VariableStatements/usingDeclarations/usingDeclarations.12.ts new file mode 100644 index 0000000000000..fd24eff921836 --- /dev/null +++ b/tests/cases/conformance/statements/VariableStatements/usingDeclarations/usingDeclarations.12.ts @@ -0,0 +1,17 @@ +// @target: es2018 +// @module: esnext +// @lib: esnext +// @noTypesAndSymbols: true +// @useDefineForClassFields: * + +class C1 { + constructor() {} +} + +class C2 extends C1 { + y = 1; + constructor() { + super(); + using d17 = { [Symbol.dispose]() {} }; + } +} \ No newline at end of file diff --git a/tests/cases/conformance/statements/VariableStatements/usingDeclarations/usingDeclarations.13.ts b/tests/cases/conformance/statements/VariableStatements/usingDeclarations/usingDeclarations.13.ts new file mode 100644 index 0000000000000..164c1fae81852 --- /dev/null +++ b/tests/cases/conformance/statements/VariableStatements/usingDeclarations/usingDeclarations.13.ts @@ -0,0 +1,7 @@ +// @target: esnext +// @module: esnext +// @lib: esnext +// @noTypesAndSymbols: true + +export using x = null; +declare using y: null; diff --git a/tests/cases/conformance/statements/VariableStatements/usingDeclarations/usingDeclarations.14.ts b/tests/cases/conformance/statements/VariableStatements/usingDeclarations/usingDeclarations.14.ts new file mode 100644 index 0000000000000..7489f99a03d60 --- /dev/null +++ b/tests/cases/conformance/statements/VariableStatements/usingDeclarations/usingDeclarations.14.ts @@ -0,0 +1,6 @@ +// @target: esnext +// @module: esnext +// @lib: esnext +// @noTypesAndSymbols: true + +using x = {}; \ No newline at end of file diff --git a/tests/cases/conformance/statements/VariableStatements/usingDeclarations/usingDeclarations.15.ts b/tests/cases/conformance/statements/VariableStatements/usingDeclarations/usingDeclarations.15.ts new file mode 100644 index 0000000000000..79b0032da9003 --- /dev/null +++ b/tests/cases/conformance/statements/VariableStatements/usingDeclarations/usingDeclarations.15.ts @@ -0,0 +1,9 @@ +// @target: esnext +// @module: esnext +// @lib: esnext +// @noTypesAndSymbols: true +// @noUnusedLocals: true + +export {}; + +using _ = { [Symbol.dispose]() {} }; \ No newline at end of file diff --git a/tests/cases/conformance/statements/VariableStatements/usingDeclarations/usingDeclarations.2.ts b/tests/cases/conformance/statements/VariableStatements/usingDeclarations/usingDeclarations.2.ts new file mode 100644 index 0000000000000..77dbf61af5d4d --- /dev/null +++ b/tests/cases/conformance/statements/VariableStatements/usingDeclarations/usingDeclarations.2.ts @@ -0,0 +1,9 @@ +// @target: esnext,es2022,es2017,es2015,es5 +// @module: esnext +// @lib: esnext +// @noTypesAndSymbols: true + +{ + using d1 = { [Symbol.dispose]() {} }, + d2 = { [Symbol.dispose]() {} }; +} diff --git a/tests/cases/conformance/statements/VariableStatements/usingDeclarations/usingDeclarations.3.ts b/tests/cases/conformance/statements/VariableStatements/usingDeclarations/usingDeclarations.3.ts new file mode 100644 index 0000000000000..90991a578edce --- /dev/null +++ b/tests/cases/conformance/statements/VariableStatements/usingDeclarations/usingDeclarations.3.ts @@ -0,0 +1,11 @@ +// @target: esnext,es2022,es2017,es2015,es5 +// @module: esnext +// @lib: esnext +// @noTypesAndSymbols: true + +{ + using d1 = { [Symbol.dispose]() {} }, + d2 = null, + d3 = undefined, + d4 = { [Symbol.dispose]() {} }; +} diff --git a/tests/cases/conformance/statements/VariableStatements/usingDeclarations/usingDeclarations.4.ts b/tests/cases/conformance/statements/VariableStatements/usingDeclarations/usingDeclarations.4.ts new file mode 100644 index 0000000000000..f8118cbe6697f --- /dev/null +++ b/tests/cases/conformance/statements/VariableStatements/usingDeclarations/usingDeclarations.4.ts @@ -0,0 +1,8 @@ +// @target: esnext +// @module: esnext +// @lib: esnext +// @noTypesAndSymbols: true + +{ + using [a] = null; +} \ No newline at end of file diff --git a/tests/cases/conformance/statements/VariableStatements/usingDeclarations/usingDeclarations.5.ts b/tests/cases/conformance/statements/VariableStatements/usingDeclarations/usingDeclarations.5.ts new file mode 100644 index 0000000000000..c328e3e9914d1 --- /dev/null +++ b/tests/cases/conformance/statements/VariableStatements/usingDeclarations/usingDeclarations.5.ts @@ -0,0 +1,10 @@ +// @target: esnext +// @module: esnext +// @lib: esnext +// @noTypesAndSymbols: true + +{ + using a = null, + [b] = null, + c = null; +} diff --git a/tests/cases/conformance/statements/VariableStatements/usingDeclarations/usingDeclarations.6.ts b/tests/cases/conformance/statements/VariableStatements/usingDeclarations/usingDeclarations.6.ts new file mode 100644 index 0000000000000..62b76cb4d3ab4 --- /dev/null +++ b/tests/cases/conformance/statements/VariableStatements/usingDeclarations/usingDeclarations.6.ts @@ -0,0 +1,8 @@ +// @target: esnext +// @module: esnext +// @lib: esnext +// @noTypesAndSymbols: true + +{ + using {a} = null; +} diff --git a/tests/cases/conformance/statements/VariableStatements/usingDeclarations/usingDeclarations.7.ts b/tests/cases/conformance/statements/VariableStatements/usingDeclarations/usingDeclarations.7.ts new file mode 100644 index 0000000000000..4f0a3620529d3 --- /dev/null +++ b/tests/cases/conformance/statements/VariableStatements/usingDeclarations/usingDeclarations.7.ts @@ -0,0 +1,10 @@ +// @target: esnext +// @module: esnext +// @lib: esnext +// @noTypesAndSymbols: true + +{ + using a = null, + {b} = null, + c = null; +} \ No newline at end of file diff --git a/tests/cases/conformance/statements/VariableStatements/usingDeclarations/usingDeclarations.8.ts b/tests/cases/conformance/statements/VariableStatements/usingDeclarations/usingDeclarations.8.ts new file mode 100644 index 0000000000000..70859a4313708 --- /dev/null +++ b/tests/cases/conformance/statements/VariableStatements/usingDeclarations/usingDeclarations.8.ts @@ -0,0 +1,8 @@ +// @target: esnext +// @module: esnext +// @lib: esnext +// @noTypesAndSymbols: true + +{ + using a; +} \ No newline at end of file diff --git a/tests/cases/conformance/statements/VariableStatements/usingDeclarations/usingDeclarations.9.ts b/tests/cases/conformance/statements/VariableStatements/usingDeclarations/usingDeclarations.9.ts new file mode 100644 index 0000000000000..cec1bd79ee30c --- /dev/null +++ b/tests/cases/conformance/statements/VariableStatements/usingDeclarations/usingDeclarations.9.ts @@ -0,0 +1,8 @@ +// @target: esnext +// @module: esnext +// @lib: es2022 +// @noTypesAndSymbols: true + +{ + using a = null; +} \ No newline at end of file diff --git a/tests/cases/conformance/statements/VariableStatements/usingDeclarations/usingDeclarationsDeclarationEmit.1.ts b/tests/cases/conformance/statements/VariableStatements/usingDeclarations/usingDeclarationsDeclarationEmit.1.ts new file mode 100644 index 0000000000000..d952dcb91e9a3 --- /dev/null +++ b/tests/cases/conformance/statements/VariableStatements/usingDeclarations/usingDeclarationsDeclarationEmit.1.ts @@ -0,0 +1,10 @@ +// @target: esnext +// @module: esnext +// @declaration: true +// @noTypesAndSymbols: true + +using r1 = { [Symbol.dispose]() {} }; +export { r1 }; + +await using r2 = { async [Symbol.asyncDispose]() {} }; +export { r2 }; diff --git a/tests/cases/conformance/statements/VariableStatements/usingDeclarations/usingDeclarationsDeclarationEmit.2.ts b/tests/cases/conformance/statements/VariableStatements/usingDeclarations/usingDeclarationsDeclarationEmit.2.ts new file mode 100644 index 0000000000000..5b3e21dea0985 --- /dev/null +++ b/tests/cases/conformance/statements/VariableStatements/usingDeclarations/usingDeclarationsDeclarationEmit.2.ts @@ -0,0 +1,10 @@ +// @target: esnext +// @module: esnext +// @declaration: true +// @noTypesAndSymbols: true + +using r1 = { [Symbol.dispose]() {} }; +export type R1 = typeof r1; + +await using r2 = { async [Symbol.asyncDispose]() {} }; +export type R2 = typeof r2; diff --git a/tests/cases/conformance/statements/VariableStatements/usingDeclarations/usingDeclarationsInFor.ts b/tests/cases/conformance/statements/VariableStatements/usingDeclarations/usingDeclarationsInFor.ts new file mode 100644 index 0000000000000..a7209fa70ceba --- /dev/null +++ b/tests/cases/conformance/statements/VariableStatements/usingDeclarations/usingDeclarationsInFor.ts @@ -0,0 +1,7 @@ +// @target: esnext,es2022,es2017,es2015,es5 +// @module: esnext +// @lib: esnext +// @noTypesAndSymbols: true + +for (using d1 = { [Symbol.dispose]() {} }, d2 = null, d3 = undefined;;) { +} diff --git a/tests/cases/conformance/statements/VariableStatements/usingDeclarations/usingDeclarationsInForAwaitOf.ts b/tests/cases/conformance/statements/VariableStatements/usingDeclarations/usingDeclarationsInForAwaitOf.ts new file mode 100644 index 0000000000000..807e2acce50d1 --- /dev/null +++ b/tests/cases/conformance/statements/VariableStatements/usingDeclarations/usingDeclarationsInForAwaitOf.ts @@ -0,0 +1,9 @@ +// @target: esnext,es2022,es2017,es2015,es5 +// @module: esnext +// @lib: esnext +// @noTypesAndSymbols: true + +async function main() { + for await (using d1 of [{ [Symbol.dispose]() {} }, null, undefined]) { + } +} diff --git a/tests/cases/conformance/statements/VariableStatements/usingDeclarations/usingDeclarationsInForIn.ts b/tests/cases/conformance/statements/VariableStatements/usingDeclarations/usingDeclarationsInForIn.ts new file mode 100644 index 0000000000000..ea9c191edd4a5 --- /dev/null +++ b/tests/cases/conformance/statements/VariableStatements/usingDeclarations/usingDeclarationsInForIn.ts @@ -0,0 +1,7 @@ +// @target: esnext +// @module: esnext +// @lib: esnext +// @noTypesAndSymbols: true + +for (using x in {}) { +} diff --git a/tests/cases/conformance/statements/VariableStatements/usingDeclarations/usingDeclarationsInForOf.1.ts b/tests/cases/conformance/statements/VariableStatements/usingDeclarations/usingDeclarationsInForOf.1.ts new file mode 100644 index 0000000000000..be2412cb1b24f --- /dev/null +++ b/tests/cases/conformance/statements/VariableStatements/usingDeclarations/usingDeclarationsInForOf.1.ts @@ -0,0 +1,7 @@ +// @target: esnext,es2022,es2017,es2015,es5 +// @module: esnext +// @lib: esnext +// @noTypesAndSymbols: true + +for (using d1 of [{ [Symbol.dispose]() {} }, null, undefined]) { +} diff --git a/tests/cases/conformance/statements/VariableStatements/usingDeclarations/usingDeclarationsInForOf.2.ts b/tests/cases/conformance/statements/VariableStatements/usingDeclarations/usingDeclarationsInForOf.2.ts new file mode 100644 index 0000000000000..50ffa8ec3555d --- /dev/null +++ b/tests/cases/conformance/statements/VariableStatements/usingDeclarations/usingDeclarationsInForOf.2.ts @@ -0,0 +1,7 @@ +// @target: esnext +// @module: esnext +// @lib: esnext +// @noTypesAndSymbols: true + +for (using of of []) { +} diff --git a/tests/cases/conformance/statements/VariableStatements/usingDeclarations/usingDeclarationsInForOf.3.ts b/tests/cases/conformance/statements/VariableStatements/usingDeclarations/usingDeclarationsInForOf.3.ts new file mode 100644 index 0000000000000..a897bf1961330 --- /dev/null +++ b/tests/cases/conformance/statements/VariableStatements/usingDeclarations/usingDeclarationsInForOf.3.ts @@ -0,0 +1,7 @@ +// @target: esnext +// @module: esnext +// @lib: esnext +// @noTypesAndSymbols: true + +for (using {} of []) { +} diff --git a/tests/cases/conformance/statements/VariableStatements/usingDeclarations/usingDeclarationsNamedEvaluationDecoratorsAndClassFields.ts b/tests/cases/conformance/statements/VariableStatements/usingDeclarations/usingDeclarationsNamedEvaluationDecoratorsAndClassFields.ts new file mode 100644 index 0000000000000..810ad466a4a44 --- /dev/null +++ b/tests/cases/conformance/statements/VariableStatements/usingDeclarations/usingDeclarationsNamedEvaluationDecoratorsAndClassFields.ts @@ -0,0 +1,26 @@ +// @target: es2018 +// @module: esnext +// @lib: esnext +// @noTypesAndSymbols: true + +export {}; + +declare var dec: any; + +using C1 = class { + static [Symbol.dispose]() {} +}; + +using C2 = class { + static x = 1; + static [Symbol.dispose]() {} +}; + +using C3 = @dec class { + static [Symbol.dispose]() {} +}; + +using C4 = @dec class { + static x = 1; + static [Symbol.dispose]() {} +}; diff --git a/tests/cases/conformance/statements/VariableStatements/usingDeclarations/usingDeclarationsTopLevelOfModule.1.ts b/tests/cases/conformance/statements/VariableStatements/usingDeclarations/usingDeclarationsTopLevelOfModule.1.ts new file mode 100644 index 0000000000000..fe7e2b6502cf5 --- /dev/null +++ b/tests/cases/conformance/statements/VariableStatements/usingDeclarations/usingDeclarationsTopLevelOfModule.1.ts @@ -0,0 +1,18 @@ +// @target: es2022 +// @lib: esnext,dom +// @module: commonjs,system,esnext,amd +// @noTypesAndSymbols: true +// @noEmitHelpers: true + +export const x = 1; +export { y }; + +using z = { [Symbol.dispose]() {} }; + +const y = 2; + +export const w = 3; + +export default 4; + +console.log(w, x, y, z); diff --git a/tests/cases/conformance/statements/VariableStatements/usingDeclarations/usingDeclarationsTopLevelOfModule.2.ts b/tests/cases/conformance/statements/VariableStatements/usingDeclarations/usingDeclarationsTopLevelOfModule.2.ts new file mode 100644 index 0000000000000..bcef291f55a8c --- /dev/null +++ b/tests/cases/conformance/statements/VariableStatements/usingDeclarations/usingDeclarationsTopLevelOfModule.2.ts @@ -0,0 +1,12 @@ +// @target: es2022 +// @lib: esnext,dom +// @module: commonjs,amd +// @noTypesAndSymbols: true +// @noEmitHelpers: true + +using z = { [Symbol.dispose]() {} }; + +const y = 2; + +console.log(y, z); +export = 4; diff --git a/tests/cases/conformance/statements/VariableStatements/usingDeclarations/usingDeclarationsTopLevelOfModule.3.ts b/tests/cases/conformance/statements/VariableStatements/usingDeclarations/usingDeclarationsTopLevelOfModule.3.ts new file mode 100644 index 0000000000000..2804f3e4a75b2 --- /dev/null +++ b/tests/cases/conformance/statements/VariableStatements/usingDeclarations/usingDeclarationsTopLevelOfModule.3.ts @@ -0,0 +1,18 @@ +// @target: es2022 +// @lib: esnext,dom +// @module: commonjs,system,esnext,amd +// @noTypesAndSymbols: true +// @noEmitHelpers: true + +export { y }; + +using z = { [Symbol.dispose]() {} }; + +if (false) { + var y = 1; +} + +function f() { + console.log(y, z); +} + diff --git a/tests/cases/conformance/statements/VariableStatements/usingDeclarations/usingDeclarationsWithESClassDecorators.1.ts b/tests/cases/conformance/statements/VariableStatements/usingDeclarations/usingDeclarationsWithESClassDecorators.1.ts new file mode 100644 index 0000000000000..e6da37efd08f2 --- /dev/null +++ b/tests/cases/conformance/statements/VariableStatements/usingDeclarations/usingDeclarationsWithESClassDecorators.1.ts @@ -0,0 +1,15 @@ +// @target: esnext,es2015,es5 +// @module: commonjs,system,esnext +// @lib: esnext +// @experimentalDecorators: false +// @noTypesAndSymbols: true +// @noEmitHelpers: true +export {}; + +declare var dec: any; + +using before = null; + +@dec +class C { +} diff --git a/tests/cases/conformance/statements/VariableStatements/usingDeclarations/usingDeclarationsWithESClassDecorators.10.ts b/tests/cases/conformance/statements/VariableStatements/usingDeclarations/usingDeclarationsWithESClassDecorators.10.ts new file mode 100644 index 0000000000000..09228bd94e081 --- /dev/null +++ b/tests/cases/conformance/statements/VariableStatements/usingDeclarations/usingDeclarationsWithESClassDecorators.10.ts @@ -0,0 +1,15 @@ +// @target: esnext,es2015,es5 +// @module: commonjs,system,esnext +// @lib: esnext +// @experimentalDecorators: false +// @noTypesAndSymbols: true +// @noEmitHelpers: true +export {}; + +declare var dec: any; + +@dec +export default class { +} + +using after = null; diff --git a/tests/cases/conformance/statements/VariableStatements/usingDeclarations/usingDeclarationsWithESClassDecorators.11.ts b/tests/cases/conformance/statements/VariableStatements/usingDeclarations/usingDeclarationsWithESClassDecorators.11.ts new file mode 100644 index 0000000000000..e3b426e0669e2 --- /dev/null +++ b/tests/cases/conformance/statements/VariableStatements/usingDeclarations/usingDeclarationsWithESClassDecorators.11.ts @@ -0,0 +1,17 @@ +// @target: esnext,es2015,es5 +// @module: commonjs,system,esnext +// @lib: esnext +// @experimentalDecorators: false +// @noTypesAndSymbols: true +// @noEmitHelpers: true +export {}; + +declare var dec: any; + +@dec +class C { +} + +export { C }; + +using after = null; diff --git a/tests/cases/conformance/statements/VariableStatements/usingDeclarations/usingDeclarationsWithESClassDecorators.12.ts b/tests/cases/conformance/statements/VariableStatements/usingDeclarations/usingDeclarationsWithESClassDecorators.12.ts new file mode 100644 index 0000000000000..e925063f9d346 --- /dev/null +++ b/tests/cases/conformance/statements/VariableStatements/usingDeclarations/usingDeclarationsWithESClassDecorators.12.ts @@ -0,0 +1,17 @@ +// @target: esnext,es2015,es5 +// @module: commonjs,system,esnext +// @lib: esnext +// @experimentalDecorators: false +// @noTypesAndSymbols: true +// @noEmitHelpers: true +export {}; + +declare var dec: any; + +@dec +class C { +} + +export { C as D }; + +using after = null; diff --git a/tests/cases/conformance/statements/VariableStatements/usingDeclarations/usingDeclarationsWithESClassDecorators.2.ts b/tests/cases/conformance/statements/VariableStatements/usingDeclarations/usingDeclarationsWithESClassDecorators.2.ts new file mode 100644 index 0000000000000..d34b1d21e54b6 --- /dev/null +++ b/tests/cases/conformance/statements/VariableStatements/usingDeclarations/usingDeclarationsWithESClassDecorators.2.ts @@ -0,0 +1,15 @@ +// @target: esnext,es2015,es5 +// @module: commonjs,system,esnext +// @lib: esnext +// @experimentalDecorators: false +// @noTypesAndSymbols: true +// @noEmitHelpers: true +export {}; + +declare var dec: any; + +using before = null; + +@dec +export class C { +} diff --git a/tests/cases/conformance/statements/VariableStatements/usingDeclarations/usingDeclarationsWithESClassDecorators.3.ts b/tests/cases/conformance/statements/VariableStatements/usingDeclarations/usingDeclarationsWithESClassDecorators.3.ts new file mode 100644 index 0000000000000..f3fdfea70b31a --- /dev/null +++ b/tests/cases/conformance/statements/VariableStatements/usingDeclarations/usingDeclarationsWithESClassDecorators.3.ts @@ -0,0 +1,17 @@ +// @target: esnext,es2015,es5 +// @module: commonjs,system,esnext +// @lib: esnext +// @experimentalDecorators: false +// @noTypesAndSymbols: true +// @noEmitHelpers: true +export {}; + +declare var dec: any; + +using before = null; + +@dec +export default class C { +} + +void C; \ No newline at end of file diff --git a/tests/cases/conformance/statements/VariableStatements/usingDeclarations/usingDeclarationsWithESClassDecorators.4.ts b/tests/cases/conformance/statements/VariableStatements/usingDeclarations/usingDeclarationsWithESClassDecorators.4.ts new file mode 100644 index 0000000000000..9ef4a5802bac2 --- /dev/null +++ b/tests/cases/conformance/statements/VariableStatements/usingDeclarations/usingDeclarationsWithESClassDecorators.4.ts @@ -0,0 +1,15 @@ +// @target: esnext,es2015,es5 +// @module: commonjs,system,esnext +// @lib: esnext +// @experimentalDecorators: false +// @noTypesAndSymbols: true +// @noEmitHelpers: true +export {}; + +declare var dec: any; + +using before = null; + +@dec +export default class { +} diff --git a/tests/cases/conformance/statements/VariableStatements/usingDeclarations/usingDeclarationsWithESClassDecorators.5.ts b/tests/cases/conformance/statements/VariableStatements/usingDeclarations/usingDeclarationsWithESClassDecorators.5.ts new file mode 100644 index 0000000000000..4062f99c9b062 --- /dev/null +++ b/tests/cases/conformance/statements/VariableStatements/usingDeclarations/usingDeclarationsWithESClassDecorators.5.ts @@ -0,0 +1,17 @@ +// @target: esnext,es2015,es5 +// @module: commonjs,system,esnext +// @lib: esnext +// @experimentalDecorators: false +// @noTypesAndSymbols: true +// @noEmitHelpers: true +export {}; + +declare var dec: any; + +using before = null; + +@dec +class C { +} + +export { C }; \ No newline at end of file diff --git a/tests/cases/conformance/statements/VariableStatements/usingDeclarations/usingDeclarationsWithESClassDecorators.6.ts b/tests/cases/conformance/statements/VariableStatements/usingDeclarations/usingDeclarationsWithESClassDecorators.6.ts new file mode 100644 index 0000000000000..334e1a3a21d12 --- /dev/null +++ b/tests/cases/conformance/statements/VariableStatements/usingDeclarations/usingDeclarationsWithESClassDecorators.6.ts @@ -0,0 +1,17 @@ +// @target: esnext,es2015,es5 +// @module: commonjs,system,esnext +// @lib: esnext +// @experimentalDecorators: false +// @noTypesAndSymbols: true +// @noEmitHelpers: true +export {}; + +declare var dec: any; + +using before = null; + +@dec +class C { +} + +export { C as D }; \ No newline at end of file diff --git a/tests/cases/conformance/statements/VariableStatements/usingDeclarations/usingDeclarationsWithESClassDecorators.7.ts b/tests/cases/conformance/statements/VariableStatements/usingDeclarations/usingDeclarationsWithESClassDecorators.7.ts new file mode 100644 index 0000000000000..8e24ea3bd5c9e --- /dev/null +++ b/tests/cases/conformance/statements/VariableStatements/usingDeclarations/usingDeclarationsWithESClassDecorators.7.ts @@ -0,0 +1,16 @@ +// @target: esnext,es2015,es5 +// @module: commonjs,system,esnext +// @lib: esnext +// @experimentalDecorators: false +// @noTypesAndSymbols: true +// @noEmitHelpers: true +export {}; + +declare var dec: any; + +@dec +class C { +} + +using after = null; + diff --git a/tests/cases/conformance/statements/VariableStatements/usingDeclarations/usingDeclarationsWithESClassDecorators.8.ts b/tests/cases/conformance/statements/VariableStatements/usingDeclarations/usingDeclarationsWithESClassDecorators.8.ts new file mode 100644 index 0000000000000..fad68539c46cf --- /dev/null +++ b/tests/cases/conformance/statements/VariableStatements/usingDeclarations/usingDeclarationsWithESClassDecorators.8.ts @@ -0,0 +1,15 @@ +// @target: esnext,es2015,es5 +// @module: commonjs,system,esnext +// @lib: esnext +// @experimentalDecorators: false +// @noTypesAndSymbols: true +// @noEmitHelpers: true +export {}; + +declare var dec: any; + +@dec +export class C { +} + +using after = null; diff --git a/tests/cases/conformance/statements/VariableStatements/usingDeclarations/usingDeclarationsWithESClassDecorators.9.ts b/tests/cases/conformance/statements/VariableStatements/usingDeclarations/usingDeclarationsWithESClassDecorators.9.ts new file mode 100644 index 0000000000000..cc26af1c70bf2 --- /dev/null +++ b/tests/cases/conformance/statements/VariableStatements/usingDeclarations/usingDeclarationsWithESClassDecorators.9.ts @@ -0,0 +1,18 @@ +// @target: esnext,es2015,es5 +// @module: commonjs,system,esnext +// @lib: esnext +// @experimentalDecorators: false +// @noTypesAndSymbols: true +// @noEmitHelpers: true +export {}; + +declare var dec: any; + +@dec +export default class C { +} + +void C; + +using after = null; + diff --git a/tests/cases/conformance/statements/VariableStatements/usingDeclarations/usingDeclarationsWithImportHelpers.ts b/tests/cases/conformance/statements/VariableStatements/usingDeclarations/usingDeclarationsWithImportHelpers.ts new file mode 100644 index 0000000000000..e137a9bc0cd57 --- /dev/null +++ b/tests/cases/conformance/statements/VariableStatements/usingDeclarations/usingDeclarationsWithImportHelpers.ts @@ -0,0 +1,11 @@ +// @target: esnext +// @module: esnext +// @lib: esnext +// @importHelpers: true +// @noTypesAndSymbols: true + +export {}; + +{ + using a = null; +} \ No newline at end of file diff --git a/tests/cases/conformance/statements/VariableStatements/usingDeclarations/usingDeclarationsWithLegacyClassDecorators.1.ts b/tests/cases/conformance/statements/VariableStatements/usingDeclarations/usingDeclarationsWithLegacyClassDecorators.1.ts new file mode 100644 index 0000000000000..72d1e56f2d204 --- /dev/null +++ b/tests/cases/conformance/statements/VariableStatements/usingDeclarations/usingDeclarationsWithLegacyClassDecorators.1.ts @@ -0,0 +1,15 @@ +// @target: esnext,es2015,es5 +// @module: commonjs,system,esnext +// @lib: esnext +// @experimentalDecorators: true +// @noTypesAndSymbols: true +// @noEmitHelpers: true +export {}; + +declare var dec: any; + +using before = null; + +@dec +class C { +} diff --git a/tests/cases/conformance/statements/VariableStatements/usingDeclarations/usingDeclarationsWithLegacyClassDecorators.10.ts b/tests/cases/conformance/statements/VariableStatements/usingDeclarations/usingDeclarationsWithLegacyClassDecorators.10.ts new file mode 100644 index 0000000000000..be1f669030e1b --- /dev/null +++ b/tests/cases/conformance/statements/VariableStatements/usingDeclarations/usingDeclarationsWithLegacyClassDecorators.10.ts @@ -0,0 +1,15 @@ +// @target: esnext,es2015,es5 +// @module: commonjs,system,esnext +// @lib: esnext +// @experimentalDecorators: true +// @noTypesAndSymbols: true +// @noEmitHelpers: true +export {}; + +declare var dec: any; + +@dec +export default class { +} + +using after = null; diff --git a/tests/cases/conformance/statements/VariableStatements/usingDeclarations/usingDeclarationsWithLegacyClassDecorators.11.ts b/tests/cases/conformance/statements/VariableStatements/usingDeclarations/usingDeclarationsWithLegacyClassDecorators.11.ts new file mode 100644 index 0000000000000..b7a7e36341113 --- /dev/null +++ b/tests/cases/conformance/statements/VariableStatements/usingDeclarations/usingDeclarationsWithLegacyClassDecorators.11.ts @@ -0,0 +1,17 @@ +// @target: esnext,es2015,es5 +// @module: commonjs,system,esnext +// @lib: esnext +// @experimentalDecorators: true +// @noTypesAndSymbols: true +// @noEmitHelpers: true +export {}; + +declare var dec: any; + +@dec +class C { +} + +export { C }; + +using after = null; diff --git a/tests/cases/conformance/statements/VariableStatements/usingDeclarations/usingDeclarationsWithLegacyClassDecorators.12.ts b/tests/cases/conformance/statements/VariableStatements/usingDeclarations/usingDeclarationsWithLegacyClassDecorators.12.ts new file mode 100644 index 0000000000000..d650e4a248952 --- /dev/null +++ b/tests/cases/conformance/statements/VariableStatements/usingDeclarations/usingDeclarationsWithLegacyClassDecorators.12.ts @@ -0,0 +1,17 @@ +// @target: esnext,es2015,es5 +// @module: commonjs,system,esnext +// @lib: esnext +// @experimentalDecorators: true +// @noTypesAndSymbols: true +// @noEmitHelpers: true +export {}; + +declare var dec: any; + +@dec +class C { +} + +export { C as D }; + +using after = null; diff --git a/tests/cases/conformance/statements/VariableStatements/usingDeclarations/usingDeclarationsWithLegacyClassDecorators.2.ts b/tests/cases/conformance/statements/VariableStatements/usingDeclarations/usingDeclarationsWithLegacyClassDecorators.2.ts new file mode 100644 index 0000000000000..58d5a73ca3f33 --- /dev/null +++ b/tests/cases/conformance/statements/VariableStatements/usingDeclarations/usingDeclarationsWithLegacyClassDecorators.2.ts @@ -0,0 +1,15 @@ +// @target: esnext,es2015,es5 +// @module: commonjs,system,esnext +// @lib: esnext +// @experimentalDecorators: true +// @noTypesAndSymbols: true +// @noEmitHelpers: true +export {}; + +declare var dec: any; + +using before = null; + +@dec +export class C { +} diff --git a/tests/cases/conformance/statements/VariableStatements/usingDeclarations/usingDeclarationsWithLegacyClassDecorators.3.ts b/tests/cases/conformance/statements/VariableStatements/usingDeclarations/usingDeclarationsWithLegacyClassDecorators.3.ts new file mode 100644 index 0000000000000..680afb945a8e3 --- /dev/null +++ b/tests/cases/conformance/statements/VariableStatements/usingDeclarations/usingDeclarationsWithLegacyClassDecorators.3.ts @@ -0,0 +1,15 @@ +// @target: esnext,es2015,es5 +// @module: commonjs,system,esnext +// @lib: esnext +// @experimentalDecorators: true +// @noTypesAndSymbols: true +// @noEmitHelpers: true +export {}; + +declare var dec: any; + +using before = null; + +@dec +export default class C { +} diff --git a/tests/cases/conformance/statements/VariableStatements/usingDeclarations/usingDeclarationsWithLegacyClassDecorators.4.ts b/tests/cases/conformance/statements/VariableStatements/usingDeclarations/usingDeclarationsWithLegacyClassDecorators.4.ts new file mode 100644 index 0000000000000..61a67f91fe984 --- /dev/null +++ b/tests/cases/conformance/statements/VariableStatements/usingDeclarations/usingDeclarationsWithLegacyClassDecorators.4.ts @@ -0,0 +1,15 @@ +// @target: esnext,es2015,es5 +// @module: commonjs,system,esnext +// @lib: esnext +// @experimentalDecorators: true +// @noTypesAndSymbols: true +// @noEmitHelpers: true +export {}; + +declare var dec: any; + +using before = null; + +@dec +export default class { +} diff --git a/tests/cases/conformance/statements/VariableStatements/usingDeclarations/usingDeclarationsWithLegacyClassDecorators.5.ts b/tests/cases/conformance/statements/VariableStatements/usingDeclarations/usingDeclarationsWithLegacyClassDecorators.5.ts new file mode 100644 index 0000000000000..f3fb2c4980159 --- /dev/null +++ b/tests/cases/conformance/statements/VariableStatements/usingDeclarations/usingDeclarationsWithLegacyClassDecorators.5.ts @@ -0,0 +1,17 @@ +// @target: esnext,es2015,es5 +// @module: commonjs,system,esnext +// @lib: esnext +// @experimentalDecorators: true +// @noTypesAndSymbols: true +// @noEmitHelpers: true +export {}; + +declare var dec: any; + +using before = null; + +@dec +class C { +} + +export { C }; \ No newline at end of file diff --git a/tests/cases/conformance/statements/VariableStatements/usingDeclarations/usingDeclarationsWithLegacyClassDecorators.6.ts b/tests/cases/conformance/statements/VariableStatements/usingDeclarations/usingDeclarationsWithLegacyClassDecorators.6.ts new file mode 100644 index 0000000000000..27d3c78e46e7b --- /dev/null +++ b/tests/cases/conformance/statements/VariableStatements/usingDeclarations/usingDeclarationsWithLegacyClassDecorators.6.ts @@ -0,0 +1,17 @@ +// @target: esnext,es2015,es5 +// @module: commonjs,system,esnext +// @lib: esnext +// @experimentalDecorators: true +// @noTypesAndSymbols: true +// @noEmitHelpers: true +export {}; + +declare var dec: any; + +using before = null; + +@dec +class C { +} + +export { C as D }; \ No newline at end of file diff --git a/tests/cases/conformance/statements/VariableStatements/usingDeclarations/usingDeclarationsWithLegacyClassDecorators.7.ts b/tests/cases/conformance/statements/VariableStatements/usingDeclarations/usingDeclarationsWithLegacyClassDecorators.7.ts new file mode 100644 index 0000000000000..972810f29da56 --- /dev/null +++ b/tests/cases/conformance/statements/VariableStatements/usingDeclarations/usingDeclarationsWithLegacyClassDecorators.7.ts @@ -0,0 +1,15 @@ +// @target: esnext,es2015,es5 +// @module: commonjs,system,esnext +// @lib: esnext +// @experimentalDecorators: true +// @noTypesAndSymbols: true +// @noEmitHelpers: true +export {}; + +declare var dec: any; + +@dec +class C { +} + +using after = null; diff --git a/tests/cases/conformance/statements/VariableStatements/usingDeclarations/usingDeclarationsWithLegacyClassDecorators.8.ts b/tests/cases/conformance/statements/VariableStatements/usingDeclarations/usingDeclarationsWithLegacyClassDecorators.8.ts new file mode 100644 index 0000000000000..9ea6a419e8750 --- /dev/null +++ b/tests/cases/conformance/statements/VariableStatements/usingDeclarations/usingDeclarationsWithLegacyClassDecorators.8.ts @@ -0,0 +1,15 @@ +// @target: esnext,es2015,es5 +// @module: commonjs,system,esnext +// @lib: esnext +// @experimentalDecorators: true +// @noTypesAndSymbols: true +// @noEmitHelpers: true +export {}; + +declare var dec: any; + +@dec +export class C { +} + +using after = null; diff --git a/tests/cases/conformance/statements/VariableStatements/usingDeclarations/usingDeclarationsWithLegacyClassDecorators.9.ts b/tests/cases/conformance/statements/VariableStatements/usingDeclarations/usingDeclarationsWithLegacyClassDecorators.9.ts new file mode 100644 index 0000000000000..48dc496c5e325 --- /dev/null +++ b/tests/cases/conformance/statements/VariableStatements/usingDeclarations/usingDeclarationsWithLegacyClassDecorators.9.ts @@ -0,0 +1,15 @@ +// @target: esnext,es2015,es5 +// @module: commonjs,system,esnext +// @lib: esnext +// @experimentalDecorators: true +// @noTypesAndSymbols: true +// @noEmitHelpers: true +export {}; + +declare var dec: any; + +@dec +export default class C { +} + +using after = null;