From ea5d9cc52413a1270e25af93c353baf10282fd86 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Donny/=EA=B0=95=EB=8F=99=EC=9C=A4?= Date: Thu, 11 Apr 2024 16:22:56 +0900 Subject: [PATCH] test(es): Update `conformance` test suite from `tsc` (#8834) --- .../ES3For-ofTypeCheck1.1.normal.js | 4 +- .../ES3For-ofTypeCheck4.1.normal.js | 4 +- .../ES3For-ofTypeCheck6.1.normal.js | 4 +- .../ambientAccessors.1.normal.js | 2 + .../ambientAccessors.2.minified.js | 1 + ...ntrolFlowComputedPropertyNames.1.normal.js | 34 + ...rolFlowComputedPropertyNames.2.minified.js | 1 + .../decoratorOnClassMethod11.1.normal.js | 2 +- .../decoratorOnClassMethod11.2.minified.js | 23 +- .../decoratorOnClassMethod12.1.normal.js | 43 +- .../decoratorOnClassMethod12.2.minified.js | 32 +- .../tsc-references/errorIsolation.1.normal.js | 5 + .../errorIsolation.2.minified.js | 4 + .../tsc-references/es2018IntlAPIs.1.normal.js | 2 + .../es2018IntlAPIs.2.minified.js | 2 + ...corators-decoratorExpression.1.1.normal.js | 12 + ...rators-decoratorExpression.1.2.minified.js | 12 + ...corators-decoratorExpression.2.1.normal.js | 12 + ...rators-decoratorExpression.2.2.minified.js | 12 + ...ortsAndImportsWithUnderscores2.1.normal.js | 4 +- ...ortsAndImportsWithUnderscores3.1.normal.js | 6 +- .../tsc-references/importTag1.1.normal.js | 9 + .../tsc-references/importTag1.2.minified.js | 4 + .../tsc-references/importTag10.1.normal.js | 5 + .../tsc-references/importTag10.2.minified.js | 2 + .../tsc-references/importTag11.1.normal.js | 5 + .../tsc-references/importTag11.2.minified.js | 2 + .../tsc-references/importTag12.1.normal.js | 5 + .../tsc-references/importTag12.2.minified.js | 2 + .../tsc-references/importTag13.1.normal.js | 5 + .../tsc-references/importTag13.2.minified.js | 4 + .../tsc-references/importTag14.1.normal.js | 3 + .../tsc-references/importTag14.2.minified.js | 2 + .../tsc-references/importTag15.1.normal.js | 5 + .../tsc-references/importTag15.2.minified.js | 4 + .../tsc-references/importTag16.1.normal.js | 8 + .../tsc-references/importTag16.2.minified.js | 5 + .../tsc-references/importTag2.1.normal.js | 9 + .../tsc-references/importTag2.2.minified.js | 5 + .../tsc-references/importTag3.1.normal.js | 9 + .../tsc-references/importTag3.2.minified.js | 5 + .../tsc-references/importTag4.1.normal.js | 11 + .../tsc-references/importTag4.2.minified.js | 4 + .../tsc-references/importTag5.1.normal.js | 9 + .../tsc-references/importTag5.2.minified.js | 4 + .../tsc-references/importTag6.1.normal.js | 13 + .../tsc-references/importTag6.2.minified.js | 4 + .../tsc-references/importTag7.1.normal.js | 12 + .../tsc-references/importTag7.2.minified.js | 4 + .../tsc-references/importTag8.1.normal.js | 12 + .../tsc-references/importTag8.2.minified.js | 4 + .../tsc-references/importTag9.1.normal.js | 12 + .../tsc-references/importTag9.2.minified.js | 4 + ...torWithRHSHasSymbolHasInstance.1.normal.js | 2 + ...rWithRHSHasSymbolHasInstance.2.minified.js | 2 +- .../intlDateTimeFormatRangeES2021.1.normal.js | 4 + ...ntlDateTimeFormatRangeES2021.2.minified.js | 3 + .../intlNumberFormatES2020.1.normal.js | 36 + .../intlNumberFormatES2020.2.minified.js | 20 + .../intlNumberFormatES2023.1.normal.js | 37 + .../intlNumberFormatES2023.2.minified.js | 17 + ...intlNumberFormatES5UseGrouping.1.normal.js | 11 + ...tlNumberFormatES5UseGrouping.2.minified.js | 8 + .../libReferenceDeclarationEmit.1.normal.js | 4 +- ...ReferenceDeclarationEmitBundle.1.normal.js | 4 +- .../mappedTypesGenericTuples2.1.normal.js | 10 + .../mappedTypesGenericTuples2.2.minified.js | 7 + ...arators.decimal(target=es2020).1.normal.js | 15 + ...ators.decimal(target=es2020).2.minified.js | 1 + ...arators.decimal(target=es2021).1.normal.js | 15 + ...ators.decimal(target=es2021).2.minified.js | 1 + ...Separators.decimal(target=es5).1.normal.js | 15 + ...parators.decimal(target=es5).2.minified.js | 1 + ...arserArrowFunctionExpression10.1.normal.js | 7 + ...serArrowFunctionExpression10.2.minified.js | 5 + ...arserArrowFunctionExpression11.1.normal.js | 16 + ...serArrowFunctionExpression11.2.minified.js | 16 + ...arserArrowFunctionExpression12.1.normal.js | 7 + ...serArrowFunctionExpression12.2.minified.js | 5 + ...arserArrowFunctionExpression13.1.normal.js | 5 + ...serArrowFunctionExpression13.2.minified.js | 5 + ...arserArrowFunctionExpression14.1.normal.js | 5 + ...serArrowFunctionExpression14.2.minified.js | 5 + ...arserArrowFunctionExpression15.1.normal.js | 6 + ...serArrowFunctionExpression15.2.minified.js | 3 + ...arserArrowFunctionExpression16.1.normal.js | 6 + ...serArrowFunctionExpression16.2.minified.js | 3 + ...arserArrowFunctionExpression17.1.normal.js | 6 + ...serArrowFunctionExpression17.2.minified.js | 5 + ...parserArrowFunctionExpression8.1.normal.js | 15 + ...rserArrowFunctionExpression8.2.minified.js | 9 + ...parserArrowFunctionExpression9.1.normal.js | 7 + ...rserArrowFunctionExpression9.2.minified.js | 5 + .../privateNameES5Ban.1.normal.js | 38 + .../privateNameES5Ban.2.minified.js | 5 + .../spreadNonObject1.1.normal.js | 13 + .../spreadNonObject1.2.minified.js | 10 + .../templateLiteralTypes5.1.normal.js | 8 + .../templateLiteralTypes5.2.minified.js | 2 + .../templateLiteralTypes6.1.normal.js | 5 + .../templateLiteralTypes6.2.minified.js | 1 + .../templateLiteralTypes7.1.normal.js | 5 + .../templateLiteralTypes7.2.minified.js | 2 + .../templateStringMultiline3.1.normal.js | 3 +- .../tests/tsc/1.0lib-noErrors.ts | 4 +- .../tests/tsc/ES3For-ofTypeCheck1.ts | 2 +- .../tests/tsc/ES3For-ofTypeCheck2.ts | 2 +- .../tests/tsc/ES3For-ofTypeCheck4.ts | 2 +- .../tests/tsc/ES3For-ofTypeCheck6.ts | 2 +- .../tests/tsc/accessorWithES3.json | 367 -- .../tests/tsc/accessorWithES3.ts | 22 - .../tests/tsc/ambientAccessors.json | 204 +- .../tests/tsc/ambientAccessors.ts | 2 +- ...awaitUsingDeclarationsWithImportHelpers.ts | 2 +- .../tests/tsc/checkJsdocReturnTag1.json | 72 +- .../tests/tsc/checkJsdocReturnTag1.ts | 4 +- .../tests/tsc/checkJsdocReturnTag2.json | 52 +- .../tests/tsc/checkJsdocReturnTag2.ts | 4 +- ...nstructorDefaultValuesReferencingThis.json | 360 -- ...constructorDefaultValuesReferencingThis.ts | 11 - .../tsc/controlFlowComputedPropertyNames.json | 2060 +++++++++++ .../tsc/controlFlowComputedPropertyNames.ts | 41 + .../tests/tsc/decoratorOnClassMethod11.json | 40 +- .../tests/tsc/decoratorOnClassMethod11.ts | 2 +- .../tests/tsc/decoratorOnClassMethod12.ts | 2 +- .../tests/tsc/definePropertyOutputES3.json | 76 - .../tests/tsc/definePropertyOutputES3.ts | 5 - .../tests/tsc/errorIsolation.json | 172 + .../tests/tsc/errorIsolation.ts | 8 + .../tests/tsc/es2018IntlAPIs.json | 221 +- .../tests/tsc/es2018IntlAPIs.ts | 5 +- .../tsc/esDecorators-decoratorExpression.1.ts | 50 + .../esDecorators-decoratorExpression.2.json | 3189 +++++++++++++++++ .../tsc/esDecorators-decoratorExpression.2.ts | 60 + .../tests/tsc/esDecorators-preservesThis.ts | 2 +- .../tests/tsc/exportAndImport-es3-amd.json | 163 - .../tests/tsc/exportAndImport-es3-amd.ts | 12 - .../tests/tsc/exportAndImport-es3.json | 163 - .../tests/tsc/exportAndImport-es3.ts | 12 - .../tests/tsc/exportDefaultInJsFile01.ts | 2 +- .../tsc/exportsAndImportsWithUnderscores2.ts | 2 +- .../tsc/exportsAndImportsWithUnderscores3.ts | 2 +- .../tsc/exportsAndImportsWithUnderscores4.ts | 2 +- .../tsc/genericSetterInClassTypeJsDoc.json | 192 +- .../tsc/genericSetterInClassTypeJsDoc.ts | 2 +- .../tests/tsc/globalThisVarDeclaration.json | 356 +- .../tests/tsc/globalThisVarDeclaration.ts | 2 +- .../tsc/importCallExpressionAsyncES3AMD.json | 759 ---- .../tsc/importCallExpressionAsyncES3AMD.ts | 31 - .../tsc/importCallExpressionAsyncES3CJS.json | 759 ---- .../tsc/importCallExpressionAsyncES3CJS.ts | 31 - .../importCallExpressionAsyncES3System.json | 759 ---- .../tsc/importCallExpressionAsyncES3System.ts | 31 - .../tsc/importCallExpressionAsyncES3UMD.json | 759 ---- .../tsc/importCallExpressionAsyncES3UMD.ts | 31 - .../swc_ecma_parser/tests/tsc/importTag1.json | 146 + .../swc_ecma_parser/tests/tsc/importTag1.ts | 18 + .../tests/tsc/importTag10.json | 10 + .../swc_ecma_parser/tests/tsc/importTag10.ts | 8 + .../tests/tsc/importTag11.json | 10 + .../swc_ecma_parser/tests/tsc/importTag11.ts | 8 + .../tests/tsc/importTag12.json | 10 + .../swc_ecma_parser/tests/tsc/importTag12.ts | 8 + .../tests/tsc/importTag13.json | 91 + .../swc_ecma_parser/tests/tsc/importTag13.ts | 11 + .../tests/tsc/importTag14.json | 10 + .../swc_ecma_parser/tests/tsc/importTag14.ts | 6 + .../tests/tsc/importTag15.json | 104 + .../swc_ecma_parser/tests/tsc/importTag15.ts | 15 + .../tests/tsc/importTag16.json | 170 + .../swc_ecma_parser/tests/tsc/importTag16.ts | 17 + .../swc_ecma_parser/tests/tsc/importTag2.json | 154 + .../swc_ecma_parser/tests/tsc/importTag2.ts | 18 + .../swc_ecma_parser/tests/tsc/importTag3.json | 154 + .../swc_ecma_parser/tests/tsc/importTag3.ts | 18 + .../swc_ecma_parser/tests/tsc/importTag4.json | 146 + .../swc_ecma_parser/tests/tsc/importTag4.ts | 22 + .../swc_ecma_parser/tests/tsc/importTag5.json | 146 + .../swc_ecma_parser/tests/tsc/importTag5.ts | 19 + .../swc_ecma_parser/tests/tsc/importTag6.json | 246 ++ .../swc_ecma_parser/tests/tsc/importTag6.ts | 25 + .../swc_ecma_parser/tests/tsc/importTag7.json | 246 ++ .../swc_ecma_parser/tests/tsc/importTag7.ts | 24 + .../swc_ecma_parser/tests/tsc/importTag8.json | 246 ++ .../swc_ecma_parser/tests/tsc/importTag8.ts | 24 + .../swc_ecma_parser/tests/tsc/importTag9.json | 246 ++ .../swc_ecma_parser/tests/tsc/importTag9.ts | 24 + .../inferringClassMembersFromAssignments.json | 1716 ++++----- .../inferringClassMembersFromAssignments.ts | 2 +- ...ofOperatorWithRHSHasSymbolHasInstance.json | 783 +++- ...ceofOperatorWithRHSHasSymbolHasInstance.ts | 18 +- .../tsc/intlDateTimeFormatRangeES2021.json | 283 ++ .../tsc/intlDateTimeFormatRangeES2021.ts | 4 + .../tests/tsc/intlNumberFormatES2020.json | 1238 +++++++ .../tests/tsc/intlNumberFormatES2020.ts | 26 + .../tests/tsc/intlNumberFormatES2023.json | 2064 +++++++++++ .../tests/tsc/intlNumberFormatES2023.ts | 34 + .../tsc/intlNumberFormatES5UseGrouping.json | 431 +++ .../tsc/intlNumberFormatES5UseGrouping.ts | 8 + .../tests/tsc/jsObjectsMarkedAsOpenEnded.json | 428 +-- .../tests/tsc/jsObjectsMarkedAsOpenEnded.ts | 2 +- .../jsdocAccessibilityTagsDeclarations.json | 376 +- .../tsc/jsdocAccessibilityTagsDeclarations.ts | 4 +- .../tests/tsc/jsdocLinkTag8.json | 88 + .../tests/tsc/jsdocLinkTag8.ts | 8 + .../tests/tsc/jsdocLiteral.json | 104 +- .../swc_ecma_parser/tests/tsc/jsdocLiteral.ts | 2 +- .../tests/tsc/jsdocNeverUndefinedNull.json | 40 +- .../tests/tsc/jsdocNeverUndefinedNull.ts | 2 +- .../tests/tsc/jsdocReadonlyDeclarations.json | 176 +- .../tests/tsc/jsdocReadonlyDeclarations.ts | 4 +- .../tests/tsc/jsdocReturnTag1.json | 72 +- .../tests/tsc/jsdocReturnTag1.ts | 4 +- .../tsc/libReferenceDeclarationEmit.json | 60 +- .../tests/tsc/libReferenceDeclarationEmit.ts | 4 +- .../libReferenceDeclarationEmitBundle.json | 60 +- .../tsc/libReferenceDeclarationEmitBundle.ts | 4 +- .../tests/tsc/mappedTypesGenericTuples2.json | 503 +++ .../tests/tsc/mappedTypesGenericTuples2.ts | 13 + .../tests/tsc/methodsReturningThis.json | 640 ++-- .../tests/tsc/methodsReturningThis.ts | 2 +- .../tests/tsc/multipleDeclarations.json | 524 +-- .../tests/tsc/multipleDeclarations.ts | 2 +- .../tests/tsc/numberFormatCurrencySign.json | 219 -- .../tests/tsc/numberFormatCurrencySign.ts | 4 - .../tsc/numberFormatCurrencySignResolved.json | 265 -- .../tsc/numberFormatCurrencySignResolved.ts | 5 - .../tests/tsc/objectLiteralErrorsES3.json | 309 -- .../tests/tsc/objectLiteralErrorsES3.ts | 6 - .../tsc/parser.numericSeparators.decimal.ts | 1 + .../tsc/parserArrowFunctionExpression10.json | 108 +- .../tsc/parserArrowFunctionExpression10.ts | 2 +- .../tsc/parserArrowFunctionExpression11.ts | 2 +- .../tsc/parserArrowFunctionExpression12.json | 84 +- .../tsc/parserArrowFunctionExpression12.ts | 2 +- .../tsc/parserArrowFunctionExpression13.json | 84 +- .../tsc/parserArrowFunctionExpression13.ts | 2 +- .../tsc/parserArrowFunctionExpression14.json | 132 +- .../tsc/parserArrowFunctionExpression14.ts | 2 +- .../tsc/parserArrowFunctionExpression15.json | 76 +- .../tsc/parserArrowFunctionExpression15.ts | 2 +- .../tsc/parserArrowFunctionExpression16.json | 100 +- .../tsc/parserArrowFunctionExpression16.ts | 2 +- .../tsc/parserArrowFunctionExpression17.json | 84 +- .../tsc/parserArrowFunctionExpression17.ts | 2 +- .../tsc/parserArrowFunctionExpression8.json | 108 +- .../tsc/parserArrowFunctionExpression8.ts | 2 +- .../tsc/parserArrowFunctionExpression9.json | 68 +- .../tsc/parserArrowFunctionExpression9.ts | 2 +- .../tests/tsc/privateNameES5Ban.json | 224 +- .../tests/tsc/privateNameES5Ban.ts | 2 +- .../tests/tsc/spreadNonObject1.json | 364 ++ .../tests/tsc/spreadNonObject1.ts | 11 + .../tests/tsc/templateLiteralTypes5.json | 1472 ++++++++ .../tests/tsc/templateLiteralTypes5.ts | 19 + .../tests/tsc/templateLiteralTypes6.json | 1042 ++++++ .../tests/tsc/templateLiteralTypes6.ts | 24 + .../tests/tsc/templateLiteralTypes7.json | 1506 ++++++++ .../tests/tsc/templateLiteralTypes7.ts | 23 + .../tests/tsc/templateStringMultiline3.json | 37 +- .../tests/tsc/templateStringMultiline3.ts | 2 +- .../tsc/templateStringMultiline3_ES6.json | 37 +- .../tests/tsc/templateStringMultiline3_ES6.ts | 2 +- .../tests/tsc/topLevelThisAssignment.json | 76 +- .../tests/tsc/topLevelThisAssignment.ts | 2 +- .../tsc/topLevelVarHoistingCommonJS.json | 1631 --------- .../typeFromPropertyAssignmentOutOfOrder.ts | 2 +- .../tests/tsc/typeSatisfaction_js.json | 32 +- .../tests/tsc/typeSatisfaction_js.ts | 2 +- .../tsc/uniqueSymbolsDeclarationsInJs.json | 120 +- .../tsc/uniqueSymbolsDeclarationsInJs.ts | 2 +- .../uniqueSymbolsDeclarationsInJsErrors.json | 36 +- .../uniqueSymbolsDeclarationsInJsErrors.ts | 4 +- .../tsc/usingDeclarationsWithImportHelpers.ts | 2 +- .../tests/tsc/variadicTuples1.json | 58 +- .../tests/tsc/variadicTuples1.ts | 2 + crates/swc_ecma_parser/tests/typescript.rs | 8 +- .../tests/strip_correctness.rs | 3 + 278 files changed, 22323 insertions(+), 10197 deletions(-) create mode 100644 crates/swc/tests/tsc-references/ambientAccessors.1.normal.js create mode 100644 crates/swc/tests/tsc-references/ambientAccessors.2.minified.js create mode 100644 crates/swc/tests/tsc-references/controlFlowComputedPropertyNames.1.normal.js create mode 100644 crates/swc/tests/tsc-references/controlFlowComputedPropertyNames.2.minified.js create mode 100644 crates/swc/tests/tsc-references/errorIsolation.1.normal.js create mode 100644 crates/swc/tests/tsc-references/errorIsolation.2.minified.js create mode 100644 crates/swc/tests/tsc-references/esDecorators-decoratorExpression.1.1.normal.js create mode 100644 crates/swc/tests/tsc-references/esDecorators-decoratorExpression.1.2.minified.js create mode 100644 crates/swc/tests/tsc-references/esDecorators-decoratorExpression.2.1.normal.js create mode 100644 crates/swc/tests/tsc-references/esDecorators-decoratorExpression.2.2.minified.js create mode 100644 crates/swc/tests/tsc-references/importTag1.1.normal.js create mode 100644 crates/swc/tests/tsc-references/importTag1.2.minified.js create mode 100644 crates/swc/tests/tsc-references/importTag10.1.normal.js create mode 100644 crates/swc/tests/tsc-references/importTag10.2.minified.js create mode 100644 crates/swc/tests/tsc-references/importTag11.1.normal.js create mode 100644 crates/swc/tests/tsc-references/importTag11.2.minified.js create mode 100644 crates/swc/tests/tsc-references/importTag12.1.normal.js create mode 100644 crates/swc/tests/tsc-references/importTag12.2.minified.js create mode 100644 crates/swc/tests/tsc-references/importTag13.1.normal.js create mode 100644 crates/swc/tests/tsc-references/importTag13.2.minified.js create mode 100644 crates/swc/tests/tsc-references/importTag14.1.normal.js create mode 100644 crates/swc/tests/tsc-references/importTag14.2.minified.js create mode 100644 crates/swc/tests/tsc-references/importTag15.1.normal.js create mode 100644 crates/swc/tests/tsc-references/importTag15.2.minified.js create mode 100644 crates/swc/tests/tsc-references/importTag16.1.normal.js create mode 100644 crates/swc/tests/tsc-references/importTag16.2.minified.js create mode 100644 crates/swc/tests/tsc-references/importTag2.1.normal.js create mode 100644 crates/swc/tests/tsc-references/importTag2.2.minified.js create mode 100644 crates/swc/tests/tsc-references/importTag3.1.normal.js create mode 100644 crates/swc/tests/tsc-references/importTag3.2.minified.js create mode 100644 crates/swc/tests/tsc-references/importTag4.1.normal.js create mode 100644 crates/swc/tests/tsc-references/importTag4.2.minified.js create mode 100644 crates/swc/tests/tsc-references/importTag5.1.normal.js create mode 100644 crates/swc/tests/tsc-references/importTag5.2.minified.js create mode 100644 crates/swc/tests/tsc-references/importTag6.1.normal.js create mode 100644 crates/swc/tests/tsc-references/importTag6.2.minified.js create mode 100644 crates/swc/tests/tsc-references/importTag7.1.normal.js create mode 100644 crates/swc/tests/tsc-references/importTag7.2.minified.js create mode 100644 crates/swc/tests/tsc-references/importTag8.1.normal.js create mode 100644 crates/swc/tests/tsc-references/importTag8.2.minified.js create mode 100644 crates/swc/tests/tsc-references/importTag9.1.normal.js create mode 100644 crates/swc/tests/tsc-references/importTag9.2.minified.js create mode 100644 crates/swc/tests/tsc-references/intlDateTimeFormatRangeES2021.1.normal.js create mode 100644 crates/swc/tests/tsc-references/intlDateTimeFormatRangeES2021.2.minified.js create mode 100644 crates/swc/tests/tsc-references/intlNumberFormatES2020.1.normal.js create mode 100644 crates/swc/tests/tsc-references/intlNumberFormatES2020.2.minified.js create mode 100644 crates/swc/tests/tsc-references/intlNumberFormatES2023.1.normal.js create mode 100644 crates/swc/tests/tsc-references/intlNumberFormatES2023.2.minified.js create mode 100644 crates/swc/tests/tsc-references/intlNumberFormatES5UseGrouping.1.normal.js create mode 100644 crates/swc/tests/tsc-references/intlNumberFormatES5UseGrouping.2.minified.js create mode 100644 crates/swc/tests/tsc-references/mappedTypesGenericTuples2.1.normal.js create mode 100644 crates/swc/tests/tsc-references/mappedTypesGenericTuples2.2.minified.js create mode 100644 crates/swc/tests/tsc-references/parser.numericSeparators.decimal(target=es2020).1.normal.js create mode 100644 crates/swc/tests/tsc-references/parser.numericSeparators.decimal(target=es2020).2.minified.js create mode 100644 crates/swc/tests/tsc-references/parser.numericSeparators.decimal(target=es2021).1.normal.js create mode 100644 crates/swc/tests/tsc-references/parser.numericSeparators.decimal(target=es2021).2.minified.js create mode 100644 crates/swc/tests/tsc-references/parser.numericSeparators.decimal(target=es5).1.normal.js create mode 100644 crates/swc/tests/tsc-references/parser.numericSeparators.decimal(target=es5).2.minified.js create mode 100644 crates/swc/tests/tsc-references/parserArrowFunctionExpression10.1.normal.js create mode 100644 crates/swc/tests/tsc-references/parserArrowFunctionExpression10.2.minified.js create mode 100644 crates/swc/tests/tsc-references/parserArrowFunctionExpression11.1.normal.js create mode 100644 crates/swc/tests/tsc-references/parserArrowFunctionExpression11.2.minified.js create mode 100644 crates/swc/tests/tsc-references/parserArrowFunctionExpression12.1.normal.js create mode 100644 crates/swc/tests/tsc-references/parserArrowFunctionExpression12.2.minified.js create mode 100644 crates/swc/tests/tsc-references/parserArrowFunctionExpression13.1.normal.js create mode 100644 crates/swc/tests/tsc-references/parserArrowFunctionExpression13.2.minified.js create mode 100644 crates/swc/tests/tsc-references/parserArrowFunctionExpression14.1.normal.js create mode 100644 crates/swc/tests/tsc-references/parserArrowFunctionExpression14.2.minified.js create mode 100644 crates/swc/tests/tsc-references/parserArrowFunctionExpression15.1.normal.js create mode 100644 crates/swc/tests/tsc-references/parserArrowFunctionExpression15.2.minified.js create mode 100644 crates/swc/tests/tsc-references/parserArrowFunctionExpression16.1.normal.js create mode 100644 crates/swc/tests/tsc-references/parserArrowFunctionExpression16.2.minified.js create mode 100644 crates/swc/tests/tsc-references/parserArrowFunctionExpression17.1.normal.js create mode 100644 crates/swc/tests/tsc-references/parserArrowFunctionExpression17.2.minified.js create mode 100644 crates/swc/tests/tsc-references/parserArrowFunctionExpression8.1.normal.js create mode 100644 crates/swc/tests/tsc-references/parserArrowFunctionExpression8.2.minified.js create mode 100644 crates/swc/tests/tsc-references/parserArrowFunctionExpression9.1.normal.js create mode 100644 crates/swc/tests/tsc-references/parserArrowFunctionExpression9.2.minified.js create mode 100644 crates/swc/tests/tsc-references/privateNameES5Ban.1.normal.js create mode 100644 crates/swc/tests/tsc-references/privateNameES5Ban.2.minified.js create mode 100644 crates/swc/tests/tsc-references/spreadNonObject1.1.normal.js create mode 100644 crates/swc/tests/tsc-references/spreadNonObject1.2.minified.js create mode 100644 crates/swc/tests/tsc-references/templateLiteralTypes5.1.normal.js create mode 100644 crates/swc/tests/tsc-references/templateLiteralTypes5.2.minified.js create mode 100644 crates/swc/tests/tsc-references/templateLiteralTypes6.1.normal.js create mode 100644 crates/swc/tests/tsc-references/templateLiteralTypes6.2.minified.js create mode 100644 crates/swc/tests/tsc-references/templateLiteralTypes7.1.normal.js create mode 100644 crates/swc/tests/tsc-references/templateLiteralTypes7.2.minified.js delete mode 100644 crates/swc_ecma_parser/tests/tsc/accessorWithES3.json delete mode 100644 crates/swc_ecma_parser/tests/tsc/accessorWithES3.ts delete mode 100644 crates/swc_ecma_parser/tests/tsc/constructorDefaultValuesReferencingThis.json delete mode 100644 crates/swc_ecma_parser/tests/tsc/constructorDefaultValuesReferencingThis.ts create mode 100644 crates/swc_ecma_parser/tests/tsc/controlFlowComputedPropertyNames.json create mode 100644 crates/swc_ecma_parser/tests/tsc/controlFlowComputedPropertyNames.ts delete mode 100644 crates/swc_ecma_parser/tests/tsc/definePropertyOutputES3.json delete mode 100644 crates/swc_ecma_parser/tests/tsc/definePropertyOutputES3.ts create mode 100644 crates/swc_ecma_parser/tests/tsc/errorIsolation.json create mode 100644 crates/swc_ecma_parser/tests/tsc/errorIsolation.ts create mode 100644 crates/swc_ecma_parser/tests/tsc/esDecorators-decoratorExpression.1.ts create mode 100644 crates/swc_ecma_parser/tests/tsc/esDecorators-decoratorExpression.2.json create mode 100644 crates/swc_ecma_parser/tests/tsc/esDecorators-decoratorExpression.2.ts delete mode 100644 crates/swc_ecma_parser/tests/tsc/exportAndImport-es3-amd.json delete mode 100644 crates/swc_ecma_parser/tests/tsc/exportAndImport-es3-amd.ts delete mode 100644 crates/swc_ecma_parser/tests/tsc/exportAndImport-es3.json delete mode 100644 crates/swc_ecma_parser/tests/tsc/exportAndImport-es3.ts delete mode 100644 crates/swc_ecma_parser/tests/tsc/importCallExpressionAsyncES3AMD.json delete mode 100644 crates/swc_ecma_parser/tests/tsc/importCallExpressionAsyncES3AMD.ts delete mode 100644 crates/swc_ecma_parser/tests/tsc/importCallExpressionAsyncES3CJS.json delete mode 100644 crates/swc_ecma_parser/tests/tsc/importCallExpressionAsyncES3CJS.ts delete mode 100644 crates/swc_ecma_parser/tests/tsc/importCallExpressionAsyncES3System.json delete mode 100644 crates/swc_ecma_parser/tests/tsc/importCallExpressionAsyncES3System.ts delete mode 100644 crates/swc_ecma_parser/tests/tsc/importCallExpressionAsyncES3UMD.json delete mode 100644 crates/swc_ecma_parser/tests/tsc/importCallExpressionAsyncES3UMD.ts create mode 100644 crates/swc_ecma_parser/tests/tsc/importTag1.json create mode 100644 crates/swc_ecma_parser/tests/tsc/importTag1.ts create mode 100644 crates/swc_ecma_parser/tests/tsc/importTag10.json create mode 100644 crates/swc_ecma_parser/tests/tsc/importTag10.ts create mode 100644 crates/swc_ecma_parser/tests/tsc/importTag11.json create mode 100644 crates/swc_ecma_parser/tests/tsc/importTag11.ts create mode 100644 crates/swc_ecma_parser/tests/tsc/importTag12.json create mode 100644 crates/swc_ecma_parser/tests/tsc/importTag12.ts create mode 100644 crates/swc_ecma_parser/tests/tsc/importTag13.json create mode 100644 crates/swc_ecma_parser/tests/tsc/importTag13.ts create mode 100644 crates/swc_ecma_parser/tests/tsc/importTag14.json create mode 100644 crates/swc_ecma_parser/tests/tsc/importTag14.ts create mode 100644 crates/swc_ecma_parser/tests/tsc/importTag15.json create mode 100644 crates/swc_ecma_parser/tests/tsc/importTag15.ts create mode 100644 crates/swc_ecma_parser/tests/tsc/importTag16.json create mode 100644 crates/swc_ecma_parser/tests/tsc/importTag16.ts create mode 100644 crates/swc_ecma_parser/tests/tsc/importTag2.json create mode 100644 crates/swc_ecma_parser/tests/tsc/importTag2.ts create mode 100644 crates/swc_ecma_parser/tests/tsc/importTag3.json create mode 100644 crates/swc_ecma_parser/tests/tsc/importTag3.ts create mode 100644 crates/swc_ecma_parser/tests/tsc/importTag4.json create mode 100644 crates/swc_ecma_parser/tests/tsc/importTag4.ts create mode 100644 crates/swc_ecma_parser/tests/tsc/importTag5.json create mode 100644 crates/swc_ecma_parser/tests/tsc/importTag5.ts create mode 100644 crates/swc_ecma_parser/tests/tsc/importTag6.json create mode 100644 crates/swc_ecma_parser/tests/tsc/importTag6.ts create mode 100644 crates/swc_ecma_parser/tests/tsc/importTag7.json create mode 100644 crates/swc_ecma_parser/tests/tsc/importTag7.ts create mode 100644 crates/swc_ecma_parser/tests/tsc/importTag8.json create mode 100644 crates/swc_ecma_parser/tests/tsc/importTag8.ts create mode 100644 crates/swc_ecma_parser/tests/tsc/importTag9.json create mode 100644 crates/swc_ecma_parser/tests/tsc/importTag9.ts create mode 100644 crates/swc_ecma_parser/tests/tsc/intlDateTimeFormatRangeES2021.json create mode 100644 crates/swc_ecma_parser/tests/tsc/intlDateTimeFormatRangeES2021.ts create mode 100644 crates/swc_ecma_parser/tests/tsc/intlNumberFormatES2020.json create mode 100644 crates/swc_ecma_parser/tests/tsc/intlNumberFormatES2020.ts create mode 100644 crates/swc_ecma_parser/tests/tsc/intlNumberFormatES2023.json create mode 100644 crates/swc_ecma_parser/tests/tsc/intlNumberFormatES2023.ts create mode 100644 crates/swc_ecma_parser/tests/tsc/intlNumberFormatES5UseGrouping.json create mode 100644 crates/swc_ecma_parser/tests/tsc/intlNumberFormatES5UseGrouping.ts create mode 100644 crates/swc_ecma_parser/tests/tsc/jsdocLinkTag8.json create mode 100644 crates/swc_ecma_parser/tests/tsc/jsdocLinkTag8.ts create mode 100644 crates/swc_ecma_parser/tests/tsc/mappedTypesGenericTuples2.json create mode 100644 crates/swc_ecma_parser/tests/tsc/mappedTypesGenericTuples2.ts delete mode 100644 crates/swc_ecma_parser/tests/tsc/numberFormatCurrencySign.json delete mode 100644 crates/swc_ecma_parser/tests/tsc/numberFormatCurrencySign.ts delete mode 100644 crates/swc_ecma_parser/tests/tsc/numberFormatCurrencySignResolved.json delete mode 100644 crates/swc_ecma_parser/tests/tsc/numberFormatCurrencySignResolved.ts delete mode 100644 crates/swc_ecma_parser/tests/tsc/objectLiteralErrorsES3.json delete mode 100644 crates/swc_ecma_parser/tests/tsc/objectLiteralErrorsES3.ts create mode 100644 crates/swc_ecma_parser/tests/tsc/spreadNonObject1.json create mode 100644 crates/swc_ecma_parser/tests/tsc/spreadNonObject1.ts create mode 100644 crates/swc_ecma_parser/tests/tsc/templateLiteralTypes5.json create mode 100644 crates/swc_ecma_parser/tests/tsc/templateLiteralTypes5.ts create mode 100644 crates/swc_ecma_parser/tests/tsc/templateLiteralTypes6.json create mode 100644 crates/swc_ecma_parser/tests/tsc/templateLiteralTypes6.ts create mode 100644 crates/swc_ecma_parser/tests/tsc/templateLiteralTypes7.json create mode 100644 crates/swc_ecma_parser/tests/tsc/templateLiteralTypes7.ts delete mode 100644 crates/swc_ecma_parser/tests/tsc/topLevelVarHoistingCommonJS.json diff --git a/crates/swc/tests/tsc-references/ES3For-ofTypeCheck1.1.normal.js b/crates/swc/tests/tsc-references/ES3For-ofTypeCheck1.1.normal.js index 052496710c28..15156297eace 100644 --- a/crates/swc/tests/tsc-references/ES3For-ofTypeCheck1.1.normal.js +++ b/crates/swc/tests/tsc-references/ES3For-ofTypeCheck1.1.normal.js @@ -9,8 +9,8 @@ try { _iteratorError = err; } finally{ try { - if (!_iteratorNormalCompletion && _iterator["return"] != null) { - _iterator["return"](); + if (!_iteratorNormalCompletion && _iterator.return != null) { + _iterator.return(); } } finally{ if (_didIteratorError) { diff --git a/crates/swc/tests/tsc-references/ES3For-ofTypeCheck4.1.normal.js b/crates/swc/tests/tsc-references/ES3For-ofTypeCheck4.1.normal.js index 648d660a9eee..5bc56c910dfa 100644 --- a/crates/swc/tests/tsc-references/ES3For-ofTypeCheck4.1.normal.js +++ b/crates/swc/tests/tsc-references/ES3For-ofTypeCheck4.1.normal.js @@ -10,8 +10,8 @@ try { _iteratorError = err; } finally{ try { - if (!_iteratorNormalCompletion && _iterator["return"] != null) { - _iterator["return"](); + if (!_iteratorNormalCompletion && _iterator.return != null) { + _iterator.return(); } } finally{ if (_didIteratorError) { diff --git a/crates/swc/tests/tsc-references/ES3For-ofTypeCheck6.1.normal.js b/crates/swc/tests/tsc-references/ES3For-ofTypeCheck6.1.normal.js index 4d589b0bfa88..cebd57c37791 100644 --- a/crates/swc/tests/tsc-references/ES3For-ofTypeCheck6.1.normal.js +++ b/crates/swc/tests/tsc-references/ES3For-ofTypeCheck6.1.normal.js @@ -10,8 +10,8 @@ try { _iteratorError = err; } finally{ try { - if (!_iteratorNormalCompletion && _iterator["return"] != null) { - _iterator["return"](); + if (!_iteratorNormalCompletion && _iterator.return != null) { + _iterator.return(); } } finally{ if (_didIteratorError) { diff --git a/crates/swc/tests/tsc-references/ambientAccessors.1.normal.js b/crates/swc/tests/tsc-references/ambientAccessors.1.normal.js new file mode 100644 index 000000000000..1f89f7dee575 --- /dev/null +++ b/crates/swc/tests/tsc-references/ambientAccessors.1.normal.js @@ -0,0 +1,2 @@ +//// [ambientAccessors.ts] +// ok to use accessors in ambient class in ES3 diff --git a/crates/swc/tests/tsc-references/ambientAccessors.2.minified.js b/crates/swc/tests/tsc-references/ambientAccessors.2.minified.js new file mode 100644 index 000000000000..72a6075a8321 --- /dev/null +++ b/crates/swc/tests/tsc-references/ambientAccessors.2.minified.js @@ -0,0 +1 @@ +//// [ambientAccessors.ts] diff --git a/crates/swc/tests/tsc-references/controlFlowComputedPropertyNames.1.normal.js b/crates/swc/tests/tsc-references/controlFlowComputedPropertyNames.1.normal.js new file mode 100644 index 000000000000..0fcf61b515e8 --- /dev/null +++ b/crates/swc/tests/tsc-references/controlFlowComputedPropertyNames.1.normal.js @@ -0,0 +1,34 @@ +//// [controlFlowComputedPropertyNames.ts] +function f1(obj, key) { + if (typeof obj[key] === "string") { + obj[key].toUpperCase(); + } +} +function f2(obj, key) { + if (obj[key] !== undefined) { + obj[key].toUpperCase(); + } + var key2 = key + key; + if (obj[key2] !== undefined) { + obj[key2].toUpperCase(); + } + var key3 = key + key; + if (obj[key3] !== undefined) { + obj[key3].toUpperCase(); + } +} +function f3(obj, key) { + if (obj[key] !== undefined) { + if (typeof obj[key] === "string") { + obj[key].toUpperCase(); + } + if (typeof obj[key] === "number") { + obj[key].toFixed(); + } + } +} +function f4(obj, key) { + if (obj[key]) { + obj[key].toUpperCase(); + } +} diff --git a/crates/swc/tests/tsc-references/controlFlowComputedPropertyNames.2.minified.js b/crates/swc/tests/tsc-references/controlFlowComputedPropertyNames.2.minified.js new file mode 100644 index 000000000000..d30b31bc6714 --- /dev/null +++ b/crates/swc/tests/tsc-references/controlFlowComputedPropertyNames.2.minified.js @@ -0,0 +1 @@ +//// [controlFlowComputedPropertyNames.ts] diff --git a/crates/swc/tests/tsc-references/decoratorOnClassMethod11.1.normal.js b/crates/swc/tests/tsc-references/decoratorOnClassMethod11.1.normal.js index aa6e44323687..c58da50c3b29 100644 --- a/crates/swc/tests/tsc-references/decoratorOnClassMethod11.1.normal.js +++ b/crates/swc/tests/tsc-references/decoratorOnClassMethod11.1.normal.js @@ -14,6 +14,6 @@ var M; return C; }(); _ts_decorate([ - _this.decorator + this.decorator ], C.prototype, "method", null); })(M || (M = {})); diff --git a/crates/swc/tests/tsc-references/decoratorOnClassMethod11.2.minified.js b/crates/swc/tests/tsc-references/decoratorOnClassMethod11.2.minified.js index b1f4d4fc10b3..ccf5586923dd 100644 --- a/crates/swc/tests/tsc-references/decoratorOnClassMethod11.2.minified.js +++ b/crates/swc/tests/tsc-references/decoratorOnClassMethod11.2.minified.js @@ -1,13 +1,16 @@ //// [decoratorOnClassMethod11.ts] -var M, C; +var M; import { _ as _class_call_check } from "@swc/helpers/_/_class_call_check"; import { _ as _ts_decorate } from "@swc/helpers/_/_ts_decorate"; -M || (M = {}), C = function() { - function C() { - _class_call_check(this, C); - } - var _proto = C.prototype; - return _proto.decorator = function(target, key) {}, _proto.method = function() {}, C; -}(), _ts_decorate([ - _this.decorator -], C.prototype, "method", null); +!function(M) { + var C = function() { + function C() { + _class_call_check(this, C); + } + var _proto = C.prototype; + return _proto.decorator = function(target, key) {}, _proto.method = function() {}, C; + }(); + _ts_decorate([ + this.decorator + ], C.prototype, "method", null); +}(M || (M = {})); diff --git a/crates/swc/tests/tsc-references/decoratorOnClassMethod12.1.normal.js b/crates/swc/tests/tsc-references/decoratorOnClassMethod12.1.normal.js index d2b42c83835b..2644714bf671 100644 --- a/crates/swc/tests/tsc-references/decoratorOnClassMethod12.1.normal.js +++ b/crates/swc/tests/tsc-references/decoratorOnClassMethod12.1.normal.js @@ -1,13 +1,32 @@ //// [decoratorOnClassMethod12.ts] -//! -//! x Expected ident -//! ,-[3:1] -//! 3 | decorator(target: Object, key: string): void { } -//! 4 | } -//! 5 | class C extends S { -//! 6 | @super.decorator -//! : ^^^^^ -//! 7 | method() { } -//! 8 | } -//! 9 | } -//! `---- +import { _ as _class_call_check } from "@swc/helpers/_/_class_call_check"; +import { _ as _inherits } from "@swc/helpers/_/_inherits"; +import { _ as _create_super } from "@swc/helpers/_/_create_super"; +import { _ as _ts_decorate } from "@swc/helpers/_/_ts_decorate"; +var M; +(function(M) { + var S = /*#__PURE__*/ function() { + "use strict"; + function S() { + _class_call_check(this, S); + } + var _proto = S.prototype; + _proto.decorator = function decorator(target, key) {}; + return S; + }(); + var C = /*#__PURE__*/ function(S) { + "use strict"; + _inherits(C, S); + var _super = _create_super(C); + function C() { + _class_call_check(this, C); + return _super.apply(this, arguments); + } + var _proto = C.prototype; + _proto.method = function method() {}; + return C; + }(S); + _ts_decorate([ + super.decorator + ], C.prototype, "method", null); +})(M || (M = {})); diff --git a/crates/swc/tests/tsc-references/decoratorOnClassMethod12.2.minified.js b/crates/swc/tests/tsc-references/decoratorOnClassMethod12.2.minified.js index d2b42c83835b..cd29930ef76e 100644 --- a/crates/swc/tests/tsc-references/decoratorOnClassMethod12.2.minified.js +++ b/crates/swc/tests/tsc-references/decoratorOnClassMethod12.2.minified.js @@ -1,13 +1,21 @@ //// [decoratorOnClassMethod12.ts] -//! -//! x Expected ident -//! ,-[3:1] -//! 3 | decorator(target: Object, key: string): void { } -//! 4 | } -//! 5 | class C extends S { -//! 6 | @super.decorator -//! : ^^^^^ -//! 7 | method() { } -//! 8 | } -//! 9 | } -//! `---- +var M, C; +import { _ as _class_call_check } from "@swc/helpers/_/_class_call_check"; +import { _ as _inherits } from "@swc/helpers/_/_inherits"; +import { _ as _create_super } from "@swc/helpers/_/_create_super"; +import { _ as _ts_decorate } from "@swc/helpers/_/_ts_decorate"; +M || (M = {}), C = function(S) { + _inherits(C, S); + var _super = _create_super(C); + function C() { + return _class_call_check(this, C), _super.apply(this, arguments); + } + return C.prototype.method = function() {}, C; +}(function() { + function S() { + _class_call_check(this, S); + } + return S.prototype.decorator = function(target, key) {}, S; +}()), _ts_decorate([ + super.decorator +], C.prototype, "method", null); diff --git a/crates/swc/tests/tsc-references/errorIsolation.1.normal.js b/crates/swc/tests/tsc-references/errorIsolation.1.normal.js new file mode 100644 index 000000000000..423389c61945 --- /dev/null +++ b/crates/swc/tests/tsc-references/errorIsolation.1.normal.js @@ -0,0 +1,5 @@ +//// [errorIsolation.js] +var async = { + doSomething: function(_) {} +}; +async.doSomething(/***/ function() {}); diff --git a/crates/swc/tests/tsc-references/errorIsolation.2.minified.js b/crates/swc/tests/tsc-references/errorIsolation.2.minified.js new file mode 100644 index 000000000000..de9d795e844d --- /dev/null +++ b/crates/swc/tests/tsc-references/errorIsolation.2.minified.js @@ -0,0 +1,4 @@ +//// [errorIsolation.js] +({ + doSomething: function(_) {} +}).doSomething(function() {}); diff --git a/crates/swc/tests/tsc-references/es2018IntlAPIs.1.normal.js b/crates/swc/tests/tsc-references/es2018IntlAPIs.1.normal.js index 5a375d05e68b..49982d115b9a 100644 --- a/crates/swc/tests/tsc-references/es2018IntlAPIs.1.normal.js +++ b/crates/swc/tests/tsc-references/es2018IntlAPIs.1.normal.js @@ -10,3 +10,5 @@ const options = { localeMatcher: 'lookup' }; console.log(Intl.PluralRules.supportedLocalesOf(locales, options).join(', ')); +const [part] = new Intl.NumberFormat().formatToParts(); +console.log(part.type, part.value); diff --git a/crates/swc/tests/tsc-references/es2018IntlAPIs.2.minified.js b/crates/swc/tests/tsc-references/es2018IntlAPIs.2.minified.js index 1d353e68c16c..64e0f730b62b 100644 --- a/crates/swc/tests/tsc-references/es2018IntlAPIs.2.minified.js +++ b/crates/swc/tests/tsc-references/es2018IntlAPIs.2.minified.js @@ -6,3 +6,5 @@ console.log(Intl.PluralRules.supportedLocalesOf([ ], { localeMatcher: 'lookup' }).join(', ')); +const [part] = new Intl.NumberFormat().formatToParts(); +console.log(part.type, part.value); diff --git a/crates/swc/tests/tsc-references/esDecorators-decoratorExpression.1.1.normal.js b/crates/swc/tests/tsc-references/esDecorators-decoratorExpression.1.1.normal.js new file mode 100644 index 000000000000..ebc3ab8aa349 --- /dev/null +++ b/crates/swc/tests/tsc-references/esDecorators-decoratorExpression.1.1.normal.js @@ -0,0 +1,12 @@ +//// [esDecorators-decoratorExpression.1.ts] +//! +//! x Expression expected +//! ,-[1:1] +//! 1 | +//! 2 | declare let x: any; +//! 3 | +//! 4 | { @x().y class C {} } +//! : ^ +//! 5 | +//! 6 | { @new x class C {} } +//! `---- diff --git a/crates/swc/tests/tsc-references/esDecorators-decoratorExpression.1.2.minified.js b/crates/swc/tests/tsc-references/esDecorators-decoratorExpression.1.2.minified.js new file mode 100644 index 000000000000..ebc3ab8aa349 --- /dev/null +++ b/crates/swc/tests/tsc-references/esDecorators-decoratorExpression.1.2.minified.js @@ -0,0 +1,12 @@ +//// [esDecorators-decoratorExpression.1.ts] +//! +//! x Expression expected +//! ,-[1:1] +//! 1 | +//! 2 | declare let x: any; +//! 3 | +//! 4 | { @x().y class C {} } +//! : ^ +//! 5 | +//! 6 | { @new x class C {} } +//! `---- diff --git a/crates/swc/tests/tsc-references/esDecorators-decoratorExpression.2.1.normal.js b/crates/swc/tests/tsc-references/esDecorators-decoratorExpression.2.1.normal.js new file mode 100644 index 000000000000..075850ff4bcc --- /dev/null +++ b/crates/swc/tests/tsc-references/esDecorators-decoratorExpression.2.1.normal.js @@ -0,0 +1,12 @@ +//// [esDecorators-decoratorExpression.2.ts] +//! +//! x Expression expected +//! ,-[3:1] +//! 3 | declare let g: (...args: any) => any; +//! 4 | declare let h: () => (...args: any) => any; +//! 5 | +//! 6 | { @x! class C {} } +//! : ^ +//! 7 | +//! 8 | { @x.y! class C {} } +//! `---- diff --git a/crates/swc/tests/tsc-references/esDecorators-decoratorExpression.2.2.minified.js b/crates/swc/tests/tsc-references/esDecorators-decoratorExpression.2.2.minified.js new file mode 100644 index 000000000000..075850ff4bcc --- /dev/null +++ b/crates/swc/tests/tsc-references/esDecorators-decoratorExpression.2.2.minified.js @@ -0,0 +1,12 @@ +//// [esDecorators-decoratorExpression.2.ts] +//! +//! x Expression expected +//! ,-[3:1] +//! 3 | declare let g: (...args: any) => any; +//! 4 | declare let h: () => (...args: any) => any; +//! 5 | +//! 6 | { @x! class C {} } +//! : ^ +//! 7 | +//! 8 | { @x.y! class C {} } +//! `---- diff --git a/crates/swc/tests/tsc-references/exportsAndImportsWithUnderscores2.1.normal.js b/crates/swc/tests/tsc-references/exportsAndImportsWithUnderscores2.1.normal.js index 3ca90d11ab45..295b0abb947e 100644 --- a/crates/swc/tests/tsc-references/exportsAndImportsWithUnderscores2.1.normal.js +++ b/crates/swc/tests/tsc-references/exportsAndImportsWithUnderscores2.1.normal.js @@ -13,8 +13,8 @@ Object.defineProperty(exports, "default", { }); var R; var _default = R = { - __esmodule: true, - __proto__: {} + "__esmodule": true, + "__proto__": {} }; //// [m2.ts] "use strict"; diff --git a/crates/swc/tests/tsc-references/exportsAndImportsWithUnderscores3.1.normal.js b/crates/swc/tests/tsc-references/exportsAndImportsWithUnderscores3.1.normal.js index 47bce16cea69..790fd75c6ed6 100644 --- a/crates/swc/tests/tsc-references/exportsAndImportsWithUnderscores3.1.normal.js +++ b/crates/swc/tests/tsc-references/exportsAndImportsWithUnderscores3.1.normal.js @@ -13,9 +13,9 @@ Object.defineProperty(exports, "default", { }); var R; var _default = R = { - ___: 30, - ___hello: 21, - _hi: 40 + "___": 30, + "___hello": 21, + "_hi": 40 }; //// [m2.ts] "use strict"; diff --git a/crates/swc/tests/tsc-references/importTag1.1.normal.js b/crates/swc/tests/tsc-references/importTag1.1.normal.js new file mode 100644 index 000000000000..d3b7d448e327 --- /dev/null +++ b/crates/swc/tests/tsc-references/importTag1.1.normal.js @@ -0,0 +1,9 @@ +//// [importTag1.ts] +//// [/types.ts] +export { }; +//// [/foo.js] +/** + * @import { Foo } from "./types" + */ /** + * @param { Foo } foo + */ function f(foo) {} diff --git a/crates/swc/tests/tsc-references/importTag1.2.minified.js b/crates/swc/tests/tsc-references/importTag1.2.minified.js new file mode 100644 index 000000000000..ee5b39618056 --- /dev/null +++ b/crates/swc/tests/tsc-references/importTag1.2.minified.js @@ -0,0 +1,4 @@ +//// [importTag1.ts] +//// [/types.ts] +export { }; +//// [/foo.js] diff --git a/crates/swc/tests/tsc-references/importTag10.1.normal.js b/crates/swc/tests/tsc-references/importTag10.1.normal.js new file mode 100644 index 000000000000..83d09921ec70 --- /dev/null +++ b/crates/swc/tests/tsc-references/importTag10.1.normal.js @@ -0,0 +1,5 @@ +//// [importTag10.ts] +//// [/foo.js] +/** + * @import + */ diff --git a/crates/swc/tests/tsc-references/importTag10.2.minified.js b/crates/swc/tests/tsc-references/importTag10.2.minified.js new file mode 100644 index 000000000000..e56a75fdd757 --- /dev/null +++ b/crates/swc/tests/tsc-references/importTag10.2.minified.js @@ -0,0 +1,2 @@ +//// [importTag10.ts] +//// [/foo.js] diff --git a/crates/swc/tests/tsc-references/importTag11.1.normal.js b/crates/swc/tests/tsc-references/importTag11.1.normal.js new file mode 100644 index 000000000000..7cbe3cf2ebef --- /dev/null +++ b/crates/swc/tests/tsc-references/importTag11.1.normal.js @@ -0,0 +1,5 @@ +//// [importTag11.ts] +//// [/foo.js] +/** + * @import foo + */ diff --git a/crates/swc/tests/tsc-references/importTag11.2.minified.js b/crates/swc/tests/tsc-references/importTag11.2.minified.js new file mode 100644 index 000000000000..4c39d1a03d8e --- /dev/null +++ b/crates/swc/tests/tsc-references/importTag11.2.minified.js @@ -0,0 +1,2 @@ +//// [importTag11.ts] +//// [/foo.js] diff --git a/crates/swc/tests/tsc-references/importTag12.1.normal.js b/crates/swc/tests/tsc-references/importTag12.1.normal.js new file mode 100644 index 000000000000..7e6926a004ab --- /dev/null +++ b/crates/swc/tests/tsc-references/importTag12.1.normal.js @@ -0,0 +1,5 @@ +//// [importTag12.ts] +//// [/foo.js] +/** + * @import foo from + */ diff --git a/crates/swc/tests/tsc-references/importTag12.2.minified.js b/crates/swc/tests/tsc-references/importTag12.2.minified.js new file mode 100644 index 000000000000..5cc1657cf0a7 --- /dev/null +++ b/crates/swc/tests/tsc-references/importTag12.2.minified.js @@ -0,0 +1,2 @@ +//// [importTag12.ts] +//// [/foo.js] diff --git a/crates/swc/tests/tsc-references/importTag13.1.normal.js b/crates/swc/tests/tsc-references/importTag13.1.normal.js new file mode 100644 index 000000000000..d1c6edd34a9b --- /dev/null +++ b/crates/swc/tests/tsc-references/importTag13.1.normal.js @@ -0,0 +1,5 @@ +//// [importTag13.ts] +//// [/types.ts] +export { }; +//// [/foo.js] +/** @import x = require("types") */ diff --git a/crates/swc/tests/tsc-references/importTag13.2.minified.js b/crates/swc/tests/tsc-references/importTag13.2.minified.js new file mode 100644 index 000000000000..d34dedf7f2f6 --- /dev/null +++ b/crates/swc/tests/tsc-references/importTag13.2.minified.js @@ -0,0 +1,4 @@ +//// [importTag13.ts] +//// [/types.ts] +export { }; +//// [/foo.js] diff --git a/crates/swc/tests/tsc-references/importTag14.1.normal.js b/crates/swc/tests/tsc-references/importTag14.1.normal.js new file mode 100644 index 000000000000..facf85a6ae68 --- /dev/null +++ b/crates/swc/tests/tsc-references/importTag14.1.normal.js @@ -0,0 +1,3 @@ +//// [importTag14.ts] +//// [/foo.js] +/** @import * as f from "./foo" with */ diff --git a/crates/swc/tests/tsc-references/importTag14.2.minified.js b/crates/swc/tests/tsc-references/importTag14.2.minified.js new file mode 100644 index 000000000000..c2928e07d122 --- /dev/null +++ b/crates/swc/tests/tsc-references/importTag14.2.minified.js @@ -0,0 +1,2 @@ +//// [importTag14.ts] +//// [/foo.js] diff --git a/crates/swc/tests/tsc-references/importTag15.1.normal.js b/crates/swc/tests/tsc-references/importTag15.1.normal.js new file mode 100644 index 000000000000..b5dca2ca3d59 --- /dev/null +++ b/crates/swc/tests/tsc-references/importTag15.1.normal.js @@ -0,0 +1,5 @@ +//// [importTag15.ts] +//// [0.ts] +export { }; +//// [1.js] +/** @import { I } from './0' with { type: "json" } */ /** @import * as foo from './0' with { type: "json" } */ /** @param {I} a */ function f(a) {} diff --git a/crates/swc/tests/tsc-references/importTag15.2.minified.js b/crates/swc/tests/tsc-references/importTag15.2.minified.js new file mode 100644 index 000000000000..fd0b7ddcb178 --- /dev/null +++ b/crates/swc/tests/tsc-references/importTag15.2.minified.js @@ -0,0 +1,4 @@ +//// [importTag15.ts] +//// [0.ts] +export { }; +//// [1.js] diff --git a/crates/swc/tests/tsc-references/importTag16.1.normal.js b/crates/swc/tests/tsc-references/importTag16.1.normal.js new file mode 100644 index 000000000000..8697085bcc0d --- /dev/null +++ b/crates/swc/tests/tsc-references/importTag16.1.normal.js @@ -0,0 +1,8 @@ +//// [importTag16.ts] +//// [a.ts] +export { }; +//// [b.js] +/** @import Foo, { I } from "./a" */ /** + * @param {Foo} a + * @param {I} b + */ export function foo(a, b) {} diff --git a/crates/swc/tests/tsc-references/importTag16.2.minified.js b/crates/swc/tests/tsc-references/importTag16.2.minified.js new file mode 100644 index 000000000000..03592d47d9b8 --- /dev/null +++ b/crates/swc/tests/tsc-references/importTag16.2.minified.js @@ -0,0 +1,5 @@ +//// [importTag16.ts] +//// [a.ts] +export { }; +//// [b.js] +export function foo(a, b) {} diff --git a/crates/swc/tests/tsc-references/importTag2.1.normal.js b/crates/swc/tests/tsc-references/importTag2.1.normal.js new file mode 100644 index 000000000000..55e29b80ce9e --- /dev/null +++ b/crates/swc/tests/tsc-references/importTag2.1.normal.js @@ -0,0 +1,9 @@ +//// [importTag2.ts] +//// [/types.ts] +export { }; +//// [/foo.js] +/** + * @import * as types from "./types" + */ /** + * @param { types.Foo } foo + */ export function f(foo) {} diff --git a/crates/swc/tests/tsc-references/importTag2.2.minified.js b/crates/swc/tests/tsc-references/importTag2.2.minified.js new file mode 100644 index 000000000000..b15a0150fbb9 --- /dev/null +++ b/crates/swc/tests/tsc-references/importTag2.2.minified.js @@ -0,0 +1,5 @@ +//// [importTag2.ts] +//// [/types.ts] +export { }; +//// [/foo.js] +export function f(foo) {} diff --git a/crates/swc/tests/tsc-references/importTag3.1.normal.js b/crates/swc/tests/tsc-references/importTag3.1.normal.js new file mode 100644 index 000000000000..b44d352ee17e --- /dev/null +++ b/crates/swc/tests/tsc-references/importTag3.1.normal.js @@ -0,0 +1,9 @@ +//// [importTag3.ts] +//// [/types.ts] +export { }; +//// [/foo.js] +/** + * @import Foo from "./types" + */ /** + * @param { Foo } foo + */ export function f(foo) {} diff --git a/crates/swc/tests/tsc-references/importTag3.2.minified.js b/crates/swc/tests/tsc-references/importTag3.2.minified.js new file mode 100644 index 000000000000..5c8c013ecd35 --- /dev/null +++ b/crates/swc/tests/tsc-references/importTag3.2.minified.js @@ -0,0 +1,5 @@ +//// [importTag3.ts] +//// [/types.ts] +export { }; +//// [/foo.js] +export function f(foo) {} diff --git a/crates/swc/tests/tsc-references/importTag4.1.normal.js b/crates/swc/tests/tsc-references/importTag4.1.normal.js new file mode 100644 index 000000000000..c6e8de4e1fe7 --- /dev/null +++ b/crates/swc/tests/tsc-references/importTag4.1.normal.js @@ -0,0 +1,11 @@ +//// [importTag4.ts] +//// [/types.ts] +export { }; +//// [/foo.js] +/** + * @import { Foo } from "./types" + */ /** + * @import { Foo } from "./types" + */ /** + * @param { Foo } foo + */ function f(foo) {} diff --git a/crates/swc/tests/tsc-references/importTag4.2.minified.js b/crates/swc/tests/tsc-references/importTag4.2.minified.js new file mode 100644 index 000000000000..b55d3d3f5ac8 --- /dev/null +++ b/crates/swc/tests/tsc-references/importTag4.2.minified.js @@ -0,0 +1,4 @@ +//// [importTag4.ts] +//// [/types.ts] +export { }; +//// [/foo.js] diff --git a/crates/swc/tests/tsc-references/importTag5.1.normal.js b/crates/swc/tests/tsc-references/importTag5.1.normal.js new file mode 100644 index 000000000000..15354a7faa76 --- /dev/null +++ b/crates/swc/tests/tsc-references/importTag5.1.normal.js @@ -0,0 +1,9 @@ +//// [importTag5.ts] +//// [/types.ts] +export { }; +//// [/foo.js] +/** + * @import { Foo } from "./types" + */ /** + * @param { Foo } foo + */ function f(foo) {} diff --git a/crates/swc/tests/tsc-references/importTag5.2.minified.js b/crates/swc/tests/tsc-references/importTag5.2.minified.js new file mode 100644 index 000000000000..ed1e0d73fa9d --- /dev/null +++ b/crates/swc/tests/tsc-references/importTag5.2.minified.js @@ -0,0 +1,4 @@ +//// [importTag5.ts] +//// [/types.ts] +export { }; +//// [/foo.js] diff --git a/crates/swc/tests/tsc-references/importTag6.1.normal.js b/crates/swc/tests/tsc-references/importTag6.1.normal.js new file mode 100644 index 000000000000..03149342778a --- /dev/null +++ b/crates/swc/tests/tsc-references/importTag6.1.normal.js @@ -0,0 +1,13 @@ +//// [importTag6.ts] +//// [/types.ts] +export { }; +//// [/foo.js] +/** + * @import { + * A, + * B, + * } from "./types" + */ /** + * @param { A } a + * @param { B } b + */ function f(a, b) {} diff --git a/crates/swc/tests/tsc-references/importTag6.2.minified.js b/crates/swc/tests/tsc-references/importTag6.2.minified.js new file mode 100644 index 000000000000..2b24e4af5271 --- /dev/null +++ b/crates/swc/tests/tsc-references/importTag6.2.minified.js @@ -0,0 +1,4 @@ +//// [importTag6.ts] +//// [/types.ts] +export { }; +//// [/foo.js] diff --git a/crates/swc/tests/tsc-references/importTag7.1.normal.js b/crates/swc/tests/tsc-references/importTag7.1.normal.js new file mode 100644 index 000000000000..b37333799c57 --- /dev/null +++ b/crates/swc/tests/tsc-references/importTag7.1.normal.js @@ -0,0 +1,12 @@ +//// [importTag7.ts] +//// [/types.ts] +export { }; +//// [/foo.js] +/** + * @import { + * A, + * B } from "./types" + */ /** + * @param { A } a + * @param { B } b + */ function f(a, b) {} diff --git a/crates/swc/tests/tsc-references/importTag7.2.minified.js b/crates/swc/tests/tsc-references/importTag7.2.minified.js new file mode 100644 index 000000000000..4a737048d4d1 --- /dev/null +++ b/crates/swc/tests/tsc-references/importTag7.2.minified.js @@ -0,0 +1,4 @@ +//// [importTag7.ts] +//// [/types.ts] +export { }; +//// [/foo.js] diff --git a/crates/swc/tests/tsc-references/importTag8.1.normal.js b/crates/swc/tests/tsc-references/importTag8.1.normal.js new file mode 100644 index 000000000000..cc2cbf77b453 --- /dev/null +++ b/crates/swc/tests/tsc-references/importTag8.1.normal.js @@ -0,0 +1,12 @@ +//// [importTag8.ts] +//// [/types.ts] +export { }; +//// [/foo.js] +/** + * @import + * { A, B } + * from "./types" + */ /** + * @param { A } a + * @param { B } b + */ function f(a, b) {} diff --git a/crates/swc/tests/tsc-references/importTag8.2.minified.js b/crates/swc/tests/tsc-references/importTag8.2.minified.js new file mode 100644 index 000000000000..e87362f00c9f --- /dev/null +++ b/crates/swc/tests/tsc-references/importTag8.2.minified.js @@ -0,0 +1,4 @@ +//// [importTag8.ts] +//// [/types.ts] +export { }; +//// [/foo.js] diff --git a/crates/swc/tests/tsc-references/importTag9.1.normal.js b/crates/swc/tests/tsc-references/importTag9.1.normal.js new file mode 100644 index 000000000000..ee0d5b816f56 --- /dev/null +++ b/crates/swc/tests/tsc-references/importTag9.1.normal.js @@ -0,0 +1,12 @@ +//// [importTag9.ts] +//// [/types.ts] +export { }; +//// [/foo.js] +/** + * @import + * * as types + * from "./types" + */ /** + * @param { types.A } a + * @param { types.B } b + */ function f(a, b) {} diff --git a/crates/swc/tests/tsc-references/importTag9.2.minified.js b/crates/swc/tests/tsc-references/importTag9.2.minified.js new file mode 100644 index 000000000000..0f7f96782606 --- /dev/null +++ b/crates/swc/tests/tsc-references/importTag9.2.minified.js @@ -0,0 +1,4 @@ +//// [importTag9.ts] +//// [/types.ts] +export { }; +//// [/foo.js] diff --git a/crates/swc/tests/tsc-references/instanceofOperatorWithRHSHasSymbolHasInstance.1.normal.js b/crates/swc/tests/tsc-references/instanceofOperatorWithRHSHasSymbolHasInstance.1.normal.js index 5e2ed17ea24a..3bcd60e9060a 100644 --- a/crates/swc/tests/tsc-references/instanceofOperatorWithRHSHasSymbolHasInstance.1.normal.js +++ b/crates/swc/tests/tsc-references/instanceofOperatorWithRHSHasSymbolHasInstance.1.normal.js @@ -63,3 +63,5 @@ if (obj instanceof A) { if (obj instanceof B) { obj; // B } +lhs0 instanceof rhs14 && lhs0; +lhs0 instanceof rhs15 && lhs0; diff --git a/crates/swc/tests/tsc-references/instanceofOperatorWithRHSHasSymbolHasInstance.2.minified.js b/crates/swc/tests/tsc-references/instanceofOperatorWithRHSHasSymbolHasInstance.2.minified.js index 1bb1e9c2d019..003bae624f97 100644 --- a/crates/swc/tests/tsc-references/instanceofOperatorWithRHSHasSymbolHasInstance.2.minified.js +++ b/crates/swc/tests/tsc-references/instanceofOperatorWithRHSHasSymbolHasInstance.2.minified.js @@ -1,2 +1,2 @@ //// [instanceofOperatorWithRHSHasSymbolHasInstance.ts] -lhs0 instanceof rhs0 && lhs0, lhs0 instanceof rhs1 && lhs0, lhs0 instanceof rhs2 && lhs0, lhs0 instanceof rhs3 && lhs0, lhs0 instanceof rhs4 && lhs0, lhs0 instanceof rhs5 && lhs0, lhs0 instanceof rhs6 && lhs0, lhs0 instanceof Rhs7 && lhs0, lhs0 instanceof Rhs8 && lhs0, lhs0 instanceof Rhs9 && lhs0, lhs0 instanceof Rhs10 && lhs0, lhs0 instanceof Rhs11 && lhs0, lhs0 instanceof Rhs12 && lhs0, lhs0 instanceof Rhs13 && lhs0, lhs1 instanceof rhs0 && lhs1, lhs1 instanceof rhs1 && lhs1, lhs1 instanceof rhs2 && lhs1, lhs1 instanceof Rhs7 && lhs1, lhs1 instanceof Rhs8 && lhs1, lhs1 instanceof Rhs9 && lhs1, lhs2 instanceof rhs0 && lhs2, lhs2 instanceof rhs1 && lhs2, lhs2 instanceof rhs2 && lhs2, lhs2 instanceof rhs3 && lhs2, lhs2 instanceof rhs4 && lhs2, lhs2 instanceof rhs5 && lhs2, lhs2 instanceof Rhs7 && lhs2, lhs2 instanceof Rhs8 && lhs2, lhs2 instanceof Rhs9 && lhs2, lhs2 instanceof Rhs10 && lhs2, lhs2 instanceof Rhs11 && lhs2, lhs2 instanceof Rhs12 && lhs2, lhs3 instanceof rhs0 && lhs3, lhs3 instanceof rhs1 && lhs3, lhs3 instanceof rhs2 && lhs3, lhs3 instanceof rhs3 && lhs3, lhs3 instanceof rhs4 && lhs3, lhs3 instanceof rhs5 && lhs3, lhs3 instanceof rhs6 && lhs3, lhs3 instanceof Rhs7 && lhs3, lhs3 instanceof Rhs8 && lhs3, lhs3 instanceof Rhs9 && lhs3, lhs3 instanceof Rhs10 && lhs3, lhs3 instanceof Rhs11 && lhs3, lhs3 instanceof Rhs12 && lhs3, lhs3 instanceof Rhs13 && lhs3, lhs4 instanceof rhs0 && lhs4, lhs4 instanceof rhs1 && lhs4, lhs4 instanceof rhs2 && lhs4, lhs4 instanceof rhs3 && lhs4, lhs4 instanceof rhs4 && lhs4, lhs4 instanceof rhs5 && lhs4, lhs4 instanceof Rhs7 && lhs4, lhs4 instanceof Rhs8 && lhs4, lhs4 instanceof Rhs9 && lhs4, lhs4 instanceof Rhs10 && lhs4, lhs4 instanceof Rhs11 && lhs4, lhs4 instanceof Rhs12 && lhs4, obj instanceof A && obj, obj instanceof B && obj; +lhs0 instanceof rhs0 && lhs0, lhs0 instanceof rhs1 && lhs0, lhs0 instanceof rhs2 && lhs0, lhs0 instanceof rhs3 && lhs0, lhs0 instanceof rhs4 && lhs0, lhs0 instanceof rhs5 && lhs0, lhs0 instanceof rhs6 && lhs0, lhs0 instanceof Rhs7 && lhs0, lhs0 instanceof Rhs8 && lhs0, lhs0 instanceof Rhs9 && lhs0, lhs0 instanceof Rhs10 && lhs0, lhs0 instanceof Rhs11 && lhs0, lhs0 instanceof Rhs12 && lhs0, lhs0 instanceof Rhs13 && lhs0, lhs1 instanceof rhs0 && lhs1, lhs1 instanceof rhs1 && lhs1, lhs1 instanceof rhs2 && lhs1, lhs1 instanceof Rhs7 && lhs1, lhs1 instanceof Rhs8 && lhs1, lhs1 instanceof Rhs9 && lhs1, lhs2 instanceof rhs0 && lhs2, lhs2 instanceof rhs1 && lhs2, lhs2 instanceof rhs2 && lhs2, lhs2 instanceof rhs3 && lhs2, lhs2 instanceof rhs4 && lhs2, lhs2 instanceof rhs5 && lhs2, lhs2 instanceof Rhs7 && lhs2, lhs2 instanceof Rhs8 && lhs2, lhs2 instanceof Rhs9 && lhs2, lhs2 instanceof Rhs10 && lhs2, lhs2 instanceof Rhs11 && lhs2, lhs2 instanceof Rhs12 && lhs2, lhs3 instanceof rhs0 && lhs3, lhs3 instanceof rhs1 && lhs3, lhs3 instanceof rhs2 && lhs3, lhs3 instanceof rhs3 && lhs3, lhs3 instanceof rhs4 && lhs3, lhs3 instanceof rhs5 && lhs3, lhs3 instanceof rhs6 && lhs3, lhs3 instanceof Rhs7 && lhs3, lhs3 instanceof Rhs8 && lhs3, lhs3 instanceof Rhs9 && lhs3, lhs3 instanceof Rhs10 && lhs3, lhs3 instanceof Rhs11 && lhs3, lhs3 instanceof Rhs12 && lhs3, lhs3 instanceof Rhs13 && lhs3, lhs4 instanceof rhs0 && lhs4, lhs4 instanceof rhs1 && lhs4, lhs4 instanceof rhs2 && lhs4, lhs4 instanceof rhs3 && lhs4, lhs4 instanceof rhs4 && lhs4, lhs4 instanceof rhs5 && lhs4, lhs4 instanceof Rhs7 && lhs4, lhs4 instanceof Rhs8 && lhs4, lhs4 instanceof Rhs9 && lhs4, lhs4 instanceof Rhs10 && lhs4, lhs4 instanceof Rhs11 && lhs4, lhs4 instanceof Rhs12 && lhs4, obj instanceof A && obj, obj instanceof B && obj, lhs0 instanceof rhs14 && lhs0, lhs0 instanceof rhs15 && lhs0; diff --git a/crates/swc/tests/tsc-references/intlDateTimeFormatRangeES2021.1.normal.js b/crates/swc/tests/tsc-references/intlDateTimeFormatRangeES2021.1.normal.js new file mode 100644 index 000000000000..6122cf5ca14e --- /dev/null +++ b/crates/swc/tests/tsc-references/intlDateTimeFormatRangeES2021.1.normal.js @@ -0,0 +1,4 @@ +//// [intlDateTimeFormatRangeES2021.ts] +import { _ as _sliced_to_array } from "@swc/helpers/_/_sliced_to_array"; +new Intl.DateTimeFormat().formatRange(new Date(0), new Date()); +var _formatRangeToParts = _sliced_to_array(new Intl.DateTimeFormat().formatRangeToParts(1000, 1000000000), 1), part = _formatRangeToParts[0]; diff --git a/crates/swc/tests/tsc-references/intlDateTimeFormatRangeES2021.2.minified.js b/crates/swc/tests/tsc-references/intlDateTimeFormatRangeES2021.2.minified.js new file mode 100644 index 000000000000..ec0b809c3998 --- /dev/null +++ b/crates/swc/tests/tsc-references/intlDateTimeFormatRangeES2021.2.minified.js @@ -0,0 +1,3 @@ +//// [intlDateTimeFormatRangeES2021.ts] +import { _ as _sliced_to_array } from "@swc/helpers/_/_sliced_to_array"; +new Intl.DateTimeFormat().formatRange(new Date(0), new Date()), _sliced_to_array(new Intl.DateTimeFormat().formatRangeToParts(1000, 1000000000), 1)[0]; diff --git a/crates/swc/tests/tsc-references/intlNumberFormatES2020.1.normal.js b/crates/swc/tests/tsc-references/intlNumberFormatES2020.1.normal.js new file mode 100644 index 000000000000..a0efb6a2d818 --- /dev/null +++ b/crates/swc/tests/tsc-references/intlNumberFormatES2020.1.normal.js @@ -0,0 +1,36 @@ +//// [intlNumberFormatES2020.ts] +// New/updated resolved options in ES2020 +const { notation, style, signDisplay } = new Intl.NumberFormat('en-NZ').resolvedOptions(); +// Empty options +new Intl.NumberFormat('en-NZ', {}); +// Override numbering system +new Intl.NumberFormat('en-NZ', { + numberingSystem: 'arab' +}); +// Currency +const { currency, currencySign } = new Intl.NumberFormat('en-NZ', { + style: 'currency', + currency: 'NZD', + currencySign: 'accounting' +}).resolvedOptions(); +// Units +const { unit, unitDisplay } = new Intl.NumberFormat('en-NZ', { + style: 'unit', + unit: 'kilogram', + unitDisplay: 'narrow' +}).resolvedOptions(); +// Compact +const { compactDisplay } = new Intl.NumberFormat('en-NZ', { + notation: 'compact', + compactDisplay: 'long' +}).resolvedOptions(); +// Sign display +new Intl.NumberFormat('en-NZ', { + signDisplay: 'always' +}); +// New additions to NumberFormatPartTypes +const types = [ + 'compact', + 'unit', + 'unknown' +]; diff --git a/crates/swc/tests/tsc-references/intlNumberFormatES2020.2.minified.js b/crates/swc/tests/tsc-references/intlNumberFormatES2020.2.minified.js new file mode 100644 index 000000000000..603a129016bb --- /dev/null +++ b/crates/swc/tests/tsc-references/intlNumberFormatES2020.2.minified.js @@ -0,0 +1,20 @@ +//// [intlNumberFormatES2020.ts] +const { notation, style, signDisplay } = new Intl.NumberFormat('en-NZ').resolvedOptions(); +new Intl.NumberFormat('en-NZ', {}), new Intl.NumberFormat('en-NZ', { + numberingSystem: 'arab' +}); +const { currency, currencySign } = new Intl.NumberFormat('en-NZ', { + style: 'currency', + currency: 'NZD', + currencySign: 'accounting' +}).resolvedOptions(), { unit, unitDisplay } = new Intl.NumberFormat('en-NZ', { + style: 'unit', + unit: 'kilogram', + unitDisplay: 'narrow' +}).resolvedOptions(), { compactDisplay } = new Intl.NumberFormat('en-NZ', { + notation: 'compact', + compactDisplay: 'long' +}).resolvedOptions(); +new Intl.NumberFormat('en-NZ', { + signDisplay: 'always' +}); diff --git a/crates/swc/tests/tsc-references/intlNumberFormatES2023.1.normal.js b/crates/swc/tests/tsc-references/intlNumberFormatES2023.1.normal.js new file mode 100644 index 000000000000..61f5ecb37790 --- /dev/null +++ b/crates/swc/tests/tsc-references/intlNumberFormatES2023.1.normal.js @@ -0,0 +1,37 @@ +//// [intlNumberFormatES2023.ts] +// New / updated resolved options in ES2023, including type change for useGrouping +const { roundingPriority, roundingMode, roundingIncrement, trailingZeroDisplay, useGrouping } = new Intl.NumberFormat('en-GB').resolvedOptions(); +// Empty options +new Intl.NumberFormat('en-GB', {}); +// Rounding +new Intl.NumberFormat('en-GB', { + roundingPriority: 'lessPrecision', + roundingIncrement: 100, + roundingMode: 'trunc' +}); +// Changes to signDisplay +const { signDisplay } = new Intl.NumberFormat('en-GB', { + signDisplay: 'negative' +}).resolvedOptions(); +// Changes to useGrouping +new Intl.NumberFormat('en-GB', { + useGrouping: true +}); +new Intl.NumberFormat('en-GB', { + useGrouping: 'true' +}); +new Intl.NumberFormat('en-GB', { + useGrouping: 'always' +}); +// formatRange +new Intl.NumberFormat('en-GB').formatRange(10, 100); +new Intl.NumberFormat('en-GB').formatRange(10n, 1000n); +new Intl.NumberFormat('en-GB').formatRangeToParts(10, 1000)[0]; +new Intl.NumberFormat('en-GB').formatRangeToParts(10n, 1000n)[0]; +// Arbitrary-precision string arguments +new Intl.NumberFormat('en-GB').format('-12.3E-4'); +new Intl.NumberFormat('en-GB').formatRange('123.4', '567.8'); +new Intl.NumberFormat('en-GB').formatRangeToParts('123E-4', '567E8'); +new Intl.NumberFormat('en-GB').format('Infinity'); +new Intl.NumberFormat('en-GB').format('-Infinity'); +new Intl.NumberFormat('en-GB').format('+Infinity'); diff --git a/crates/swc/tests/tsc-references/intlNumberFormatES2023.2.minified.js b/crates/swc/tests/tsc-references/intlNumberFormatES2023.2.minified.js new file mode 100644 index 000000000000..7020deaaa3c3 --- /dev/null +++ b/crates/swc/tests/tsc-references/intlNumberFormatES2023.2.minified.js @@ -0,0 +1,17 @@ +//// [intlNumberFormatES2023.ts] +const { roundingPriority, roundingMode, roundingIncrement, trailingZeroDisplay, useGrouping } = new Intl.NumberFormat('en-GB').resolvedOptions(); +new Intl.NumberFormat('en-GB', {}), new Intl.NumberFormat('en-GB', { + roundingPriority: 'lessPrecision', + roundingIncrement: 100, + roundingMode: 'trunc' +}); +const { signDisplay } = new Intl.NumberFormat('en-GB', { + signDisplay: 'negative' +}).resolvedOptions(); +new Intl.NumberFormat('en-GB', { + useGrouping: !0 +}), new Intl.NumberFormat('en-GB', { + useGrouping: 'true' +}), new Intl.NumberFormat('en-GB', { + useGrouping: 'always' +}), new Intl.NumberFormat('en-GB').formatRange(10, 100), new Intl.NumberFormat('en-GB').formatRange(10n, 1000n), new Intl.NumberFormat('en-GB').formatRangeToParts(10, 1000)[0], new Intl.NumberFormat('en-GB').formatRangeToParts(10n, 1000n)[0], new Intl.NumberFormat('en-GB').format('-12.3E-4'), new Intl.NumberFormat('en-GB').formatRange('123.4', '567.8'), new Intl.NumberFormat('en-GB').formatRangeToParts('123E-4', '567E8'), new Intl.NumberFormat('en-GB').format('Infinity'), new Intl.NumberFormat('en-GB').format('-Infinity'), new Intl.NumberFormat('en-GB').format('+Infinity'); diff --git a/crates/swc/tests/tsc-references/intlNumberFormatES5UseGrouping.1.normal.js b/crates/swc/tests/tsc-references/intlNumberFormatES5UseGrouping.1.normal.js new file mode 100644 index 000000000000..97294df9f709 --- /dev/null +++ b/crates/swc/tests/tsc-references/intlNumberFormatES5UseGrouping.1.normal.js @@ -0,0 +1,11 @@ +//// [intlNumberFormatES5UseGrouping.ts] +new Intl.NumberFormat("en-GB", { + useGrouping: true +}); +new Intl.NumberFormat("en-GB", { + useGrouping: "true" +}); // expect error +new Intl.NumberFormat("en-GB", { + useGrouping: "always" +}); // expect error +var useGrouping = new Intl.NumberFormat("en-GB").resolvedOptions().useGrouping; diff --git a/crates/swc/tests/tsc-references/intlNumberFormatES5UseGrouping.2.minified.js b/crates/swc/tests/tsc-references/intlNumberFormatES5UseGrouping.2.minified.js new file mode 100644 index 000000000000..db0f4a2441e4 --- /dev/null +++ b/crates/swc/tests/tsc-references/intlNumberFormatES5UseGrouping.2.minified.js @@ -0,0 +1,8 @@ +//// [intlNumberFormatES5UseGrouping.ts] +new Intl.NumberFormat("en-GB", { + useGrouping: !0 +}), new Intl.NumberFormat("en-GB", { + useGrouping: "true" +}), new Intl.NumberFormat("en-GB", { + useGrouping: "always" +}), new Intl.NumberFormat("en-GB").resolvedOptions().useGrouping; diff --git a/crates/swc/tests/tsc-references/libReferenceDeclarationEmit.1.normal.js b/crates/swc/tests/tsc-references/libReferenceDeclarationEmit.1.normal.js index a6e719a8a2c9..25d23d45f6b1 100644 --- a/crates/swc/tests/tsc-references/libReferenceDeclarationEmit.1.normal.js +++ b/crates/swc/tests/tsc-references/libReferenceDeclarationEmit.1.normal.js @@ -1,11 +1,11 @@ //// [file1.ts] -/// +/// "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); //// [file2.ts] -/// +/// "use strict"; Object.defineProperty(exports, "__esModule", { value: true diff --git a/crates/swc/tests/tsc-references/libReferenceDeclarationEmitBundle.1.normal.js b/crates/swc/tests/tsc-references/libReferenceDeclarationEmitBundle.1.normal.js index 7b256d853251..d5b8c7c2721a 100644 --- a/crates/swc/tests/tsc-references/libReferenceDeclarationEmitBundle.1.normal.js +++ b/crates/swc/tests/tsc-references/libReferenceDeclarationEmitBundle.1.normal.js @@ -1,5 +1,5 @@ //// [file1.ts] -/// +/// define([ "require", "exports" @@ -10,7 +10,7 @@ define([ }); }); //// [file2.ts] -/// +/// define([ "require", "exports" diff --git a/crates/swc/tests/tsc-references/mappedTypesGenericTuples2.1.normal.js b/crates/swc/tests/tsc-references/mappedTypesGenericTuples2.1.normal.js new file mode 100644 index 000000000000..0c068df05270 --- /dev/null +++ b/crates/swc/tests/tsc-references/mappedTypesGenericTuples2.1.normal.js @@ -0,0 +1,10 @@ +//// [mappedTypesGenericTuples2.ts] +// https://github.com/microsoft/TypeScript/issues/57389 +import { _ as _to_consumable_array } from "@swc/helpers/_/_to_consumable_array"; +Promise.all([ + getT() +].concat(_to_consumable_array(getT()))).then(function(result) { + var head = result[0]; // string + var tail = result.slice(1); // any[] + tail; // ok +}); diff --git a/crates/swc/tests/tsc-references/mappedTypesGenericTuples2.2.minified.js b/crates/swc/tests/tsc-references/mappedTypesGenericTuples2.2.minified.js new file mode 100644 index 000000000000..047f69d219db --- /dev/null +++ b/crates/swc/tests/tsc-references/mappedTypesGenericTuples2.2.minified.js @@ -0,0 +1,7 @@ +//// [mappedTypesGenericTuples2.ts] +import { _ as _to_consumable_array } from "@swc/helpers/_/_to_consumable_array"; +Promise.all([ + getT() +].concat(_to_consumable_array(getT()))).then(function(result) { + result[0], result.slice(1); +}); diff --git a/crates/swc/tests/tsc-references/parser.numericSeparators.decimal(target=es2020).1.normal.js b/crates/swc/tests/tsc-references/parser.numericSeparators.decimal(target=es2020).1.normal.js new file mode 100644 index 000000000000..59c6429aea79 --- /dev/null +++ b/crates/swc/tests/tsc-references/parser.numericSeparators.decimal(target=es2020).1.normal.js @@ -0,0 +1,15 @@ +//// [parser.numericSeparators.decimal.ts] +1000000000; +1.10001; +1e10; +1e+10; +1e-10; +1.1e100; +1.1e+100; +1.1e-100; +123456; +122333; +12.34; +12.34e56; +12.34e+56; +12.34e-56; diff --git a/crates/swc/tests/tsc-references/parser.numericSeparators.decimal(target=es2020).2.minified.js b/crates/swc/tests/tsc-references/parser.numericSeparators.decimal(target=es2020).2.minified.js new file mode 100644 index 000000000000..47f5aa77bef2 --- /dev/null +++ b/crates/swc/tests/tsc-references/parser.numericSeparators.decimal(target=es2020).2.minified.js @@ -0,0 +1 @@ +//// [parser.numericSeparators.decimal.ts] diff --git a/crates/swc/tests/tsc-references/parser.numericSeparators.decimal(target=es2021).1.normal.js b/crates/swc/tests/tsc-references/parser.numericSeparators.decimal(target=es2021).1.normal.js new file mode 100644 index 000000000000..971089834e3f --- /dev/null +++ b/crates/swc/tests/tsc-references/parser.numericSeparators.decimal(target=es2021).1.normal.js @@ -0,0 +1,15 @@ +//// [parser.numericSeparators.decimal.ts] +1_000_000_000; +1.1_00_01; +1e1_0; +1e+1_0; +1e-1_0; +1.1e10_0; +1.1e+10_0; +1.1e-10_0; +12_34_56; +1_22_333; +1_2.3_4; +1_2.3_4e5_6; +1_2.3_4e+5_6; +1_2.3_4e-5_6; diff --git a/crates/swc/tests/tsc-references/parser.numericSeparators.decimal(target=es2021).2.minified.js b/crates/swc/tests/tsc-references/parser.numericSeparators.decimal(target=es2021).2.minified.js new file mode 100644 index 000000000000..47f5aa77bef2 --- /dev/null +++ b/crates/swc/tests/tsc-references/parser.numericSeparators.decimal(target=es2021).2.minified.js @@ -0,0 +1 @@ +//// [parser.numericSeparators.decimal.ts] diff --git a/crates/swc/tests/tsc-references/parser.numericSeparators.decimal(target=es5).1.normal.js b/crates/swc/tests/tsc-references/parser.numericSeparators.decimal(target=es5).1.normal.js new file mode 100644 index 000000000000..59c6429aea79 --- /dev/null +++ b/crates/swc/tests/tsc-references/parser.numericSeparators.decimal(target=es5).1.normal.js @@ -0,0 +1,15 @@ +//// [parser.numericSeparators.decimal.ts] +1000000000; +1.10001; +1e10; +1e+10; +1e-10; +1.1e100; +1.1e+100; +1.1e-100; +123456; +122333; +12.34; +12.34e56; +12.34e+56; +12.34e-56; diff --git a/crates/swc/tests/tsc-references/parser.numericSeparators.decimal(target=es5).2.minified.js b/crates/swc/tests/tsc-references/parser.numericSeparators.decimal(target=es5).2.minified.js new file mode 100644 index 000000000000..47f5aa77bef2 --- /dev/null +++ b/crates/swc/tests/tsc-references/parser.numericSeparators.decimal(target=es5).2.minified.js @@ -0,0 +1 @@ +//// [parser.numericSeparators.decimal.ts] diff --git a/crates/swc/tests/tsc-references/parserArrowFunctionExpression10.1.normal.js b/crates/swc/tests/tsc-references/parserArrowFunctionExpression10.1.normal.js new file mode 100644 index 000000000000..9120f0eeaa5e --- /dev/null +++ b/crates/swc/tests/tsc-references/parserArrowFunctionExpression10.1.normal.js @@ -0,0 +1,7 @@ +//// [parserArrowFunctionExpression10.ts] +//// [fileJs.js] +a ? (b)=>d : (e)=>f // Not legal JS; "Unexpected token ':'" at last colon + // Not legal JS; "Unexpected token ':'" at last colon +; +//// [fileTs.ts] +a ? (b)=>d : (e)=>f; diff --git a/crates/swc/tests/tsc-references/parserArrowFunctionExpression10.2.minified.js b/crates/swc/tests/tsc-references/parserArrowFunctionExpression10.2.minified.js new file mode 100644 index 000000000000..55a0a8c14a76 --- /dev/null +++ b/crates/swc/tests/tsc-references/parserArrowFunctionExpression10.2.minified.js @@ -0,0 +1,5 @@ +//// [parserArrowFunctionExpression10.ts] +//// [fileJs.js] +a || ((e)=>f); +//// [fileTs.ts] +a || ((e)=>f); diff --git a/crates/swc/tests/tsc-references/parserArrowFunctionExpression11.1.normal.js b/crates/swc/tests/tsc-references/parserArrowFunctionExpression11.1.normal.js new file mode 100644 index 000000000000..630a2b0eaf29 --- /dev/null +++ b/crates/swc/tests/tsc-references/parserArrowFunctionExpression11.1.normal.js @@ -0,0 +1,16 @@ +//// [parserArrowFunctionExpression11.ts] +//// [fileJs.js] +//! +//! x Expected ':', got '' +//! ,-[1:1] +//! 1 | a ? b ? c : (d) : e => f // Legal JS +//! : ^ +//! 2 | +//! `---- +//// [fileTs.ts] +//! +//! x Expected ':', got '' +//! ,---- +//! 1 | a ? b ? c : (d) : e => f +//! : ^ +//! `---- diff --git a/crates/swc/tests/tsc-references/parserArrowFunctionExpression11.2.minified.js b/crates/swc/tests/tsc-references/parserArrowFunctionExpression11.2.minified.js new file mode 100644 index 000000000000..630a2b0eaf29 --- /dev/null +++ b/crates/swc/tests/tsc-references/parserArrowFunctionExpression11.2.minified.js @@ -0,0 +1,16 @@ +//// [parserArrowFunctionExpression11.ts] +//// [fileJs.js] +//! +//! x Expected ':', got '' +//! ,-[1:1] +//! 1 | a ? b ? c : (d) : e => f // Legal JS +//! : ^ +//! 2 | +//! `---- +//// [fileTs.ts] +//! +//! x Expected ':', got '' +//! ,---- +//! 1 | a ? b ? c : (d) : e => f +//! : ^ +//! `---- diff --git a/crates/swc/tests/tsc-references/parserArrowFunctionExpression12.1.normal.js b/crates/swc/tests/tsc-references/parserArrowFunctionExpression12.1.normal.js new file mode 100644 index 000000000000..3e44c07136ab --- /dev/null +++ b/crates/swc/tests/tsc-references/parserArrowFunctionExpression12.1.normal.js @@ -0,0 +1,7 @@ +//// [parserArrowFunctionExpression12.ts] +//// [fileJs.js] +a ? (b)=>c : (d)=>e // Legal JS + // Legal JS +; +//// [fileTs.ts] +a ? (b)=>c : (d)=>e; diff --git a/crates/swc/tests/tsc-references/parserArrowFunctionExpression12.2.minified.js b/crates/swc/tests/tsc-references/parserArrowFunctionExpression12.2.minified.js new file mode 100644 index 000000000000..3db81a70b451 --- /dev/null +++ b/crates/swc/tests/tsc-references/parserArrowFunctionExpression12.2.minified.js @@ -0,0 +1,5 @@ +//// [parserArrowFunctionExpression12.ts] +//// [fileJs.js] +a || ((d)=>e); +//// [fileTs.ts] +a || ((d)=>e); diff --git a/crates/swc/tests/tsc-references/parserArrowFunctionExpression13.1.normal.js b/crates/swc/tests/tsc-references/parserArrowFunctionExpression13.1.normal.js new file mode 100644 index 000000000000..66c4ed550982 --- /dev/null +++ b/crates/swc/tests/tsc-references/parserArrowFunctionExpression13.1.normal.js @@ -0,0 +1,5 @@ +//// [parserArrowFunctionExpression13.ts] +//// [fileJs.js] +a ? ()=>a() : ()=>null; // Not legal JS; "Unexpected token ')'" at last paren +//// [fileTs.ts] +a ? ()=>a() : ()=>null; diff --git a/crates/swc/tests/tsc-references/parserArrowFunctionExpression13.2.minified.js b/crates/swc/tests/tsc-references/parserArrowFunctionExpression13.2.minified.js new file mode 100644 index 000000000000..1d5876994726 --- /dev/null +++ b/crates/swc/tests/tsc-references/parserArrowFunctionExpression13.2.minified.js @@ -0,0 +1,5 @@ +//// [parserArrowFunctionExpression13.ts] +//// [fileJs.js] +a || (()=>null); +//// [fileTs.ts] +a || (()=>null); diff --git a/crates/swc/tests/tsc-references/parserArrowFunctionExpression14.1.normal.js b/crates/swc/tests/tsc-references/parserArrowFunctionExpression14.1.normal.js new file mode 100644 index 000000000000..c790b5016466 --- /dev/null +++ b/crates/swc/tests/tsc-references/parserArrowFunctionExpression14.1.normal.js @@ -0,0 +1,5 @@ +//// [parserArrowFunctionExpression14.ts] +//// [fileJs.js] +a() ? (b, c)=>d() : e; // Not legal JS; "Unexpected token ':'" at first colon +//// [fileTs.ts] +a() ? (b, c)=>d() : e; diff --git a/crates/swc/tests/tsc-references/parserArrowFunctionExpression14.2.minified.js b/crates/swc/tests/tsc-references/parserArrowFunctionExpression14.2.minified.js new file mode 100644 index 000000000000..a5ac086615ea --- /dev/null +++ b/crates/swc/tests/tsc-references/parserArrowFunctionExpression14.2.minified.js @@ -0,0 +1,5 @@ +//// [parserArrowFunctionExpression14.ts] +//// [fileJs.js] +a() || e; +//// [fileTs.ts] +a() || e; diff --git a/crates/swc/tests/tsc-references/parserArrowFunctionExpression15.1.normal.js b/crates/swc/tests/tsc-references/parserArrowFunctionExpression15.1.normal.js new file mode 100644 index 000000000000..ff216a6d741b --- /dev/null +++ b/crates/swc/tests/tsc-references/parserArrowFunctionExpression15.1.normal.js @@ -0,0 +1,6 @@ +//// [parserArrowFunctionExpression15.ts] +//// [fileJs.js] +false ? (param)=>param : null // Not legal JS; "Unexpected token ':'" at last colon +; +//// [fileTs.ts] +false ? (param)=>param : null; diff --git a/crates/swc/tests/tsc-references/parserArrowFunctionExpression15.2.minified.js b/crates/swc/tests/tsc-references/parserArrowFunctionExpression15.2.minified.js new file mode 100644 index 000000000000..1e82829ffcae --- /dev/null +++ b/crates/swc/tests/tsc-references/parserArrowFunctionExpression15.2.minified.js @@ -0,0 +1,3 @@ +//// [parserArrowFunctionExpression15.ts] +//// [fileJs.js] +//// [fileTs.ts] diff --git a/crates/swc/tests/tsc-references/parserArrowFunctionExpression16.1.normal.js b/crates/swc/tests/tsc-references/parserArrowFunctionExpression16.1.normal.js new file mode 100644 index 000000000000..b8e84a8b22dc --- /dev/null +++ b/crates/swc/tests/tsc-references/parserArrowFunctionExpression16.1.normal.js @@ -0,0 +1,6 @@ +//// [parserArrowFunctionExpression16.ts] +//// [fileJs.js] +true ? false ? (param)=>param : null : null // Not legal JS; "Unexpected token ':'" at last colon +; +//// [fileTs.ts] +true ? false ? (param)=>param : null : null; diff --git a/crates/swc/tests/tsc-references/parserArrowFunctionExpression16.2.minified.js b/crates/swc/tests/tsc-references/parserArrowFunctionExpression16.2.minified.js new file mode 100644 index 000000000000..8de23efa2a3c --- /dev/null +++ b/crates/swc/tests/tsc-references/parserArrowFunctionExpression16.2.minified.js @@ -0,0 +1,3 @@ +//// [parserArrowFunctionExpression16.ts] +//// [fileJs.js] +//// [fileTs.ts] diff --git a/crates/swc/tests/tsc-references/parserArrowFunctionExpression17.1.normal.js b/crates/swc/tests/tsc-references/parserArrowFunctionExpression17.1.normal.js new file mode 100644 index 000000000000..d5d624018e29 --- /dev/null +++ b/crates/swc/tests/tsc-references/parserArrowFunctionExpression17.1.normal.js @@ -0,0 +1,6 @@ +//// [parserArrowFunctionExpression17.ts] +//// [fileJs.js] +a ? b : (c)=>e // Not legal JS; "Unexpected token ':'" at last colon +; +//// [fileTs.ts] +a ? b : (c)=>e; diff --git a/crates/swc/tests/tsc-references/parserArrowFunctionExpression17.2.minified.js b/crates/swc/tests/tsc-references/parserArrowFunctionExpression17.2.minified.js new file mode 100644 index 000000000000..877ccd114c47 --- /dev/null +++ b/crates/swc/tests/tsc-references/parserArrowFunctionExpression17.2.minified.js @@ -0,0 +1,5 @@ +//// [parserArrowFunctionExpression17.ts] +//// [fileJs.js] +a && b; +//// [fileTs.ts] +a && b; diff --git a/crates/swc/tests/tsc-references/parserArrowFunctionExpression8.1.normal.js b/crates/swc/tests/tsc-references/parserArrowFunctionExpression8.1.normal.js new file mode 100644 index 000000000000..1830b5928d32 --- /dev/null +++ b/crates/swc/tests/tsc-references/parserArrowFunctionExpression8.1.normal.js @@ -0,0 +1,15 @@ +//// [parserArrowFunctionExpression8.ts] +//// [fileJs.js] +x ? (y)=>({ + y + }) : (z)=>({ + z + } // Legal JS + // Legal JS + ); +//// [fileTs.ts] +x ? (y)=>({ + y + }) : (z)=>({ + z + }); diff --git a/crates/swc/tests/tsc-references/parserArrowFunctionExpression8.2.minified.js b/crates/swc/tests/tsc-references/parserArrowFunctionExpression8.2.minified.js new file mode 100644 index 000000000000..cf6b319eaf18 --- /dev/null +++ b/crates/swc/tests/tsc-references/parserArrowFunctionExpression8.2.minified.js @@ -0,0 +1,9 @@ +//// [parserArrowFunctionExpression8.ts] +//// [fileJs.js] +x || ((z)=>({ + z + })); +//// [fileTs.ts] +x || ((z)=>({ + z + })); diff --git a/crates/swc/tests/tsc-references/parserArrowFunctionExpression9.1.normal.js b/crates/swc/tests/tsc-references/parserArrowFunctionExpression9.1.normal.js new file mode 100644 index 000000000000..922e889b1458 --- /dev/null +++ b/crates/swc/tests/tsc-references/parserArrowFunctionExpression9.1.normal.js @@ -0,0 +1,7 @@ +//// [parserArrowFunctionExpression9.ts] +//// [fileJs.js] +b ? c : (d)=>e // Legal JS + // Legal JS +; +//// [fileTs.ts] +b ? c : (d)=>e; diff --git a/crates/swc/tests/tsc-references/parserArrowFunctionExpression9.2.minified.js b/crates/swc/tests/tsc-references/parserArrowFunctionExpression9.2.minified.js new file mode 100644 index 000000000000..93bd42f0712e --- /dev/null +++ b/crates/swc/tests/tsc-references/parserArrowFunctionExpression9.2.minified.js @@ -0,0 +1,5 @@ +//// [parserArrowFunctionExpression9.ts] +//// [fileJs.js] +b && c; +//// [fileTs.ts] +b && c; diff --git a/crates/swc/tests/tsc-references/privateNameES5Ban.1.normal.js b/crates/swc/tests/tsc-references/privateNameES5Ban.1.normal.js new file mode 100644 index 000000000000..22bf837baaa7 --- /dev/null +++ b/crates/swc/tests/tsc-references/privateNameES5Ban.1.normal.js @@ -0,0 +1,38 @@ +//// [privateNameES5Ban.ts] +import { _ as _class_call_check } from "@swc/helpers/_/_class_call_check"; +import { _ as _class_private_field_init } from "@swc/helpers/_/_class_private_field_init"; +import { _ as _class_private_field_set } from "@swc/helpers/_/_class_private_field_set"; +import { _ as _class_private_method_init } from "@swc/helpers/_/_class_private_method_init"; +var _field = /*#__PURE__*/ new WeakMap(), _method = /*#__PURE__*/ new WeakSet(), _acc = /*#__PURE__*/ new WeakMap(); +var A = function A() { + "use strict"; + _class_call_check(this, A); + _class_private_method_init(this, _method); + _class_private_field_init(this, _acc, { + get: get_acc, + set: set_acc + }); + _class_private_field_init(this, _field, { + writable: true, + value: void 0 + }); + _class_private_field_set(this, _field, 123); +}; +var _sAcc = { + get: get_sAcc, + set: set_sAcc +}; +var _sField = { + writable: true, + value: "hello world" +}; +function method() {} +function sMethod() {} +function get_acc() { + return ""; +} +function set_acc(x) {} +function get_sAcc() { + return 0; +} +function set_sAcc(x) {} diff --git a/crates/swc/tests/tsc-references/privateNameES5Ban.2.minified.js b/crates/swc/tests/tsc-references/privateNameES5Ban.2.minified.js new file mode 100644 index 000000000000..12f711897b5f --- /dev/null +++ b/crates/swc/tests/tsc-references/privateNameES5Ban.2.minified.js @@ -0,0 +1,5 @@ +//// [privateNameES5Ban.ts] +import "@swc/helpers/_/_class_call_check"; +import "@swc/helpers/_/_class_private_field_init"; +import "@swc/helpers/_/_class_private_field_set"; +import "@swc/helpers/_/_class_private_method_init"; diff --git a/crates/swc/tests/tsc-references/spreadNonObject1.1.normal.js b/crates/swc/tests/tsc-references/spreadNonObject1.1.normal.js new file mode 100644 index 000000000000..25a8eeb414e8 --- /dev/null +++ b/crates/swc/tests/tsc-references/spreadNonObject1.1.normal.js @@ -0,0 +1,13 @@ +//// [spreadNonObject1.ts] +// https://github.com/microsoft/TypeScript/issues/45493 +import { _ as _object_spread } from "@swc/helpers/_/_object_spread"; +import { _ as _object_spread_props } from "@swc/helpers/_/_object_spread_props"; +var b = { + c: [ + "4" + ].map(function(s) { + var a = _object_spread_props(_object_spread({}, s), { + y: 6 + }); + }) +}; diff --git a/crates/swc/tests/tsc-references/spreadNonObject1.2.minified.js b/crates/swc/tests/tsc-references/spreadNonObject1.2.minified.js new file mode 100644 index 000000000000..6d0ede3a5713 --- /dev/null +++ b/crates/swc/tests/tsc-references/spreadNonObject1.2.minified.js @@ -0,0 +1,10 @@ +//// [spreadNonObject1.ts] +import { _ as _object_spread } from "@swc/helpers/_/_object_spread"; +import { _ as _object_spread_props } from "@swc/helpers/_/_object_spread_props"; +[ + "4" +].map(function(s) { + _object_spread_props(_object_spread({}, s), { + y: 6 + }); +}); diff --git a/crates/swc/tests/tsc-references/templateLiteralTypes5.1.normal.js b/crates/swc/tests/tsc-references/templateLiteralTypes5.1.normal.js new file mode 100644 index 000000000000..b1ed7654a674 --- /dev/null +++ b/crates/swc/tests/tsc-references/templateLiteralTypes5.1.normal.js @@ -0,0 +1,8 @@ +//// [templateLiteralTypes5.ts] +// https://github.com/microsoft/TypeScript/issues/55364 +const f1 = f; +const f2 = f; +function f3(x) { + const test1 = x; + const test2 = ""; +} diff --git a/crates/swc/tests/tsc-references/templateLiteralTypes5.2.minified.js b/crates/swc/tests/tsc-references/templateLiteralTypes5.2.minified.js new file mode 100644 index 000000000000..51dc93488a5d --- /dev/null +++ b/crates/swc/tests/tsc-references/templateLiteralTypes5.2.minified.js @@ -0,0 +1,2 @@ +//// [templateLiteralTypes5.ts] +f, f; diff --git a/crates/swc/tests/tsc-references/templateLiteralTypes6.1.normal.js b/crates/swc/tests/tsc-references/templateLiteralTypes6.1.normal.js new file mode 100644 index 000000000000..837be90a7c6b --- /dev/null +++ b/crates/swc/tests/tsc-references/templateLiteralTypes6.1.normal.js @@ -0,0 +1,5 @@ +//// [templateLiteralTypes6.ts] +// https://github.com/microsoft/TypeScript/issues/56659 +function f2(scope, event) { + f1(`${scope}:${event}`); +} diff --git a/crates/swc/tests/tsc-references/templateLiteralTypes6.2.minified.js b/crates/swc/tests/tsc-references/templateLiteralTypes6.2.minified.js new file mode 100644 index 000000000000..d1bdf58060c2 --- /dev/null +++ b/crates/swc/tests/tsc-references/templateLiteralTypes6.2.minified.js @@ -0,0 +1 @@ +//// [templateLiteralTypes6.ts] diff --git a/crates/swc/tests/tsc-references/templateLiteralTypes7.1.normal.js b/crates/swc/tests/tsc-references/templateLiteralTypes7.1.normal.js new file mode 100644 index 000000000000..23213ef967db --- /dev/null +++ b/crates/swc/tests/tsc-references/templateLiteralTypes7.1.normal.js @@ -0,0 +1,5 @@ +//// [templateLiteralTypes7.ts] +// https://github.com/microsoft/TypeScript/issues/57807 +const g1 = g; // ok +const g2 = g; // error +const g3 = g; // ok diff --git a/crates/swc/tests/tsc-references/templateLiteralTypes7.2.minified.js b/crates/swc/tests/tsc-references/templateLiteralTypes7.2.minified.js new file mode 100644 index 000000000000..f1f19ee7a0f9 --- /dev/null +++ b/crates/swc/tests/tsc-references/templateLiteralTypes7.2.minified.js @@ -0,0 +1,2 @@ +//// [templateLiteralTypes7.ts] +g, g, g; diff --git a/crates/swc/tests/tsc-references/templateStringMultiline3.1.normal.js b/crates/swc/tests/tsc-references/templateStringMultiline3.1.normal.js index a6dcc059a4cc..c58859469643 100644 --- a/crates/swc/tests/tsc-references/templateStringMultiline3.1.normal.js +++ b/crates/swc/tests/tsc-references/templateStringMultiline3.1.normal.js @@ -1,3 +1,2 @@ //// [templateStringMultiline3.ts] -// newlines are -"\n"; +// newlines are `\` diff --git a/crates/swc_ecma_parser/tests/tsc/1.0lib-noErrors.ts b/crates/swc_ecma_parser/tests/tsc/1.0lib-noErrors.ts index 74f6bd28043e..49d8e03877fb 100644 --- a/crates/swc_ecma_parser/tests/tsc/1.0lib-noErrors.ts +++ b/crates/swc_ecma_parser/tests/tsc/1.0lib-noErrors.ts @@ -661,7 +661,7 @@ interface Date { getMilliseconds(): number; /** Gets the milliseconds of a Date object using Universal Coordinated Time (UTC). */ getUTCMilliseconds(): number; - /** Gets the difference in minutes between the time on the local computer and Universal Coordinated Time (UTC). */ + /** Gets the difference in minutes between Universal Coordinated Time (UTC) and the time on the local computer. */ getTimezoneOffset(): number; /** * Sets the date and time value in the Date object. @@ -1141,4 +1141,4 @@ declare var Array: { (...items: T[]): T[]; isArray(arg: any): boolean; prototype: Array; -} \ No newline at end of file +} \ No newline at end of file diff --git a/crates/swc_ecma_parser/tests/tsc/ES3For-ofTypeCheck1.ts b/crates/swc_ecma_parser/tests/tsc/ES3For-ofTypeCheck1.ts index cf410a8d307b..3a2c2ec82e44 100644 --- a/crates/swc_ecma_parser/tests/tsc/ES3For-ofTypeCheck1.ts +++ b/crates/swc_ecma_parser/tests/tsc/ES3For-ofTypeCheck1.ts @@ -1,2 +1,2 @@ -//@target: ES3 +//@target: ES5 for (var v of "") { } \ No newline at end of file diff --git a/crates/swc_ecma_parser/tests/tsc/ES3For-ofTypeCheck2.ts b/crates/swc_ecma_parser/tests/tsc/ES3For-ofTypeCheck2.ts index 3598e70e92af..cb8563ed4e7f 100644 --- a/crates/swc_ecma_parser/tests/tsc/ES3For-ofTypeCheck2.ts +++ b/crates/swc_ecma_parser/tests/tsc/ES3For-ofTypeCheck2.ts @@ -1,2 +1,2 @@ -//@target: ES3 +//@target: ES5 for (var v of [true]) { } \ No newline at end of file diff --git a/crates/swc_ecma_parser/tests/tsc/ES3For-ofTypeCheck4.ts b/crates/swc_ecma_parser/tests/tsc/ES3For-ofTypeCheck4.ts index 34a55aedc0c1..489216c92623 100644 --- a/crates/swc_ecma_parser/tests/tsc/ES3For-ofTypeCheck4.ts +++ b/crates/swc_ecma_parser/tests/tsc/ES3For-ofTypeCheck4.ts @@ -1,3 +1,3 @@ -//@target: ES3 +//@target: ES5 var union: string | string[]; for (const v of union) { } \ No newline at end of file diff --git a/crates/swc_ecma_parser/tests/tsc/ES3For-ofTypeCheck6.ts b/crates/swc_ecma_parser/tests/tsc/ES3For-ofTypeCheck6.ts index 2d0a4b72dece..9ad18ae02b0e 100644 --- a/crates/swc_ecma_parser/tests/tsc/ES3For-ofTypeCheck6.ts +++ b/crates/swc_ecma_parser/tests/tsc/ES3For-ofTypeCheck6.ts @@ -1,3 +1,3 @@ -//@target: ES3 +//@target: ES5 var union: string[] | number[]; for (var v of union) { } \ No newline at end of file diff --git a/crates/swc_ecma_parser/tests/tsc/accessorWithES3.json b/crates/swc_ecma_parser/tests/tsc/accessorWithES3.json deleted file mode 100644 index 46ab643a6282..000000000000 --- a/crates/swc_ecma_parser/tests/tsc/accessorWithES3.json +++ /dev/null @@ -1,367 +0,0 @@ -{ - "type": "Script", - "span": { - "start": 57, - "end": 208, - "ctxt": 0 - }, - "body": [ - { - "type": "ClassDeclaration", - "identifier": { - "type": "Identifier", - "span": { - "start": 63, - "end": 64, - "ctxt": 0 - }, - "value": "C", - "optional": false - }, - "declare": false, - "span": { - "start": 57, - "end": 106, - "ctxt": 0 - }, - "decorators": [], - "body": [ - { - "type": "ClassMethod", - "span": { - "start": 71, - "end": 104, - "ctxt": 0 - }, - "key": { - "type": "Identifier", - "span": { - "start": 75, - "end": 76, - "ctxt": 0 - }, - "value": "x", - "optional": false - }, - "function": { - "params": [], - "decorators": [], - "span": { - "start": 71, - "end": 104, - "ctxt": 0 - }, - "body": { - "type": "BlockStatement", - "span": { - "start": 79, - "end": 104, - "ctxt": 0 - }, - "stmts": [ - { - "type": "ReturnStatement", - "span": { - "start": 89, - "end": 98, - "ctxt": 0 - }, - "argument": { - "type": "NumericLiteral", - "span": { - "start": 96, - "end": 97, - "ctxt": 0 - }, - "value": 1.0, - "raw": "1" - } - } - ] - }, - "generator": false, - "async": false, - "typeParameters": null, - "returnType": null - }, - "kind": "getter", - "isStatic": false, - "accessibility": null, - "isAbstract": false, - "isOptional": false, - "isOverride": false - } - ], - "superClass": null, - "isAbstract": false, - "typeParams": null, - "superTypeParams": null, - "implements": [] - }, - { - "type": "ClassDeclaration", - "identifier": { - "type": "Identifier", - "span": { - "start": 114, - "end": 115, - "ctxt": 0 - }, - "value": "D", - "optional": false - }, - "declare": false, - "span": { - "start": 108, - "end": 140, - "ctxt": 0 - }, - "decorators": [], - "body": [ - { - "type": "ClassMethod", - "span": { - "start": 122, - "end": 138, - "ctxt": 0 - }, - "key": { - "type": "Identifier", - "span": { - "start": 126, - "end": 127, - "ctxt": 0 - }, - "value": "x", - "optional": false - }, - "function": { - "params": [ - { - "type": "Parameter", - "span": { - "start": 128, - "end": 129, - "ctxt": 0 - }, - "decorators": [], - "pat": { - "type": "Identifier", - "span": { - "start": 128, - "end": 129, - "ctxt": 0 - }, - "value": "v", - "optional": false, - "typeAnnotation": null - } - } - ], - "decorators": [], - "span": { - "start": 122, - "end": 138, - "ctxt": 0 - }, - "body": { - "type": "BlockStatement", - "span": { - "start": 131, - "end": 138, - "ctxt": 0 - }, - "stmts": [] - }, - "generator": false, - "async": false, - "typeParameters": null, - "returnType": null - }, - "kind": "setter", - "isStatic": false, - "accessibility": null, - "isAbstract": false, - "isOptional": false, - "isOverride": false - } - ], - "superClass": null, - "isAbstract": false, - "typeParams": null, - "superTypeParams": null, - "implements": [] - }, - { - "type": "VariableDeclaration", - "span": { - "start": 142, - "end": 178, - "ctxt": 0 - }, - "kind": "var", - "declare": false, - "declarations": [ - { - "type": "VariableDeclarator", - "span": { - "start": 146, - "end": 178, - "ctxt": 0 - }, - "id": { - "type": "Identifier", - "span": { - "start": 146, - "end": 147, - "ctxt": 0 - }, - "value": "x", - "optional": false, - "typeAnnotation": null - }, - "init": { - "type": "ObjectExpression", - "span": { - "start": 150, - "end": 178, - "ctxt": 0 - }, - "properties": [ - { - "type": "GetterProperty", - "span": { - "start": 156, - "end": 176, - "ctxt": 0 - }, - "key": { - "type": "Identifier", - "span": { - "start": 160, - "end": 161, - "ctxt": 0 - }, - "value": "a", - "optional": false - }, - "typeAnnotation": null, - "body": { - "type": "BlockStatement", - "span": { - "start": 164, - "end": 176, - "ctxt": 0 - }, - "stmts": [ - { - "type": "ReturnStatement", - "span": { - "start": 166, - "end": 174, - "ctxt": 0 - }, - "argument": { - "type": "NumericLiteral", - "span": { - "start": 173, - "end": 174, - "ctxt": 0 - }, - "value": 1.0, - "raw": "1" - } - } - ] - } - } - ] - }, - "definite": false - } - ] - }, - { - "type": "VariableDeclaration", - "span": { - "start": 180, - "end": 208, - "ctxt": 0 - }, - "kind": "var", - "declare": false, - "declarations": [ - { - "type": "VariableDeclarator", - "span": { - "start": 184, - "end": 208, - "ctxt": 0 - }, - "id": { - "type": "Identifier", - "span": { - "start": 184, - "end": 185, - "ctxt": 0 - }, - "value": "y", - "optional": false, - "typeAnnotation": null - }, - "init": { - "type": "ObjectExpression", - "span": { - "start": 188, - "end": 208, - "ctxt": 0 - }, - "properties": [ - { - "type": "SetterProperty", - "span": { - "start": 194, - "end": 206, - "ctxt": 0 - }, - "key": { - "type": "Identifier", - "span": { - "start": 198, - "end": 199, - "ctxt": 0 - }, - "value": "b", - "optional": false - }, - "thisParam": null, - "param": { - "type": "Identifier", - "span": { - "start": 200, - "end": 201, - "ctxt": 0 - }, - "value": "v", - "optional": false, - "typeAnnotation": null - }, - "body": { - "type": "BlockStatement", - "span": { - "start": 203, - "end": 206, - "ctxt": 0 - }, - "stmts": [] - } - } - ] - }, - "definite": false - } - ] - } - ], - "interpreter": null -} diff --git a/crates/swc_ecma_parser/tests/tsc/accessorWithES3.ts b/crates/swc_ecma_parser/tests/tsc/accessorWithES3.ts deleted file mode 100644 index 69089a004396..000000000000 --- a/crates/swc_ecma_parser/tests/tsc/accessorWithES3.ts +++ /dev/null @@ -1,22 +0,0 @@ -// @target: ES3 - -// error to use accessors in ES3 mode - -class C { - get x() { - return 1; - } -} - -class D { - set x(v) { - } -} - -var x = { - get a() { return 1 } -} - -var y = { - set b(v) { } -} \ No newline at end of file diff --git a/crates/swc_ecma_parser/tests/tsc/ambientAccessors.json b/crates/swc_ecma_parser/tests/tsc/ambientAccessors.json index dd3190a22643..abc802307b4f 100644 --- a/crates/swc_ecma_parser/tests/tsc/ambientAccessors.json +++ b/crates/swc_ecma_parser/tests/tsc/ambientAccessors.json @@ -1,8 +1,8 @@ { "type": "Script", "span": { - "start": 91, - "end": 357, + "start": 86, + "end": 352, "ctxt": 0 }, "body": [ @@ -11,8 +11,8 @@ "identifier": { "type": "Identifier", "span": { - "start": 105, - "end": 106, + "start": 100, + "end": 101, "ctxt": 0 }, "value": "C", @@ -20,8 +20,8 @@ }, "declare": true, "span": { - "start": 91, - "end": 357, + "start": 86, + "end": 352, "ctxt": 0 }, "decorators": [], @@ -29,15 +29,15 @@ { "type": "ClassMethod", "span": { - "start": 113, - "end": 136, + "start": 108, + "end": 131, "ctxt": 0 }, "key": { "type": "Identifier", "span": { - "start": 124, - "end": 125, + "start": 119, + "end": 120, "ctxt": 0 }, "value": "a", @@ -47,8 +47,8 @@ "params": [], "decorators": [], "span": { - "start": 113, - "end": 136, + "start": 108, + "end": 131, "ctxt": 0 }, "body": null, @@ -58,15 +58,15 @@ "returnType": { "type": "TsTypeAnnotation", "span": { - "start": 127, - "end": 135, + "start": 122, + "end": 130, "ctxt": 0 }, "typeAnnotation": { "type": "TsKeywordType", "span": { - "start": 129, - "end": 135, + "start": 124, + "end": 130, "ctxt": 0 }, "kind": "string" @@ -83,15 +83,15 @@ { "type": "ClassMethod", "span": { - "start": 141, - "end": 169, + "start": 136, + "end": 164, "ctxt": 0 }, "key": { "type": "Identifier", "span": { - "start": 152, - "end": 153, + "start": 147, + "end": 148, "ctxt": 0 }, "value": "a", @@ -102,16 +102,16 @@ { "type": "Parameter", "span": { - "start": 154, - "end": 167, + "start": 149, + "end": 162, "ctxt": 0 }, "decorators": [], "pat": { "type": "Identifier", "span": { - "start": 154, - "end": 167, + "start": 149, + "end": 162, "ctxt": 0 }, "value": "value", @@ -119,15 +119,15 @@ "typeAnnotation": { "type": "TsTypeAnnotation", "span": { - "start": 159, - "end": 167, + "start": 154, + "end": 162, "ctxt": 0 }, "typeAnnotation": { "type": "TsKeywordType", "span": { - "start": 161, - "end": 167, + "start": 156, + "end": 162, "ctxt": 0 }, "kind": "string" @@ -138,8 +138,8 @@ ], "decorators": [], "span": { - "start": 141, - "end": 169, + "start": 136, + "end": 164, "ctxt": 0 }, "body": null, @@ -158,15 +158,15 @@ { "type": "ClassMethod", "span": { - "start": 175, - "end": 206, + "start": 170, + "end": 201, "ctxt": 0 }, "key": { "type": "Identifier", "span": { - "start": 194, - "end": 195, + "start": 189, + "end": 190, "ctxt": 0 }, "value": "b", @@ -176,8 +176,8 @@ "params": [], "decorators": [], "span": { - "start": 175, - "end": 206, + "start": 170, + "end": 201, "ctxt": 0 }, "body": null, @@ -187,15 +187,15 @@ "returnType": { "type": "TsTypeAnnotation", "span": { - "start": 197, - "end": 205, + "start": 192, + "end": 200, "ctxt": 0 }, "typeAnnotation": { "type": "TsKeywordType", "span": { - "start": 199, - "end": 205, + "start": 194, + "end": 200, "ctxt": 0 }, "kind": "string" @@ -212,15 +212,15 @@ { "type": "ClassMethod", "span": { - "start": 211, - "end": 245, + "start": 206, + "end": 240, "ctxt": 0 }, "key": { "type": "Identifier", "span": { - "start": 230, - "end": 231, + "start": 225, + "end": 226, "ctxt": 0 }, "value": "b", @@ -231,16 +231,16 @@ { "type": "Parameter", "span": { - "start": 232, - "end": 243, + "start": 227, + "end": 238, "ctxt": 0 }, "decorators": [], "pat": { "type": "Identifier", "span": { - "start": 232, - "end": 243, + "start": 227, + "end": 238, "ctxt": 0 }, "value": "foo", @@ -248,15 +248,15 @@ "typeAnnotation": { "type": "TsTypeAnnotation", "span": { - "start": 235, - "end": 243, + "start": 230, + "end": 238, "ctxt": 0 }, "typeAnnotation": { "type": "TsKeywordType", "span": { - "start": 237, - "end": 243, + "start": 232, + "end": 238, "ctxt": 0 }, "kind": "string" @@ -267,8 +267,8 @@ ], "decorators": [], "span": { - "start": 211, - "end": 245, + "start": 206, + "end": 240, "ctxt": 0 }, "body": null, @@ -287,15 +287,15 @@ { "type": "ClassMethod", "span": { - "start": 251, - "end": 267, + "start": 246, + "end": 262, "ctxt": 0 }, "key": { "type": "Identifier", "span": { - "start": 255, - "end": 256, + "start": 250, + "end": 251, "ctxt": 0 }, "value": "x", @@ -305,8 +305,8 @@ "params": [], "decorators": [], "span": { - "start": 251, - "end": 267, + "start": 246, + "end": 262, "ctxt": 0 }, "body": null, @@ -316,15 +316,15 @@ "returnType": { "type": "TsTypeAnnotation", "span": { - "start": 258, - "end": 266, + "start": 253, + "end": 261, "ctxt": 0 }, "typeAnnotation": { "type": "TsKeywordType", "span": { - "start": 260, - "end": 266, + "start": 255, + "end": 261, "ctxt": 0 }, "kind": "string" @@ -341,15 +341,15 @@ { "type": "ClassMethod", "span": { - "start": 272, - "end": 293, + "start": 267, + "end": 288, "ctxt": 0 }, "key": { "type": "Identifier", "span": { - "start": 276, - "end": 277, + "start": 271, + "end": 272, "ctxt": 0 }, "value": "x", @@ -360,16 +360,16 @@ { "type": "Parameter", "span": { - "start": 278, - "end": 291, + "start": 273, + "end": 286, "ctxt": 0 }, "decorators": [], "pat": { "type": "Identifier", "span": { - "start": 278, - "end": 291, + "start": 273, + "end": 286, "ctxt": 0 }, "value": "value", @@ -377,15 +377,15 @@ "typeAnnotation": { "type": "TsTypeAnnotation", "span": { - "start": 283, - "end": 291, + "start": 278, + "end": 286, "ctxt": 0 }, "typeAnnotation": { "type": "TsKeywordType", "span": { - "start": 285, - "end": 291, + "start": 280, + "end": 286, "ctxt": 0 }, "kind": "string" @@ -396,8 +396,8 @@ ], "decorators": [], "span": { - "start": 272, - "end": 293, + "start": 267, + "end": 288, "ctxt": 0 }, "body": null, @@ -416,15 +416,15 @@ { "type": "ClassMethod", "span": { - "start": 299, - "end": 323, + "start": 294, + "end": 318, "ctxt": 0 }, "key": { "type": "Identifier", "span": { - "start": 311, - "end": 312, + "start": 306, + "end": 307, "ctxt": 0 }, "value": "y", @@ -434,8 +434,8 @@ "params": [], "decorators": [], "span": { - "start": 299, - "end": 323, + "start": 294, + "end": 318, "ctxt": 0 }, "body": null, @@ -445,15 +445,15 @@ "returnType": { "type": "TsTypeAnnotation", "span": { - "start": 314, - "end": 322, + "start": 309, + "end": 317, "ctxt": 0 }, "typeAnnotation": { "type": "TsKeywordType", "span": { - "start": 316, - "end": 322, + "start": 311, + "end": 317, "ctxt": 0 }, "kind": "string" @@ -470,15 +470,15 @@ { "type": "ClassMethod", "span": { - "start": 328, - "end": 355, + "start": 323, + "end": 350, "ctxt": 0 }, "key": { "type": "Identifier", "span": { - "start": 340, - "end": 341, + "start": 335, + "end": 336, "ctxt": 0 }, "value": "y", @@ -489,16 +489,16 @@ { "type": "Parameter", "span": { - "start": 342, - "end": 353, + "start": 337, + "end": 348, "ctxt": 0 }, "decorators": [], "pat": { "type": "Identifier", "span": { - "start": 342, - "end": 353, + "start": 337, + "end": 348, "ctxt": 0 }, "value": "foo", @@ -506,15 +506,15 @@ "typeAnnotation": { "type": "TsTypeAnnotation", "span": { - "start": 345, - "end": 353, + "start": 340, + "end": 348, "ctxt": 0 }, "typeAnnotation": { "type": "TsKeywordType", "span": { - "start": 347, - "end": 353, + "start": 342, + "end": 348, "ctxt": 0 }, "kind": "string" @@ -525,8 +525,8 @@ ], "decorators": [], "span": { - "start": 328, - "end": 355, + "start": 323, + "end": 350, "ctxt": 0 }, "body": null, diff --git a/crates/swc_ecma_parser/tests/tsc/ambientAccessors.ts b/crates/swc_ecma_parser/tests/tsc/ambientAccessors.ts index 636d4fa75c44..b49ab127826d 100644 --- a/crates/swc_ecma_parser/tests/tsc/ambientAccessors.ts +++ b/crates/swc_ecma_parser/tests/tsc/ambientAccessors.ts @@ -1,4 +1,4 @@ -// @target: es3, es5 +// @target: es5 // @declaration: true // ok to use accessors in ambient class in ES3 declare class C { diff --git a/crates/swc_ecma_parser/tests/tsc/awaitUsingDeclarationsWithImportHelpers.ts b/crates/swc_ecma_parser/tests/tsc/awaitUsingDeclarationsWithImportHelpers.ts index 0eec97f7eddd..0247aa5ad311 100644 --- a/crates/swc_ecma_parser/tests/tsc/awaitUsingDeclarationsWithImportHelpers.ts +++ b/crates/swc_ecma_parser/tests/tsc/awaitUsingDeclarationsWithImportHelpers.ts @@ -1,4 +1,4 @@ -// @target: esnext +// @target: es2022 // @module: esnext // @lib: esnext // @importHelpers: true diff --git a/crates/swc_ecma_parser/tests/tsc/checkJsdocReturnTag1.json b/crates/swc_ecma_parser/tests/tsc/checkJsdocReturnTag1.json index 3ba4279ca88f..441163f670fb 100644 --- a/crates/swc_ecma_parser/tests/tsc/checkJsdocReturnTag1.json +++ b/crates/swc_ecma_parser/tests/tsc/checkJsdocReturnTag1.json @@ -1,8 +1,8 @@ { "type": "Script", "span": { - "start": 143, - "end": 410, + "start": 147, + "end": 414, "ctxt": 0 }, "body": [ @@ -11,8 +11,8 @@ "identifier": { "type": "Identifier", "span": { - "start": 152, - "end": 153, + "start": 156, + "end": 157, "ctxt": 0 }, "value": "f", @@ -22,30 +22,30 @@ "params": [], "decorators": [], "span": { - "start": 143, - "end": 179, + "start": 147, + "end": 183, "ctxt": 0 }, "body": { "type": "BlockStatement", "span": { - "start": 156, - "end": 179, + "start": 160, + "end": 183, "ctxt": 0 }, "stmts": [ { "type": "ReturnStatement", "span": { - "start": 162, - "end": 177, + "start": 166, + "end": 181, "ctxt": 0 }, "argument": { "type": "StringLiteral", "span": { - "start": 169, - "end": 176, + "start": 173, + "end": 180, "ctxt": 0 }, "value": "hello", @@ -64,8 +64,8 @@ "identifier": { "type": "Identifier", "span": { - "start": 258, - "end": 260, + "start": 262, + "end": 264, "ctxt": 0 }, "value": "f1", @@ -75,30 +75,30 @@ "params": [], "decorators": [], "span": { - "start": 249, - "end": 292, + "start": 253, + "end": 296, "ctxt": 0 }, "body": { "type": "BlockStatement", "span": { - "start": 263, - "end": 292, + "start": 267, + "end": 296, "ctxt": 0 }, "stmts": [ { "type": "ReturnStatement", "span": { - "start": 269, - "end": 290, + "start": 273, + "end": 294, "ctxt": 0 }, "argument": { "type": "StringLiteral", "span": { - "start": 276, - "end": 289, + "start": 280, + "end": 293, "ctxt": 0 }, "value": "hello world", @@ -117,8 +117,8 @@ "identifier": { "type": "Identifier", "span": { - "start": 377, - "end": 379, + "start": 381, + "end": 383, "ctxt": 0 }, "value": "f2", @@ -128,38 +128,38 @@ "params": [], "decorators": [], "span": { - "start": 368, - "end": 410, + "start": 372, + "end": 414, "ctxt": 0 }, "body": { "type": "BlockStatement", "span": { - "start": 382, - "end": 410, + "start": 386, + "end": 414, "ctxt": 0 }, "stmts": [ { "type": "ReturnStatement", "span": { - "start": 388, - "end": 408, + "start": 392, + "end": 412, "ctxt": 0 }, "argument": { "type": "BinaryExpression", "span": { - "start": 395, - "end": 407, + "start": 399, + "end": 411, "ctxt": 0 }, "operator": "||", "left": { "type": "NumericLiteral", "span": { - "start": 395, - "end": 396, + "start": 399, + "end": 400, "ctxt": 0 }, "value": 5.0, @@ -168,8 +168,8 @@ "right": { "type": "StringLiteral", "span": { - "start": 400, - "end": 407, + "start": 404, + "end": 411, "ctxt": 0 }, "value": "hello", diff --git a/crates/swc_ecma_parser/tests/tsc/checkJsdocReturnTag1.ts b/crates/swc_ecma_parser/tests/tsc/checkJsdocReturnTag1.ts index 8c6217bb44db..c0da052dc907 100644 --- a/crates/swc_ecma_parser/tests/tsc/checkJsdocReturnTag1.ts +++ b/crates/swc_ecma_parser/tests/tsc/checkJsdocReturnTag1.ts @@ -1,5 +1,5 @@ // @allowJs: true -// @out: dummy.js +// @outFile: dummy.js // @filename: returns.js // @ts-check @@ -22,4 +22,4 @@ function f1() { */ function f2() { return 5 || "hello"; -} \ No newline at end of file +} diff --git a/crates/swc_ecma_parser/tests/tsc/checkJsdocReturnTag2.json b/crates/swc_ecma_parser/tests/tsc/checkJsdocReturnTag2.json index de3ba49c80ac..a5a7c92e890f 100644 --- a/crates/swc_ecma_parser/tests/tsc/checkJsdocReturnTag2.json +++ b/crates/swc_ecma_parser/tests/tsc/checkJsdocReturnTag2.json @@ -1,8 +1,8 @@ { "type": "Script", "span": { - "start": 143, - "end": 290, + "start": 147, + "end": 294, "ctxt": 0 }, "body": [ @@ -11,8 +11,8 @@ "identifier": { "type": "Identifier", "span": { - "start": 152, - "end": 153, + "start": 156, + "end": 157, "ctxt": 0 }, "value": "f", @@ -22,30 +22,30 @@ "params": [], "decorators": [], "span": { - "start": 143, - "end": 173, + "start": 147, + "end": 177, "ctxt": 0 }, "body": { "type": "BlockStatement", "span": { - "start": 156, - "end": 173, + "start": 160, + "end": 177, "ctxt": 0 }, "stmts": [ { "type": "ReturnStatement", "span": { - "start": 162, - "end": 171, + "start": 166, + "end": 175, "ctxt": 0 }, "argument": { "type": "NumericLiteral", "span": { - "start": 169, - "end": 170, + "start": 173, + "end": 174, "ctxt": 0 }, "value": 5.0, @@ -64,8 +64,8 @@ "identifier": { "type": "Identifier", "span": { - "start": 260, - "end": 262, + "start": 264, + "end": 266, "ctxt": 0 }, "value": "f1", @@ -75,38 +75,38 @@ "params": [], "decorators": [], "span": { - "start": 251, - "end": 290, + "start": 255, + "end": 294, "ctxt": 0 }, "body": { "type": "BlockStatement", "span": { - "start": 265, - "end": 290, + "start": 269, + "end": 294, "ctxt": 0 }, "stmts": [ { "type": "ReturnStatement", "span": { - "start": 271, - "end": 288, + "start": 275, + "end": 292, "ctxt": 0 }, "argument": { "type": "BinaryExpression", "span": { - "start": 278, - "end": 287, + "start": 282, + "end": 291, "ctxt": 0 }, "operator": "||", "left": { "type": "NumericLiteral", "span": { - "start": 278, - "end": 279, + "start": 282, + "end": 283, "ctxt": 0 }, "value": 5.0, @@ -115,8 +115,8 @@ "right": { "type": "BooleanLiteral", "span": { - "start": 283, - "end": 287, + "start": 287, + "end": 291, "ctxt": 0 }, "value": true diff --git a/crates/swc_ecma_parser/tests/tsc/checkJsdocReturnTag2.ts b/crates/swc_ecma_parser/tests/tsc/checkJsdocReturnTag2.ts index 8da62b9b2899..437b3880907e 100644 --- a/crates/swc_ecma_parser/tests/tsc/checkJsdocReturnTag2.ts +++ b/crates/swc_ecma_parser/tests/tsc/checkJsdocReturnTag2.ts @@ -1,5 +1,5 @@ // @allowJs: true -// @out: dummy.js +// @outFile: dummy.js // @filename: returns.js // @ts-check @@ -15,4 +15,4 @@ function f() { */ function f1() { return 5 || true; -} \ No newline at end of file +} diff --git a/crates/swc_ecma_parser/tests/tsc/constructorDefaultValuesReferencingThis.json b/crates/swc_ecma_parser/tests/tsc/constructorDefaultValuesReferencingThis.json deleted file mode 100644 index 8c16e3e82490..000000000000 --- a/crates/swc_ecma_parser/tests/tsc/constructorDefaultValuesReferencingThis.json +++ /dev/null @@ -1,360 +0,0 @@ -{ - "type": "Script", - "span": { - "start": 1, - "end": 141, - "ctxt": 0 - }, - "body": [ - { - "type": "ClassDeclaration", - "identifier": { - "type": "Identifier", - "span": { - "start": 7, - "end": 8, - "ctxt": 0 - }, - "value": "C", - "optional": false - }, - "declare": false, - "span": { - "start": 1, - "end": 42, - "ctxt": 0 - }, - "decorators": [], - "body": [ - { - "type": "Constructor", - "span": { - "start": 15, - "end": 40, - "ctxt": 0 - }, - "key": { - "type": "Identifier", - "span": { - "start": 15, - "end": 26, - "ctxt": 0 - }, - "value": "constructor", - "optional": false - }, - "params": [ - { - "type": "Parameter", - "span": { - "start": 27, - "end": 35, - "ctxt": 0 - }, - "decorators": [], - "pat": { - "type": "AssignmentPattern", - "span": { - "start": 27, - "end": 35, - "ctxt": 0 - }, - "left": { - "type": "Identifier", - "span": { - "start": 27, - "end": 28, - "ctxt": 0 - }, - "value": "x", - "optional": false, - "typeAnnotation": null - }, - "right": { - "type": "ThisExpression", - "span": { - "start": 31, - "end": 35, - "ctxt": 0 - } - } - } - } - ], - "body": { - "type": "BlockStatement", - "span": { - "start": 37, - "end": 40, - "ctxt": 0 - }, - "stmts": [] - }, - "accessibility": null, - "isOptional": false - } - ], - "superClass": null, - "isAbstract": false, - "typeParams": null, - "superTypeParams": null, - "implements": [] - }, - { - "type": "ClassDeclaration", - "identifier": { - "type": "Identifier", - "span": { - "start": 50, - "end": 51, - "ctxt": 0 - }, - "value": "D", - "optional": false - }, - "declare": false, - "span": { - "start": 44, - "end": 88, - "ctxt": 0 - }, - "decorators": [], - "body": [ - { - "type": "Constructor", - "span": { - "start": 61, - "end": 86, - "ctxt": 0 - }, - "key": { - "type": "Identifier", - "span": { - "start": 61, - "end": 72, - "ctxt": 0 - }, - "value": "constructor", - "optional": false - }, - "params": [ - { - "type": "Parameter", - "span": { - "start": 73, - "end": 81, - "ctxt": 0 - }, - "decorators": [], - "pat": { - "type": "AssignmentPattern", - "span": { - "start": 73, - "end": 81, - "ctxt": 0 - }, - "left": { - "type": "Identifier", - "span": { - "start": 73, - "end": 74, - "ctxt": 0 - }, - "value": "x", - "optional": false, - "typeAnnotation": null - }, - "right": { - "type": "ThisExpression", - "span": { - "start": 77, - "end": 81, - "ctxt": 0 - } - } - } - } - ], - "body": { - "type": "BlockStatement", - "span": { - "start": 83, - "end": 86, - "ctxt": 0 - }, - "stmts": [] - }, - "accessibility": null, - "isOptional": false - } - ], - "superClass": null, - "isAbstract": false, - "typeParams": { - "type": "TsTypeParameterDeclaration", - "span": { - "start": 51, - "end": 54, - "ctxt": 0 - }, - "parameters": [ - { - "type": "TsTypeParameter", - "span": { - "start": 52, - "end": 53, - "ctxt": 0 - }, - "name": { - "type": "Identifier", - "span": { - "start": 52, - "end": 53, - "ctxt": 0 - }, - "value": "T", - "optional": false - }, - "in": false, - "out": false, - "const": false, - "constraint": null, - "default": null - } - ] - }, - "superTypeParams": null, - "implements": [] - }, - { - "type": "ClassDeclaration", - "identifier": { - "type": "Identifier", - "span": { - "start": 96, - "end": 97, - "ctxt": 0 - }, - "value": "E", - "optional": false - }, - "declare": false, - "span": { - "start": 90, - "end": 141, - "ctxt": 0 - }, - "decorators": [], - "body": [ - { - "type": "Constructor", - "span": { - "start": 107, - "end": 139, - "ctxt": 0 - }, - "key": { - "type": "Identifier", - "span": { - "start": 107, - "end": 118, - "ctxt": 0 - }, - "value": "constructor", - "optional": false - }, - "params": [ - { - "type": "TsParameterProperty", - "span": { - "start": 119, - "end": 134, - "ctxt": 0 - }, - "decorators": [], - "accessibility": "public", - "override": false, - "readonly": false, - "param": { - "type": "AssignmentPattern", - "span": { - "start": 126, - "end": 134, - "ctxt": 0 - }, - "left": { - "type": "Identifier", - "span": { - "start": 126, - "end": 127, - "ctxt": 0 - }, - "value": "x", - "optional": false, - "typeAnnotation": null - }, - "right": { - "type": "ThisExpression", - "span": { - "start": 130, - "end": 134, - "ctxt": 0 - } - } - } - } - ], - "body": { - "type": "BlockStatement", - "span": { - "start": 136, - "end": 139, - "ctxt": 0 - }, - "stmts": [] - }, - "accessibility": null, - "isOptional": false - } - ], - "superClass": null, - "isAbstract": false, - "typeParams": { - "type": "TsTypeParameterDeclaration", - "span": { - "start": 97, - "end": 100, - "ctxt": 0 - }, - "parameters": [ - { - "type": "TsTypeParameter", - "span": { - "start": 98, - "end": 99, - "ctxt": 0 - }, - "name": { - "type": "Identifier", - "span": { - "start": 98, - "end": 99, - "ctxt": 0 - }, - "value": "T", - "optional": false - }, - "in": false, - "out": false, - "const": false, - "constraint": null, - "default": null - } - ] - }, - "superTypeParams": null, - "implements": [] - } - ], - "interpreter": null -} diff --git a/crates/swc_ecma_parser/tests/tsc/constructorDefaultValuesReferencingThis.ts b/crates/swc_ecma_parser/tests/tsc/constructorDefaultValuesReferencingThis.ts deleted file mode 100644 index bec1b484a6f6..000000000000 --- a/crates/swc_ecma_parser/tests/tsc/constructorDefaultValuesReferencingThis.ts +++ /dev/null @@ -1,11 +0,0 @@ -class C { - constructor(x = this) { } -} - -class D { - constructor(x = this) { } -} - -class E { - constructor(public x = this) { } -} \ No newline at end of file diff --git a/crates/swc_ecma_parser/tests/tsc/controlFlowComputedPropertyNames.json b/crates/swc_ecma_parser/tests/tsc/controlFlowComputedPropertyNames.json new file mode 100644 index 000000000000..2a11a61d8e21 --- /dev/null +++ b/crates/swc_ecma_parser/tests/tsc/controlFlowComputedPropertyNames.json @@ -0,0 +1,2060 @@ +{ + "type": "Script", + "span": { + "start": 36, + "end": 971, + "ctxt": 0 + }, + "body": [ + { + "type": "FunctionDeclaration", + "identifier": { + "type": "Identifier", + "span": { + "start": 45, + "end": 47, + "ctxt": 0 + }, + "value": "f1", + "optional": false + }, + "declare": false, + "params": [ + { + "type": "Parameter", + "span": { + "start": 48, + "end": 76, + "ctxt": 0 + }, + "decorators": [], + "pat": { + "type": "Identifier", + "span": { + "start": 48, + "end": 76, + "ctxt": 0 + }, + "value": "obj", + "optional": false, + "typeAnnotation": { + "type": "TsTypeAnnotation", + "span": { + "start": 51, + "end": 76, + "ctxt": 0 + }, + "typeAnnotation": { + "type": "TsTypeReference", + "span": { + "start": 53, + "end": 76, + "ctxt": 0 + }, + "typeName": { + "type": "Identifier", + "span": { + "start": 53, + "end": 59, + "ctxt": 0 + }, + "value": "Record", + "optional": false + }, + "typeParams": { + "type": "TsTypeParameterInstantiation", + "span": { + "start": 59, + "end": 76, + "ctxt": 0 + }, + "params": [ + { + "type": "TsKeywordType", + "span": { + "start": 60, + "end": 66, + "ctxt": 0 + }, + "kind": "string" + }, + { + "type": "TsKeywordType", + "span": { + "start": 68, + "end": 75, + "ctxt": 0 + }, + "kind": "unknown" + } + ] + } + } + } + } + }, + { + "type": "Parameter", + "span": { + "start": 78, + "end": 89, + "ctxt": 0 + }, + "decorators": [], + "pat": { + "type": "Identifier", + "span": { + "start": 78, + "end": 89, + "ctxt": 0 + }, + "value": "key", + "optional": false, + "typeAnnotation": { + "type": "TsTypeAnnotation", + "span": { + "start": 81, + "end": 89, + "ctxt": 0 + }, + "typeAnnotation": { + "type": "TsKeywordType", + "span": { + "start": 83, + "end": 89, + "ctxt": 0 + }, + "kind": "string" + } + } + } + } + ], + "decorators": [], + "span": { + "start": 36, + "end": 172, + "ctxt": 0 + }, + "body": { + "type": "BlockStatement", + "span": { + "start": 91, + "end": 172, + "ctxt": 0 + }, + "stmts": [ + { + "type": "IfStatement", + "span": { + "start": 97, + "end": 170, + "ctxt": 0 + }, + "test": { + "type": "BinaryExpression", + "span": { + "start": 101, + "end": 129, + "ctxt": 0 + }, + "operator": "===", + "left": { + "type": "UnaryExpression", + "span": { + "start": 101, + "end": 116, + "ctxt": 0 + }, + "operator": "typeof", + "argument": { + "type": "MemberExpression", + "span": { + "start": 108, + "end": 116, + "ctxt": 0 + }, + "object": { + "type": "Identifier", + "span": { + "start": 108, + "end": 111, + "ctxt": 0 + }, + "value": "obj", + "optional": false + }, + "property": { + "type": "Computed", + "span": { + "start": 111, + "end": 116, + "ctxt": 0 + }, + "expression": { + "type": "Identifier", + "span": { + "start": 112, + "end": 115, + "ctxt": 0 + }, + "value": "key", + "optional": false + } + } + } + }, + "right": { + "type": "StringLiteral", + "span": { + "start": 121, + "end": 129, + "ctxt": 0 + }, + "value": "string", + "raw": "\"string\"" + } + }, + "consequent": { + "type": "BlockStatement", + "span": { + "start": 131, + "end": 170, + "ctxt": 0 + }, + "stmts": [ + { + "type": "ExpressionStatement", + "span": { + "start": 141, + "end": 164, + "ctxt": 0 + }, + "expression": { + "type": "CallExpression", + "span": { + "start": 141, + "end": 163, + "ctxt": 0 + }, + "callee": { + "type": "MemberExpression", + "span": { + "start": 141, + "end": 161, + "ctxt": 0 + }, + "object": { + "type": "MemberExpression", + "span": { + "start": 141, + "end": 149, + "ctxt": 0 + }, + "object": { + "type": "Identifier", + "span": { + "start": 141, + "end": 144, + "ctxt": 0 + }, + "value": "obj", + "optional": false + }, + "property": { + "type": "Computed", + "span": { + "start": 144, + "end": 149, + "ctxt": 0 + }, + "expression": { + "type": "Identifier", + "span": { + "start": 145, + "end": 148, + "ctxt": 0 + }, + "value": "key", + "optional": false + } + } + }, + "property": { + "type": "Identifier", + "span": { + "start": 150, + "end": 161, + "ctxt": 0 + }, + "value": "toUpperCase", + "optional": false + } + }, + "arguments": [], + "typeArguments": null + } + } + ] + }, + "alternate": null + } + ] + }, + "generator": false, + "async": false, + "typeParameters": null, + "returnType": null + }, + { + "type": "FunctionDeclaration", + "identifier": { + "type": "Identifier", + "span": { + "start": 183, + "end": 185, + "ctxt": 0 + }, + "value": "f2", + "optional": false + }, + "declare": false, + "params": [ + { + "type": "Parameter", + "span": { + "start": 186, + "end": 225, + "ctxt": 0 + }, + "decorators": [], + "pat": { + "type": "Identifier", + "span": { + "start": 186, + "end": 225, + "ctxt": 0 + }, + "value": "obj", + "optional": false, + "typeAnnotation": { + "type": "TsTypeAnnotation", + "span": { + "start": 189, + "end": 225, + "ctxt": 0 + }, + "typeAnnotation": { + "type": "TsTypeReference", + "span": { + "start": 191, + "end": 225, + "ctxt": 0 + }, + "typeName": { + "type": "Identifier", + "span": { + "start": 191, + "end": 197, + "ctxt": 0 + }, + "value": "Record", + "optional": false + }, + "typeParams": { + "type": "TsTypeParameterInstantiation", + "span": { + "start": 197, + "end": 225, + "ctxt": 0 + }, + "params": [ + { + "type": "TsKeywordType", + "span": { + "start": 198, + "end": 204, + "ctxt": 0 + }, + "kind": "string" + }, + { + "type": "TsUnionType", + "span": { + "start": 206, + "end": 224, + "ctxt": 0 + }, + "types": [ + { + "type": "TsKeywordType", + "span": { + "start": 206, + "end": 212, + "ctxt": 0 + }, + "kind": "string" + }, + { + "type": "TsKeywordType", + "span": { + "start": 215, + "end": 224, + "ctxt": 0 + }, + "kind": "undefined" + } + ] + } + ] + } + } + } + } + }, + { + "type": "Parameter", + "span": { + "start": 227, + "end": 238, + "ctxt": 0 + }, + "decorators": [], + "pat": { + "type": "Identifier", + "span": { + "start": 227, + "end": 238, + "ctxt": 0 + }, + "value": "key", + "optional": false, + "typeAnnotation": { + "type": "TsTypeAnnotation", + "span": { + "start": 230, + "end": 238, + "ctxt": 0 + }, + "typeAnnotation": { + "type": "TsKeywordType", + "span": { + "start": 232, + "end": 238, + "ctxt": 0 + }, + "kind": "string" + } + } + } + } + ], + "decorators": [], + "span": { + "start": 174, + "end": 517, + "ctxt": 0 + }, + "body": { + "type": "BlockStatement", + "span": { + "start": 240, + "end": 517, + "ctxt": 0 + }, + "stmts": [ + { + "type": "IfStatement", + "span": { + "start": 246, + "end": 313, + "ctxt": 0 + }, + "test": { + "type": "BinaryExpression", + "span": { + "start": 250, + "end": 272, + "ctxt": 0 + }, + "operator": "!==", + "left": { + "type": "MemberExpression", + "span": { + "start": 250, + "end": 258, + "ctxt": 0 + }, + "object": { + "type": "Identifier", + "span": { + "start": 250, + "end": 253, + "ctxt": 0 + }, + "value": "obj", + "optional": false + }, + "property": { + "type": "Computed", + "span": { + "start": 253, + "end": 258, + "ctxt": 0 + }, + "expression": { + "type": "Identifier", + "span": { + "start": 254, + "end": 257, + "ctxt": 0 + }, + "value": "key", + "optional": false + } + } + }, + "right": { + "type": "Identifier", + "span": { + "start": 263, + "end": 272, + "ctxt": 0 + }, + "value": "undefined", + "optional": false + } + }, + "consequent": { + "type": "BlockStatement", + "span": { + "start": 274, + "end": 313, + "ctxt": 0 + }, + "stmts": [ + { + "type": "ExpressionStatement", + "span": { + "start": 284, + "end": 307, + "ctxt": 0 + }, + "expression": { + "type": "CallExpression", + "span": { + "start": 284, + "end": 306, + "ctxt": 0 + }, + "callee": { + "type": "MemberExpression", + "span": { + "start": 284, + "end": 304, + "ctxt": 0 + }, + "object": { + "type": "MemberExpression", + "span": { + "start": 284, + "end": 292, + "ctxt": 0 + }, + "object": { + "type": "Identifier", + "span": { + "start": 284, + "end": 287, + "ctxt": 0 + }, + "value": "obj", + "optional": false + }, + "property": { + "type": "Computed", + "span": { + "start": 287, + "end": 292, + "ctxt": 0 + }, + "expression": { + "type": "Identifier", + "span": { + "start": 288, + "end": 291, + "ctxt": 0 + }, + "value": "key", + "optional": false + } + } + }, + "property": { + "type": "Identifier", + "span": { + "start": 293, + "end": 304, + "ctxt": 0 + }, + "value": "toUpperCase", + "optional": false + } + }, + "arguments": [], + "typeArguments": null + } + } + ] + }, + "alternate": null + }, + { + "type": "VariableDeclaration", + "span": { + "start": 318, + "end": 339, + "ctxt": 0 + }, + "kind": "let", + "declare": false, + "declarations": [ + { + "type": "VariableDeclarator", + "span": { + "start": 322, + "end": 338, + "ctxt": 0 + }, + "id": { + "type": "Identifier", + "span": { + "start": 322, + "end": 326, + "ctxt": 0 + }, + "value": "key2", + "optional": false, + "typeAnnotation": null + }, + "init": { + "type": "BinaryExpression", + "span": { + "start": 329, + "end": 338, + "ctxt": 0 + }, + "operator": "+", + "left": { + "type": "Identifier", + "span": { + "start": 329, + "end": 332, + "ctxt": 0 + }, + "value": "key", + "optional": false + }, + "right": { + "type": "Identifier", + "span": { + "start": 335, + "end": 338, + "ctxt": 0 + }, + "value": "key", + "optional": false + } + }, + "definite": false + } + ] + }, + { + "type": "IfStatement", + "span": { + "start": 344, + "end": 413, + "ctxt": 0 + }, + "test": { + "type": "BinaryExpression", + "span": { + "start": 348, + "end": 371, + "ctxt": 0 + }, + "operator": "!==", + "left": { + "type": "MemberExpression", + "span": { + "start": 348, + "end": 357, + "ctxt": 0 + }, + "object": { + "type": "Identifier", + "span": { + "start": 348, + "end": 351, + "ctxt": 0 + }, + "value": "obj", + "optional": false + }, + "property": { + "type": "Computed", + "span": { + "start": 351, + "end": 357, + "ctxt": 0 + }, + "expression": { + "type": "Identifier", + "span": { + "start": 352, + "end": 356, + "ctxt": 0 + }, + "value": "key2", + "optional": false + } + } + }, + "right": { + "type": "Identifier", + "span": { + "start": 362, + "end": 371, + "ctxt": 0 + }, + "value": "undefined", + "optional": false + } + }, + "consequent": { + "type": "BlockStatement", + "span": { + "start": 373, + "end": 413, + "ctxt": 0 + }, + "stmts": [ + { + "type": "ExpressionStatement", + "span": { + "start": 383, + "end": 407, + "ctxt": 0 + }, + "expression": { + "type": "CallExpression", + "span": { + "start": 383, + "end": 406, + "ctxt": 0 + }, + "callee": { + "type": "MemberExpression", + "span": { + "start": 383, + "end": 404, + "ctxt": 0 + }, + "object": { + "type": "MemberExpression", + "span": { + "start": 383, + "end": 392, + "ctxt": 0 + }, + "object": { + "type": "Identifier", + "span": { + "start": 383, + "end": 386, + "ctxt": 0 + }, + "value": "obj", + "optional": false + }, + "property": { + "type": "Computed", + "span": { + "start": 386, + "end": 392, + "ctxt": 0 + }, + "expression": { + "type": "Identifier", + "span": { + "start": 387, + "end": 391, + "ctxt": 0 + }, + "value": "key2", + "optional": false + } + } + }, + "property": { + "type": "Identifier", + "span": { + "start": 393, + "end": 404, + "ctxt": 0 + }, + "value": "toUpperCase", + "optional": false + } + }, + "arguments": [], + "typeArguments": null + } + } + ] + }, + "alternate": null + }, + { + "type": "VariableDeclaration", + "span": { + "start": 418, + "end": 441, + "ctxt": 0 + }, + "kind": "const", + "declare": false, + "declarations": [ + { + "type": "VariableDeclarator", + "span": { + "start": 424, + "end": 440, + "ctxt": 0 + }, + "id": { + "type": "Identifier", + "span": { + "start": 424, + "end": 428, + "ctxt": 0 + }, + "value": "key3", + "optional": false, + "typeAnnotation": null + }, + "init": { + "type": "BinaryExpression", + "span": { + "start": 431, + "end": 440, + "ctxt": 0 + }, + "operator": "+", + "left": { + "type": "Identifier", + "span": { + "start": 431, + "end": 434, + "ctxt": 0 + }, + "value": "key", + "optional": false + }, + "right": { + "type": "Identifier", + "span": { + "start": 437, + "end": 440, + "ctxt": 0 + }, + "value": "key", + "optional": false + } + }, + "definite": false + } + ] + }, + { + "type": "IfStatement", + "span": { + "start": 446, + "end": 515, + "ctxt": 0 + }, + "test": { + "type": "BinaryExpression", + "span": { + "start": 450, + "end": 473, + "ctxt": 0 + }, + "operator": "!==", + "left": { + "type": "MemberExpression", + "span": { + "start": 450, + "end": 459, + "ctxt": 0 + }, + "object": { + "type": "Identifier", + "span": { + "start": 450, + "end": 453, + "ctxt": 0 + }, + "value": "obj", + "optional": false + }, + "property": { + "type": "Computed", + "span": { + "start": 453, + "end": 459, + "ctxt": 0 + }, + "expression": { + "type": "Identifier", + "span": { + "start": 454, + "end": 458, + "ctxt": 0 + }, + "value": "key3", + "optional": false + } + } + }, + "right": { + "type": "Identifier", + "span": { + "start": 464, + "end": 473, + "ctxt": 0 + }, + "value": "undefined", + "optional": false + } + }, + "consequent": { + "type": "BlockStatement", + "span": { + "start": 475, + "end": 515, + "ctxt": 0 + }, + "stmts": [ + { + "type": "ExpressionStatement", + "span": { + "start": 485, + "end": 509, + "ctxt": 0 + }, + "expression": { + "type": "CallExpression", + "span": { + "start": 485, + "end": 508, + "ctxt": 0 + }, + "callee": { + "type": "MemberExpression", + "span": { + "start": 485, + "end": 506, + "ctxt": 0 + }, + "object": { + "type": "MemberExpression", + "span": { + "start": 485, + "end": 494, + "ctxt": 0 + }, + "object": { + "type": "Identifier", + "span": { + "start": 485, + "end": 488, + "ctxt": 0 + }, + "value": "obj", + "optional": false + }, + "property": { + "type": "Computed", + "span": { + "start": 488, + "end": 494, + "ctxt": 0 + }, + "expression": { + "type": "Identifier", + "span": { + "start": 489, + "end": 493, + "ctxt": 0 + }, + "value": "key3", + "optional": false + } + } + }, + "property": { + "type": "Identifier", + "span": { + "start": 495, + "end": 506, + "ctxt": 0 + }, + "value": "toUpperCase", + "optional": false + } + }, + "arguments": [], + "typeArguments": null + } + } + ] + }, + "alternate": null + } + ] + }, + "generator": false, + "async": false, + "typeParameters": null, + "returnType": null + }, + { + "type": "TsTypeAliasDeclaration", + "span": { + "start": 519, + "end": 571, + "ctxt": 0 + }, + "declare": false, + "id": { + "type": "Identifier", + "span": { + "start": 524, + "end": 529, + "ctxt": 0 + }, + "value": "Thing", + "optional": false + }, + "typeParams": null, + "typeAnnotation": { + "type": "TsTypeLiteral", + "span": { + "start": 532, + "end": 570, + "ctxt": 0 + }, + "members": [ + { + "type": "TsPropertySignature", + "span": { + "start": 534, + "end": 545, + "ctxt": 0 + }, + "readonly": false, + "key": { + "type": "Identifier", + "span": { + "start": 534, + "end": 535, + "ctxt": 0 + }, + "value": "a", + "optional": false + }, + "computed": false, + "optional": true, + "init": null, + "params": [], + "typeAnnotation": { + "type": "TsTypeAnnotation", + "span": { + "start": 536, + "end": 544, + "ctxt": 0 + }, + "typeAnnotation": { + "type": "TsKeywordType", + "span": { + "start": 538, + "end": 544, + "ctxt": 0 + }, + "kind": "string" + } + }, + "typeParams": null + }, + { + "type": "TsPropertySignature", + "span": { + "start": 546, + "end": 557, + "ctxt": 0 + }, + "readonly": false, + "key": { + "type": "Identifier", + "span": { + "start": 546, + "end": 547, + "ctxt": 0 + }, + "value": "b", + "optional": false + }, + "computed": false, + "optional": true, + "init": null, + "params": [], + "typeAnnotation": { + "type": "TsTypeAnnotation", + "span": { + "start": 548, + "end": 556, + "ctxt": 0 + }, + "typeAnnotation": { + "type": "TsKeywordType", + "span": { + "start": 550, + "end": 556, + "ctxt": 0 + }, + "kind": "number" + } + }, + "typeParams": null + }, + { + "type": "TsPropertySignature", + "span": { + "start": 558, + "end": 568, + "ctxt": 0 + }, + "readonly": false, + "key": { + "type": "Identifier", + "span": { + "start": 558, + "end": 559, + "ctxt": 0 + }, + "value": "c", + "optional": false + }, + "computed": false, + "optional": true, + "init": null, + "params": [], + "typeAnnotation": { + "type": "TsTypeAnnotation", + "span": { + "start": 560, + "end": 568, + "ctxt": 0 + }, + "typeAnnotation": { + "type": "TsKeywordType", + "span": { + "start": 562, + "end": 568, + "ctxt": 0 + }, + "kind": "number" + } + }, + "typeParams": null + } + ] + } + }, + { + "type": "FunctionDeclaration", + "identifier": { + "type": "Identifier", + "span": { + "start": 582, + "end": 584, + "ctxt": 0 + }, + "value": "f3", + "optional": false + }, + "declare": false, + "params": [ + { + "type": "Parameter", + "span": { + "start": 585, + "end": 595, + "ctxt": 0 + }, + "decorators": [], + "pat": { + "type": "Identifier", + "span": { + "start": 585, + "end": 595, + "ctxt": 0 + }, + "value": "obj", + "optional": false, + "typeAnnotation": { + "type": "TsTypeAnnotation", + "span": { + "start": 588, + "end": 595, + "ctxt": 0 + }, + "typeAnnotation": { + "type": "TsTypeReference", + "span": { + "start": 590, + "end": 595, + "ctxt": 0 + }, + "typeName": { + "type": "Identifier", + "span": { + "start": 590, + "end": 595, + "ctxt": 0 + }, + "value": "Thing", + "optional": false + }, + "typeParams": null + } + } + } + }, + { + "type": "Parameter", + "span": { + "start": 597, + "end": 613, + "ctxt": 0 + }, + "decorators": [], + "pat": { + "type": "Identifier", + "span": { + "start": 597, + "end": 613, + "ctxt": 0 + }, + "value": "key", + "optional": false, + "typeAnnotation": { + "type": "TsTypeAnnotation", + "span": { + "start": 600, + "end": 613, + "ctxt": 0 + }, + "typeAnnotation": { + "type": "TsTypeOperator", + "span": { + "start": 602, + "end": 613, + "ctxt": 0 + }, + "op": "keyof", + "typeAnnotation": { + "type": "TsTypeReference", + "span": { + "start": 608, + "end": 613, + "ctxt": 0 + }, + "typeName": { + "type": "Identifier", + "span": { + "start": 608, + "end": 613, + "ctxt": 0 + }, + "value": "Thing", + "optional": false + }, + "typeParams": null + } + } + } + } + } + ], + "decorators": [], + "span": { + "start": 573, + "end": 834, + "ctxt": 0 + }, + "body": { + "type": "BlockStatement", + "span": { + "start": 615, + "end": 834, + "ctxt": 0 + }, + "stmts": [ + { + "type": "IfStatement", + "span": { + "start": 621, + "end": 832, + "ctxt": 0 + }, + "test": { + "type": "BinaryExpression", + "span": { + "start": 625, + "end": 647, + "ctxt": 0 + }, + "operator": "!==", + "left": { + "type": "MemberExpression", + "span": { + "start": 625, + "end": 633, + "ctxt": 0 + }, + "object": { + "type": "Identifier", + "span": { + "start": 625, + "end": 628, + "ctxt": 0 + }, + "value": "obj", + "optional": false + }, + "property": { + "type": "Computed", + "span": { + "start": 628, + "end": 633, + "ctxt": 0 + }, + "expression": { + "type": "Identifier", + "span": { + "start": 629, + "end": 632, + "ctxt": 0 + }, + "value": "key", + "optional": false + } + } + }, + "right": { + "type": "Identifier", + "span": { + "start": 638, + "end": 647, + "ctxt": 0 + }, + "value": "undefined", + "optional": false + } + }, + "consequent": { + "type": "BlockStatement", + "span": { + "start": 649, + "end": 832, + "ctxt": 0 + }, + "stmts": [ + { + "type": "IfStatement", + "span": { + "start": 659, + "end": 740, + "ctxt": 0 + }, + "test": { + "type": "BinaryExpression", + "span": { + "start": 663, + "end": 691, + "ctxt": 0 + }, + "operator": "===", + "left": { + "type": "UnaryExpression", + "span": { + "start": 663, + "end": 678, + "ctxt": 0 + }, + "operator": "typeof", + "argument": { + "type": "MemberExpression", + "span": { + "start": 670, + "end": 678, + "ctxt": 0 + }, + "object": { + "type": "Identifier", + "span": { + "start": 670, + "end": 673, + "ctxt": 0 + }, + "value": "obj", + "optional": false + }, + "property": { + "type": "Computed", + "span": { + "start": 673, + "end": 678, + "ctxt": 0 + }, + "expression": { + "type": "Identifier", + "span": { + "start": 674, + "end": 677, + "ctxt": 0 + }, + "value": "key", + "optional": false + } + } + } + }, + "right": { + "type": "StringLiteral", + "span": { + "start": 683, + "end": 691, + "ctxt": 0 + }, + "value": "string", + "raw": "\"string\"" + } + }, + "consequent": { + "type": "BlockStatement", + "span": { + "start": 693, + "end": 740, + "ctxt": 0 + }, + "stmts": [ + { + "type": "ExpressionStatement", + "span": { + "start": 707, + "end": 730, + "ctxt": 0 + }, + "expression": { + "type": "CallExpression", + "span": { + "start": 707, + "end": 729, + "ctxt": 0 + }, + "callee": { + "type": "MemberExpression", + "span": { + "start": 707, + "end": 727, + "ctxt": 0 + }, + "object": { + "type": "MemberExpression", + "span": { + "start": 707, + "end": 715, + "ctxt": 0 + }, + "object": { + "type": "Identifier", + "span": { + "start": 707, + "end": 710, + "ctxt": 0 + }, + "value": "obj", + "optional": false + }, + "property": { + "type": "Computed", + "span": { + "start": 710, + "end": 715, + "ctxt": 0 + }, + "expression": { + "type": "Identifier", + "span": { + "start": 711, + "end": 714, + "ctxt": 0 + }, + "value": "key", + "optional": false + } + } + }, + "property": { + "type": "Identifier", + "span": { + "start": 716, + "end": 727, + "ctxt": 0 + }, + "value": "toUpperCase", + "optional": false + } + }, + "arguments": [], + "typeArguments": null + } + } + ] + }, + "alternate": null + }, + { + "type": "IfStatement", + "span": { + "start": 749, + "end": 826, + "ctxt": 0 + }, + "test": { + "type": "BinaryExpression", + "span": { + "start": 753, + "end": 781, + "ctxt": 0 + }, + "operator": "===", + "left": { + "type": "UnaryExpression", + "span": { + "start": 753, + "end": 768, + "ctxt": 0 + }, + "operator": "typeof", + "argument": { + "type": "MemberExpression", + "span": { + "start": 760, + "end": 768, + "ctxt": 0 + }, + "object": { + "type": "Identifier", + "span": { + "start": 760, + "end": 763, + "ctxt": 0 + }, + "value": "obj", + "optional": false + }, + "property": { + "type": "Computed", + "span": { + "start": 763, + "end": 768, + "ctxt": 0 + }, + "expression": { + "type": "Identifier", + "span": { + "start": 764, + "end": 767, + "ctxt": 0 + }, + "value": "key", + "optional": false + } + } + } + }, + "right": { + "type": "StringLiteral", + "span": { + "start": 773, + "end": 781, + "ctxt": 0 + }, + "value": "number", + "raw": "\"number\"" + } + }, + "consequent": { + "type": "BlockStatement", + "span": { + "start": 783, + "end": 826, + "ctxt": 0 + }, + "stmts": [ + { + "type": "ExpressionStatement", + "span": { + "start": 797, + "end": 816, + "ctxt": 0 + }, + "expression": { + "type": "CallExpression", + "span": { + "start": 797, + "end": 815, + "ctxt": 0 + }, + "callee": { + "type": "MemberExpression", + "span": { + "start": 797, + "end": 813, + "ctxt": 0 + }, + "object": { + "type": "MemberExpression", + "span": { + "start": 797, + "end": 805, + "ctxt": 0 + }, + "object": { + "type": "Identifier", + "span": { + "start": 797, + "end": 800, + "ctxt": 0 + }, + "value": "obj", + "optional": false + }, + "property": { + "type": "Computed", + "span": { + "start": 800, + "end": 805, + "ctxt": 0 + }, + "expression": { + "type": "Identifier", + "span": { + "start": 801, + "end": 804, + "ctxt": 0 + }, + "value": "key", + "optional": false + } + } + }, + "property": { + "type": "Identifier", + "span": { + "start": 806, + "end": 813, + "ctxt": 0 + }, + "value": "toFixed", + "optional": false + } + }, + "arguments": [], + "typeArguments": null + } + } + ] + }, + "alternate": null + } + ] + }, + "alternate": null + } + ] + }, + "generator": false, + "async": false, + "typeParameters": null, + "returnType": null + }, + { + "type": "FunctionDeclaration", + "identifier": { + "type": "Identifier", + "span": { + "start": 845, + "end": 847, + "ctxt": 0 + }, + "value": "f4", + "optional": false + }, + "declare": false, + "params": [ + { + "type": "Parameter", + "span": { + "start": 866, + "end": 900, + "ctxt": 0 + }, + "decorators": [], + "pat": { + "type": "Identifier", + "span": { + "start": 866, + "end": 900, + "ctxt": 0 + }, + "value": "obj", + "optional": false, + "typeAnnotation": { + "type": "TsTypeAnnotation", + "span": { + "start": 869, + "end": 900, + "ctxt": 0 + }, + "typeAnnotation": { + "type": "TsTypeReference", + "span": { + "start": 871, + "end": 900, + "ctxt": 0 + }, + "typeName": { + "type": "Identifier", + "span": { + "start": 871, + "end": 877, + "ctxt": 0 + }, + "value": "Record", + "optional": false + }, + "typeParams": { + "type": "TsTypeParameterInstantiation", + "span": { + "start": 877, + "end": 900, + "ctxt": 0 + }, + "params": [ + { + "type": "TsTypeReference", + "span": { + "start": 878, + "end": 879, + "ctxt": 0 + }, + "typeName": { + "type": "Identifier", + "span": { + "start": 878, + "end": 879, + "ctxt": 0 + }, + "value": "K", + "optional": false + }, + "typeParams": null + }, + { + "type": "TsUnionType", + "span": { + "start": 881, + "end": 899, + "ctxt": 0 + }, + "types": [ + { + "type": "TsKeywordType", + "span": { + "start": 881, + "end": 887, + "ctxt": 0 + }, + "kind": "string" + }, + { + "type": "TsKeywordType", + "span": { + "start": 890, + "end": 899, + "ctxt": 0 + }, + "kind": "undefined" + } + ] + } + ] + } + } + } + } + }, + { + "type": "Parameter", + "span": { + "start": 902, + "end": 908, + "ctxt": 0 + }, + "decorators": [], + "pat": { + "type": "Identifier", + "span": { + "start": 902, + "end": 908, + "ctxt": 0 + }, + "value": "key", + "optional": false, + "typeAnnotation": { + "type": "TsTypeAnnotation", + "span": { + "start": 905, + "end": 908, + "ctxt": 0 + }, + "typeAnnotation": { + "type": "TsTypeReference", + "span": { + "start": 907, + "end": 908, + "ctxt": 0 + }, + "typeName": { + "type": "Identifier", + "span": { + "start": 907, + "end": 908, + "ctxt": 0 + }, + "value": "K", + "optional": false + }, + "typeParams": null + } + } + } + } + ], + "decorators": [], + "span": { + "start": 836, + "end": 971, + "ctxt": 0 + }, + "body": { + "type": "BlockStatement", + "span": { + "start": 910, + "end": 971, + "ctxt": 0 + }, + "stmts": [ + { + "type": "IfStatement", + "span": { + "start": 916, + "end": 969, + "ctxt": 0 + }, + "test": { + "type": "MemberExpression", + "span": { + "start": 920, + "end": 928, + "ctxt": 0 + }, + "object": { + "type": "Identifier", + "span": { + "start": 920, + "end": 923, + "ctxt": 0 + }, + "value": "obj", + "optional": false + }, + "property": { + "type": "Computed", + "span": { + "start": 923, + "end": 928, + "ctxt": 0 + }, + "expression": { + "type": "Identifier", + "span": { + "start": 924, + "end": 927, + "ctxt": 0 + }, + "value": "key", + "optional": false + } + } + }, + "consequent": { + "type": "BlockStatement", + "span": { + "start": 930, + "end": 969, + "ctxt": 0 + }, + "stmts": [ + { + "type": "ExpressionStatement", + "span": { + "start": 940, + "end": 963, + "ctxt": 0 + }, + "expression": { + "type": "CallExpression", + "span": { + "start": 940, + "end": 962, + "ctxt": 0 + }, + "callee": { + "type": "MemberExpression", + "span": { + "start": 940, + "end": 960, + "ctxt": 0 + }, + "object": { + "type": "MemberExpression", + "span": { + "start": 940, + "end": 948, + "ctxt": 0 + }, + "object": { + "type": "Identifier", + "span": { + "start": 940, + "end": 943, + "ctxt": 0 + }, + "value": "obj", + "optional": false + }, + "property": { + "type": "Computed", + "span": { + "start": 943, + "end": 948, + "ctxt": 0 + }, + "expression": { + "type": "Identifier", + "span": { + "start": 944, + "end": 947, + "ctxt": 0 + }, + "value": "key", + "optional": false + } + } + }, + "property": { + "type": "Identifier", + "span": { + "start": 949, + "end": 960, + "ctxt": 0 + }, + "value": "toUpperCase", + "optional": false + } + }, + "arguments": [], + "typeArguments": null + } + } + ] + }, + "alternate": null + } + ] + }, + "generator": false, + "async": false, + "typeParameters": { + "type": "TsTypeParameterDeclaration", + "span": { + "start": 847, + "end": 865, + "ctxt": 0 + }, + "parameters": [ + { + "type": "TsTypeParameter", + "span": { + "start": 848, + "end": 864, + "ctxt": 0 + }, + "name": { + "type": "Identifier", + "span": { + "start": 848, + "end": 849, + "ctxt": 0 + }, + "value": "K", + "optional": false + }, + "in": false, + "out": false, + "const": false, + "constraint": { + "type": "TsKeywordType", + "span": { + "start": 858, + "end": 864, + "ctxt": 0 + }, + "kind": "string" + }, + "default": null + } + ] + }, + "returnType": null + } + ], + "interpreter": null +} diff --git a/crates/swc_ecma_parser/tests/tsc/controlFlowComputedPropertyNames.ts b/crates/swc_ecma_parser/tests/tsc/controlFlowComputedPropertyNames.ts new file mode 100644 index 000000000000..e4bdfb049be2 --- /dev/null +++ b/crates/swc_ecma_parser/tests/tsc/controlFlowComputedPropertyNames.ts @@ -0,0 +1,41 @@ +// @strict: true +// @noEmit: true + +function f1(obj: Record, key: string) { + if (typeof obj[key] === "string") { + obj[key].toUpperCase(); + } +} + +function f2(obj: Record, key: string) { + if (obj[key] !== undefined) { + obj[key].toUpperCase(); + } + let key2 = key + key; + if (obj[key2] !== undefined) { + obj[key2].toUpperCase(); + } + const key3 = key + key; + if (obj[key3] !== undefined) { + obj[key3].toUpperCase(); + } +} + +type Thing = { a?: string, b?: number, c?: number }; + +function f3(obj: Thing, key: keyof Thing) { + if (obj[key] !== undefined) { + if (typeof obj[key] === "string") { + obj[key].toUpperCase(); + } + if (typeof obj[key] === "number") { + obj[key].toFixed(); + } + } +} + +function f4(obj: Record, key: K) { + if (obj[key]) { + obj[key].toUpperCase(); + } +} diff --git a/crates/swc_ecma_parser/tests/tsc/decoratorOnClassMethod11.json b/crates/swc_ecma_parser/tests/tsc/decoratorOnClassMethod11.json index 7f8716ae043f..8b9cd3f6e1a8 100644 --- a/crates/swc_ecma_parser/tests/tsc/decoratorOnClassMethod11.json +++ b/crates/swc_ecma_parser/tests/tsc/decoratorOnClassMethod11.json @@ -2,7 +2,7 @@ "type": "Script", "span": { "start": 50, - "end": 185, + "end": 187, "ctxt": 0 }, "body": [ @@ -10,7 +10,7 @@ "type": "TsModuleDeclaration", "span": { "start": 50, - "end": 185, + "end": 187, "ctxt": 0 }, "declare": false, @@ -29,7 +29,7 @@ "type": "TsModuleBlock", "span": { "start": 59, - "end": 185, + "end": 187, "ctxt": 0 }, "body": [ @@ -48,7 +48,7 @@ "declare": false, "span": { "start": 65, - "end": 183, + "end": 185, "ctxt": 0 }, "decorators": [], @@ -202,14 +202,14 @@ "type": "ClassMethod", "span": { "start": 141, - "end": 177, + "end": 179, "ctxt": 0 }, "key": { "type": "Identifier", "span": { - "start": 165, - "end": 171, + "start": 167, + "end": 173, "ctxt": 0 }, "value": "method", @@ -222,31 +222,29 @@ "type": "Decorator", "span": { "start": 141, - "end": 156, + "end": 158, "ctxt": 0 }, "expression": { "type": "MemberExpression", "span": { - "start": 142, - "end": 156, + "start": 143, + "end": 157, "ctxt": 0 }, "object": { - "type": "Identifier", + "type": "ThisExpression", "span": { - "start": 142, - "end": 146, + "start": 143, + "end": 147, "ctxt": 0 - }, - "value": "this", - "optional": false + } }, "property": { "type": "Identifier", "span": { - "start": 147, - "end": 156, + "start": 148, + "end": 157, "ctxt": 0 }, "value": "decorator", @@ -257,14 +255,14 @@ ], "span": { "start": 141, - "end": 177, + "end": 179, "ctxt": 0 }, "body": { "type": "BlockStatement", "span": { - "start": 174, - "end": 177, + "start": 176, + "end": 179, "ctxt": 0 }, "stmts": [] diff --git a/crates/swc_ecma_parser/tests/tsc/decoratorOnClassMethod11.ts b/crates/swc_ecma_parser/tests/tsc/decoratorOnClassMethod11.ts index f3a03715ff08..7a76cb8d0663 100644 --- a/crates/swc_ecma_parser/tests/tsc/decoratorOnClassMethod11.ts +++ b/crates/swc_ecma_parser/tests/tsc/decoratorOnClassMethod11.ts @@ -4,7 +4,7 @@ module M { class C { decorator(target: Object, key: string): void { } - @this.decorator + @(this.decorator) method() { } } } \ No newline at end of file diff --git a/crates/swc_ecma_parser/tests/tsc/decoratorOnClassMethod12.ts b/crates/swc_ecma_parser/tests/tsc/decoratorOnClassMethod12.ts index 9af80e32c46b..e353d0db587e 100644 --- a/crates/swc_ecma_parser/tests/tsc/decoratorOnClassMethod12.ts +++ b/crates/swc_ecma_parser/tests/tsc/decoratorOnClassMethod12.ts @@ -5,7 +5,7 @@ module M { decorator(target: Object, key: string): void { } } class C extends S { - @super.decorator + @(super.decorator) method() { } } } \ No newline at end of file diff --git a/crates/swc_ecma_parser/tests/tsc/definePropertyOutputES3.json b/crates/swc_ecma_parser/tests/tsc/definePropertyOutputES3.json deleted file mode 100644 index c2511c67ee0c..000000000000 --- a/crates/swc_ecma_parser/tests/tsc/definePropertyOutputES3.json +++ /dev/null @@ -1,76 +0,0 @@ -{ - "type": "Script", - "span": { - "start": 51, - "end": 73, - "ctxt": 0 - }, - "body": [ - { - "type": "ClassDeclaration", - "identifier": { - "type": "Identifier", - "span": { - "start": 57, - "end": 58, - "ctxt": 0 - }, - "value": "A", - "optional": false - }, - "declare": false, - "span": { - "start": 51, - "end": 73, - "ctxt": 0 - }, - "decorators": [], - "body": [ - { - "type": "ClassProperty", - "span": { - "start": 65, - "end": 71, - "ctxt": 0 - }, - "key": { - "type": "Identifier", - "span": { - "start": 65, - "end": 66, - "ctxt": 0 - }, - "value": "a", - "optional": false - }, - "value": { - "type": "NumericLiteral", - "span": { - "start": 69, - "end": 71, - "ctxt": 0 - }, - "value": 12.0, - "raw": "12" - }, - "typeAnnotation": null, - "isStatic": false, - "decorators": [], - "accessibility": null, - "isAbstract": false, - "isOptional": false, - "isOverride": false, - "readonly": false, - "declare": false, - "definite": false - } - ], - "superClass": null, - "isAbstract": false, - "typeParams": null, - "superTypeParams": null, - "implements": [] - } - ], - "interpreter": null -} diff --git a/crates/swc_ecma_parser/tests/tsc/definePropertyOutputES3.ts b/crates/swc_ecma_parser/tests/tsc/definePropertyOutputES3.ts deleted file mode 100644 index f6a62d32650f..000000000000 --- a/crates/swc_ecma_parser/tests/tsc/definePropertyOutputES3.ts +++ /dev/null @@ -1,5 +0,0 @@ -// @target: es3 -// @useDefineForClassFields: true -class A { - a = 12 -} diff --git a/crates/swc_ecma_parser/tests/tsc/errorIsolation.json b/crates/swc_ecma_parser/tests/tsc/errorIsolation.json new file mode 100644 index 000000000000..c8c58c7a5840 --- /dev/null +++ b/crates/swc_ecma_parser/tests/tsc/errorIsolation.json @@ -0,0 +1,172 @@ +{ + "type": "Script", + "span": { + "start": 68, + "end": 146, + "ctxt": 0 + }, + "body": [ + { + "type": "VariableDeclaration", + "span": { + "start": 68, + "end": 107, + "ctxt": 0 + }, + "kind": "const", + "declare": false, + "declarations": [ + { + "type": "VariableDeclarator", + "span": { + "start": 74, + "end": 106, + "ctxt": 0 + }, + "id": { + "type": "Identifier", + "span": { + "start": 74, + "end": 79, + "ctxt": 0 + }, + "value": "async", + "optional": false, + "typeAnnotation": null + }, + "init": { + "type": "ObjectExpression", + "span": { + "start": 82, + "end": 106, + "ctxt": 0 + }, + "properties": [ + { + "type": "KeyValueProperty", + "key": { + "type": "Identifier", + "span": { + "start": 84, + "end": 95, + "ctxt": 0 + }, + "value": "doSomething", + "optional": false + }, + "value": { + "type": "ArrowFunctionExpression", + "span": { + "start": 97, + "end": 104, + "ctxt": 0 + }, + "params": [ + { + "type": "Identifier", + "span": { + "start": 97, + "end": 98, + "ctxt": 0 + }, + "value": "_", + "optional": false, + "typeAnnotation": null + } + ], + "body": { + "type": "BlockStatement", + "span": { + "start": 102, + "end": 104, + "ctxt": 0 + }, + "stmts": [] + }, + "async": false, + "generator": false, + "typeParameters": null, + "returnType": null + } + } + ] + }, + "definite": false + } + ] + }, + { + "type": "ExpressionStatement", + "span": { + "start": 108, + "end": 146, + "ctxt": 0 + }, + "expression": { + "type": "CallExpression", + "span": { + "start": 108, + "end": 145, + "ctxt": 0 + }, + "callee": { + "type": "MemberExpression", + "span": { + "start": 108, + "end": 125, + "ctxt": 0 + }, + "object": { + "type": "Identifier", + "span": { + "start": 108, + "end": 113, + "ctxt": 0 + }, + "value": "async", + "optional": false + }, + "property": { + "type": "Identifier", + "span": { + "start": 114, + "end": 125, + "ctxt": 0 + }, + "value": "doSomething", + "optional": false + } + }, + "arguments": [ + { + "spread": null, + "expression": { + "type": "ArrowFunctionExpression", + "span": { + "start": 135, + "end": 143, + "ctxt": 0 + }, + "params": [], + "body": { + "type": "BlockStatement", + "span": { + "start": 141, + "end": 143, + "ctxt": 0 + }, + "stmts": [] + }, + "async": false, + "generator": false, + "typeParameters": null, + "returnType": null + } + } + ], + "typeArguments": null + } + } + ], + "interpreter": null +} diff --git a/crates/swc_ecma_parser/tests/tsc/errorIsolation.ts b/crates/swc_ecma_parser/tests/tsc/errorIsolation.ts new file mode 100644 index 000000000000..d06d76dcac86 --- /dev/null +++ b/crates/swc_ecma_parser/tests/tsc/errorIsolation.ts @@ -0,0 +1,8 @@ +// @noEmit: true +// @checkJs: true +// @filename: errorIsolation.js +const async = { doSomething: _ => {} }; +async.doSomething( + /***/ + () => {} +); \ No newline at end of file diff --git a/crates/swc_ecma_parser/tests/tsc/es2018IntlAPIs.json b/crates/swc_ecma_parser/tests/tsc/es2018IntlAPIs.json index 5b4c1470df3d..885d285a8230 100644 --- a/crates/swc_ecma_parser/tests/tsc/es2018IntlAPIs.json +++ b/crates/swc_ecma_parser/tests/tsc/es2018IntlAPIs.json @@ -2,7 +2,7 @@ "type": "Script", "span": { "start": 156, - "end": 340, + "end": 435, "ctxt": 0 }, "body": [ @@ -334,6 +334,225 @@ ], "typeArguments": null } + }, + { + "type": "VariableDeclaration", + "span": { + "start": 342, + "end": 399, + "ctxt": 0 + }, + "kind": "const", + "declare": false, + "declarations": [ + { + "type": "VariableDeclarator", + "span": { + "start": 348, + "end": 398, + "ctxt": 0 + }, + "id": { + "type": "ArrayPattern", + "span": { + "start": 348, + "end": 356, + "ctxt": 0 + }, + "elements": [ + { + "type": "Identifier", + "span": { + "start": 350, + "end": 354, + "ctxt": 0 + }, + "value": "part", + "optional": false, + "typeAnnotation": null + } + ], + "optional": false, + "typeAnnotation": null + }, + "init": { + "type": "CallExpression", + "span": { + "start": 359, + "end": 398, + "ctxt": 0 + }, + "callee": { + "type": "MemberExpression", + "span": { + "start": 359, + "end": 396, + "ctxt": 0 + }, + "object": { + "type": "NewExpression", + "span": { + "start": 359, + "end": 382, + "ctxt": 0 + }, + "callee": { + "type": "MemberExpression", + "span": { + "start": 363, + "end": 380, + "ctxt": 0 + }, + "object": { + "type": "Identifier", + "span": { + "start": 363, + "end": 367, + "ctxt": 0 + }, + "value": "Intl", + "optional": false + }, + "property": { + "type": "Identifier", + "span": { + "start": 368, + "end": 380, + "ctxt": 0 + }, + "value": "NumberFormat", + "optional": false + } + }, + "arguments": [], + "typeArguments": null + }, + "property": { + "type": "Identifier", + "span": { + "start": 383, + "end": 396, + "ctxt": 0 + }, + "value": "formatToParts", + "optional": false + } + }, + "arguments": [], + "typeArguments": null + }, + "definite": false + } + ] + }, + { + "type": "ExpressionStatement", + "span": { + "start": 400, + "end": 435, + "ctxt": 0 + }, + "expression": { + "type": "CallExpression", + "span": { + "start": 400, + "end": 434, + "ctxt": 0 + }, + "callee": { + "type": "MemberExpression", + "span": { + "start": 400, + "end": 411, + "ctxt": 0 + }, + "object": { + "type": "Identifier", + "span": { + "start": 400, + "end": 407, + "ctxt": 0 + }, + "value": "console", + "optional": false + }, + "property": { + "type": "Identifier", + "span": { + "start": 408, + "end": 411, + "ctxt": 0 + }, + "value": "log", + "optional": false + } + }, + "arguments": [ + { + "spread": null, + "expression": { + "type": "MemberExpression", + "span": { + "start": 412, + "end": 421, + "ctxt": 0 + }, + "object": { + "type": "Identifier", + "span": { + "start": 412, + "end": 416, + "ctxt": 0 + }, + "value": "part", + "optional": false + }, + "property": { + "type": "Identifier", + "span": { + "start": 417, + "end": 421, + "ctxt": 0 + }, + "value": "type", + "optional": false + } + } + }, + { + "spread": null, + "expression": { + "type": "MemberExpression", + "span": { + "start": 423, + "end": 433, + "ctxt": 0 + }, + "object": { + "type": "Identifier", + "span": { + "start": 423, + "end": 427, + "ctxt": 0 + }, + "value": "part", + "optional": false + }, + "property": { + "type": "Identifier", + "span": { + "start": 428, + "end": 433, + "ctxt": 0 + }, + "value": "value", + "optional": false + } + } + } + ], + "typeArguments": null + } } ], "interpreter": null diff --git a/crates/swc_ecma_parser/tests/tsc/es2018IntlAPIs.ts b/crates/swc_ecma_parser/tests/tsc/es2018IntlAPIs.ts index c1f6739202d7..d9c3c03c780a 100644 --- a/crates/swc_ecma_parser/tests/tsc/es2018IntlAPIs.ts +++ b/crates/swc_ecma_parser/tests/tsc/es2018IntlAPIs.ts @@ -4,4 +4,7 @@ // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/PluralRules/supportedLocalesOf const locales = ['ban', 'id-u-co-pinyin', 'de-ID']; const options = { localeMatcher: 'lookup' } as const; -console.log(Intl.PluralRules.supportedLocalesOf(locales, options).join(', ')); \ No newline at end of file +console.log(Intl.PluralRules.supportedLocalesOf(locales, options).join(', ')); + +const [ part ] = new Intl.NumberFormat().formatToParts(); +console.log(part.type, part.value); diff --git a/crates/swc_ecma_parser/tests/tsc/esDecorators-decoratorExpression.1.ts b/crates/swc_ecma_parser/tests/tsc/esDecorators-decoratorExpression.1.ts new file mode 100644 index 000000000000..333e42638354 --- /dev/null +++ b/crates/swc_ecma_parser/tests/tsc/esDecorators-decoratorExpression.1.ts @@ -0,0 +1,50 @@ +// @target: esnext +// @experimentalDecorators: * +// @noEmitHelpers: true +// @noTypesAndSymbols: true + +declare let x: any; + +{ @x().y class C {} } + +{ @new x class C {} } + +{ @x().y() class C {} } + +{ @x?.y class C {} } + +{ @x?.y() class C {} } + +{ @x?.["y"] class C {} } + +{ @x?.() class C {} } + +{ @x`` class C {} } + +{ @x``() class C {} } + +{ @x.y`` class C {} } + +{ @x.y``() class C {} } + +{ class C { @x().y m() {} } } + +{ class C { @new x m() {} } } + +{ class C { @x().y() m() {} } } + +{ class C { @x?.y m() {} } } + +{ class C { @x?.y() m() {} } } + +{ class C { @x?.["y"] m() {} } } + +{ class C { @x?.() m() {} } } + +{ class C { @x`` m() {} } } + +{ class C { @x``() m() {} } } + +{ class C { @x.y`` m() {} } } + +{ class C { @x.y``() m() {} } } diff --git a/crates/swc_ecma_parser/tests/tsc/esDecorators-decoratorExpression.2.json b/crates/swc_ecma_parser/tests/tsc/esDecorators-decoratorExpression.2.json new file mode 100644 index 000000000000..630229417836 --- /dev/null +++ b/crates/swc_ecma_parser/tests/tsc/esDecorators-decoratorExpression.2.json @@ -0,0 +1,3189 @@ +{ + "type": "Script", + "span": { + "start": 103, + "end": 978, + "ctxt": 0 + }, + "body": [ + { + "type": "VariableDeclaration", + "span": { + "start": 103, + "end": 122, + "ctxt": 0 + }, + "kind": "let", + "declare": true, + "declarations": [ + { + "type": "VariableDeclarator", + "span": { + "start": 115, + "end": 121, + "ctxt": 0 + }, + "id": { + "type": "Identifier", + "span": { + "start": 115, + "end": 116, + "ctxt": 0 + }, + "value": "x", + "optional": false, + "typeAnnotation": { + "type": "TsTypeAnnotation", + "span": { + "start": 116, + "end": 121, + "ctxt": 0 + }, + "typeAnnotation": { + "type": "TsKeywordType", + "span": { + "start": 118, + "end": 121, + "ctxt": 0 + }, + "kind": "any" + } + } + }, + "init": null, + "definite": false + } + ] + }, + { + "type": "VariableDeclaration", + "span": { + "start": 123, + "end": 163, + "ctxt": 0 + }, + "kind": "let", + "declare": true, + "declarations": [ + { + "type": "VariableDeclarator", + "span": { + "start": 135, + "end": 162, + "ctxt": 0 + }, + "id": { + "type": "Identifier", + "span": { + "start": 135, + "end": 136, + "ctxt": 0 + }, + "value": "g", + "optional": false, + "typeAnnotation": { + "type": "TsTypeAnnotation", + "span": { + "start": 136, + "end": 162, + "ctxt": 0 + }, + "typeAnnotation": { + "type": "TsFunctionType", + "span": { + "start": 138, + "end": 162, + "ctxt": 0 + }, + "params": [ + { + "type": "RestElement", + "span": { + "start": 142, + "end": 154, + "ctxt": 0 + }, + "rest": { + "start": 142, + "end": 145, + "ctxt": 0 + }, + "argument": { + "type": "Identifier", + "span": { + "start": 145, + "end": 149, + "ctxt": 0 + }, + "value": "args", + "optional": false, + "typeAnnotation": null + }, + "typeAnnotation": { + "type": "TsTypeAnnotation", + "span": { + "start": 149, + "end": 154, + "ctxt": 0 + }, + "typeAnnotation": { + "type": "TsKeywordType", + "span": { + "start": 151, + "end": 154, + "ctxt": 0 + }, + "kind": "any" + } + } + } + ], + "typeParams": { + "type": "TsTypeParameterDeclaration", + "span": { + "start": 138, + "end": 141, + "ctxt": 0 + }, + "parameters": [ + { + "type": "TsTypeParameter", + "span": { + "start": 139, + "end": 140, + "ctxt": 0 + }, + "name": { + "type": "Identifier", + "span": { + "start": 139, + "end": 140, + "ctxt": 0 + }, + "value": "T", + "optional": false + }, + "in": false, + "out": false, + "const": false, + "constraint": null, + "default": null + } + ] + }, + "typeAnnotation": { + "type": "TsTypeAnnotation", + "span": { + "start": 156, + "end": 162, + "ctxt": 0 + }, + "typeAnnotation": { + "type": "TsKeywordType", + "span": { + "start": 159, + "end": 162, + "ctxt": 0 + }, + "kind": "any" + } + } + } + } + }, + "init": null, + "definite": false + } + ] + }, + { + "type": "VariableDeclaration", + "span": { + "start": 164, + "end": 210, + "ctxt": 0 + }, + "kind": "let", + "declare": true, + "declarations": [ + { + "type": "VariableDeclarator", + "span": { + "start": 176, + "end": 209, + "ctxt": 0 + }, + "id": { + "type": "Identifier", + "span": { + "start": 176, + "end": 177, + "ctxt": 0 + }, + "value": "h", + "optional": false, + "typeAnnotation": { + "type": "TsTypeAnnotation", + "span": { + "start": 177, + "end": 209, + "ctxt": 0 + }, + "typeAnnotation": { + "type": "TsFunctionType", + "span": { + "start": 179, + "end": 209, + "ctxt": 0 + }, + "params": [], + "typeParams": null, + "typeAnnotation": { + "type": "TsTypeAnnotation", + "span": { + "start": 182, + "end": 209, + "ctxt": 0 + }, + "typeAnnotation": { + "type": "TsFunctionType", + "span": { + "start": 185, + "end": 209, + "ctxt": 0 + }, + "params": [ + { + "type": "RestElement", + "span": { + "start": 189, + "end": 201, + "ctxt": 0 + }, + "rest": { + "start": 189, + "end": 192, + "ctxt": 0 + }, + "argument": { + "type": "Identifier", + "span": { + "start": 192, + "end": 196, + "ctxt": 0 + }, + "value": "args", + "optional": false, + "typeAnnotation": null + }, + "typeAnnotation": { + "type": "TsTypeAnnotation", + "span": { + "start": 196, + "end": 201, + "ctxt": 0 + }, + "typeAnnotation": { + "type": "TsKeywordType", + "span": { + "start": 198, + "end": 201, + "ctxt": 0 + }, + "kind": "any" + } + } + } + ], + "typeParams": { + "type": "TsTypeParameterDeclaration", + "span": { + "start": 185, + "end": 188, + "ctxt": 0 + }, + "parameters": [ + { + "type": "TsTypeParameter", + "span": { + "start": 186, + "end": 187, + "ctxt": 0 + }, + "name": { + "type": "Identifier", + "span": { + "start": 186, + "end": 187, + "ctxt": 0 + }, + "value": "T", + "optional": false + }, + "in": false, + "out": false, + "const": false, + "constraint": null, + "default": null + } + ] + }, + "typeAnnotation": { + "type": "TsTypeAnnotation", + "span": { + "start": 203, + "end": 209, + "ctxt": 0 + }, + "typeAnnotation": { + "type": "TsKeywordType", + "span": { + "start": 206, + "end": 209, + "ctxt": 0 + }, + "kind": "any" + } + } + } + } + } + } + }, + "init": null, + "definite": false + } + ] + }, + { + "type": "BlockStatement", + "span": { + "start": 212, + "end": 230, + "ctxt": 0 + }, + "stmts": [ + { + "type": "ClassDeclaration", + "identifier": { + "type": "Identifier", + "span": { + "start": 224, + "end": 225, + "ctxt": 0 + }, + "value": "C", + "optional": false + }, + "declare": false, + "span": { + "start": 214, + "end": 228, + "ctxt": 0 + }, + "decorators": [ + { + "type": "Decorator", + "span": { + "start": 214, + "end": 217, + "ctxt": 0 + }, + "expression": { + "type": "TsNonNullExpression", + "span": { + "start": 215, + "end": 217, + "ctxt": 0 + }, + "expression": { + "type": "Identifier", + "span": { + "start": 215, + "end": 216, + "ctxt": 0 + }, + "value": "x", + "optional": false + } + } + } + ], + "body": [], + "superClass": null, + "isAbstract": false, + "typeParams": null, + "superTypeParams": null, + "implements": [] + } + ] + }, + { + "type": "BlockStatement", + "span": { + "start": 232, + "end": 252, + "ctxt": 0 + }, + "stmts": [ + { + "type": "ClassDeclaration", + "identifier": { + "type": "Identifier", + "span": { + "start": 246, + "end": 247, + "ctxt": 0 + }, + "value": "C", + "optional": false + }, + "declare": false, + "span": { + "start": 234, + "end": 250, + "ctxt": 0 + }, + "decorators": [ + { + "type": "Decorator", + "span": { + "start": 234, + "end": 239, + "ctxt": 0 + }, + "expression": { + "type": "TsNonNullExpression", + "span": { + "start": 235, + "end": 239, + "ctxt": 0 + }, + "expression": { + "type": "MemberExpression", + "span": { + "start": 235, + "end": 238, + "ctxt": 0 + }, + "object": { + "type": "Identifier", + "span": { + "start": 235, + "end": 236, + "ctxt": 0 + }, + "value": "x", + "optional": false + }, + "property": { + "type": "Identifier", + "span": { + "start": 237, + "end": 238, + "ctxt": 0 + }, + "value": "y", + "optional": false + } + } + } + } + ], + "body": [], + "superClass": null, + "isAbstract": false, + "typeParams": null, + "superTypeParams": null, + "implements": [] + } + ] + }, + { + "type": "BlockStatement", + "span": { + "start": 254, + "end": 274, + "ctxt": 0 + }, + "stmts": [ + { + "type": "ClassDeclaration", + "identifier": { + "type": "Identifier", + "span": { + "start": 268, + "end": 269, + "ctxt": 0 + }, + "value": "C", + "optional": false + }, + "declare": false, + "span": { + "start": 256, + "end": 272, + "ctxt": 0 + }, + "decorators": [ + { + "type": "Decorator", + "span": { + "start": 256, + "end": 261, + "ctxt": 0 + }, + "expression": { + "type": "MemberExpression", + "span": { + "start": 257, + "end": 261, + "ctxt": 0 + }, + "object": { + "type": "TsNonNullExpression", + "span": { + "start": 257, + "end": 259, + "ctxt": 0 + }, + "expression": { + "type": "Identifier", + "span": { + "start": 257, + "end": 258, + "ctxt": 0 + }, + "value": "x", + "optional": false + } + }, + "property": { + "type": "Identifier", + "span": { + "start": 260, + "end": 261, + "ctxt": 0 + }, + "value": "y", + "optional": false + } + } + } + ], + "body": [], + "superClass": null, + "isAbstract": false, + "typeParams": null, + "superTypeParams": null, + "implements": [] + } + ] + }, + { + "type": "BlockStatement", + "span": { + "start": 276, + "end": 303, + "ctxt": 0 + }, + "stmts": [ + { + "type": "ClassDeclaration", + "identifier": { + "type": "Identifier", + "span": { + "start": 297, + "end": 298, + "ctxt": 0 + }, + "value": "C", + "optional": false + }, + "declare": false, + "span": { + "start": 278, + "end": 301, + "ctxt": 0 + }, + "decorators": [ + { + "type": "Decorator", + "span": { + "start": 278, + "end": 290, + "ctxt": 0 + }, + "expression": { + "type": "CallExpression", + "span": { + "start": 279, + "end": 290, + "ctxt": 0 + }, + "callee": { + "type": "Identifier", + "span": { + "start": 279, + "end": 280, + "ctxt": 0 + }, + "value": "g", + "optional": false + }, + "arguments": [], + "typeArguments": { + "type": "TsTypeParameterInstantiation", + "span": { + "start": 280, + "end": 288, + "ctxt": 0 + }, + "params": [ + { + "type": "TsKeywordType", + "span": { + "start": 281, + "end": 287, + "ctxt": 0 + }, + "kind": "number" + } + ] + } + } + } + ], + "body": [], + "superClass": null, + "isAbstract": false, + "typeParams": null, + "superTypeParams": null, + "implements": [] + } + ] + }, + { + "type": "BlockStatement", + "span": { + "start": 305, + "end": 332, + "ctxt": 0 + }, + "stmts": [ + { + "type": "ClassDeclaration", + "identifier": { + "type": "Identifier", + "span": { + "start": 326, + "end": 327, + "ctxt": 0 + }, + "value": "C", + "optional": false + }, + "declare": false, + "span": { + "start": 307, + "end": 330, + "ctxt": 0 + }, + "decorators": [ + { + "type": "Decorator", + "span": { + "start": 307, + "end": 319, + "ctxt": 0 + }, + "expression": { + "type": "TsInstantiation", + "span": { + "start": 309, + "end": 318, + "ctxt": 0 + }, + "expression": { + "type": "Identifier", + "span": { + "start": 309, + "end": 310, + "ctxt": 0 + }, + "value": "g", + "optional": false + }, + "typeArguments": { + "type": "TsTypeParameterInstantiation", + "span": { + "start": 310, + "end": 318, + "ctxt": 0 + }, + "params": [ + { + "type": "TsKeywordType", + "span": { + "start": 311, + "end": 317, + "ctxt": 0 + }, + "kind": "number" + } + ] + } + } + } + ], + "body": [], + "superClass": null, + "isAbstract": false, + "typeParams": null, + "superTypeParams": null, + "implements": [] + } + ] + }, + { + "type": "BlockStatement", + "span": { + "start": 334, + "end": 363, + "ctxt": 0 + }, + "stmts": [ + { + "type": "ClassDeclaration", + "identifier": { + "type": "Identifier", + "span": { + "start": 357, + "end": 358, + "ctxt": 0 + }, + "value": "C", + "optional": false + }, + "declare": false, + "span": { + "start": 336, + "end": 361, + "ctxt": 0 + }, + "decorators": [ + { + "type": "Decorator", + "span": { + "start": 336, + "end": 350, + "ctxt": 0 + }, + "expression": { + "type": "TsInstantiation", + "span": { + "start": 338, + "end": 349, + "ctxt": 0 + }, + "expression": { + "type": "CallExpression", + "span": { + "start": 338, + "end": 341, + "ctxt": 0 + }, + "callee": { + "type": "Identifier", + "span": { + "start": 338, + "end": 339, + "ctxt": 0 + }, + "value": "h", + "optional": false + }, + "arguments": [], + "typeArguments": null + }, + "typeArguments": { + "type": "TsTypeParameterInstantiation", + "span": { + "start": 341, + "end": 349, + "ctxt": 0 + }, + "params": [ + { + "type": "TsKeywordType", + "span": { + "start": 342, + "end": 348, + "ctxt": 0 + }, + "kind": "number" + } + ] + } + } + } + ], + "body": [], + "superClass": null, + "isAbstract": false, + "typeParams": null, + "superTypeParams": null, + "implements": [] + } + ] + }, + { + "type": "BlockStatement", + "span": { + "start": 365, + "end": 388, + "ctxt": 0 + }, + "stmts": [ + { + "type": "ClassDeclaration", + "identifier": { + "type": "Identifier", + "span": { + "start": 382, + "end": 383, + "ctxt": 0 + }, + "value": "C", + "optional": false + }, + "declare": false, + "span": { + "start": 367, + "end": 386, + "ctxt": 0 + }, + "decorators": [ + { + "type": "Decorator", + "span": { + "start": 367, + "end": 375, + "ctxt": 0 + }, + "expression": { + "type": "MemberExpression", + "span": { + "start": 369, + "end": 374, + "ctxt": 0 + }, + "object": { + "type": "CallExpression", + "span": { + "start": 369, + "end": 372, + "ctxt": 0 + }, + "callee": { + "type": "Identifier", + "span": { + "start": 369, + "end": 370, + "ctxt": 0 + }, + "value": "x", + "optional": false + }, + "arguments": [], + "typeArguments": null + }, + "property": { + "type": "Identifier", + "span": { + "start": 373, + "end": 374, + "ctxt": 0 + }, + "value": "y", + "optional": false + } + } + } + ], + "body": [], + "superClass": null, + "isAbstract": false, + "typeParams": null, + "superTypeParams": null, + "implements": [] + } + ] + }, + { + "type": "BlockStatement", + "span": { + "start": 390, + "end": 415, + "ctxt": 0 + }, + "stmts": [ + { + "type": "ClassDeclaration", + "identifier": { + "type": "Identifier", + "span": { + "start": 409, + "end": 410, + "ctxt": 0 + }, + "value": "C", + "optional": false + }, + "declare": false, + "span": { + "start": 392, + "end": 413, + "ctxt": 0 + }, + "decorators": [ + { + "type": "Decorator", + "span": { + "start": 392, + "end": 402, + "ctxt": 0 + }, + "expression": { + "type": "CallExpression", + "span": { + "start": 394, + "end": 401, + "ctxt": 0 + }, + "callee": { + "type": "MemberExpression", + "span": { + "start": 394, + "end": 399, + "ctxt": 0 + }, + "object": { + "type": "CallExpression", + "span": { + "start": 394, + "end": 397, + "ctxt": 0 + }, + "callee": { + "type": "Identifier", + "span": { + "start": 394, + "end": 395, + "ctxt": 0 + }, + "value": "x", + "optional": false + }, + "arguments": [], + "typeArguments": null + }, + "property": { + "type": "Identifier", + "span": { + "start": 398, + "end": 399, + "ctxt": 0 + }, + "value": "y", + "optional": false + } + }, + "arguments": [], + "typeArguments": null + } + } + ], + "body": [], + "superClass": null, + "isAbstract": false, + "typeParams": null, + "superTypeParams": null, + "implements": [] + } + ] + }, + { + "type": "BlockStatement", + "span": { + "start": 417, + "end": 438, + "ctxt": 0 + }, + "stmts": [ + { + "type": "ClassDeclaration", + "identifier": { + "type": "Identifier", + "span": { + "start": 432, + "end": 433, + "ctxt": 0 + }, + "value": "C", + "optional": false + }, + "declare": false, + "span": { + "start": 419, + "end": 436, + "ctxt": 0 + }, + "decorators": [ + { + "type": "Decorator", + "span": { + "start": 419, + "end": 425, + "ctxt": 0 + }, + "expression": { + "type": "TaggedTemplateExpression", + "span": { + "start": 421, + "end": 424, + "ctxt": 0 + }, + "tag": { + "type": "Identifier", + "span": { + "start": 421, + "end": 422, + "ctxt": 0 + }, + "value": "x", + "optional": false + }, + "typeParameters": null, + "template": { + "type": "TemplateLiteral", + "span": { + "start": 422, + "end": 424, + "ctxt": 0 + }, + "expressions": [], + "quasis": [ + { + "type": "TemplateElement", + "span": { + "start": 423, + "end": 423, + "ctxt": 0 + }, + "tail": true, + "cooked": "", + "raw": "" + } + ] + } + } + } + ], + "body": [], + "superClass": null, + "isAbstract": false, + "typeParams": null, + "superTypeParams": null, + "implements": [] + } + ] + }, + { + "type": "BlockStatement", + "span": { + "start": 440, + "end": 463, + "ctxt": 0 + }, + "stmts": [ + { + "type": "ClassDeclaration", + "identifier": { + "type": "Identifier", + "span": { + "start": 457, + "end": 458, + "ctxt": 0 + }, + "value": "C", + "optional": false + }, + "declare": false, + "span": { + "start": 442, + "end": 461, + "ctxt": 0 + }, + "decorators": [ + { + "type": "Decorator", + "span": { + "start": 442, + "end": 450, + "ctxt": 0 + }, + "expression": { + "type": "TaggedTemplateExpression", + "span": { + "start": 444, + "end": 449, + "ctxt": 0 + }, + "tag": { + "type": "MemberExpression", + "span": { + "start": 444, + "end": 447, + "ctxt": 0 + }, + "object": { + "type": "Identifier", + "span": { + "start": 444, + "end": 445, + "ctxt": 0 + }, + "value": "x", + "optional": false + }, + "property": { + "type": "Identifier", + "span": { + "start": 446, + "end": 447, + "ctxt": 0 + }, + "value": "y", + "optional": false + } + }, + "typeParameters": null, + "template": { + "type": "TemplateLiteral", + "span": { + "start": 447, + "end": 449, + "ctxt": 0 + }, + "expressions": [], + "quasis": [ + { + "type": "TemplateElement", + "span": { + "start": 448, + "end": 448, + "ctxt": 0 + }, + "tail": true, + "cooked": "", + "raw": "" + } + ] + } + } + } + ], + "body": [], + "superClass": null, + "isAbstract": false, + "typeParams": null, + "superTypeParams": null, + "implements": [] + } + ] + }, + { + "type": "BlockStatement", + "span": { + "start": 465, + "end": 488, + "ctxt": 0 + }, + "stmts": [ + { + "type": "ClassDeclaration", + "identifier": { + "type": "Identifier", + "span": { + "start": 482, + "end": 483, + "ctxt": 0 + }, + "value": "C", + "optional": false + }, + "declare": false, + "span": { + "start": 467, + "end": 486, + "ctxt": 0 + }, + "decorators": [ + { + "type": "Decorator", + "span": { + "start": 467, + "end": 475, + "ctxt": 0 + }, + "expression": { + "type": "TsNonNullExpression", + "span": { + "start": 469, + "end": 474, + "ctxt": 0 + }, + "expression": { + "type": "OptionalChainingExpression", + "span": { + "start": 469, + "end": 473, + "ctxt": 0 + }, + "optional": true, + "base": { + "type": "MemberExpression", + "span": { + "start": 469, + "end": 473, + "ctxt": 0 + }, + "object": { + "type": "Identifier", + "span": { + "start": 469, + "end": 470, + "ctxt": 0 + }, + "value": "x", + "optional": false + }, + "property": { + "type": "Identifier", + "span": { + "start": 472, + "end": 473, + "ctxt": 0 + }, + "value": "y", + "optional": false + } + } + } + } + } + ], + "body": [], + "superClass": null, + "isAbstract": false, + "typeParams": null, + "superTypeParams": null, + "implements": [] + } + ] + }, + { + "type": "BlockStatement", + "span": { + "start": 490, + "end": 514, + "ctxt": 0 + }, + "stmts": [ + { + "type": "ClassDeclaration", + "identifier": { + "type": "Identifier", + "span": { + "start": 508, + "end": 509, + "ctxt": 0 + }, + "value": "C", + "optional": false + }, + "declare": false, + "span": { + "start": 492, + "end": 512, + "ctxt": 0 + }, + "decorators": [ + { + "type": "Decorator", + "span": { + "start": 492, + "end": 501, + "ctxt": 0 + }, + "expression": { + "type": "MemberExpression", + "span": { + "start": 494, + "end": 500, + "ctxt": 0 + }, + "object": { + "type": "Identifier", + "span": { + "start": 494, + "end": 495, + "ctxt": 0 + }, + "value": "x", + "optional": false + }, + "property": { + "type": "Computed", + "span": { + "start": 495, + "end": 500, + "ctxt": 0 + }, + "expression": { + "type": "StringLiteral", + "span": { + "start": 496, + "end": 499, + "ctxt": 0 + }, + "value": "y", + "raw": "\"y\"" + } + } + } + } + ], + "body": [], + "superClass": null, + "isAbstract": false, + "typeParams": null, + "superTypeParams": null, + "implements": [] + } + ] + }, + { + "type": "BlockStatement", + "span": { + "start": 516, + "end": 542, + "ctxt": 0 + }, + "stmts": [ + { + "type": "ClassDeclaration", + "identifier": { + "type": "Identifier", + "span": { + "start": 536, + "end": 537, + "ctxt": 0 + }, + "value": "C", + "optional": false + }, + "declare": false, + "span": { + "start": 518, + "end": 540, + "ctxt": 0 + }, + "decorators": [ + { + "type": "Decorator", + "span": { + "start": 518, + "end": 529, + "ctxt": 0 + }, + "expression": { + "type": "OptionalChainingExpression", + "span": { + "start": 520, + "end": 528, + "ctxt": 0 + }, + "optional": true, + "base": { + "type": "MemberExpression", + "span": { + "start": 520, + "end": 528, + "ctxt": 0 + }, + "object": { + "type": "Identifier", + "span": { + "start": 520, + "end": 521, + "ctxt": 0 + }, + "value": "x", + "optional": false + }, + "property": { + "type": "Computed", + "span": { + "start": 523, + "end": 528, + "ctxt": 0 + }, + "expression": { + "type": "StringLiteral", + "span": { + "start": 524, + "end": 527, + "ctxt": 0 + }, + "value": "y", + "raw": "\"y\"" + } + } + } + } + } + ], + "body": [], + "superClass": null, + "isAbstract": false, + "typeParams": null, + "superTypeParams": null, + "implements": [] + } + ] + }, + { + "type": "BlockStatement", + "span": { + "start": 544, + "end": 570, + "ctxt": 0 + }, + "stmts": [ + { + "type": "ClassDeclaration", + "identifier": { + "type": "Identifier", + "span": { + "start": 552, + "end": 553, + "ctxt": 0 + }, + "value": "C", + "optional": false + }, + "declare": false, + "span": { + "start": 546, + "end": 568, + "ctxt": 0 + }, + "decorators": [], + "body": [ + { + "type": "ClassMethod", + "span": { + "start": 556, + "end": 566, + "ctxt": 0 + }, + "key": { + "type": "Identifier", + "span": { + "start": 560, + "end": 561, + "ctxt": 0 + }, + "value": "m", + "optional": false + }, + "function": { + "params": [], + "decorators": [ + { + "type": "Decorator", + "span": { + "start": 556, + "end": 559, + "ctxt": 0 + }, + "expression": { + "type": "TsNonNullExpression", + "span": { + "start": 557, + "end": 559, + "ctxt": 0 + }, + "expression": { + "type": "Identifier", + "span": { + "start": 557, + "end": 558, + "ctxt": 0 + }, + "value": "x", + "optional": false + } + } + } + ], + "span": { + "start": 556, + "end": 566, + "ctxt": 0 + }, + "body": { + "type": "BlockStatement", + "span": { + "start": 564, + "end": 566, + "ctxt": 0 + }, + "stmts": [] + }, + "generator": false, + "async": false, + "typeParameters": null, + "returnType": null + }, + "kind": "method", + "isStatic": false, + "accessibility": null, + "isAbstract": false, + "isOptional": false, + "isOverride": false + } + ], + "superClass": null, + "isAbstract": false, + "typeParams": null, + "superTypeParams": null, + "implements": [] + } + ] + }, + { + "type": "BlockStatement", + "span": { + "start": 572, + "end": 600, + "ctxt": 0 + }, + "stmts": [ + { + "type": "ClassDeclaration", + "identifier": { + "type": "Identifier", + "span": { + "start": 580, + "end": 581, + "ctxt": 0 + }, + "value": "C", + "optional": false + }, + "declare": false, + "span": { + "start": 574, + "end": 598, + "ctxt": 0 + }, + "decorators": [], + "body": [ + { + "type": "ClassMethod", + "span": { + "start": 584, + "end": 596, + "ctxt": 0 + }, + "key": { + "type": "Identifier", + "span": { + "start": 590, + "end": 591, + "ctxt": 0 + }, + "value": "m", + "optional": false + }, + "function": { + "params": [], + "decorators": [ + { + "type": "Decorator", + "span": { + "start": 584, + "end": 589, + "ctxt": 0 + }, + "expression": { + "type": "TsNonNullExpression", + "span": { + "start": 585, + "end": 589, + "ctxt": 0 + }, + "expression": { + "type": "MemberExpression", + "span": { + "start": 585, + "end": 588, + "ctxt": 0 + }, + "object": { + "type": "Identifier", + "span": { + "start": 585, + "end": 586, + "ctxt": 0 + }, + "value": "x", + "optional": false + }, + "property": { + "type": "Identifier", + "span": { + "start": 587, + "end": 588, + "ctxt": 0 + }, + "value": "y", + "optional": false + } + } + } + } + ], + "span": { + "start": 584, + "end": 596, + "ctxt": 0 + }, + "body": { + "type": "BlockStatement", + "span": { + "start": 594, + "end": 596, + "ctxt": 0 + }, + "stmts": [] + }, + "generator": false, + "async": false, + "typeParameters": null, + "returnType": null + }, + "kind": "method", + "isStatic": false, + "accessibility": null, + "isAbstract": false, + "isOptional": false, + "isOverride": false + } + ], + "superClass": null, + "isAbstract": false, + "typeParams": null, + "superTypeParams": null, + "implements": [] + } + ] + }, + { + "type": "BlockStatement", + "span": { + "start": 602, + "end": 630, + "ctxt": 0 + }, + "stmts": [ + { + "type": "ClassDeclaration", + "identifier": { + "type": "Identifier", + "span": { + "start": 610, + "end": 611, + "ctxt": 0 + }, + "value": "C", + "optional": false + }, + "declare": false, + "span": { + "start": 604, + "end": 628, + "ctxt": 0 + }, + "decorators": [], + "body": [ + { + "type": "ClassMethod", + "span": { + "start": 614, + "end": 626, + "ctxt": 0 + }, + "key": { + "type": "Identifier", + "span": { + "start": 620, + "end": 621, + "ctxt": 0 + }, + "value": "m", + "optional": false + }, + "function": { + "params": [], + "decorators": [ + { + "type": "Decorator", + "span": { + "start": 614, + "end": 619, + "ctxt": 0 + }, + "expression": { + "type": "MemberExpression", + "span": { + "start": 615, + "end": 619, + "ctxt": 0 + }, + "object": { + "type": "TsNonNullExpression", + "span": { + "start": 615, + "end": 617, + "ctxt": 0 + }, + "expression": { + "type": "Identifier", + "span": { + "start": 615, + "end": 616, + "ctxt": 0 + }, + "value": "x", + "optional": false + } + }, + "property": { + "type": "Identifier", + "span": { + "start": 618, + "end": 619, + "ctxt": 0 + }, + "value": "y", + "optional": false + } + } + } + ], + "span": { + "start": 614, + "end": 626, + "ctxt": 0 + }, + "body": { + "type": "BlockStatement", + "span": { + "start": 624, + "end": 626, + "ctxt": 0 + }, + "stmts": [] + }, + "generator": false, + "async": false, + "typeParameters": null, + "returnType": null + }, + "kind": "method", + "isStatic": false, + "accessibility": null, + "isAbstract": false, + "isOptional": false, + "isOverride": false + } + ], + "superClass": null, + "isAbstract": false, + "typeParams": null, + "superTypeParams": null, + "implements": [] + } + ] + }, + { + "type": "BlockStatement", + "span": { + "start": 632, + "end": 667, + "ctxt": 0 + }, + "stmts": [ + { + "type": "ClassDeclaration", + "identifier": { + "type": "Identifier", + "span": { + "start": 640, + "end": 641, + "ctxt": 0 + }, + "value": "C", + "optional": false + }, + "declare": false, + "span": { + "start": 634, + "end": 665, + "ctxt": 0 + }, + "decorators": [], + "body": [ + { + "type": "ClassMethod", + "span": { + "start": 644, + "end": 663, + "ctxt": 0 + }, + "key": { + "type": "Identifier", + "span": { + "start": 657, + "end": 658, + "ctxt": 0 + }, + "value": "m", + "optional": false + }, + "function": { + "params": [], + "decorators": [ + { + "type": "Decorator", + "span": { + "start": 644, + "end": 656, + "ctxt": 0 + }, + "expression": { + "type": "CallExpression", + "span": { + "start": 645, + "end": 656, + "ctxt": 0 + }, + "callee": { + "type": "Identifier", + "span": { + "start": 645, + "end": 646, + "ctxt": 0 + }, + "value": "g", + "optional": false + }, + "arguments": [], + "typeArguments": { + "type": "TsTypeParameterInstantiation", + "span": { + "start": 646, + "end": 654, + "ctxt": 0 + }, + "params": [ + { + "type": "TsKeywordType", + "span": { + "start": 647, + "end": 653, + "ctxt": 0 + }, + "kind": "number" + } + ] + } + } + } + ], + "span": { + "start": 644, + "end": 663, + "ctxt": 0 + }, + "body": { + "type": "BlockStatement", + "span": { + "start": 661, + "end": 663, + "ctxt": 0 + }, + "stmts": [] + }, + "generator": false, + "async": false, + "typeParameters": null, + "returnType": null + }, + "kind": "method", + "isStatic": false, + "accessibility": null, + "isAbstract": false, + "isOptional": false, + "isOverride": false + } + ], + "superClass": null, + "isAbstract": false, + "typeParams": null, + "superTypeParams": null, + "implements": [] + } + ] + }, + { + "type": "BlockStatement", + "span": { + "start": 669, + "end": 704, + "ctxt": 0 + }, + "stmts": [ + { + "type": "ClassDeclaration", + "identifier": { + "type": "Identifier", + "span": { + "start": 677, + "end": 678, + "ctxt": 0 + }, + "value": "C", + "optional": false + }, + "declare": false, + "span": { + "start": 671, + "end": 702, + "ctxt": 0 + }, + "decorators": [], + "body": [ + { + "type": "ClassMethod", + "span": { + "start": 681, + "end": 700, + "ctxt": 0 + }, + "key": { + "type": "Identifier", + "span": { + "start": 694, + "end": 695, + "ctxt": 0 + }, + "value": "m", + "optional": false + }, + "function": { + "params": [], + "decorators": [ + { + "type": "Decorator", + "span": { + "start": 681, + "end": 693, + "ctxt": 0 + }, + "expression": { + "type": "TsInstantiation", + "span": { + "start": 683, + "end": 692, + "ctxt": 0 + }, + "expression": { + "type": "Identifier", + "span": { + "start": 683, + "end": 684, + "ctxt": 0 + }, + "value": "g", + "optional": false + }, + "typeArguments": { + "type": "TsTypeParameterInstantiation", + "span": { + "start": 684, + "end": 692, + "ctxt": 0 + }, + "params": [ + { + "type": "TsKeywordType", + "span": { + "start": 685, + "end": 691, + "ctxt": 0 + }, + "kind": "number" + } + ] + } + } + } + ], + "span": { + "start": 681, + "end": 700, + "ctxt": 0 + }, + "body": { + "type": "BlockStatement", + "span": { + "start": 698, + "end": 700, + "ctxt": 0 + }, + "stmts": [] + }, + "generator": false, + "async": false, + "typeParameters": null, + "returnType": null + }, + "kind": "method", + "isStatic": false, + "accessibility": null, + "isAbstract": false, + "isOptional": false, + "isOverride": false + } + ], + "superClass": null, + "isAbstract": false, + "typeParams": null, + "superTypeParams": null, + "implements": [] + } + ] + }, + { + "type": "BlockStatement", + "span": { + "start": 706, + "end": 743, + "ctxt": 0 + }, + "stmts": [ + { + "type": "ClassDeclaration", + "identifier": { + "type": "Identifier", + "span": { + "start": 714, + "end": 715, + "ctxt": 0 + }, + "value": "C", + "optional": false + }, + "declare": false, + "span": { + "start": 708, + "end": 741, + "ctxt": 0 + }, + "decorators": [], + "body": [ + { + "type": "ClassMethod", + "span": { + "start": 718, + "end": 739, + "ctxt": 0 + }, + "key": { + "type": "Identifier", + "span": { + "start": 733, + "end": 734, + "ctxt": 0 + }, + "value": "m", + "optional": false + }, + "function": { + "params": [], + "decorators": [ + { + "type": "Decorator", + "span": { + "start": 718, + "end": 732, + "ctxt": 0 + }, + "expression": { + "type": "TsInstantiation", + "span": { + "start": 720, + "end": 731, + "ctxt": 0 + }, + "expression": { + "type": "CallExpression", + "span": { + "start": 720, + "end": 723, + "ctxt": 0 + }, + "callee": { + "type": "Identifier", + "span": { + "start": 720, + "end": 721, + "ctxt": 0 + }, + "value": "h", + "optional": false + }, + "arguments": [], + "typeArguments": null + }, + "typeArguments": { + "type": "TsTypeParameterInstantiation", + "span": { + "start": 723, + "end": 731, + "ctxt": 0 + }, + "params": [ + { + "type": "TsKeywordType", + "span": { + "start": 724, + "end": 730, + "ctxt": 0 + }, + "kind": "number" + } + ] + } + } + } + ], + "span": { + "start": 718, + "end": 739, + "ctxt": 0 + }, + "body": { + "type": "BlockStatement", + "span": { + "start": 737, + "end": 739, + "ctxt": 0 + }, + "stmts": [] + }, + "generator": false, + "async": false, + "typeParameters": null, + "returnType": null + }, + "kind": "method", + "isStatic": false, + "accessibility": null, + "isAbstract": false, + "isOptional": false, + "isOverride": false + } + ], + "superClass": null, + "isAbstract": false, + "typeParams": null, + "superTypeParams": null, + "implements": [] + } + ] + }, + { + "type": "BlockStatement", + "span": { + "start": 745, + "end": 776, + "ctxt": 0 + }, + "stmts": [ + { + "type": "ClassDeclaration", + "identifier": { + "type": "Identifier", + "span": { + "start": 753, + "end": 754, + "ctxt": 0 + }, + "value": "C", + "optional": false + }, + "declare": false, + "span": { + "start": 747, + "end": 774, + "ctxt": 0 + }, + "decorators": [], + "body": [ + { + "type": "ClassMethod", + "span": { + "start": 757, + "end": 772, + "ctxt": 0 + }, + "key": { + "type": "Identifier", + "span": { + "start": 766, + "end": 767, + "ctxt": 0 + }, + "value": "m", + "optional": false + }, + "function": { + "params": [], + "decorators": [ + { + "type": "Decorator", + "span": { + "start": 757, + "end": 765, + "ctxt": 0 + }, + "expression": { + "type": "MemberExpression", + "span": { + "start": 759, + "end": 764, + "ctxt": 0 + }, + "object": { + "type": "CallExpression", + "span": { + "start": 759, + "end": 762, + "ctxt": 0 + }, + "callee": { + "type": "Identifier", + "span": { + "start": 759, + "end": 760, + "ctxt": 0 + }, + "value": "x", + "optional": false + }, + "arguments": [], + "typeArguments": null + }, + "property": { + "type": "Identifier", + "span": { + "start": 763, + "end": 764, + "ctxt": 0 + }, + "value": "y", + "optional": false + } + } + } + ], + "span": { + "start": 757, + "end": 772, + "ctxt": 0 + }, + "body": { + "type": "BlockStatement", + "span": { + "start": 770, + "end": 772, + "ctxt": 0 + }, + "stmts": [] + }, + "generator": false, + "async": false, + "typeParameters": null, + "returnType": null + }, + "kind": "method", + "isStatic": false, + "accessibility": null, + "isAbstract": false, + "isOptional": false, + "isOverride": false + } + ], + "superClass": null, + "isAbstract": false, + "typeParams": null, + "superTypeParams": null, + "implements": [] + } + ] + }, + { + "type": "BlockStatement", + "span": { + "start": 778, + "end": 811, + "ctxt": 0 + }, + "stmts": [ + { + "type": "ClassDeclaration", + "identifier": { + "type": "Identifier", + "span": { + "start": 786, + "end": 787, + "ctxt": 0 + }, + "value": "C", + "optional": false + }, + "declare": false, + "span": { + "start": 780, + "end": 809, + "ctxt": 0 + }, + "decorators": [], + "body": [ + { + "type": "ClassMethod", + "span": { + "start": 790, + "end": 807, + "ctxt": 0 + }, + "key": { + "type": "Identifier", + "span": { + "start": 801, + "end": 802, + "ctxt": 0 + }, + "value": "m", + "optional": false + }, + "function": { + "params": [], + "decorators": [ + { + "type": "Decorator", + "span": { + "start": 790, + "end": 800, + "ctxt": 0 + }, + "expression": { + "type": "CallExpression", + "span": { + "start": 792, + "end": 799, + "ctxt": 0 + }, + "callee": { + "type": "MemberExpression", + "span": { + "start": 792, + "end": 797, + "ctxt": 0 + }, + "object": { + "type": "CallExpression", + "span": { + "start": 792, + "end": 795, + "ctxt": 0 + }, + "callee": { + "type": "Identifier", + "span": { + "start": 792, + "end": 793, + "ctxt": 0 + }, + "value": "x", + "optional": false + }, + "arguments": [], + "typeArguments": null + }, + "property": { + "type": "Identifier", + "span": { + "start": 796, + "end": 797, + "ctxt": 0 + }, + "value": "y", + "optional": false + } + }, + "arguments": [], + "typeArguments": null + } + } + ], + "span": { + "start": 790, + "end": 807, + "ctxt": 0 + }, + "body": { + "type": "BlockStatement", + "span": { + "start": 805, + "end": 807, + "ctxt": 0 + }, + "stmts": [] + }, + "generator": false, + "async": false, + "typeParameters": null, + "returnType": null + }, + "kind": "method", + "isStatic": false, + "accessibility": null, + "isAbstract": false, + "isOptional": false, + "isOverride": false + } + ], + "superClass": null, + "isAbstract": false, + "typeParams": null, + "superTypeParams": null, + "implements": [] + } + ] + }, + { + "type": "BlockStatement", + "span": { + "start": 813, + "end": 842, + "ctxt": 0 + }, + "stmts": [ + { + "type": "ClassDeclaration", + "identifier": { + "type": "Identifier", + "span": { + "start": 821, + "end": 822, + "ctxt": 0 + }, + "value": "C", + "optional": false + }, + "declare": false, + "span": { + "start": 815, + "end": 840, + "ctxt": 0 + }, + "decorators": [], + "body": [ + { + "type": "ClassMethod", + "span": { + "start": 825, + "end": 838, + "ctxt": 0 + }, + "key": { + "type": "Identifier", + "span": { + "start": 832, + "end": 833, + "ctxt": 0 + }, + "value": "m", + "optional": false + }, + "function": { + "params": [], + "decorators": [ + { + "type": "Decorator", + "span": { + "start": 825, + "end": 831, + "ctxt": 0 + }, + "expression": { + "type": "TaggedTemplateExpression", + "span": { + "start": 827, + "end": 830, + "ctxt": 0 + }, + "tag": { + "type": "Identifier", + "span": { + "start": 827, + "end": 828, + "ctxt": 0 + }, + "value": "x", + "optional": false + }, + "typeParameters": null, + "template": { + "type": "TemplateLiteral", + "span": { + "start": 828, + "end": 830, + "ctxt": 0 + }, + "expressions": [], + "quasis": [ + { + "type": "TemplateElement", + "span": { + "start": 829, + "end": 829, + "ctxt": 0 + }, + "tail": true, + "cooked": "", + "raw": "" + } + ] + } + } + } + ], + "span": { + "start": 825, + "end": 838, + "ctxt": 0 + }, + "body": { + "type": "BlockStatement", + "span": { + "start": 836, + "end": 838, + "ctxt": 0 + }, + "stmts": [] + }, + "generator": false, + "async": false, + "typeParameters": null, + "returnType": null + }, + "kind": "method", + "isStatic": false, + "accessibility": null, + "isAbstract": false, + "isOptional": false, + "isOverride": false + } + ], + "superClass": null, + "isAbstract": false, + "typeParams": null, + "superTypeParams": null, + "implements": [] + } + ] + }, + { + "type": "BlockStatement", + "span": { + "start": 844, + "end": 875, + "ctxt": 0 + }, + "stmts": [ + { + "type": "ClassDeclaration", + "identifier": { + "type": "Identifier", + "span": { + "start": 852, + "end": 853, + "ctxt": 0 + }, + "value": "C", + "optional": false + }, + "declare": false, + "span": { + "start": 846, + "end": 873, + "ctxt": 0 + }, + "decorators": [], + "body": [ + { + "type": "ClassMethod", + "span": { + "start": 856, + "end": 871, + "ctxt": 0 + }, + "key": { + "type": "Identifier", + "span": { + "start": 865, + "end": 866, + "ctxt": 0 + }, + "value": "m", + "optional": false + }, + "function": { + "params": [], + "decorators": [ + { + "type": "Decorator", + "span": { + "start": 856, + "end": 864, + "ctxt": 0 + }, + "expression": { + "type": "TaggedTemplateExpression", + "span": { + "start": 858, + "end": 863, + "ctxt": 0 + }, + "tag": { + "type": "MemberExpression", + "span": { + "start": 858, + "end": 861, + "ctxt": 0 + }, + "object": { + "type": "Identifier", + "span": { + "start": 858, + "end": 859, + "ctxt": 0 + }, + "value": "x", + "optional": false + }, + "property": { + "type": "Identifier", + "span": { + "start": 860, + "end": 861, + "ctxt": 0 + }, + "value": "y", + "optional": false + } + }, + "typeParameters": null, + "template": { + "type": "TemplateLiteral", + "span": { + "start": 861, + "end": 863, + "ctxt": 0 + }, + "expressions": [], + "quasis": [ + { + "type": "TemplateElement", + "span": { + "start": 862, + "end": 862, + "ctxt": 0 + }, + "tail": true, + "cooked": "", + "raw": "" + } + ] + } + } + } + ], + "span": { + "start": 856, + "end": 871, + "ctxt": 0 + }, + "body": { + "type": "BlockStatement", + "span": { + "start": 869, + "end": 871, + "ctxt": 0 + }, + "stmts": [] + }, + "generator": false, + "async": false, + "typeParameters": null, + "returnType": null + }, + "kind": "method", + "isStatic": false, + "accessibility": null, + "isAbstract": false, + "isOptional": false, + "isOverride": false + } + ], + "superClass": null, + "isAbstract": false, + "typeParams": null, + "superTypeParams": null, + "implements": [] + } + ] + }, + { + "type": "BlockStatement", + "span": { + "start": 877, + "end": 908, + "ctxt": 0 + }, + "stmts": [ + { + "type": "ClassDeclaration", + "identifier": { + "type": "Identifier", + "span": { + "start": 885, + "end": 886, + "ctxt": 0 + }, + "value": "C", + "optional": false + }, + "declare": false, + "span": { + "start": 879, + "end": 906, + "ctxt": 0 + }, + "decorators": [], + "body": [ + { + "type": "ClassMethod", + "span": { + "start": 889, + "end": 904, + "ctxt": 0 + }, + "key": { + "type": "Identifier", + "span": { + "start": 898, + "end": 899, + "ctxt": 0 + }, + "value": "m", + "optional": false + }, + "function": { + "params": [], + "decorators": [ + { + "type": "Decorator", + "span": { + "start": 889, + "end": 897, + "ctxt": 0 + }, + "expression": { + "type": "TsNonNullExpression", + "span": { + "start": 891, + "end": 896, + "ctxt": 0 + }, + "expression": { + "type": "OptionalChainingExpression", + "span": { + "start": 891, + "end": 895, + "ctxt": 0 + }, + "optional": true, + "base": { + "type": "MemberExpression", + "span": { + "start": 891, + "end": 895, + "ctxt": 0 + }, + "object": { + "type": "Identifier", + "span": { + "start": 891, + "end": 892, + "ctxt": 0 + }, + "value": "x", + "optional": false + }, + "property": { + "type": "Identifier", + "span": { + "start": 894, + "end": 895, + "ctxt": 0 + }, + "value": "y", + "optional": false + } + } + } + } + } + ], + "span": { + "start": 889, + "end": 904, + "ctxt": 0 + }, + "body": { + "type": "BlockStatement", + "span": { + "start": 902, + "end": 904, + "ctxt": 0 + }, + "stmts": [] + }, + "generator": false, + "async": false, + "typeParameters": null, + "returnType": null + }, + "kind": "method", + "isStatic": false, + "accessibility": null, + "isAbstract": false, + "isOptional": false, + "isOverride": false + } + ], + "superClass": null, + "isAbstract": false, + "typeParams": null, + "superTypeParams": null, + "implements": [] + } + ] + }, + { + "type": "BlockStatement", + "span": { + "start": 910, + "end": 942, + "ctxt": 0 + }, + "stmts": [ + { + "type": "ClassDeclaration", + "identifier": { + "type": "Identifier", + "span": { + "start": 918, + "end": 919, + "ctxt": 0 + }, + "value": "C", + "optional": false + }, + "declare": false, + "span": { + "start": 912, + "end": 940, + "ctxt": 0 + }, + "decorators": [], + "body": [ + { + "type": "ClassMethod", + "span": { + "start": 922, + "end": 938, + "ctxt": 0 + }, + "key": { + "type": "Identifier", + "span": { + "start": 932, + "end": 933, + "ctxt": 0 + }, + "value": "m", + "optional": false + }, + "function": { + "params": [], + "decorators": [ + { + "type": "Decorator", + "span": { + "start": 922, + "end": 931, + "ctxt": 0 + }, + "expression": { + "type": "MemberExpression", + "span": { + "start": 924, + "end": 930, + "ctxt": 0 + }, + "object": { + "type": "Identifier", + "span": { + "start": 924, + "end": 925, + "ctxt": 0 + }, + "value": "x", + "optional": false + }, + "property": { + "type": "Computed", + "span": { + "start": 925, + "end": 930, + "ctxt": 0 + }, + "expression": { + "type": "StringLiteral", + "span": { + "start": 926, + "end": 929, + "ctxt": 0 + }, + "value": "y", + "raw": "\"y\"" + } + } + } + } + ], + "span": { + "start": 922, + "end": 938, + "ctxt": 0 + }, + "body": { + "type": "BlockStatement", + "span": { + "start": 936, + "end": 938, + "ctxt": 0 + }, + "stmts": [] + }, + "generator": false, + "async": false, + "typeParameters": null, + "returnType": null + }, + "kind": "method", + "isStatic": false, + "accessibility": null, + "isAbstract": false, + "isOptional": false, + "isOverride": false + } + ], + "superClass": null, + "isAbstract": false, + "typeParams": null, + "superTypeParams": null, + "implements": [] + } + ] + }, + { + "type": "BlockStatement", + "span": { + "start": 944, + "end": 978, + "ctxt": 0 + }, + "stmts": [ + { + "type": "ClassDeclaration", + "identifier": { + "type": "Identifier", + "span": { + "start": 952, + "end": 953, + "ctxt": 0 + }, + "value": "C", + "optional": false + }, + "declare": false, + "span": { + "start": 946, + "end": 976, + "ctxt": 0 + }, + "decorators": [], + "body": [ + { + "type": "ClassMethod", + "span": { + "start": 956, + "end": 974, + "ctxt": 0 + }, + "key": { + "type": "Identifier", + "span": { + "start": 968, + "end": 969, + "ctxt": 0 + }, + "value": "m", + "optional": false + }, + "function": { + "params": [], + "decorators": [ + { + "type": "Decorator", + "span": { + "start": 956, + "end": 967, + "ctxt": 0 + }, + "expression": { + "type": "OptionalChainingExpression", + "span": { + "start": 958, + "end": 966, + "ctxt": 0 + }, + "optional": true, + "base": { + "type": "MemberExpression", + "span": { + "start": 958, + "end": 966, + "ctxt": 0 + }, + "object": { + "type": "Identifier", + "span": { + "start": 958, + "end": 959, + "ctxt": 0 + }, + "value": "x", + "optional": false + }, + "property": { + "type": "Computed", + "span": { + "start": 961, + "end": 966, + "ctxt": 0 + }, + "expression": { + "type": "StringLiteral", + "span": { + "start": 962, + "end": 965, + "ctxt": 0 + }, + "value": "y", + "raw": "\"y\"" + } + } + } + } + } + ], + "span": { + "start": 956, + "end": 974, + "ctxt": 0 + }, + "body": { + "type": "BlockStatement", + "span": { + "start": 972, + "end": 974, + "ctxt": 0 + }, + "stmts": [] + }, + "generator": false, + "async": false, + "typeParameters": null, + "returnType": null + }, + "kind": "method", + "isStatic": false, + "accessibility": null, + "isAbstract": false, + "isOptional": false, + "isOverride": false + } + ], + "superClass": null, + "isAbstract": false, + "typeParams": null, + "superTypeParams": null, + "implements": [] + } + ] + } + ], + "interpreter": null +} diff --git a/crates/swc_ecma_parser/tests/tsc/esDecorators-decoratorExpression.2.ts b/crates/swc_ecma_parser/tests/tsc/esDecorators-decoratorExpression.2.ts new file mode 100644 index 000000000000..36903099cb6d --- /dev/null +++ b/crates/swc_ecma_parser/tests/tsc/esDecorators-decoratorExpression.2.ts @@ -0,0 +1,60 @@ +// @target: esnext +// @experimentalDecorators: * +// @noEmitHelpers: true +// @noTypesAndSymbols: true + +declare let x: any; +declare let g: (...args: any) => any; +declare let h: () => (...args: any) => any; + +{ @x! class C {} } + +{ @x.y! class C {} } + +{ @x!.y class C {} } + +{ @g() class C {} } + +{ @(g) class C {} } + +{ @(h()) class C {} } + +{ @(x().y) class C {} } + +{ @(x().y()) class C {} } + +{ @(x``) class C {} } + +{ @(x.y``) class C {} } + +{ @(x?.y!) class C {} } + +{ @(x["y"]) class C {} } + +{ @(x?.["y"]) class C {} } + +{ class C { @x! m() {} } } + +{ class C { @x.y! m() {} } } + +{ class C { @x!.y m() {} } } + +{ class C { @g() m() {} } } + +{ class C { @(g) m() {} } } + +{ class C { @(h()) m() {} } } + +{ class C { @(x().y) m() {} } } + +{ class C { @(x().y()) m() {} } } + +{ class C { @(x``) m() {} } } + +{ class C { @(x.y``) m() {} } } + +{ class C { @(x?.y!) m() {} } } + +{ class C { @(x["y"]) m() {} } } + +{ class C { @(x?.["y"]) m() {} } } diff --git a/crates/swc_ecma_parser/tests/tsc/esDecorators-preservesThis.ts b/crates/swc_ecma_parser/tests/tsc/esDecorators-preservesThis.ts index e1c688099f96..6972c8287068 100644 --- a/crates/swc_ecma_parser/tests/tsc/esDecorators-preservesThis.ts +++ b/crates/swc_ecma_parser/tests/tsc/esDecorators-preservesThis.ts @@ -24,7 +24,7 @@ class C { class D extends DecoratorProvider { m() { class C { - @super.decorate + @(super.decorate) method1() { } @(super["decorate"]) diff --git a/crates/swc_ecma_parser/tests/tsc/exportAndImport-es3-amd.json b/crates/swc_ecma_parser/tests/tsc/exportAndImport-es3-amd.json deleted file mode 100644 index e25c7d79af45..000000000000 --- a/crates/swc_ecma_parser/tests/tsc/exportAndImport-es3-amd.json +++ /dev/null @@ -1,163 +0,0 @@ -{ - "type": "Module", - "span": { - "start": 52, - "end": 171, - "ctxt": 0 - }, - "body": [ - { - "type": "ExportDefaultDeclaration", - "span": { - "start": 52, - "end": 84, - "ctxt": 0 - }, - "decl": { - "type": "FunctionExpression", - "identifier": { - "type": "Identifier", - "span": { - "start": 76, - "end": 78, - "ctxt": 0 - }, - "value": "f1", - "optional": false - }, - "params": [], - "decorators": [], - "span": { - "start": 67, - "end": 84, - "ctxt": 0 - }, - "body": { - "type": "BlockStatement", - "span": { - "start": 81, - "end": 84, - "ctxt": 0 - }, - "stmts": [] - }, - "generator": false, - "async": false, - "typeParameters": null, - "returnType": null - } - }, - { - "type": "ImportDeclaration", - "span": { - "start": 106, - "end": 128, - "ctxt": 0 - }, - "specifiers": [ - { - "type": "ImportDefaultSpecifier", - "span": { - "start": 113, - "end": 115, - "ctxt": 0 - }, - "local": { - "type": "Identifier", - "span": { - "start": 113, - "end": 115, - "ctxt": 0 - }, - "value": "f1", - "optional": false - } - } - ], - "source": { - "type": "StringLiteral", - "span": { - "start": 121, - "end": 127, - "ctxt": 0 - }, - "value": "./m1", - "raw": "\"./m1\"" - }, - "typeOnly": false, - "with": null, - "phase": "evaluation" - }, - { - "type": "ExportDefaultDeclaration", - "span": { - "start": 129, - "end": 171, - "ctxt": 0 - }, - "decl": { - "type": "FunctionExpression", - "identifier": { - "type": "Identifier", - "span": { - "start": 153, - "end": 155, - "ctxt": 0 - }, - "value": "f2", - "optional": false - }, - "params": [], - "decorators": [], - "span": { - "start": 144, - "end": 171, - "ctxt": 0 - }, - "body": { - "type": "BlockStatement", - "span": { - "start": 158, - "end": 171, - "ctxt": 0 - }, - "stmts": [ - { - "type": "ExpressionStatement", - "span": { - "start": 164, - "end": 169, - "ctxt": 0 - }, - "expression": { - "type": "CallExpression", - "span": { - "start": 164, - "end": 168, - "ctxt": 0 - }, - "callee": { - "type": "Identifier", - "span": { - "start": 164, - "end": 166, - "ctxt": 0 - }, - "value": "f1", - "optional": false - }, - "arguments": [], - "typeArguments": null - } - } - ] - }, - "generator": false, - "async": false, - "typeParameters": null, - "returnType": null - } - } - ], - "interpreter": null -} diff --git a/crates/swc_ecma_parser/tests/tsc/exportAndImport-es3-amd.ts b/crates/swc_ecma_parser/tests/tsc/exportAndImport-es3-amd.ts deleted file mode 100644 index 725230dbe6d0..000000000000 --- a/crates/swc_ecma_parser/tests/tsc/exportAndImport-es3-amd.ts +++ /dev/null @@ -1,12 +0,0 @@ -//@module: amd -//@target: ES3 - -// @filename: m1.ts -export default function f1() { -} - -// @filename: m2.ts -import f1 from "./m1"; -export default function f2() { - f1(); -} diff --git a/crates/swc_ecma_parser/tests/tsc/exportAndImport-es3.json b/crates/swc_ecma_parser/tests/tsc/exportAndImport-es3.json deleted file mode 100644 index 61d7986a4bd6..000000000000 --- a/crates/swc_ecma_parser/tests/tsc/exportAndImport-es3.json +++ /dev/null @@ -1,163 +0,0 @@ -{ - "type": "Module", - "span": { - "start": 57, - "end": 174, - "ctxt": 0 - }, - "body": [ - { - "type": "ExportDefaultDeclaration", - "span": { - "start": 57, - "end": 89, - "ctxt": 0 - }, - "decl": { - "type": "FunctionExpression", - "identifier": { - "type": "Identifier", - "span": { - "start": 81, - "end": 83, - "ctxt": 0 - }, - "value": "f1", - "optional": false - }, - "params": [], - "decorators": [], - "span": { - "start": 72, - "end": 89, - "ctxt": 0 - }, - "body": { - "type": "BlockStatement", - "span": { - "start": 86, - "end": 89, - "ctxt": 0 - }, - "stmts": [] - }, - "generator": false, - "async": false, - "typeParameters": null, - "returnType": null - } - }, - { - "type": "ImportDeclaration", - "span": { - "start": 111, - "end": 133, - "ctxt": 0 - }, - "specifiers": [ - { - "type": "ImportDefaultSpecifier", - "span": { - "start": 118, - "end": 120, - "ctxt": 0 - }, - "local": { - "type": "Identifier", - "span": { - "start": 118, - "end": 120, - "ctxt": 0 - }, - "value": "f1", - "optional": false - } - } - ], - "source": { - "type": "StringLiteral", - "span": { - "start": 126, - "end": 132, - "ctxt": 0 - }, - "value": "./m1", - "raw": "\"./m1\"" - }, - "typeOnly": false, - "with": null, - "phase": "evaluation" - }, - { - "type": "ExportDefaultDeclaration", - "span": { - "start": 134, - "end": 174, - "ctxt": 0 - }, - "decl": { - "type": "FunctionExpression", - "identifier": { - "type": "Identifier", - "span": { - "start": 158, - "end": 160, - "ctxt": 0 - }, - "value": "f2", - "optional": false - }, - "params": [], - "decorators": [], - "span": { - "start": 149, - "end": 174, - "ctxt": 0 - }, - "body": { - "type": "BlockStatement", - "span": { - "start": 163, - "end": 174, - "ctxt": 0 - }, - "stmts": [ - { - "type": "ExpressionStatement", - "span": { - "start": 167, - "end": 172, - "ctxt": 0 - }, - "expression": { - "type": "CallExpression", - "span": { - "start": 167, - "end": 171, - "ctxt": 0 - }, - "callee": { - "type": "Identifier", - "span": { - "start": 167, - "end": 169, - "ctxt": 0 - }, - "value": "f1", - "optional": false - }, - "arguments": [], - "typeArguments": null - } - } - ] - }, - "generator": false, - "async": false, - "typeParameters": null, - "returnType": null - } - } - ], - "interpreter": null -} diff --git a/crates/swc_ecma_parser/tests/tsc/exportAndImport-es3.ts b/crates/swc_ecma_parser/tests/tsc/exportAndImport-es3.ts deleted file mode 100644 index fbb6ad5f20bf..000000000000 --- a/crates/swc_ecma_parser/tests/tsc/exportAndImport-es3.ts +++ /dev/null @@ -1,12 +0,0 @@ -//@module: commonjs -//@target: ES3 - -// @filename: m1.ts -export default function f1() { -} - -// @filename: m2.ts -import f1 from "./m1"; -export default function f2() { - f1(); -} diff --git a/crates/swc_ecma_parser/tests/tsc/exportDefaultInJsFile01.ts b/crates/swc_ecma_parser/tests/tsc/exportDefaultInJsFile01.ts index 7bb17d6a6019..e07f8fbfb3f8 100644 --- a/crates/swc_ecma_parser/tests/tsc/exportDefaultInJsFile01.ts +++ b/crates/swc_ecma_parser/tests/tsc/exportDefaultInJsFile01.ts @@ -1,5 +1,5 @@ // @allowJS: true -// @target: es3 +// @target: es5 // @module: commonjs // @filename: myFile01.js diff --git a/crates/swc_ecma_parser/tests/tsc/exportsAndImportsWithUnderscores2.ts b/crates/swc_ecma_parser/tests/tsc/exportsAndImportsWithUnderscores2.ts index 26c123f2aa20..dc2381cd207f 100644 --- a/crates/swc_ecma_parser/tests/tsc/exportsAndImportsWithUnderscores2.ts +++ b/crates/swc_ecma_parser/tests/tsc/exportsAndImportsWithUnderscores2.ts @@ -1,5 +1,5 @@ //@module: commonjs -//@target: ES3 +//@target: ES5 // @filename: m1.ts var R: any diff --git a/crates/swc_ecma_parser/tests/tsc/exportsAndImportsWithUnderscores3.ts b/crates/swc_ecma_parser/tests/tsc/exportsAndImportsWithUnderscores3.ts index 6eb6351ad684..03b7a008e2fc 100644 --- a/crates/swc_ecma_parser/tests/tsc/exportsAndImportsWithUnderscores3.ts +++ b/crates/swc_ecma_parser/tests/tsc/exportsAndImportsWithUnderscores3.ts @@ -1,5 +1,5 @@ //@module: commonjs -//@target: ES3 +//@target: ES5 // @filename: m1.ts var R: any diff --git a/crates/swc_ecma_parser/tests/tsc/exportsAndImportsWithUnderscores4.ts b/crates/swc_ecma_parser/tests/tsc/exportsAndImportsWithUnderscores4.ts index 3c40d1986705..93b86c9b06bf 100644 --- a/crates/swc_ecma_parser/tests/tsc/exportsAndImportsWithUnderscores4.ts +++ b/crates/swc_ecma_parser/tests/tsc/exportsAndImportsWithUnderscores4.ts @@ -1,5 +1,5 @@ //@module: commonjs -//@target: ES3 +//@target: ES5 // @filename: m1.ts declare var console: any; diff --git a/crates/swc_ecma_parser/tests/tsc/genericSetterInClassTypeJsDoc.json b/crates/swc_ecma_parser/tests/tsc/genericSetterInClassTypeJsDoc.json index 777ebcf39f07..e30b914aa4bd 100644 --- a/crates/swc_ecma_parser/tests/tsc/genericSetterInClassTypeJsDoc.json +++ b/crates/swc_ecma_parser/tests/tsc/genericSetterInClassTypeJsDoc.json @@ -1,8 +1,8 @@ { "type": "Script", "span": { - "start": 212, - "end": 507, + "start": 216, + "end": 511, "ctxt": 0 }, "body": [ @@ -11,8 +11,8 @@ "identifier": { "type": "Identifier", "span": { - "start": 218, - "end": 221, + "start": 222, + "end": 225, "ctxt": 0 }, "value": "Box", @@ -20,8 +20,8 @@ }, "declare": false, "span": { - "start": 212, - "end": 484, + "start": 216, + "end": 488, "ctxt": 0 }, "decorators": [], @@ -29,22 +29,22 @@ { "type": "PrivateProperty", "span": { - "start": 228, - "end": 235, + "start": 232, + "end": 239, "ctxt": 0 }, "key": { "type": "PrivateName", "span": { - "start": 228, - "end": 234, + "start": 232, + "end": 238, "ctxt": 0 }, "id": { "type": "Identifier", "span": { - "start": 229, - "end": 234, + "start": 233, + "end": 238, "ctxt": 0 }, "value": "value", @@ -64,15 +64,15 @@ { "type": "Constructor", "span": { - "start": 276, - "end": 345, + "start": 280, + "end": 349, "ctxt": 0 }, "key": { "type": "Identifier", "span": { - "start": 276, - "end": 287, + "start": 280, + "end": 291, "ctxt": 0 }, "value": "constructor", @@ -82,16 +82,16 @@ { "type": "Parameter", "span": { - "start": 288, - "end": 300, + "start": 292, + "end": 304, "ctxt": 0 }, "decorators": [], "pat": { "type": "Identifier", "span": { - "start": 288, - "end": 300, + "start": 292, + "end": 304, "ctxt": 0 }, "value": "initialValue", @@ -103,53 +103,53 @@ "body": { "type": "BlockStatement", "span": { - "start": 302, - "end": 345, + "start": 306, + "end": 349, "ctxt": 0 }, "stmts": [ { "type": "ExpressionStatement", "span": { - "start": 312, - "end": 339, + "start": 316, + "end": 343, "ctxt": 0 }, "expression": { "type": "AssignmentExpression", "span": { - "start": 312, - "end": 338, + "start": 316, + "end": 342, "ctxt": 0 }, "operator": "=", "left": { "type": "MemberExpression", "span": { - "start": 312, - "end": 323, + "start": 316, + "end": 327, "ctxt": 0 }, "object": { "type": "ThisExpression", "span": { - "start": 312, - "end": 316, + "start": 316, + "end": 320, "ctxt": 0 } }, "property": { "type": "PrivateName", "span": { - "start": 317, - "end": 323, + "start": 321, + "end": 327, "ctxt": 0 }, "id": { "type": "Identifier", "span": { - "start": 318, - "end": 323, + "start": 322, + "end": 327, "ctxt": 0 }, "value": "value", @@ -160,8 +160,8 @@ "right": { "type": "Identifier", "span": { - "start": 326, - "end": 338, + "start": 330, + "end": 342, "ctxt": 0 }, "value": "initialValue", @@ -177,15 +177,15 @@ { "type": "ClassMethod", "span": { - "start": 376, - "end": 423, + "start": 380, + "end": 427, "ctxt": 0 }, "key": { "type": "Identifier", "span": { - "start": 380, - "end": 385, + "start": 384, + "end": 389, "ctxt": 0 }, "value": "value", @@ -195,52 +195,52 @@ "params": [], "decorators": [], "span": { - "start": 376, - "end": 423, + "start": 380, + "end": 427, "ctxt": 0 }, "body": { "type": "BlockStatement", "span": { - "start": 388, - "end": 423, + "start": 392, + "end": 427, "ctxt": 0 }, "stmts": [ { "type": "ReturnStatement", "span": { - "start": 398, - "end": 417, + "start": 402, + "end": 421, "ctxt": 0 }, "argument": { "type": "MemberExpression", "span": { - "start": 405, - "end": 416, + "start": 409, + "end": 420, "ctxt": 0 }, "object": { "type": "ThisExpression", "span": { - "start": 405, - "end": 409, + "start": 409, + "end": 413, "ctxt": 0 } }, "property": { "type": "PrivateName", "span": { - "start": 410, - "end": 416, + "start": 414, + "end": 420, "ctxt": 0 }, "id": { "type": "Identifier", "span": { - "start": 411, - "end": 416, + "start": 415, + "end": 420, "ctxt": 0 }, "value": "value", @@ -266,15 +266,15 @@ { "type": "ClassMethod", "span": { - "start": 429, - "end": 482, + "start": 433, + "end": 486, "ctxt": 0 }, "key": { "type": "Identifier", "span": { - "start": 433, - "end": 438, + "start": 437, + "end": 442, "ctxt": 0 }, "value": "value", @@ -285,16 +285,16 @@ { "type": "Parameter", "span": { - "start": 439, - "end": 444, + "start": 443, + "end": 448, "ctxt": 0 }, "decorators": [], "pat": { "type": "Identifier", "span": { - "start": 439, - "end": 444, + "start": 443, + "end": 448, "ctxt": 0 }, "value": "value", @@ -305,60 +305,60 @@ ], "decorators": [], "span": { - "start": 429, - "end": 482, + "start": 433, + "end": 486, "ctxt": 0 }, "body": { "type": "BlockStatement", "span": { - "start": 446, - "end": 482, + "start": 450, + "end": 486, "ctxt": 0 }, "stmts": [ { "type": "ExpressionStatement", "span": { - "start": 456, - "end": 476, + "start": 460, + "end": 480, "ctxt": 0 }, "expression": { "type": "AssignmentExpression", "span": { - "start": 456, - "end": 475, + "start": 460, + "end": 479, "ctxt": 0 }, "operator": "=", "left": { "type": "MemberExpression", "span": { - "start": 456, - "end": 467, + "start": 460, + "end": 471, "ctxt": 0 }, "object": { "type": "ThisExpression", "span": { - "start": 456, - "end": 460, + "start": 460, + "end": 464, "ctxt": 0 } }, "property": { "type": "PrivateName", "span": { - "start": 461, - "end": 467, + "start": 465, + "end": 471, "ctxt": 0 }, "id": { "type": "Identifier", "span": { - "start": 462, - "end": 467, + "start": 466, + "end": 471, "ctxt": 0 }, "value": "value", @@ -369,8 +369,8 @@ "right": { "type": "Identifier", "span": { - "start": 470, - "end": 475, + "start": 474, + "end": 479, "ctxt": 0 }, "value": "value", @@ -402,37 +402,37 @@ { "type": "ExpressionStatement", "span": { - "start": 486, - "end": 507, + "start": 490, + "end": 511, "ctxt": 0 }, "expression": { "type": "AssignmentExpression", "span": { - "start": 486, - "end": 506, + "start": 490, + "end": 510, "ctxt": 0 }, "operator": "=", "left": { "type": "MemberExpression", "span": { - "start": 486, - "end": 502, + "start": 490, + "end": 506, "ctxt": 0 }, "object": { "type": "NewExpression", "span": { - "start": 486, - "end": 496, + "start": 490, + "end": 500, "ctxt": 0 }, "callee": { "type": "Identifier", "span": { - "start": 490, - "end": 493, + "start": 494, + "end": 497, "ctxt": 0 }, "value": "Box", @@ -444,8 +444,8 @@ "expression": { "type": "NumericLiteral", "span": { - "start": 494, - "end": 495, + "start": 498, + "end": 499, "ctxt": 0 }, "value": 3.0, @@ -458,8 +458,8 @@ "property": { "type": "Identifier", "span": { - "start": 497, - "end": 502, + "start": 501, + "end": 506, "ctxt": 0 }, "value": "value", @@ -469,8 +469,8 @@ "right": { "type": "NumericLiteral", "span": { - "start": 505, - "end": 506, + "start": 509, + "end": 510, "ctxt": 0 }, "value": 3.0, diff --git a/crates/swc_ecma_parser/tests/tsc/genericSetterInClassTypeJsDoc.ts b/crates/swc_ecma_parser/tests/tsc/genericSetterInClassTypeJsDoc.ts index 243e8605d40a..b5cfb17a9c17 100644 --- a/crates/swc_ecma_parser/tests/tsc/genericSetterInClassTypeJsDoc.ts +++ b/crates/swc_ecma_parser/tests/tsc/genericSetterInClassTypeJsDoc.ts @@ -4,7 +4,7 @@ // @allowJs: true // @checkJs: true // @filename: genericSetterInClassTypeJsDoc.js -// @out: genericSetterInClassTypeJsDoc-out.js +// @outFile: genericSetterInClassTypeJsDoc-out.js /** * @template T diff --git a/crates/swc_ecma_parser/tests/tsc/globalThisVarDeclaration.json b/crates/swc_ecma_parser/tests/tsc/globalThisVarDeclaration.json index f5771cd361cc..54e68ca30de4 100644 --- a/crates/swc_ecma_parser/tests/tsc/globalThisVarDeclaration.json +++ b/crates/swc_ecma_parser/tests/tsc/globalThisVarDeclaration.json @@ -1,16 +1,16 @@ { "type": "Script", "span": { - "start": 115, - "end": 483, + "start": 119, + "end": 487, "ctxt": 0 }, "body": [ { "type": "VariableDeclaration", "span": { - "start": 115, - "end": 126, + "start": 119, + "end": 130, "ctxt": 0 }, "kind": "var", @@ -19,15 +19,15 @@ { "type": "VariableDeclarator", "span": { - "start": 119, - "end": 125, + "start": 123, + "end": 129, "ctxt": 0 }, "id": { "type": "Identifier", "span": { - "start": 119, - "end": 120, + "start": 123, + "end": 124, "ctxt": 0 }, "value": "a", @@ -37,8 +37,8 @@ "init": { "type": "NumericLiteral", "span": { - "start": 123, - "end": 125, + "start": 127, + "end": 129, "ctxt": 0 }, "value": 10.0, @@ -51,30 +51,30 @@ { "type": "ExpressionStatement", "span": { - "start": 127, - "end": 134, + "start": 131, + "end": 138, "ctxt": 0 }, "expression": { "type": "MemberExpression", "span": { - "start": 127, - "end": 133, + "start": 131, + "end": 137, "ctxt": 0 }, "object": { "type": "ThisExpression", "span": { - "start": 127, - "end": 131, + "start": 131, + "end": 135, "ctxt": 0 } }, "property": { "type": "Identifier", "span": { - "start": 132, - "end": 133, + "start": 136, + "end": 137, "ctxt": 0 }, "value": "a", @@ -85,30 +85,30 @@ { "type": "ExpressionStatement", "span": { - "start": 135, - "end": 142, + "start": 139, + "end": 146, "ctxt": 0 }, "expression": { "type": "MemberExpression", "span": { - "start": 135, - "end": 141, + "start": 139, + "end": 145, "ctxt": 0 }, "object": { "type": "ThisExpression", "span": { - "start": 135, - "end": 139, + "start": 139, + "end": 143, "ctxt": 0 } }, "property": { "type": "Identifier", "span": { - "start": 140, - "end": 141, + "start": 144, + "end": 145, "ctxt": 0 }, "value": "b", @@ -119,22 +119,22 @@ { "type": "ExpressionStatement", "span": { - "start": 143, - "end": 156, + "start": 147, + "end": 160, "ctxt": 0 }, "expression": { "type": "MemberExpression", "span": { - "start": 143, - "end": 155, + "start": 147, + "end": 159, "ctxt": 0 }, "object": { "type": "Identifier", "span": { - "start": 143, - "end": 153, + "start": 147, + "end": 157, "ctxt": 0 }, "value": "globalThis", @@ -143,8 +143,8 @@ "property": { "type": "Identifier", "span": { - "start": 154, - "end": 155, + "start": 158, + "end": 159, "ctxt": 0 }, "value": "a", @@ -155,22 +155,22 @@ { "type": "ExpressionStatement", "span": { - "start": 157, - "end": 170, + "start": 161, + "end": 174, "ctxt": 0 }, "expression": { "type": "MemberExpression", "span": { - "start": 157, - "end": 169, + "start": 161, + "end": 173, "ctxt": 0 }, "object": { "type": "Identifier", "span": { - "start": 157, - "end": 167, + "start": 161, + "end": 171, "ctxt": 0 }, "value": "globalThis", @@ -179,8 +179,8 @@ "property": { "type": "Identifier", "span": { - "start": 168, - "end": 169, + "start": 172, + "end": 173, "ctxt": 0 }, "value": "b", @@ -191,22 +191,22 @@ { "type": "ExpressionStatement", "span": { - "start": 254, - "end": 261, + "start": 258, + "end": 265, "ctxt": 0 }, "expression": { "type": "MemberExpression", "span": { - "start": 254, - "end": 260, + "start": 258, + "end": 264, "ctxt": 0 }, "object": { "type": "Identifier", "span": { - "start": 254, - "end": 258, + "start": 258, + "end": 262, "ctxt": 0 }, "value": "self", @@ -215,8 +215,8 @@ "property": { "type": "Identifier", "span": { - "start": 259, - "end": 260, + "start": 263, + "end": 264, "ctxt": 0 }, "value": "a", @@ -227,22 +227,22 @@ { "type": "ExpressionStatement", "span": { - "start": 262, - "end": 269, + "start": 266, + "end": 273, "ctxt": 0 }, "expression": { "type": "MemberExpression", "span": { - "start": 262, - "end": 268, + "start": 266, + "end": 272, "ctxt": 0 }, "object": { "type": "Identifier", "span": { - "start": 262, - "end": 266, + "start": 266, + "end": 270, "ctxt": 0 }, "value": "self", @@ -251,8 +251,8 @@ "property": { "type": "Identifier", "span": { - "start": 267, - "end": 268, + "start": 271, + "end": 272, "ctxt": 0 }, "value": "b", @@ -263,22 +263,22 @@ { "type": "ExpressionStatement", "span": { - "start": 270, - "end": 279, + "start": 274, + "end": 283, "ctxt": 0 }, "expression": { "type": "MemberExpression", "span": { - "start": 270, - "end": 278, + "start": 274, + "end": 282, "ctxt": 0 }, "object": { "type": "Identifier", "span": { - "start": 270, - "end": 276, + "start": 274, + "end": 280, "ctxt": 0 }, "value": "window", @@ -287,8 +287,8 @@ "property": { "type": "Identifier", "span": { - "start": 277, - "end": 278, + "start": 281, + "end": 282, "ctxt": 0 }, "value": "a", @@ -299,22 +299,22 @@ { "type": "ExpressionStatement", "span": { - "start": 280, - "end": 289, + "start": 284, + "end": 293, "ctxt": 0 }, "expression": { "type": "MemberExpression", "span": { - "start": 280, - "end": 288, + "start": 284, + "end": 292, "ctxt": 0 }, "object": { "type": "Identifier", "span": { - "start": 280, - "end": 286, + "start": 284, + "end": 290, "ctxt": 0 }, "value": "window", @@ -323,8 +323,8 @@ "property": { "type": "Identifier", "span": { - "start": 287, - "end": 288, + "start": 291, + "end": 292, "ctxt": 0 }, "value": "b", @@ -335,22 +335,22 @@ { "type": "ExpressionStatement", "span": { - "start": 290, - "end": 296, + "start": 294, + "end": 300, "ctxt": 0 }, "expression": { "type": "MemberExpression", "span": { - "start": 290, - "end": 295, + "start": 294, + "end": 299, "ctxt": 0 }, "object": { "type": "Identifier", "span": { - "start": 290, - "end": 293, + "start": 294, + "end": 297, "ctxt": 0 }, "value": "top", @@ -359,8 +359,8 @@ "property": { "type": "Identifier", "span": { - "start": 294, - "end": 295, + "start": 298, + "end": 299, "ctxt": 0 }, "value": "a", @@ -371,22 +371,22 @@ { "type": "ExpressionStatement", "span": { - "start": 297, - "end": 303, + "start": 301, + "end": 307, "ctxt": 0 }, "expression": { "type": "MemberExpression", "span": { - "start": 297, - "end": 302, + "start": 301, + "end": 306, "ctxt": 0 }, "object": { "type": "Identifier", "span": { - "start": 297, - "end": 300, + "start": 301, + "end": 304, "ctxt": 0 }, "value": "top", @@ -395,8 +395,8 @@ "property": { "type": "Identifier", "span": { - "start": 301, - "end": 302, + "start": 305, + "end": 306, "ctxt": 0 }, "value": "b", @@ -407,8 +407,8 @@ { "type": "VariableDeclaration", "span": { - "start": 329, - "end": 340, + "start": 333, + "end": 344, "ctxt": 0 }, "kind": "var", @@ -417,15 +417,15 @@ { "type": "VariableDeclarator", "span": { - "start": 333, - "end": 339, + "start": 337, + "end": 343, "ctxt": 0 }, "id": { "type": "Identifier", "span": { - "start": 333, - "end": 334, + "start": 337, + "end": 338, "ctxt": 0 }, "value": "b", @@ -435,8 +435,8 @@ "init": { "type": "NumericLiteral", "span": { - "start": 337, - "end": 339, + "start": 341, + "end": 343, "ctxt": 0 }, "value": 10.0, @@ -449,30 +449,30 @@ { "type": "ExpressionStatement", "span": { - "start": 341, - "end": 348, + "start": 345, + "end": 352, "ctxt": 0 }, "expression": { "type": "MemberExpression", "span": { - "start": 341, - "end": 347, + "start": 345, + "end": 351, "ctxt": 0 }, "object": { "type": "ThisExpression", "span": { - "start": 341, - "end": 345, + "start": 345, + "end": 349, "ctxt": 0 } }, "property": { "type": "Identifier", "span": { - "start": 346, - "end": 347, + "start": 350, + "end": 351, "ctxt": 0 }, "value": "a", @@ -483,30 +483,30 @@ { "type": "ExpressionStatement", "span": { - "start": 349, - "end": 356, + "start": 353, + "end": 360, "ctxt": 0 }, "expression": { "type": "MemberExpression", "span": { - "start": 349, - "end": 355, + "start": 353, + "end": 359, "ctxt": 0 }, "object": { "type": "ThisExpression", "span": { - "start": 349, - "end": 353, + "start": 353, + "end": 357, "ctxt": 0 } }, "property": { "type": "Identifier", "span": { - "start": 354, - "end": 355, + "start": 358, + "end": 359, "ctxt": 0 }, "value": "b", @@ -517,22 +517,22 @@ { "type": "ExpressionStatement", "span": { - "start": 357, - "end": 370, + "start": 361, + "end": 374, "ctxt": 0 }, "expression": { "type": "MemberExpression", "span": { - "start": 357, - "end": 369, + "start": 361, + "end": 373, "ctxt": 0 }, "object": { "type": "Identifier", "span": { - "start": 357, - "end": 367, + "start": 361, + "end": 371, "ctxt": 0 }, "value": "globalThis", @@ -541,8 +541,8 @@ "property": { "type": "Identifier", "span": { - "start": 368, - "end": 369, + "start": 372, + "end": 373, "ctxt": 0 }, "value": "a", @@ -553,22 +553,22 @@ { "type": "ExpressionStatement", "span": { - "start": 371, - "end": 384, + "start": 375, + "end": 388, "ctxt": 0 }, "expression": { "type": "MemberExpression", "span": { - "start": 371, - "end": 383, + "start": 375, + "end": 387, "ctxt": 0 }, "object": { "type": "Identifier", "span": { - "start": 371, - "end": 381, + "start": 375, + "end": 385, "ctxt": 0 }, "value": "globalThis", @@ -577,8 +577,8 @@ "property": { "type": "Identifier", "span": { - "start": 382, - "end": 383, + "start": 386, + "end": 387, "ctxt": 0 }, "value": "b", @@ -589,22 +589,22 @@ { "type": "ExpressionStatement", "span": { - "start": 434, - "end": 441, + "start": 438, + "end": 445, "ctxt": 0 }, "expression": { "type": "MemberExpression", "span": { - "start": 434, - "end": 440, + "start": 438, + "end": 444, "ctxt": 0 }, "object": { "type": "Identifier", "span": { - "start": 434, - "end": 438, + "start": 438, + "end": 442, "ctxt": 0 }, "value": "self", @@ -613,8 +613,8 @@ "property": { "type": "Identifier", "span": { - "start": 439, - "end": 440, + "start": 443, + "end": 444, "ctxt": 0 }, "value": "a", @@ -625,22 +625,22 @@ { "type": "ExpressionStatement", "span": { - "start": 442, - "end": 449, + "start": 446, + "end": 453, "ctxt": 0 }, "expression": { "type": "MemberExpression", "span": { - "start": 442, - "end": 448, + "start": 446, + "end": 452, "ctxt": 0 }, "object": { "type": "Identifier", "span": { - "start": 442, - "end": 446, + "start": 446, + "end": 450, "ctxt": 0 }, "value": "self", @@ -649,8 +649,8 @@ "property": { "type": "Identifier", "span": { - "start": 447, - "end": 448, + "start": 451, + "end": 452, "ctxt": 0 }, "value": "b", @@ -661,22 +661,22 @@ { "type": "ExpressionStatement", "span": { - "start": 450, - "end": 459, + "start": 454, + "end": 463, "ctxt": 0 }, "expression": { "type": "MemberExpression", "span": { - "start": 450, - "end": 458, + "start": 454, + "end": 462, "ctxt": 0 }, "object": { "type": "Identifier", "span": { - "start": 450, - "end": 456, + "start": 454, + "end": 460, "ctxt": 0 }, "value": "window", @@ -685,8 +685,8 @@ "property": { "type": "Identifier", "span": { - "start": 457, - "end": 458, + "start": 461, + "end": 462, "ctxt": 0 }, "value": "a", @@ -697,22 +697,22 @@ { "type": "ExpressionStatement", "span": { - "start": 460, - "end": 469, + "start": 464, + "end": 473, "ctxt": 0 }, "expression": { "type": "MemberExpression", "span": { - "start": 460, - "end": 468, + "start": 464, + "end": 472, "ctxt": 0 }, "object": { "type": "Identifier", "span": { - "start": 460, - "end": 466, + "start": 464, + "end": 470, "ctxt": 0 }, "value": "window", @@ -721,8 +721,8 @@ "property": { "type": "Identifier", "span": { - "start": 467, - "end": 468, + "start": 471, + "end": 472, "ctxt": 0 }, "value": "b", @@ -733,22 +733,22 @@ { "type": "ExpressionStatement", "span": { - "start": 470, - "end": 476, + "start": 474, + "end": 480, "ctxt": 0 }, "expression": { "type": "MemberExpression", "span": { - "start": 470, - "end": 475, + "start": 474, + "end": 479, "ctxt": 0 }, "object": { "type": "Identifier", "span": { - "start": 470, - "end": 473, + "start": 474, + "end": 477, "ctxt": 0 }, "value": "top", @@ -757,8 +757,8 @@ "property": { "type": "Identifier", "span": { - "start": 474, - "end": 475, + "start": 478, + "end": 479, "ctxt": 0 }, "value": "a", @@ -769,22 +769,22 @@ { "type": "ExpressionStatement", "span": { - "start": 477, - "end": 483, + "start": 481, + "end": 487, "ctxt": 0 }, "expression": { "type": "MemberExpression", "span": { - "start": 477, - "end": 482, + "start": 481, + "end": 486, "ctxt": 0 }, "object": { "type": "Identifier", "span": { - "start": 477, - "end": 480, + "start": 481, + "end": 484, "ctxt": 0 }, "value": "top", @@ -793,8 +793,8 @@ "property": { "type": "Identifier", "span": { - "start": 481, - "end": 482, + "start": 485, + "end": 486, "ctxt": 0 }, "value": "b", diff --git a/crates/swc_ecma_parser/tests/tsc/globalThisVarDeclaration.ts b/crates/swc_ecma_parser/tests/tsc/globalThisVarDeclaration.ts index 5b75d1095a68..1c7435902780 100644 --- a/crates/swc_ecma_parser/tests/tsc/globalThisVarDeclaration.ts +++ b/crates/swc_ecma_parser/tests/tsc/globalThisVarDeclaration.ts @@ -1,4 +1,4 @@ -// @out: output.js +// @outFile: output.js // @target: esnext // @lib: esnext, dom // @Filename: b.js diff --git a/crates/swc_ecma_parser/tests/tsc/importCallExpressionAsyncES3AMD.json b/crates/swc_ecma_parser/tests/tsc/importCallExpressionAsyncES3AMD.json deleted file mode 100644 index e09d7cbdd60b..000000000000 --- a/crates/swc_ecma_parser/tests/tsc/importCallExpressionAsyncES3AMD.json +++ /dev/null @@ -1,759 +0,0 @@ -{ - "type": "Module", - "span": { - "start": 68, - "end": 564, - "ctxt": 0 - }, - "body": [ - { - "type": "ExportDeclaration", - "span": { - "start": 68, - "end": 144, - "ctxt": 0 - }, - "declaration": { - "type": "FunctionDeclaration", - "identifier": { - "type": "Identifier", - "span": { - "start": 90, - "end": 92, - "ctxt": 0 - }, - "value": "fn", - "optional": false - }, - "declare": false, - "params": [], - "decorators": [], - "span": { - "start": 75, - "end": 144, - "ctxt": 0 - }, - "body": { - "type": "BlockStatement", - "span": { - "start": 95, - "end": 144, - "ctxt": 0 - }, - "stmts": [ - { - "type": "VariableDeclaration", - "span": { - "start": 101, - "end": 135, - "ctxt": 0 - }, - "kind": "const", - "declare": false, - "declarations": [ - { - "type": "VariableDeclarator", - "span": { - "start": 107, - "end": 135, - "ctxt": 0 - }, - "id": { - "type": "Identifier", - "span": { - "start": 107, - "end": 110, - "ctxt": 0 - }, - "value": "req", - "optional": false, - "typeAnnotation": null - }, - "init": { - "type": "AwaitExpression", - "span": { - "start": 113, - "end": 135, - "ctxt": 0 - }, - "argument": { - "type": "CallExpression", - "span": { - "start": 119, - "end": 135, - "ctxt": 0 - }, - "callee": { - "type": "Import", - "span": { - "start": 119, - "end": 125, - "ctxt": 0 - }, - "phase": "evaluation" - }, - "arguments": [ - { - "spread": null, - "expression": { - "type": "StringLiteral", - "span": { - "start": 126, - "end": 134, - "ctxt": 0 - }, - "value": "./test", - "raw": "'./test'" - } - } - ], - "typeArguments": null - } - }, - "definite": false - } - ] - } - ] - }, - "generator": false, - "async": true, - "typeParameters": null, - "returnType": null - } - }, - { - "type": "ExportDeclaration", - "span": { - "start": 146, - "end": 245, - "ctxt": 0 - }, - "declaration": { - "type": "ClassDeclaration", - "identifier": { - "type": "Identifier", - "span": { - "start": 159, - "end": 162, - "ctxt": 0 - }, - "value": "cl1", - "optional": false - }, - "declare": false, - "span": { - "start": 153, - "end": 245, - "ctxt": 0 - }, - "decorators": [], - "body": [ - { - "type": "ClassMethod", - "span": { - "start": 169, - "end": 243, - "ctxt": 0 - }, - "key": { - "type": "Identifier", - "span": { - "start": 182, - "end": 183, - "ctxt": 0 - }, - "value": "m", - "optional": false - }, - "function": { - "params": [], - "decorators": [], - "span": { - "start": 169, - "end": 243, - "ctxt": 0 - }, - "body": { - "type": "BlockStatement", - "span": { - "start": 186, - "end": 243, - "ctxt": 0 - }, - "stmts": [ - { - "type": "VariableDeclaration", - "span": { - "start": 196, - "end": 230, - "ctxt": 0 - }, - "kind": "const", - "declare": false, - "declarations": [ - { - "type": "VariableDeclarator", - "span": { - "start": 202, - "end": 230, - "ctxt": 0 - }, - "id": { - "type": "Identifier", - "span": { - "start": 202, - "end": 205, - "ctxt": 0 - }, - "value": "req", - "optional": false, - "typeAnnotation": null - }, - "init": { - "type": "AwaitExpression", - "span": { - "start": 208, - "end": 230, - "ctxt": 0 - }, - "argument": { - "type": "CallExpression", - "span": { - "start": 214, - "end": 230, - "ctxt": 0 - }, - "callee": { - "type": "Import", - "span": { - "start": 214, - "end": 220, - "ctxt": 0 - }, - "phase": "evaluation" - }, - "arguments": [ - { - "spread": null, - "expression": { - "type": "StringLiteral", - "span": { - "start": 221, - "end": 229, - "ctxt": 0 - }, - "value": "./test", - "raw": "'./test'" - } - } - ], - "typeArguments": null - } - }, - "definite": false - } - ] - } - ] - }, - "generator": false, - "async": true, - "typeParameters": null, - "returnType": null - }, - "kind": "method", - "isStatic": false, - "accessibility": "public", - "isAbstract": false, - "isOptional": false, - "isOverride": false - } - ], - "superClass": null, - "isAbstract": false, - "typeParams": null, - "superTypeParams": null, - "implements": [] - } - }, - { - "type": "ExportDeclaration", - "span": { - "start": 247, - "end": 348, - "ctxt": 0 - }, - "declaration": { - "type": "VariableDeclaration", - "span": { - "start": 254, - "end": 348, - "ctxt": 0 - }, - "kind": "const", - "declare": false, - "declarations": [ - { - "type": "VariableDeclarator", - "span": { - "start": 260, - "end": 348, - "ctxt": 0 - }, - "id": { - "type": "Identifier", - "span": { - "start": 260, - "end": 263, - "ctxt": 0 - }, - "value": "obj", - "optional": false, - "typeAnnotation": null - }, - "init": { - "type": "ObjectExpression", - "span": { - "start": 266, - "end": 348, - "ctxt": 0 - }, - "properties": [ - { - "type": "KeyValueProperty", - "key": { - "type": "Identifier", - "span": { - "start": 272, - "end": 273, - "ctxt": 0 - }, - "value": "m", - "optional": false - }, - "value": { - "type": "ArrowFunctionExpression", - "span": { - "start": 275, - "end": 346, - "ctxt": 0 - }, - "params": [], - "body": { - "type": "BlockStatement", - "span": { - "start": 287, - "end": 346, - "ctxt": 0 - }, - "stmts": [ - { - "type": "VariableDeclaration", - "span": { - "start": 297, - "end": 331, - "ctxt": 0 - }, - "kind": "const", - "declare": false, - "declarations": [ - { - "type": "VariableDeclarator", - "span": { - "start": 303, - "end": 331, - "ctxt": 0 - }, - "id": { - "type": "Identifier", - "span": { - "start": 303, - "end": 306, - "ctxt": 0 - }, - "value": "req", - "optional": false, - "typeAnnotation": null - }, - "init": { - "type": "AwaitExpression", - "span": { - "start": 309, - "end": 331, - "ctxt": 0 - }, - "argument": { - "type": "CallExpression", - "span": { - "start": 315, - "end": 331, - "ctxt": 0 - }, - "callee": { - "type": "Import", - "span": { - "start": 315, - "end": 321, - "ctxt": 0 - }, - "phase": "evaluation" - }, - "arguments": [ - { - "spread": null, - "expression": { - "type": "StringLiteral", - "span": { - "start": 322, - "end": 330, - "ctxt": 0 - }, - "value": "./test", - "raw": "'./test'" - } - } - ], - "typeArguments": null - } - }, - "definite": false - } - ] - } - ] - }, - "async": true, - "generator": false, - "typeParameters": null, - "returnType": null - } - } - ] - }, - "definite": false - } - ] - } - }, - { - "type": "ExportDeclaration", - "span": { - "start": 350, - "end": 483, - "ctxt": 0 - }, - "declaration": { - "type": "ClassDeclaration", - "identifier": { - "type": "Identifier", - "span": { - "start": 363, - "end": 366, - "ctxt": 0 - }, - "value": "cl2", - "optional": false - }, - "declare": false, - "span": { - "start": 357, - "end": 483, - "ctxt": 0 - }, - "decorators": [], - "body": [ - { - "type": "ClassProperty", - "span": { - "start": 373, - "end": 481, - "ctxt": 0 - }, - "key": { - "type": "Identifier", - "span": { - "start": 380, - "end": 381, - "ctxt": 0 - }, - "value": "p", - "optional": false - }, - "value": { - "type": "ObjectExpression", - "span": { - "start": 384, - "end": 481, - "ctxt": 0 - }, - "properties": [ - { - "type": "KeyValueProperty", - "key": { - "type": "Identifier", - "span": { - "start": 394, - "end": 395, - "ctxt": 0 - }, - "value": "m", - "optional": false - }, - "value": { - "type": "ArrowFunctionExpression", - "span": { - "start": 397, - "end": 475, - "ctxt": 0 - }, - "params": [], - "body": { - "type": "BlockStatement", - "span": { - "start": 409, - "end": 475, - "ctxt": 0 - }, - "stmts": [ - { - "type": "VariableDeclaration", - "span": { - "start": 423, - "end": 457, - "ctxt": 0 - }, - "kind": "const", - "declare": false, - "declarations": [ - { - "type": "VariableDeclarator", - "span": { - "start": 429, - "end": 457, - "ctxt": 0 - }, - "id": { - "type": "Identifier", - "span": { - "start": 429, - "end": 432, - "ctxt": 0 - }, - "value": "req", - "optional": false, - "typeAnnotation": null - }, - "init": { - "type": "AwaitExpression", - "span": { - "start": 435, - "end": 457, - "ctxt": 0 - }, - "argument": { - "type": "CallExpression", - "span": { - "start": 441, - "end": 457, - "ctxt": 0 - }, - "callee": { - "type": "Import", - "span": { - "start": 441, - "end": 447, - "ctxt": 0 - }, - "phase": "evaluation" - }, - "arguments": [ - { - "spread": null, - "expression": { - "type": "StringLiteral", - "span": { - "start": 448, - "end": 456, - "ctxt": 0 - }, - "value": "./test", - "raw": "'./test'" - } - } - ], - "typeArguments": null - } - }, - "definite": false - } - ] - } - ] - }, - "async": true, - "generator": false, - "typeParameters": null, - "returnType": null - } - } - ] - }, - "typeAnnotation": null, - "isStatic": false, - "decorators": [], - "accessibility": "public", - "isAbstract": false, - "isOptional": false, - "isOverride": false, - "readonly": false, - "declare": false, - "definite": false - } - ], - "superClass": null, - "isAbstract": false, - "typeParams": null, - "superTypeParams": null, - "implements": [] - } - }, - { - "type": "ExportDeclaration", - "span": { - "start": 485, - "end": 564, - "ctxt": 0 - }, - "declaration": { - "type": "VariableDeclaration", - "span": { - "start": 492, - "end": 564, - "ctxt": 0 - }, - "kind": "const", - "declare": false, - "declarations": [ - { - "type": "VariableDeclarator", - "span": { - "start": 498, - "end": 564, - "ctxt": 0 - }, - "id": { - "type": "Identifier", - "span": { - "start": 498, - "end": 499, - "ctxt": 0 - }, - "value": "l", - "optional": false, - "typeAnnotation": null - }, - "init": { - "type": "ArrowFunctionExpression", - "span": { - "start": 502, - "end": 564, - "ctxt": 0 - }, - "params": [], - "body": { - "type": "BlockStatement", - "span": { - "start": 514, - "end": 564, - "ctxt": 0 - }, - "stmts": [ - { - "type": "VariableDeclaration", - "span": { - "start": 520, - "end": 554, - "ctxt": 0 - }, - "kind": "const", - "declare": false, - "declarations": [ - { - "type": "VariableDeclarator", - "span": { - "start": 526, - "end": 554, - "ctxt": 0 - }, - "id": { - "type": "Identifier", - "span": { - "start": 526, - "end": 529, - "ctxt": 0 - }, - "value": "req", - "optional": false, - "typeAnnotation": null - }, - "init": { - "type": "AwaitExpression", - "span": { - "start": 532, - "end": 554, - "ctxt": 0 - }, - "argument": { - "type": "CallExpression", - "span": { - "start": 538, - "end": 554, - "ctxt": 0 - }, - "callee": { - "type": "Import", - "span": { - "start": 538, - "end": 544, - "ctxt": 0 - }, - "phase": "evaluation" - }, - "arguments": [ - { - "spread": null, - "expression": { - "type": "StringLiteral", - "span": { - "start": 545, - "end": 553, - "ctxt": 0 - }, - "value": "./test", - "raw": "'./test'" - } - } - ], - "typeArguments": null - } - }, - "definite": false - } - ] - } - ] - }, - "async": true, - "generator": false, - "typeParameters": null, - "returnType": null - }, - "definite": false - } - ] - } - } - ], - "interpreter": null -} diff --git a/crates/swc_ecma_parser/tests/tsc/importCallExpressionAsyncES3AMD.ts b/crates/swc_ecma_parser/tests/tsc/importCallExpressionAsyncES3AMD.ts deleted file mode 100644 index ee6c3c5d8ea4..000000000000 --- a/crates/swc_ecma_parser/tests/tsc/importCallExpressionAsyncES3AMD.ts +++ /dev/null @@ -1,31 +0,0 @@ -// @module: amd -// @target: es3 -// @lib: es6 -// @filename: test.ts -export async function fn() { - const req = await import('./test') // ONE -} - -export class cl1 { - public async m() { - const req = await import('./test') // TWO - } -} - -export const obj = { - m: async () => { - const req = await import('./test') // THREE - } -} - -export class cl2 { - public p = { - m: async () => { - const req = await import('./test') // FOUR - } - } -} - -export const l = async () => { - const req = await import('./test') // FIVE -} diff --git a/crates/swc_ecma_parser/tests/tsc/importCallExpressionAsyncES3CJS.json b/crates/swc_ecma_parser/tests/tsc/importCallExpressionAsyncES3CJS.json deleted file mode 100644 index d0089a7214f2..000000000000 --- a/crates/swc_ecma_parser/tests/tsc/importCallExpressionAsyncES3CJS.json +++ /dev/null @@ -1,759 +0,0 @@ -{ - "type": "Module", - "span": { - "start": 73, - "end": 569, - "ctxt": 0 - }, - "body": [ - { - "type": "ExportDeclaration", - "span": { - "start": 73, - "end": 149, - "ctxt": 0 - }, - "declaration": { - "type": "FunctionDeclaration", - "identifier": { - "type": "Identifier", - "span": { - "start": 95, - "end": 97, - "ctxt": 0 - }, - "value": "fn", - "optional": false - }, - "declare": false, - "params": [], - "decorators": [], - "span": { - "start": 80, - "end": 149, - "ctxt": 0 - }, - "body": { - "type": "BlockStatement", - "span": { - "start": 100, - "end": 149, - "ctxt": 0 - }, - "stmts": [ - { - "type": "VariableDeclaration", - "span": { - "start": 106, - "end": 140, - "ctxt": 0 - }, - "kind": "const", - "declare": false, - "declarations": [ - { - "type": "VariableDeclarator", - "span": { - "start": 112, - "end": 140, - "ctxt": 0 - }, - "id": { - "type": "Identifier", - "span": { - "start": 112, - "end": 115, - "ctxt": 0 - }, - "value": "req", - "optional": false, - "typeAnnotation": null - }, - "init": { - "type": "AwaitExpression", - "span": { - "start": 118, - "end": 140, - "ctxt": 0 - }, - "argument": { - "type": "CallExpression", - "span": { - "start": 124, - "end": 140, - "ctxt": 0 - }, - "callee": { - "type": "Import", - "span": { - "start": 124, - "end": 130, - "ctxt": 0 - }, - "phase": "evaluation" - }, - "arguments": [ - { - "spread": null, - "expression": { - "type": "StringLiteral", - "span": { - "start": 131, - "end": 139, - "ctxt": 0 - }, - "value": "./test", - "raw": "'./test'" - } - } - ], - "typeArguments": null - } - }, - "definite": false - } - ] - } - ] - }, - "generator": false, - "async": true, - "typeParameters": null, - "returnType": null - } - }, - { - "type": "ExportDeclaration", - "span": { - "start": 151, - "end": 250, - "ctxt": 0 - }, - "declaration": { - "type": "ClassDeclaration", - "identifier": { - "type": "Identifier", - "span": { - "start": 164, - "end": 167, - "ctxt": 0 - }, - "value": "cl1", - "optional": false - }, - "declare": false, - "span": { - "start": 158, - "end": 250, - "ctxt": 0 - }, - "decorators": [], - "body": [ - { - "type": "ClassMethod", - "span": { - "start": 174, - "end": 248, - "ctxt": 0 - }, - "key": { - "type": "Identifier", - "span": { - "start": 187, - "end": 188, - "ctxt": 0 - }, - "value": "m", - "optional": false - }, - "function": { - "params": [], - "decorators": [], - "span": { - "start": 174, - "end": 248, - "ctxt": 0 - }, - "body": { - "type": "BlockStatement", - "span": { - "start": 191, - "end": 248, - "ctxt": 0 - }, - "stmts": [ - { - "type": "VariableDeclaration", - "span": { - "start": 201, - "end": 235, - "ctxt": 0 - }, - "kind": "const", - "declare": false, - "declarations": [ - { - "type": "VariableDeclarator", - "span": { - "start": 207, - "end": 235, - "ctxt": 0 - }, - "id": { - "type": "Identifier", - "span": { - "start": 207, - "end": 210, - "ctxt": 0 - }, - "value": "req", - "optional": false, - "typeAnnotation": null - }, - "init": { - "type": "AwaitExpression", - "span": { - "start": 213, - "end": 235, - "ctxt": 0 - }, - "argument": { - "type": "CallExpression", - "span": { - "start": 219, - "end": 235, - "ctxt": 0 - }, - "callee": { - "type": "Import", - "span": { - "start": 219, - "end": 225, - "ctxt": 0 - }, - "phase": "evaluation" - }, - "arguments": [ - { - "spread": null, - "expression": { - "type": "StringLiteral", - "span": { - "start": 226, - "end": 234, - "ctxt": 0 - }, - "value": "./test", - "raw": "'./test'" - } - } - ], - "typeArguments": null - } - }, - "definite": false - } - ] - } - ] - }, - "generator": false, - "async": true, - "typeParameters": null, - "returnType": null - }, - "kind": "method", - "isStatic": false, - "accessibility": "public", - "isAbstract": false, - "isOptional": false, - "isOverride": false - } - ], - "superClass": null, - "isAbstract": false, - "typeParams": null, - "superTypeParams": null, - "implements": [] - } - }, - { - "type": "ExportDeclaration", - "span": { - "start": 252, - "end": 353, - "ctxt": 0 - }, - "declaration": { - "type": "VariableDeclaration", - "span": { - "start": 259, - "end": 353, - "ctxt": 0 - }, - "kind": "const", - "declare": false, - "declarations": [ - { - "type": "VariableDeclarator", - "span": { - "start": 265, - "end": 353, - "ctxt": 0 - }, - "id": { - "type": "Identifier", - "span": { - "start": 265, - "end": 268, - "ctxt": 0 - }, - "value": "obj", - "optional": false, - "typeAnnotation": null - }, - "init": { - "type": "ObjectExpression", - "span": { - "start": 271, - "end": 353, - "ctxt": 0 - }, - "properties": [ - { - "type": "KeyValueProperty", - "key": { - "type": "Identifier", - "span": { - "start": 277, - "end": 278, - "ctxt": 0 - }, - "value": "m", - "optional": false - }, - "value": { - "type": "ArrowFunctionExpression", - "span": { - "start": 280, - "end": 351, - "ctxt": 0 - }, - "params": [], - "body": { - "type": "BlockStatement", - "span": { - "start": 292, - "end": 351, - "ctxt": 0 - }, - "stmts": [ - { - "type": "VariableDeclaration", - "span": { - "start": 302, - "end": 336, - "ctxt": 0 - }, - "kind": "const", - "declare": false, - "declarations": [ - { - "type": "VariableDeclarator", - "span": { - "start": 308, - "end": 336, - "ctxt": 0 - }, - "id": { - "type": "Identifier", - "span": { - "start": 308, - "end": 311, - "ctxt": 0 - }, - "value": "req", - "optional": false, - "typeAnnotation": null - }, - "init": { - "type": "AwaitExpression", - "span": { - "start": 314, - "end": 336, - "ctxt": 0 - }, - "argument": { - "type": "CallExpression", - "span": { - "start": 320, - "end": 336, - "ctxt": 0 - }, - "callee": { - "type": "Import", - "span": { - "start": 320, - "end": 326, - "ctxt": 0 - }, - "phase": "evaluation" - }, - "arguments": [ - { - "spread": null, - "expression": { - "type": "StringLiteral", - "span": { - "start": 327, - "end": 335, - "ctxt": 0 - }, - "value": "./test", - "raw": "'./test'" - } - } - ], - "typeArguments": null - } - }, - "definite": false - } - ] - } - ] - }, - "async": true, - "generator": false, - "typeParameters": null, - "returnType": null - } - } - ] - }, - "definite": false - } - ] - } - }, - { - "type": "ExportDeclaration", - "span": { - "start": 355, - "end": 488, - "ctxt": 0 - }, - "declaration": { - "type": "ClassDeclaration", - "identifier": { - "type": "Identifier", - "span": { - "start": 368, - "end": 371, - "ctxt": 0 - }, - "value": "cl2", - "optional": false - }, - "declare": false, - "span": { - "start": 362, - "end": 488, - "ctxt": 0 - }, - "decorators": [], - "body": [ - { - "type": "ClassProperty", - "span": { - "start": 378, - "end": 486, - "ctxt": 0 - }, - "key": { - "type": "Identifier", - "span": { - "start": 385, - "end": 386, - "ctxt": 0 - }, - "value": "p", - "optional": false - }, - "value": { - "type": "ObjectExpression", - "span": { - "start": 389, - "end": 486, - "ctxt": 0 - }, - "properties": [ - { - "type": "KeyValueProperty", - "key": { - "type": "Identifier", - "span": { - "start": 399, - "end": 400, - "ctxt": 0 - }, - "value": "m", - "optional": false - }, - "value": { - "type": "ArrowFunctionExpression", - "span": { - "start": 402, - "end": 480, - "ctxt": 0 - }, - "params": [], - "body": { - "type": "BlockStatement", - "span": { - "start": 414, - "end": 480, - "ctxt": 0 - }, - "stmts": [ - { - "type": "VariableDeclaration", - "span": { - "start": 428, - "end": 462, - "ctxt": 0 - }, - "kind": "const", - "declare": false, - "declarations": [ - { - "type": "VariableDeclarator", - "span": { - "start": 434, - "end": 462, - "ctxt": 0 - }, - "id": { - "type": "Identifier", - "span": { - "start": 434, - "end": 437, - "ctxt": 0 - }, - "value": "req", - "optional": false, - "typeAnnotation": null - }, - "init": { - "type": "AwaitExpression", - "span": { - "start": 440, - "end": 462, - "ctxt": 0 - }, - "argument": { - "type": "CallExpression", - "span": { - "start": 446, - "end": 462, - "ctxt": 0 - }, - "callee": { - "type": "Import", - "span": { - "start": 446, - "end": 452, - "ctxt": 0 - }, - "phase": "evaluation" - }, - "arguments": [ - { - "spread": null, - "expression": { - "type": "StringLiteral", - "span": { - "start": 453, - "end": 461, - "ctxt": 0 - }, - "value": "./test", - "raw": "'./test'" - } - } - ], - "typeArguments": null - } - }, - "definite": false - } - ] - } - ] - }, - "async": true, - "generator": false, - "typeParameters": null, - "returnType": null - } - } - ] - }, - "typeAnnotation": null, - "isStatic": false, - "decorators": [], - "accessibility": "public", - "isAbstract": false, - "isOptional": false, - "isOverride": false, - "readonly": false, - "declare": false, - "definite": false - } - ], - "superClass": null, - "isAbstract": false, - "typeParams": null, - "superTypeParams": null, - "implements": [] - } - }, - { - "type": "ExportDeclaration", - "span": { - "start": 490, - "end": 569, - "ctxt": 0 - }, - "declaration": { - "type": "VariableDeclaration", - "span": { - "start": 497, - "end": 569, - "ctxt": 0 - }, - "kind": "const", - "declare": false, - "declarations": [ - { - "type": "VariableDeclarator", - "span": { - "start": 503, - "end": 569, - "ctxt": 0 - }, - "id": { - "type": "Identifier", - "span": { - "start": 503, - "end": 504, - "ctxt": 0 - }, - "value": "l", - "optional": false, - "typeAnnotation": null - }, - "init": { - "type": "ArrowFunctionExpression", - "span": { - "start": 507, - "end": 569, - "ctxt": 0 - }, - "params": [], - "body": { - "type": "BlockStatement", - "span": { - "start": 519, - "end": 569, - "ctxt": 0 - }, - "stmts": [ - { - "type": "VariableDeclaration", - "span": { - "start": 525, - "end": 559, - "ctxt": 0 - }, - "kind": "const", - "declare": false, - "declarations": [ - { - "type": "VariableDeclarator", - "span": { - "start": 531, - "end": 559, - "ctxt": 0 - }, - "id": { - "type": "Identifier", - "span": { - "start": 531, - "end": 534, - "ctxt": 0 - }, - "value": "req", - "optional": false, - "typeAnnotation": null - }, - "init": { - "type": "AwaitExpression", - "span": { - "start": 537, - "end": 559, - "ctxt": 0 - }, - "argument": { - "type": "CallExpression", - "span": { - "start": 543, - "end": 559, - "ctxt": 0 - }, - "callee": { - "type": "Import", - "span": { - "start": 543, - "end": 549, - "ctxt": 0 - }, - "phase": "evaluation" - }, - "arguments": [ - { - "spread": null, - "expression": { - "type": "StringLiteral", - "span": { - "start": 550, - "end": 558, - "ctxt": 0 - }, - "value": "./test", - "raw": "'./test'" - } - } - ], - "typeArguments": null - } - }, - "definite": false - } - ] - } - ] - }, - "async": true, - "generator": false, - "typeParameters": null, - "returnType": null - }, - "definite": false - } - ] - } - } - ], - "interpreter": null -} diff --git a/crates/swc_ecma_parser/tests/tsc/importCallExpressionAsyncES3CJS.ts b/crates/swc_ecma_parser/tests/tsc/importCallExpressionAsyncES3CJS.ts deleted file mode 100644 index 3742604a77ad..000000000000 --- a/crates/swc_ecma_parser/tests/tsc/importCallExpressionAsyncES3CJS.ts +++ /dev/null @@ -1,31 +0,0 @@ -// @module: commonjs -// @target: es3 -// @lib: es6 -// @filename: test.ts -export async function fn() { - const req = await import('./test') // ONE -} - -export class cl1 { - public async m() { - const req = await import('./test') // TWO - } -} - -export const obj = { - m: async () => { - const req = await import('./test') // THREE - } -} - -export class cl2 { - public p = { - m: async () => { - const req = await import('./test') // FOUR - } - } -} - -export const l = async () => { - const req = await import('./test') // FIVE -} diff --git a/crates/swc_ecma_parser/tests/tsc/importCallExpressionAsyncES3System.json b/crates/swc_ecma_parser/tests/tsc/importCallExpressionAsyncES3System.json deleted file mode 100644 index b87d75d2ccdf..000000000000 --- a/crates/swc_ecma_parser/tests/tsc/importCallExpressionAsyncES3System.json +++ /dev/null @@ -1,759 +0,0 @@ -{ - "type": "Module", - "span": { - "start": 71, - "end": 567, - "ctxt": 0 - }, - "body": [ - { - "type": "ExportDeclaration", - "span": { - "start": 71, - "end": 147, - "ctxt": 0 - }, - "declaration": { - "type": "FunctionDeclaration", - "identifier": { - "type": "Identifier", - "span": { - "start": 93, - "end": 95, - "ctxt": 0 - }, - "value": "fn", - "optional": false - }, - "declare": false, - "params": [], - "decorators": [], - "span": { - "start": 78, - "end": 147, - "ctxt": 0 - }, - "body": { - "type": "BlockStatement", - "span": { - "start": 98, - "end": 147, - "ctxt": 0 - }, - "stmts": [ - { - "type": "VariableDeclaration", - "span": { - "start": 104, - "end": 138, - "ctxt": 0 - }, - "kind": "const", - "declare": false, - "declarations": [ - { - "type": "VariableDeclarator", - "span": { - "start": 110, - "end": 138, - "ctxt": 0 - }, - "id": { - "type": "Identifier", - "span": { - "start": 110, - "end": 113, - "ctxt": 0 - }, - "value": "req", - "optional": false, - "typeAnnotation": null - }, - "init": { - "type": "AwaitExpression", - "span": { - "start": 116, - "end": 138, - "ctxt": 0 - }, - "argument": { - "type": "CallExpression", - "span": { - "start": 122, - "end": 138, - "ctxt": 0 - }, - "callee": { - "type": "Import", - "span": { - "start": 122, - "end": 128, - "ctxt": 0 - }, - "phase": "evaluation" - }, - "arguments": [ - { - "spread": null, - "expression": { - "type": "StringLiteral", - "span": { - "start": 129, - "end": 137, - "ctxt": 0 - }, - "value": "./test", - "raw": "'./test'" - } - } - ], - "typeArguments": null - } - }, - "definite": false - } - ] - } - ] - }, - "generator": false, - "async": true, - "typeParameters": null, - "returnType": null - } - }, - { - "type": "ExportDeclaration", - "span": { - "start": 149, - "end": 248, - "ctxt": 0 - }, - "declaration": { - "type": "ClassDeclaration", - "identifier": { - "type": "Identifier", - "span": { - "start": 162, - "end": 165, - "ctxt": 0 - }, - "value": "cl1", - "optional": false - }, - "declare": false, - "span": { - "start": 156, - "end": 248, - "ctxt": 0 - }, - "decorators": [], - "body": [ - { - "type": "ClassMethod", - "span": { - "start": 172, - "end": 246, - "ctxt": 0 - }, - "key": { - "type": "Identifier", - "span": { - "start": 185, - "end": 186, - "ctxt": 0 - }, - "value": "m", - "optional": false - }, - "function": { - "params": [], - "decorators": [], - "span": { - "start": 172, - "end": 246, - "ctxt": 0 - }, - "body": { - "type": "BlockStatement", - "span": { - "start": 189, - "end": 246, - "ctxt": 0 - }, - "stmts": [ - { - "type": "VariableDeclaration", - "span": { - "start": 199, - "end": 233, - "ctxt": 0 - }, - "kind": "const", - "declare": false, - "declarations": [ - { - "type": "VariableDeclarator", - "span": { - "start": 205, - "end": 233, - "ctxt": 0 - }, - "id": { - "type": "Identifier", - "span": { - "start": 205, - "end": 208, - "ctxt": 0 - }, - "value": "req", - "optional": false, - "typeAnnotation": null - }, - "init": { - "type": "AwaitExpression", - "span": { - "start": 211, - "end": 233, - "ctxt": 0 - }, - "argument": { - "type": "CallExpression", - "span": { - "start": 217, - "end": 233, - "ctxt": 0 - }, - "callee": { - "type": "Import", - "span": { - "start": 217, - "end": 223, - "ctxt": 0 - }, - "phase": "evaluation" - }, - "arguments": [ - { - "spread": null, - "expression": { - "type": "StringLiteral", - "span": { - "start": 224, - "end": 232, - "ctxt": 0 - }, - "value": "./test", - "raw": "'./test'" - } - } - ], - "typeArguments": null - } - }, - "definite": false - } - ] - } - ] - }, - "generator": false, - "async": true, - "typeParameters": null, - "returnType": null - }, - "kind": "method", - "isStatic": false, - "accessibility": "public", - "isAbstract": false, - "isOptional": false, - "isOverride": false - } - ], - "superClass": null, - "isAbstract": false, - "typeParams": null, - "superTypeParams": null, - "implements": [] - } - }, - { - "type": "ExportDeclaration", - "span": { - "start": 250, - "end": 351, - "ctxt": 0 - }, - "declaration": { - "type": "VariableDeclaration", - "span": { - "start": 257, - "end": 351, - "ctxt": 0 - }, - "kind": "const", - "declare": false, - "declarations": [ - { - "type": "VariableDeclarator", - "span": { - "start": 263, - "end": 351, - "ctxt": 0 - }, - "id": { - "type": "Identifier", - "span": { - "start": 263, - "end": 266, - "ctxt": 0 - }, - "value": "obj", - "optional": false, - "typeAnnotation": null - }, - "init": { - "type": "ObjectExpression", - "span": { - "start": 269, - "end": 351, - "ctxt": 0 - }, - "properties": [ - { - "type": "KeyValueProperty", - "key": { - "type": "Identifier", - "span": { - "start": 275, - "end": 276, - "ctxt": 0 - }, - "value": "m", - "optional": false - }, - "value": { - "type": "ArrowFunctionExpression", - "span": { - "start": 278, - "end": 349, - "ctxt": 0 - }, - "params": [], - "body": { - "type": "BlockStatement", - "span": { - "start": 290, - "end": 349, - "ctxt": 0 - }, - "stmts": [ - { - "type": "VariableDeclaration", - "span": { - "start": 300, - "end": 334, - "ctxt": 0 - }, - "kind": "const", - "declare": false, - "declarations": [ - { - "type": "VariableDeclarator", - "span": { - "start": 306, - "end": 334, - "ctxt": 0 - }, - "id": { - "type": "Identifier", - "span": { - "start": 306, - "end": 309, - "ctxt": 0 - }, - "value": "req", - "optional": false, - "typeAnnotation": null - }, - "init": { - "type": "AwaitExpression", - "span": { - "start": 312, - "end": 334, - "ctxt": 0 - }, - "argument": { - "type": "CallExpression", - "span": { - "start": 318, - "end": 334, - "ctxt": 0 - }, - "callee": { - "type": "Import", - "span": { - "start": 318, - "end": 324, - "ctxt": 0 - }, - "phase": "evaluation" - }, - "arguments": [ - { - "spread": null, - "expression": { - "type": "StringLiteral", - "span": { - "start": 325, - "end": 333, - "ctxt": 0 - }, - "value": "./test", - "raw": "'./test'" - } - } - ], - "typeArguments": null - } - }, - "definite": false - } - ] - } - ] - }, - "async": true, - "generator": false, - "typeParameters": null, - "returnType": null - } - } - ] - }, - "definite": false - } - ] - } - }, - { - "type": "ExportDeclaration", - "span": { - "start": 353, - "end": 486, - "ctxt": 0 - }, - "declaration": { - "type": "ClassDeclaration", - "identifier": { - "type": "Identifier", - "span": { - "start": 366, - "end": 369, - "ctxt": 0 - }, - "value": "cl2", - "optional": false - }, - "declare": false, - "span": { - "start": 360, - "end": 486, - "ctxt": 0 - }, - "decorators": [], - "body": [ - { - "type": "ClassProperty", - "span": { - "start": 376, - "end": 484, - "ctxt": 0 - }, - "key": { - "type": "Identifier", - "span": { - "start": 383, - "end": 384, - "ctxt": 0 - }, - "value": "p", - "optional": false - }, - "value": { - "type": "ObjectExpression", - "span": { - "start": 387, - "end": 484, - "ctxt": 0 - }, - "properties": [ - { - "type": "KeyValueProperty", - "key": { - "type": "Identifier", - "span": { - "start": 397, - "end": 398, - "ctxt": 0 - }, - "value": "m", - "optional": false - }, - "value": { - "type": "ArrowFunctionExpression", - "span": { - "start": 400, - "end": 478, - "ctxt": 0 - }, - "params": [], - "body": { - "type": "BlockStatement", - "span": { - "start": 412, - "end": 478, - "ctxt": 0 - }, - "stmts": [ - { - "type": "VariableDeclaration", - "span": { - "start": 426, - "end": 460, - "ctxt": 0 - }, - "kind": "const", - "declare": false, - "declarations": [ - { - "type": "VariableDeclarator", - "span": { - "start": 432, - "end": 460, - "ctxt": 0 - }, - "id": { - "type": "Identifier", - "span": { - "start": 432, - "end": 435, - "ctxt": 0 - }, - "value": "req", - "optional": false, - "typeAnnotation": null - }, - "init": { - "type": "AwaitExpression", - "span": { - "start": 438, - "end": 460, - "ctxt": 0 - }, - "argument": { - "type": "CallExpression", - "span": { - "start": 444, - "end": 460, - "ctxt": 0 - }, - "callee": { - "type": "Import", - "span": { - "start": 444, - "end": 450, - "ctxt": 0 - }, - "phase": "evaluation" - }, - "arguments": [ - { - "spread": null, - "expression": { - "type": "StringLiteral", - "span": { - "start": 451, - "end": 459, - "ctxt": 0 - }, - "value": "./test", - "raw": "'./test'" - } - } - ], - "typeArguments": null - } - }, - "definite": false - } - ] - } - ] - }, - "async": true, - "generator": false, - "typeParameters": null, - "returnType": null - } - } - ] - }, - "typeAnnotation": null, - "isStatic": false, - "decorators": [], - "accessibility": "public", - "isAbstract": false, - "isOptional": false, - "isOverride": false, - "readonly": false, - "declare": false, - "definite": false - } - ], - "superClass": null, - "isAbstract": false, - "typeParams": null, - "superTypeParams": null, - "implements": [] - } - }, - { - "type": "ExportDeclaration", - "span": { - "start": 488, - "end": 567, - "ctxt": 0 - }, - "declaration": { - "type": "VariableDeclaration", - "span": { - "start": 495, - "end": 567, - "ctxt": 0 - }, - "kind": "const", - "declare": false, - "declarations": [ - { - "type": "VariableDeclarator", - "span": { - "start": 501, - "end": 567, - "ctxt": 0 - }, - "id": { - "type": "Identifier", - "span": { - "start": 501, - "end": 502, - "ctxt": 0 - }, - "value": "l", - "optional": false, - "typeAnnotation": null - }, - "init": { - "type": "ArrowFunctionExpression", - "span": { - "start": 505, - "end": 567, - "ctxt": 0 - }, - "params": [], - "body": { - "type": "BlockStatement", - "span": { - "start": 517, - "end": 567, - "ctxt": 0 - }, - "stmts": [ - { - "type": "VariableDeclaration", - "span": { - "start": 523, - "end": 557, - "ctxt": 0 - }, - "kind": "const", - "declare": false, - "declarations": [ - { - "type": "VariableDeclarator", - "span": { - "start": 529, - "end": 557, - "ctxt": 0 - }, - "id": { - "type": "Identifier", - "span": { - "start": 529, - "end": 532, - "ctxt": 0 - }, - "value": "req", - "optional": false, - "typeAnnotation": null - }, - "init": { - "type": "AwaitExpression", - "span": { - "start": 535, - "end": 557, - "ctxt": 0 - }, - "argument": { - "type": "CallExpression", - "span": { - "start": 541, - "end": 557, - "ctxt": 0 - }, - "callee": { - "type": "Import", - "span": { - "start": 541, - "end": 547, - "ctxt": 0 - }, - "phase": "evaluation" - }, - "arguments": [ - { - "spread": null, - "expression": { - "type": "StringLiteral", - "span": { - "start": 548, - "end": 556, - "ctxt": 0 - }, - "value": "./test", - "raw": "'./test'" - } - } - ], - "typeArguments": null - } - }, - "definite": false - } - ] - } - ] - }, - "async": true, - "generator": false, - "typeParameters": null, - "returnType": null - }, - "definite": false - } - ] - } - } - ], - "interpreter": null -} diff --git a/crates/swc_ecma_parser/tests/tsc/importCallExpressionAsyncES3System.ts b/crates/swc_ecma_parser/tests/tsc/importCallExpressionAsyncES3System.ts deleted file mode 100644 index 6cbfa746bea9..000000000000 --- a/crates/swc_ecma_parser/tests/tsc/importCallExpressionAsyncES3System.ts +++ /dev/null @@ -1,31 +0,0 @@ -// @module: system -// @target: es3 -// @lib: es6 -// @filename: test.ts -export async function fn() { - const req = await import('./test') // ONE -} - -export class cl1 { - public async m() { - const req = await import('./test') // TWO - } -} - -export const obj = { - m: async () => { - const req = await import('./test') // THREE - } -} - -export class cl2 { - public p = { - m: async () => { - const req = await import('./test') // FOUR - } - } -} - -export const l = async () => { - const req = await import('./test') // FIVE -} diff --git a/crates/swc_ecma_parser/tests/tsc/importCallExpressionAsyncES3UMD.json b/crates/swc_ecma_parser/tests/tsc/importCallExpressionAsyncES3UMD.json deleted file mode 100644 index e09d7cbdd60b..000000000000 --- a/crates/swc_ecma_parser/tests/tsc/importCallExpressionAsyncES3UMD.json +++ /dev/null @@ -1,759 +0,0 @@ -{ - "type": "Module", - "span": { - "start": 68, - "end": 564, - "ctxt": 0 - }, - "body": [ - { - "type": "ExportDeclaration", - "span": { - "start": 68, - "end": 144, - "ctxt": 0 - }, - "declaration": { - "type": "FunctionDeclaration", - "identifier": { - "type": "Identifier", - "span": { - "start": 90, - "end": 92, - "ctxt": 0 - }, - "value": "fn", - "optional": false - }, - "declare": false, - "params": [], - "decorators": [], - "span": { - "start": 75, - "end": 144, - "ctxt": 0 - }, - "body": { - "type": "BlockStatement", - "span": { - "start": 95, - "end": 144, - "ctxt": 0 - }, - "stmts": [ - { - "type": "VariableDeclaration", - "span": { - "start": 101, - "end": 135, - "ctxt": 0 - }, - "kind": "const", - "declare": false, - "declarations": [ - { - "type": "VariableDeclarator", - "span": { - "start": 107, - "end": 135, - "ctxt": 0 - }, - "id": { - "type": "Identifier", - "span": { - "start": 107, - "end": 110, - "ctxt": 0 - }, - "value": "req", - "optional": false, - "typeAnnotation": null - }, - "init": { - "type": "AwaitExpression", - "span": { - "start": 113, - "end": 135, - "ctxt": 0 - }, - "argument": { - "type": "CallExpression", - "span": { - "start": 119, - "end": 135, - "ctxt": 0 - }, - "callee": { - "type": "Import", - "span": { - "start": 119, - "end": 125, - "ctxt": 0 - }, - "phase": "evaluation" - }, - "arguments": [ - { - "spread": null, - "expression": { - "type": "StringLiteral", - "span": { - "start": 126, - "end": 134, - "ctxt": 0 - }, - "value": "./test", - "raw": "'./test'" - } - } - ], - "typeArguments": null - } - }, - "definite": false - } - ] - } - ] - }, - "generator": false, - "async": true, - "typeParameters": null, - "returnType": null - } - }, - { - "type": "ExportDeclaration", - "span": { - "start": 146, - "end": 245, - "ctxt": 0 - }, - "declaration": { - "type": "ClassDeclaration", - "identifier": { - "type": "Identifier", - "span": { - "start": 159, - "end": 162, - "ctxt": 0 - }, - "value": "cl1", - "optional": false - }, - "declare": false, - "span": { - "start": 153, - "end": 245, - "ctxt": 0 - }, - "decorators": [], - "body": [ - { - "type": "ClassMethod", - "span": { - "start": 169, - "end": 243, - "ctxt": 0 - }, - "key": { - "type": "Identifier", - "span": { - "start": 182, - "end": 183, - "ctxt": 0 - }, - "value": "m", - "optional": false - }, - "function": { - "params": [], - "decorators": [], - "span": { - "start": 169, - "end": 243, - "ctxt": 0 - }, - "body": { - "type": "BlockStatement", - "span": { - "start": 186, - "end": 243, - "ctxt": 0 - }, - "stmts": [ - { - "type": "VariableDeclaration", - "span": { - "start": 196, - "end": 230, - "ctxt": 0 - }, - "kind": "const", - "declare": false, - "declarations": [ - { - "type": "VariableDeclarator", - "span": { - "start": 202, - "end": 230, - "ctxt": 0 - }, - "id": { - "type": "Identifier", - "span": { - "start": 202, - "end": 205, - "ctxt": 0 - }, - "value": "req", - "optional": false, - "typeAnnotation": null - }, - "init": { - "type": "AwaitExpression", - "span": { - "start": 208, - "end": 230, - "ctxt": 0 - }, - "argument": { - "type": "CallExpression", - "span": { - "start": 214, - "end": 230, - "ctxt": 0 - }, - "callee": { - "type": "Import", - "span": { - "start": 214, - "end": 220, - "ctxt": 0 - }, - "phase": "evaluation" - }, - "arguments": [ - { - "spread": null, - "expression": { - "type": "StringLiteral", - "span": { - "start": 221, - "end": 229, - "ctxt": 0 - }, - "value": "./test", - "raw": "'./test'" - } - } - ], - "typeArguments": null - } - }, - "definite": false - } - ] - } - ] - }, - "generator": false, - "async": true, - "typeParameters": null, - "returnType": null - }, - "kind": "method", - "isStatic": false, - "accessibility": "public", - "isAbstract": false, - "isOptional": false, - "isOverride": false - } - ], - "superClass": null, - "isAbstract": false, - "typeParams": null, - "superTypeParams": null, - "implements": [] - } - }, - { - "type": "ExportDeclaration", - "span": { - "start": 247, - "end": 348, - "ctxt": 0 - }, - "declaration": { - "type": "VariableDeclaration", - "span": { - "start": 254, - "end": 348, - "ctxt": 0 - }, - "kind": "const", - "declare": false, - "declarations": [ - { - "type": "VariableDeclarator", - "span": { - "start": 260, - "end": 348, - "ctxt": 0 - }, - "id": { - "type": "Identifier", - "span": { - "start": 260, - "end": 263, - "ctxt": 0 - }, - "value": "obj", - "optional": false, - "typeAnnotation": null - }, - "init": { - "type": "ObjectExpression", - "span": { - "start": 266, - "end": 348, - "ctxt": 0 - }, - "properties": [ - { - "type": "KeyValueProperty", - "key": { - "type": "Identifier", - "span": { - "start": 272, - "end": 273, - "ctxt": 0 - }, - "value": "m", - "optional": false - }, - "value": { - "type": "ArrowFunctionExpression", - "span": { - "start": 275, - "end": 346, - "ctxt": 0 - }, - "params": [], - "body": { - "type": "BlockStatement", - "span": { - "start": 287, - "end": 346, - "ctxt": 0 - }, - "stmts": [ - { - "type": "VariableDeclaration", - "span": { - "start": 297, - "end": 331, - "ctxt": 0 - }, - "kind": "const", - "declare": false, - "declarations": [ - { - "type": "VariableDeclarator", - "span": { - "start": 303, - "end": 331, - "ctxt": 0 - }, - "id": { - "type": "Identifier", - "span": { - "start": 303, - "end": 306, - "ctxt": 0 - }, - "value": "req", - "optional": false, - "typeAnnotation": null - }, - "init": { - "type": "AwaitExpression", - "span": { - "start": 309, - "end": 331, - "ctxt": 0 - }, - "argument": { - "type": "CallExpression", - "span": { - "start": 315, - "end": 331, - "ctxt": 0 - }, - "callee": { - "type": "Import", - "span": { - "start": 315, - "end": 321, - "ctxt": 0 - }, - "phase": "evaluation" - }, - "arguments": [ - { - "spread": null, - "expression": { - "type": "StringLiteral", - "span": { - "start": 322, - "end": 330, - "ctxt": 0 - }, - "value": "./test", - "raw": "'./test'" - } - } - ], - "typeArguments": null - } - }, - "definite": false - } - ] - } - ] - }, - "async": true, - "generator": false, - "typeParameters": null, - "returnType": null - } - } - ] - }, - "definite": false - } - ] - } - }, - { - "type": "ExportDeclaration", - "span": { - "start": 350, - "end": 483, - "ctxt": 0 - }, - "declaration": { - "type": "ClassDeclaration", - "identifier": { - "type": "Identifier", - "span": { - "start": 363, - "end": 366, - "ctxt": 0 - }, - "value": "cl2", - "optional": false - }, - "declare": false, - "span": { - "start": 357, - "end": 483, - "ctxt": 0 - }, - "decorators": [], - "body": [ - { - "type": "ClassProperty", - "span": { - "start": 373, - "end": 481, - "ctxt": 0 - }, - "key": { - "type": "Identifier", - "span": { - "start": 380, - "end": 381, - "ctxt": 0 - }, - "value": "p", - "optional": false - }, - "value": { - "type": "ObjectExpression", - "span": { - "start": 384, - "end": 481, - "ctxt": 0 - }, - "properties": [ - { - "type": "KeyValueProperty", - "key": { - "type": "Identifier", - "span": { - "start": 394, - "end": 395, - "ctxt": 0 - }, - "value": "m", - "optional": false - }, - "value": { - "type": "ArrowFunctionExpression", - "span": { - "start": 397, - "end": 475, - "ctxt": 0 - }, - "params": [], - "body": { - "type": "BlockStatement", - "span": { - "start": 409, - "end": 475, - "ctxt": 0 - }, - "stmts": [ - { - "type": "VariableDeclaration", - "span": { - "start": 423, - "end": 457, - "ctxt": 0 - }, - "kind": "const", - "declare": false, - "declarations": [ - { - "type": "VariableDeclarator", - "span": { - "start": 429, - "end": 457, - "ctxt": 0 - }, - "id": { - "type": "Identifier", - "span": { - "start": 429, - "end": 432, - "ctxt": 0 - }, - "value": "req", - "optional": false, - "typeAnnotation": null - }, - "init": { - "type": "AwaitExpression", - "span": { - "start": 435, - "end": 457, - "ctxt": 0 - }, - "argument": { - "type": "CallExpression", - "span": { - "start": 441, - "end": 457, - "ctxt": 0 - }, - "callee": { - "type": "Import", - "span": { - "start": 441, - "end": 447, - "ctxt": 0 - }, - "phase": "evaluation" - }, - "arguments": [ - { - "spread": null, - "expression": { - "type": "StringLiteral", - "span": { - "start": 448, - "end": 456, - "ctxt": 0 - }, - "value": "./test", - "raw": "'./test'" - } - } - ], - "typeArguments": null - } - }, - "definite": false - } - ] - } - ] - }, - "async": true, - "generator": false, - "typeParameters": null, - "returnType": null - } - } - ] - }, - "typeAnnotation": null, - "isStatic": false, - "decorators": [], - "accessibility": "public", - "isAbstract": false, - "isOptional": false, - "isOverride": false, - "readonly": false, - "declare": false, - "definite": false - } - ], - "superClass": null, - "isAbstract": false, - "typeParams": null, - "superTypeParams": null, - "implements": [] - } - }, - { - "type": "ExportDeclaration", - "span": { - "start": 485, - "end": 564, - "ctxt": 0 - }, - "declaration": { - "type": "VariableDeclaration", - "span": { - "start": 492, - "end": 564, - "ctxt": 0 - }, - "kind": "const", - "declare": false, - "declarations": [ - { - "type": "VariableDeclarator", - "span": { - "start": 498, - "end": 564, - "ctxt": 0 - }, - "id": { - "type": "Identifier", - "span": { - "start": 498, - "end": 499, - "ctxt": 0 - }, - "value": "l", - "optional": false, - "typeAnnotation": null - }, - "init": { - "type": "ArrowFunctionExpression", - "span": { - "start": 502, - "end": 564, - "ctxt": 0 - }, - "params": [], - "body": { - "type": "BlockStatement", - "span": { - "start": 514, - "end": 564, - "ctxt": 0 - }, - "stmts": [ - { - "type": "VariableDeclaration", - "span": { - "start": 520, - "end": 554, - "ctxt": 0 - }, - "kind": "const", - "declare": false, - "declarations": [ - { - "type": "VariableDeclarator", - "span": { - "start": 526, - "end": 554, - "ctxt": 0 - }, - "id": { - "type": "Identifier", - "span": { - "start": 526, - "end": 529, - "ctxt": 0 - }, - "value": "req", - "optional": false, - "typeAnnotation": null - }, - "init": { - "type": "AwaitExpression", - "span": { - "start": 532, - "end": 554, - "ctxt": 0 - }, - "argument": { - "type": "CallExpression", - "span": { - "start": 538, - "end": 554, - "ctxt": 0 - }, - "callee": { - "type": "Import", - "span": { - "start": 538, - "end": 544, - "ctxt": 0 - }, - "phase": "evaluation" - }, - "arguments": [ - { - "spread": null, - "expression": { - "type": "StringLiteral", - "span": { - "start": 545, - "end": 553, - "ctxt": 0 - }, - "value": "./test", - "raw": "'./test'" - } - } - ], - "typeArguments": null - } - }, - "definite": false - } - ] - } - ] - }, - "async": true, - "generator": false, - "typeParameters": null, - "returnType": null - }, - "definite": false - } - ] - } - } - ], - "interpreter": null -} diff --git a/crates/swc_ecma_parser/tests/tsc/importCallExpressionAsyncES3UMD.ts b/crates/swc_ecma_parser/tests/tsc/importCallExpressionAsyncES3UMD.ts deleted file mode 100644 index 59476c7acfa6..000000000000 --- a/crates/swc_ecma_parser/tests/tsc/importCallExpressionAsyncES3UMD.ts +++ /dev/null @@ -1,31 +0,0 @@ -// @module: umd -// @target: es3 -// @lib: es6 -// @filename: test.ts -export async function fn() { - const req = await import('./test') // ONE -} - -export class cl1 { - public async m() { - const req = await import('./test') // TWO - } -} - -export const obj = { - m: async () => { - const req = await import('./test') // THREE - } -} - -export class cl2 { - public p = { - m: async () => { - const req = await import('./test') // FOUR - } - } -} - -export const l = async () => { - const req = await import('./test') // FIVE -} diff --git a/crates/swc_ecma_parser/tests/tsc/importTag1.json b/crates/swc_ecma_parser/tests/tsc/importTag1.json new file mode 100644 index 000000000000..b34f81069b37 --- /dev/null +++ b/crates/swc_ecma_parser/tests/tsc/importTag1.json @@ -0,0 +1,146 @@ +{ + "type": "Module", + "span": { + "start": 79, + "end": 233, + "ctxt": 0 + }, + "body": [ + { + "type": "ExportDeclaration", + "span": { + "start": 79, + "end": 118, + "ctxt": 0 + }, + "declaration": { + "type": "TsInterfaceDeclaration", + "span": { + "start": 86, + "end": 118, + "ctxt": 0 + }, + "id": { + "type": "Identifier", + "span": { + "start": 96, + "end": 99, + "ctxt": 0 + }, + "value": "Foo", + "optional": false + }, + "declare": false, + "typeParams": null, + "extends": [], + "body": { + "type": "TsInterfaceBody", + "span": { + "start": 100, + "end": 118, + "ctxt": 0 + }, + "body": [ + { + "type": "TsPropertySignature", + "span": { + "start": 106, + "end": 116, + "ctxt": 0 + }, + "readonly": false, + "key": { + "type": "Identifier", + "span": { + "start": 106, + "end": 107, + "ctxt": 0 + }, + "value": "a", + "optional": false + }, + "computed": false, + "optional": false, + "init": null, + "params": [], + "typeAnnotation": { + "type": "TsTypeAnnotation", + "span": { + "start": 107, + "end": 115, + "ctxt": 0 + }, + "typeAnnotation": { + "type": "TsKeywordType", + "span": { + "start": 109, + "end": 115, + "ctxt": 0 + }, + "kind": "number" + } + }, + "typeParams": null + } + ] + } + } + }, + { + "type": "FunctionDeclaration", + "identifier": { + "type": "Identifier", + "span": { + "start": 224, + "end": 225, + "ctxt": 0 + }, + "value": "f", + "optional": false + }, + "declare": false, + "params": [ + { + "type": "Parameter", + "span": { + "start": 226, + "end": 229, + "ctxt": 0 + }, + "decorators": [], + "pat": { + "type": "Identifier", + "span": { + "start": 226, + "end": 229, + "ctxt": 0 + }, + "value": "foo", + "optional": false, + "typeAnnotation": null + } + } + ], + "decorators": [], + "span": { + "start": 215, + "end": 233, + "ctxt": 0 + }, + "body": { + "type": "BlockStatement", + "span": { + "start": 231, + "end": 233, + "ctxt": 0 + }, + "stmts": [] + }, + "generator": false, + "async": false, + "typeParameters": null, + "returnType": null + } + ], + "interpreter": null +} diff --git a/crates/swc_ecma_parser/tests/tsc/importTag1.ts b/crates/swc_ecma_parser/tests/tsc/importTag1.ts new file mode 100644 index 000000000000..b85735da4d96 --- /dev/null +++ b/crates/swc_ecma_parser/tests/tsc/importTag1.ts @@ -0,0 +1,18 @@ +// @checkJs: true +// @allowJs: true +// @noEmit: true + +// @filename: /types.ts +export interface Foo { + a: number; +} + +// @filename: /foo.js +/** + * @import { Foo } from "./types" + */ + +/** + * @param { Foo } foo + */ +function f(foo) {} diff --git a/crates/swc_ecma_parser/tests/tsc/importTag10.json b/crates/swc_ecma_parser/tests/tsc/importTag10.json new file mode 100644 index 000000000000..e6ebc6ba5b0c --- /dev/null +++ b/crates/swc_ecma_parser/tests/tsc/importTag10.json @@ -0,0 +1,10 @@ +{ + "type": "Script", + "span": { + "start": 1, + "end": 1, + "ctxt": 0 + }, + "body": [], + "interpreter": null +} diff --git a/crates/swc_ecma_parser/tests/tsc/importTag10.ts b/crates/swc_ecma_parser/tests/tsc/importTag10.ts new file mode 100644 index 000000000000..ae3f71e74eed --- /dev/null +++ b/crates/swc_ecma_parser/tests/tsc/importTag10.ts @@ -0,0 +1,8 @@ +// @checkJs: true +// @allowJs: true +// @noEmit: true + +// @filename: /foo.js +/** + * @import + */ diff --git a/crates/swc_ecma_parser/tests/tsc/importTag11.json b/crates/swc_ecma_parser/tests/tsc/importTag11.json new file mode 100644 index 000000000000..e6ebc6ba5b0c --- /dev/null +++ b/crates/swc_ecma_parser/tests/tsc/importTag11.json @@ -0,0 +1,10 @@ +{ + "type": "Script", + "span": { + "start": 1, + "end": 1, + "ctxt": 0 + }, + "body": [], + "interpreter": null +} diff --git a/crates/swc_ecma_parser/tests/tsc/importTag11.ts b/crates/swc_ecma_parser/tests/tsc/importTag11.ts new file mode 100644 index 000000000000..f4c2d18ecb7c --- /dev/null +++ b/crates/swc_ecma_parser/tests/tsc/importTag11.ts @@ -0,0 +1,8 @@ +// @checkJs: true +// @allowJs: true +// @noEmit: true + +// @filename: /foo.js +/** + * @import foo + */ diff --git a/crates/swc_ecma_parser/tests/tsc/importTag12.json b/crates/swc_ecma_parser/tests/tsc/importTag12.json new file mode 100644 index 000000000000..e6ebc6ba5b0c --- /dev/null +++ b/crates/swc_ecma_parser/tests/tsc/importTag12.json @@ -0,0 +1,10 @@ +{ + "type": "Script", + "span": { + "start": 1, + "end": 1, + "ctxt": 0 + }, + "body": [], + "interpreter": null +} diff --git a/crates/swc_ecma_parser/tests/tsc/importTag12.ts b/crates/swc_ecma_parser/tests/tsc/importTag12.ts new file mode 100644 index 000000000000..464444b8f924 --- /dev/null +++ b/crates/swc_ecma_parser/tests/tsc/importTag12.ts @@ -0,0 +1,8 @@ +// @checkJs: true +// @allowJs: true +// @noEmit: true + +// @filename: /foo.js +/** + * @import foo from + */ diff --git a/crates/swc_ecma_parser/tests/tsc/importTag13.json b/crates/swc_ecma_parser/tests/tsc/importTag13.json new file mode 100644 index 000000000000..e51093428a2c --- /dev/null +++ b/crates/swc_ecma_parser/tests/tsc/importTag13.json @@ -0,0 +1,91 @@ +{ + "type": "Module", + "span": { + "start": 79, + "end": 118, + "ctxt": 0 + }, + "body": [ + { + "type": "ExportDeclaration", + "span": { + "start": 79, + "end": 118, + "ctxt": 0 + }, + "declaration": { + "type": "TsInterfaceDeclaration", + "span": { + "start": 86, + "end": 118, + "ctxt": 0 + }, + "id": { + "type": "Identifier", + "span": { + "start": 96, + "end": 99, + "ctxt": 0 + }, + "value": "Foo", + "optional": false + }, + "declare": false, + "typeParams": null, + "extends": [], + "body": { + "type": "TsInterfaceBody", + "span": { + "start": 100, + "end": 118, + "ctxt": 0 + }, + "body": [ + { + "type": "TsPropertySignature", + "span": { + "start": 106, + "end": 116, + "ctxt": 0 + }, + "readonly": false, + "key": { + "type": "Identifier", + "span": { + "start": 106, + "end": 107, + "ctxt": 0 + }, + "value": "a", + "optional": false + }, + "computed": false, + "optional": false, + "init": null, + "params": [], + "typeAnnotation": { + "type": "TsTypeAnnotation", + "span": { + "start": 107, + "end": 115, + "ctxt": 0 + }, + "typeAnnotation": { + "type": "TsKeywordType", + "span": { + "start": 109, + "end": 115, + "ctxt": 0 + }, + "kind": "number" + } + }, + "typeParams": null + } + ] + } + } + } + ], + "interpreter": null +} diff --git a/crates/swc_ecma_parser/tests/tsc/importTag13.ts b/crates/swc_ecma_parser/tests/tsc/importTag13.ts new file mode 100644 index 000000000000..8f15c41695bb --- /dev/null +++ b/crates/swc_ecma_parser/tests/tsc/importTag13.ts @@ -0,0 +1,11 @@ +// @checkJs: true +// @allowJs: true +// @noEmit: true + +// @filename: /types.ts +export interface Foo { + a: number; +} + +// @filename: /foo.js +/** @import x = require("types") */ diff --git a/crates/swc_ecma_parser/tests/tsc/importTag14.json b/crates/swc_ecma_parser/tests/tsc/importTag14.json new file mode 100644 index 000000000000..e6ebc6ba5b0c --- /dev/null +++ b/crates/swc_ecma_parser/tests/tsc/importTag14.json @@ -0,0 +1,10 @@ +{ + "type": "Script", + "span": { + "start": 1, + "end": 1, + "ctxt": 0 + }, + "body": [], + "interpreter": null +} diff --git a/crates/swc_ecma_parser/tests/tsc/importTag14.ts b/crates/swc_ecma_parser/tests/tsc/importTag14.ts new file mode 100644 index 000000000000..98375d7356c3 --- /dev/null +++ b/crates/swc_ecma_parser/tests/tsc/importTag14.ts @@ -0,0 +1,6 @@ +// @checkJs: true +// @allowJs: true +// @noEmit: true + +// @filename: /foo.js +/** @import * as f from "./foo" with */ diff --git a/crates/swc_ecma_parser/tests/tsc/importTag15.json b/crates/swc_ecma_parser/tests/tsc/importTag15.json new file mode 100644 index 000000000000..8d635ac67a05 --- /dev/null +++ b/crates/swc_ecma_parser/tests/tsc/importTag15.json @@ -0,0 +1,104 @@ +{ + "type": "Module", + "span": { + "start": 135, + "end": 326, + "ctxt": 0 + }, + "body": [ + { + "type": "ExportDeclaration", + "span": { + "start": 135, + "end": 157, + "ctxt": 0 + }, + "declaration": { + "type": "TsInterfaceDeclaration", + "span": { + "start": 142, + "end": 157, + "ctxt": 0 + }, + "id": { + "type": "Identifier", + "span": { + "start": 152, + "end": 153, + "ctxt": 0 + }, + "value": "I", + "optional": false + }, + "declare": false, + "typeParams": null, + "extends": [], + "body": { + "type": "TsInterfaceBody", + "span": { + "start": 154, + "end": 157, + "ctxt": 0 + }, + "body": [] + } + } + }, + { + "type": "FunctionDeclaration", + "identifier": { + "type": "Identifier", + "span": { + "start": 319, + "end": 320, + "ctxt": 0 + }, + "value": "f", + "optional": false + }, + "declare": false, + "params": [ + { + "type": "Parameter", + "span": { + "start": 321, + "end": 322, + "ctxt": 0 + }, + "decorators": [], + "pat": { + "type": "Identifier", + "span": { + "start": 321, + "end": 322, + "ctxt": 0 + }, + "value": "a", + "optional": false, + "typeAnnotation": null + } + } + ], + "decorators": [], + "span": { + "start": 310, + "end": 326, + "ctxt": 0 + }, + "body": { + "type": "BlockStatement", + "span": { + "start": 324, + "end": 326, + "ctxt": 0 + }, + "stmts": [] + }, + "generator": false, + "async": false, + "typeParameters": null, + "returnType": null + } + ], + "interpreter": null +} diff --git a/crates/swc_ecma_parser/tests/tsc/importTag15.ts b/crates/swc_ecma_parser/tests/tsc/importTag15.ts new file mode 100644 index 000000000000..50004fdb86ac --- /dev/null +++ b/crates/swc_ecma_parser/tests/tsc/importTag15.ts @@ -0,0 +1,15 @@ +// @declaration: true +// @emitDeclarationOnly: true +// @module: esnext,es2015 +// @checkJs: true +// @allowJs: true + +// @filename: 0.ts +export interface I { } + +// @filename: 1.js +/** @import { I } from './0' with { type: "json" } */ +/** @import * as foo from './0' with { type: "json" } */ + +/** @param {I} a */ +function f(a) {} diff --git a/crates/swc_ecma_parser/tests/tsc/importTag16.json b/crates/swc_ecma_parser/tests/tsc/importTag16.json new file mode 100644 index 000000000000..ccbf06ed0b4c --- /dev/null +++ b/crates/swc_ecma_parser/tests/tsc/importTag16.json @@ -0,0 +1,170 @@ +{ + "type": "Module", + "span": { + "start": 109, + "end": 291, + "ctxt": 0 + }, + "body": [ + { + "type": "ExportDefaultDeclaration", + "span": { + "start": 109, + "end": 140, + "ctxt": 0 + }, + "decl": { + "type": "TsInterfaceDeclaration", + "span": { + "start": 124, + "end": 140, + "ctxt": 0 + }, + "id": { + "type": "Identifier", + "span": { + "start": 134, + "end": 137, + "ctxt": 0 + }, + "value": "Foo", + "optional": false + }, + "declare": false, + "typeParams": null, + "extends": [], + "body": { + "type": "TsInterfaceBody", + "span": { + "start": 138, + "end": 140, + "ctxt": 0 + }, + "body": [] + } + } + }, + { + "type": "ExportDeclaration", + "span": { + "start": 141, + "end": 162, + "ctxt": 0 + }, + "declaration": { + "type": "TsInterfaceDeclaration", + "span": { + "start": 148, + "end": 162, + "ctxt": 0 + }, + "id": { + "type": "Identifier", + "span": { + "start": 158, + "end": 159, + "ctxt": 0 + }, + "value": "I", + "optional": false + }, + "declare": false, + "typeParams": null, + "extends": [], + "body": { + "type": "TsInterfaceBody", + "span": { + "start": 160, + "end": 162, + "ctxt": 0 + }, + "body": [] + } + } + }, + { + "type": "ExportDeclaration", + "span": { + "start": 263, + "end": 291, + "ctxt": 0 + }, + "declaration": { + "type": "FunctionDeclaration", + "identifier": { + "type": "Identifier", + "span": { + "start": 279, + "end": 282, + "ctxt": 0 + }, + "value": "foo", + "optional": false + }, + "declare": false, + "params": [ + { + "type": "Parameter", + "span": { + "start": 283, + "end": 284, + "ctxt": 0 + }, + "decorators": [], + "pat": { + "type": "Identifier", + "span": { + "start": 283, + "end": 284, + "ctxt": 0 + }, + "value": "a", + "optional": false, + "typeAnnotation": null + } + }, + { + "type": "Parameter", + "span": { + "start": 286, + "end": 287, + "ctxt": 0 + }, + "decorators": [], + "pat": { + "type": "Identifier", + "span": { + "start": 286, + "end": 287, + "ctxt": 0 + }, + "value": "b", + "optional": false, + "typeAnnotation": null + } + } + ], + "decorators": [], + "span": { + "start": 270, + "end": 291, + "ctxt": 0 + }, + "body": { + "type": "BlockStatement", + "span": { + "start": 289, + "end": 291, + "ctxt": 0 + }, + "stmts": [] + }, + "generator": false, + "async": false, + "typeParameters": null, + "returnType": null + } + } + ], + "interpreter": null +} diff --git a/crates/swc_ecma_parser/tests/tsc/importTag16.ts b/crates/swc_ecma_parser/tests/tsc/importTag16.ts new file mode 100644 index 000000000000..0a28cd9c8a58 --- /dev/null +++ b/crates/swc_ecma_parser/tests/tsc/importTag16.ts @@ -0,0 +1,17 @@ +// @declaration: true +// @emitDeclarationOnly: true +// @checkJs: true +// @allowJs: true + +// @filename: a.ts +export default interface Foo {} +export interface I {} + +// @filename: b.js +/** @import Foo, { I } from "./a" */ + +/** + * @param {Foo} a + * @param {I} b + */ +export function foo(a, b) {} diff --git a/crates/swc_ecma_parser/tests/tsc/importTag2.json b/crates/swc_ecma_parser/tests/tsc/importTag2.json new file mode 100644 index 000000000000..17994669712f --- /dev/null +++ b/crates/swc_ecma_parser/tests/tsc/importTag2.json @@ -0,0 +1,154 @@ +{ + "type": "Module", + "span": { + "start": 79, + "end": 249, + "ctxt": 0 + }, + "body": [ + { + "type": "ExportDeclaration", + "span": { + "start": 79, + "end": 118, + "ctxt": 0 + }, + "declaration": { + "type": "TsInterfaceDeclaration", + "span": { + "start": 86, + "end": 118, + "ctxt": 0 + }, + "id": { + "type": "Identifier", + "span": { + "start": 96, + "end": 99, + "ctxt": 0 + }, + "value": "Foo", + "optional": false + }, + "declare": false, + "typeParams": null, + "extends": [], + "body": { + "type": "TsInterfaceBody", + "span": { + "start": 100, + "end": 118, + "ctxt": 0 + }, + "body": [ + { + "type": "TsPropertySignature", + "span": { + "start": 106, + "end": 116, + "ctxt": 0 + }, + "readonly": false, + "key": { + "type": "Identifier", + "span": { + "start": 106, + "end": 107, + "ctxt": 0 + }, + "value": "a", + "optional": false + }, + "computed": false, + "optional": false, + "init": null, + "params": [], + "typeAnnotation": { + "type": "TsTypeAnnotation", + "span": { + "start": 107, + "end": 115, + "ctxt": 0 + }, + "typeAnnotation": { + "type": "TsKeywordType", + "span": { + "start": 109, + "end": 115, + "ctxt": 0 + }, + "kind": "number" + } + }, + "typeParams": null + } + ] + } + } + }, + { + "type": "ExportDeclaration", + "span": { + "start": 224, + "end": 249, + "ctxt": 0 + }, + "declaration": { + "type": "FunctionDeclaration", + "identifier": { + "type": "Identifier", + "span": { + "start": 240, + "end": 241, + "ctxt": 0 + }, + "value": "f", + "optional": false + }, + "declare": false, + "params": [ + { + "type": "Parameter", + "span": { + "start": 242, + "end": 245, + "ctxt": 0 + }, + "decorators": [], + "pat": { + "type": "Identifier", + "span": { + "start": 242, + "end": 245, + "ctxt": 0 + }, + "value": "foo", + "optional": false, + "typeAnnotation": null + } + } + ], + "decorators": [], + "span": { + "start": 231, + "end": 249, + "ctxt": 0 + }, + "body": { + "type": "BlockStatement", + "span": { + "start": 247, + "end": 249, + "ctxt": 0 + }, + "stmts": [] + }, + "generator": false, + "async": false, + "typeParameters": null, + "returnType": null + } + } + ], + "interpreter": null +} diff --git a/crates/swc_ecma_parser/tests/tsc/importTag2.ts b/crates/swc_ecma_parser/tests/tsc/importTag2.ts new file mode 100644 index 000000000000..e306afb43a82 --- /dev/null +++ b/crates/swc_ecma_parser/tests/tsc/importTag2.ts @@ -0,0 +1,18 @@ +// @checkJs: true +// @allowJs: true +// @noEmit: true + +// @filename: /types.ts +export interface Foo { + a: number; +} + +// @filename: /foo.js +/** + * @import * as types from "./types" + */ + +/** + * @param { types.Foo } foo + */ +export function f(foo) {} diff --git a/crates/swc_ecma_parser/tests/tsc/importTag3.json b/crates/swc_ecma_parser/tests/tsc/importTag3.json new file mode 100644 index 000000000000..3c83e64db883 --- /dev/null +++ b/crates/swc_ecma_parser/tests/tsc/importTag3.json @@ -0,0 +1,154 @@ +{ + "type": "Module", + "span": { + "start": 79, + "end": 244, + "ctxt": 0 + }, + "body": [ + { + "type": "ExportDefaultDeclaration", + "span": { + "start": 79, + "end": 126, + "ctxt": 0 + }, + "decl": { + "type": "TsInterfaceDeclaration", + "span": { + "start": 94, + "end": 126, + "ctxt": 0 + }, + "id": { + "type": "Identifier", + "span": { + "start": 104, + "end": 107, + "ctxt": 0 + }, + "value": "Foo", + "optional": false + }, + "declare": false, + "typeParams": null, + "extends": [], + "body": { + "type": "TsInterfaceBody", + "span": { + "start": 108, + "end": 126, + "ctxt": 0 + }, + "body": [ + { + "type": "TsPropertySignature", + "span": { + "start": 114, + "end": 124, + "ctxt": 0 + }, + "readonly": false, + "key": { + "type": "Identifier", + "span": { + "start": 114, + "end": 115, + "ctxt": 0 + }, + "value": "a", + "optional": false + }, + "computed": false, + "optional": false, + "init": null, + "params": [], + "typeAnnotation": { + "type": "TsTypeAnnotation", + "span": { + "start": 115, + "end": 123, + "ctxt": 0 + }, + "typeAnnotation": { + "type": "TsKeywordType", + "span": { + "start": 117, + "end": 123, + "ctxt": 0 + }, + "kind": "number" + } + }, + "typeParams": null + } + ] + } + } + }, + { + "type": "ExportDeclaration", + "span": { + "start": 219, + "end": 244, + "ctxt": 0 + }, + "declaration": { + "type": "FunctionDeclaration", + "identifier": { + "type": "Identifier", + "span": { + "start": 235, + "end": 236, + "ctxt": 0 + }, + "value": "f", + "optional": false + }, + "declare": false, + "params": [ + { + "type": "Parameter", + "span": { + "start": 237, + "end": 240, + "ctxt": 0 + }, + "decorators": [], + "pat": { + "type": "Identifier", + "span": { + "start": 237, + "end": 240, + "ctxt": 0 + }, + "value": "foo", + "optional": false, + "typeAnnotation": null + } + } + ], + "decorators": [], + "span": { + "start": 226, + "end": 244, + "ctxt": 0 + }, + "body": { + "type": "BlockStatement", + "span": { + "start": 242, + "end": 244, + "ctxt": 0 + }, + "stmts": [] + }, + "generator": false, + "async": false, + "typeParameters": null, + "returnType": null + } + } + ], + "interpreter": null +} diff --git a/crates/swc_ecma_parser/tests/tsc/importTag3.ts b/crates/swc_ecma_parser/tests/tsc/importTag3.ts new file mode 100644 index 000000000000..7ebe8894b524 --- /dev/null +++ b/crates/swc_ecma_parser/tests/tsc/importTag3.ts @@ -0,0 +1,18 @@ +// @checkJs: true +// @allowJs: true +// @noEmit: true + +// @filename: /types.ts +export default interface Foo { + a: number; +} + +// @filename: /foo.js +/** + * @import Foo from "./types" + */ + +/** + * @param { Foo } foo + */ +export function f(foo) {} diff --git a/crates/swc_ecma_parser/tests/tsc/importTag4.json b/crates/swc_ecma_parser/tests/tsc/importTag4.json new file mode 100644 index 000000000000..3743aa8c0c2a --- /dev/null +++ b/crates/swc_ecma_parser/tests/tsc/importTag4.json @@ -0,0 +1,146 @@ +{ + "type": "Module", + "span": { + "start": 79, + "end": 276, + "ctxt": 0 + }, + "body": [ + { + "type": "ExportDeclaration", + "span": { + "start": 79, + "end": 118, + "ctxt": 0 + }, + "declaration": { + "type": "TsInterfaceDeclaration", + "span": { + "start": 86, + "end": 118, + "ctxt": 0 + }, + "id": { + "type": "Identifier", + "span": { + "start": 96, + "end": 99, + "ctxt": 0 + }, + "value": "Foo", + "optional": false + }, + "declare": false, + "typeParams": null, + "extends": [], + "body": { + "type": "TsInterfaceBody", + "span": { + "start": 100, + "end": 118, + "ctxt": 0 + }, + "body": [ + { + "type": "TsPropertySignature", + "span": { + "start": 106, + "end": 116, + "ctxt": 0 + }, + "readonly": false, + "key": { + "type": "Identifier", + "span": { + "start": 106, + "end": 107, + "ctxt": 0 + }, + "value": "a", + "optional": false + }, + "computed": false, + "optional": false, + "init": null, + "params": [], + "typeAnnotation": { + "type": "TsTypeAnnotation", + "span": { + "start": 107, + "end": 115, + "ctxt": 0 + }, + "typeAnnotation": { + "type": "TsKeywordType", + "span": { + "start": 109, + "end": 115, + "ctxt": 0 + }, + "kind": "number" + } + }, + "typeParams": null + } + ] + } + } + }, + { + "type": "FunctionDeclaration", + "identifier": { + "type": "Identifier", + "span": { + "start": 267, + "end": 268, + "ctxt": 0 + }, + "value": "f", + "optional": false + }, + "declare": false, + "params": [ + { + "type": "Parameter", + "span": { + "start": 269, + "end": 272, + "ctxt": 0 + }, + "decorators": [], + "pat": { + "type": "Identifier", + "span": { + "start": 269, + "end": 272, + "ctxt": 0 + }, + "value": "foo", + "optional": false, + "typeAnnotation": null + } + } + ], + "decorators": [], + "span": { + "start": 258, + "end": 276, + "ctxt": 0 + }, + "body": { + "type": "BlockStatement", + "span": { + "start": 274, + "end": 276, + "ctxt": 0 + }, + "stmts": [] + }, + "generator": false, + "async": false, + "typeParameters": null, + "returnType": null + } + ], + "interpreter": null +} diff --git a/crates/swc_ecma_parser/tests/tsc/importTag4.ts b/crates/swc_ecma_parser/tests/tsc/importTag4.ts new file mode 100644 index 000000000000..1f76717279c5 --- /dev/null +++ b/crates/swc_ecma_parser/tests/tsc/importTag4.ts @@ -0,0 +1,22 @@ +// @checkJs: true +// @allowJs: true +// @noEmit: true + +// @filename: /types.ts +export interface Foo { + a: number; +} + +// @filename: /foo.js +/** + * @import { Foo } from "./types" + */ + +/** + * @import { Foo } from "./types" + */ + +/** + * @param { Foo } foo + */ +function f(foo) {} diff --git a/crates/swc_ecma_parser/tests/tsc/importTag5.json b/crates/swc_ecma_parser/tests/tsc/importTag5.json new file mode 100644 index 000000000000..f2a600e3c7f8 --- /dev/null +++ b/crates/swc_ecma_parser/tests/tsc/importTag5.json @@ -0,0 +1,146 @@ +{ + "type": "Module", + "span": { + "start": 114, + "end": 268, + "ctxt": 0 + }, + "body": [ + { + "type": "ExportDeclaration", + "span": { + "start": 114, + "end": 153, + "ctxt": 0 + }, + "declaration": { + "type": "TsInterfaceDeclaration", + "span": { + "start": 121, + "end": 153, + "ctxt": 0 + }, + "id": { + "type": "Identifier", + "span": { + "start": 131, + "end": 134, + "ctxt": 0 + }, + "value": "Foo", + "optional": false + }, + "declare": false, + "typeParams": null, + "extends": [], + "body": { + "type": "TsInterfaceBody", + "span": { + "start": 135, + "end": 153, + "ctxt": 0 + }, + "body": [ + { + "type": "TsPropertySignature", + "span": { + "start": 141, + "end": 151, + "ctxt": 0 + }, + "readonly": false, + "key": { + "type": "Identifier", + "span": { + "start": 141, + "end": 142, + "ctxt": 0 + }, + "value": "a", + "optional": false + }, + "computed": false, + "optional": false, + "init": null, + "params": [], + "typeAnnotation": { + "type": "TsTypeAnnotation", + "span": { + "start": 142, + "end": 150, + "ctxt": 0 + }, + "typeAnnotation": { + "type": "TsKeywordType", + "span": { + "start": 144, + "end": 150, + "ctxt": 0 + }, + "kind": "number" + } + }, + "typeParams": null + } + ] + } + } + }, + { + "type": "FunctionDeclaration", + "identifier": { + "type": "Identifier", + "span": { + "start": 259, + "end": 260, + "ctxt": 0 + }, + "value": "f", + "optional": false + }, + "declare": false, + "params": [ + { + "type": "Parameter", + "span": { + "start": 261, + "end": 264, + "ctxt": 0 + }, + "decorators": [], + "pat": { + "type": "Identifier", + "span": { + "start": 261, + "end": 264, + "ctxt": 0 + }, + "value": "foo", + "optional": false, + "typeAnnotation": null + } + } + ], + "decorators": [], + "span": { + "start": 250, + "end": 268, + "ctxt": 0 + }, + "body": { + "type": "BlockStatement", + "span": { + "start": 266, + "end": 268, + "ctxt": 0 + }, + "stmts": [] + }, + "generator": false, + "async": false, + "typeParameters": null, + "returnType": null + } + ], + "interpreter": null +} diff --git a/crates/swc_ecma_parser/tests/tsc/importTag5.ts b/crates/swc_ecma_parser/tests/tsc/importTag5.ts new file mode 100644 index 000000000000..7dfedad464d9 --- /dev/null +++ b/crates/swc_ecma_parser/tests/tsc/importTag5.ts @@ -0,0 +1,19 @@ +// @checkJs: true +// @allowJs: true +// @declaration: true +// @emitDeclarationOnly: true + +// @filename: /types.ts +export interface Foo { + a: number; +} + +// @filename: /foo.js +/** + * @import { Foo } from "./types" + */ + +/** + * @param { Foo } foo + */ +function f(foo) {} diff --git a/crates/swc_ecma_parser/tests/tsc/importTag6.json b/crates/swc_ecma_parser/tests/tsc/importTag6.json new file mode 100644 index 000000000000..4ca570b6a04e --- /dev/null +++ b/crates/swc_ecma_parser/tests/tsc/importTag6.json @@ -0,0 +1,246 @@ +{ + "type": "Module", + "span": { + "start": 79, + "end": 303, + "ctxt": 0 + }, + "body": [ + { + "type": "ExportDeclaration", + "span": { + "start": 79, + "end": 116, + "ctxt": 0 + }, + "declaration": { + "type": "TsInterfaceDeclaration", + "span": { + "start": 86, + "end": 116, + "ctxt": 0 + }, + "id": { + "type": "Identifier", + "span": { + "start": 96, + "end": 97, + "ctxt": 0 + }, + "value": "A", + "optional": false + }, + "declare": false, + "typeParams": null, + "extends": [], + "body": { + "type": "TsInterfaceBody", + "span": { + "start": 98, + "end": 116, + "ctxt": 0 + }, + "body": [ + { + "type": "TsPropertySignature", + "span": { + "start": 104, + "end": 114, + "ctxt": 0 + }, + "readonly": false, + "key": { + "type": "Identifier", + "span": { + "start": 104, + "end": 105, + "ctxt": 0 + }, + "value": "a", + "optional": false + }, + "computed": false, + "optional": false, + "init": null, + "params": [], + "typeAnnotation": { + "type": "TsTypeAnnotation", + "span": { + "start": 105, + "end": 113, + "ctxt": 0 + }, + "typeAnnotation": { + "type": "TsKeywordType", + "span": { + "start": 107, + "end": 113, + "ctxt": 0 + }, + "kind": "number" + } + }, + "typeParams": null + } + ] + } + } + }, + { + "type": "ExportDeclaration", + "span": { + "start": 117, + "end": 154, + "ctxt": 0 + }, + "declaration": { + "type": "TsInterfaceDeclaration", + "span": { + "start": 124, + "end": 154, + "ctxt": 0 + }, + "id": { + "type": "Identifier", + "span": { + "start": 134, + "end": 135, + "ctxt": 0 + }, + "value": "B", + "optional": false + }, + "declare": false, + "typeParams": null, + "extends": [], + "body": { + "type": "TsInterfaceBody", + "span": { + "start": 136, + "end": 154, + "ctxt": 0 + }, + "body": [ + { + "type": "TsPropertySignature", + "span": { + "start": 142, + "end": 152, + "ctxt": 0 + }, + "readonly": false, + "key": { + "type": "Identifier", + "span": { + "start": 142, + "end": 143, + "ctxt": 0 + }, + "value": "a", + "optional": false + }, + "computed": false, + "optional": false, + "init": null, + "params": [], + "typeAnnotation": { + "type": "TsTypeAnnotation", + "span": { + "start": 143, + "end": 151, + "ctxt": 0 + }, + "typeAnnotation": { + "type": "TsKeywordType", + "span": { + "start": 145, + "end": 151, + "ctxt": 0 + }, + "kind": "number" + } + }, + "typeParams": null + } + ] + } + } + }, + { + "type": "FunctionDeclaration", + "identifier": { + "type": "Identifier", + "span": { + "start": 293, + "end": 294, + "ctxt": 0 + }, + "value": "f", + "optional": false + }, + "declare": false, + "params": [ + { + "type": "Parameter", + "span": { + "start": 295, + "end": 296, + "ctxt": 0 + }, + "decorators": [], + "pat": { + "type": "Identifier", + "span": { + "start": 295, + "end": 296, + "ctxt": 0 + }, + "value": "a", + "optional": false, + "typeAnnotation": null + } + }, + { + "type": "Parameter", + "span": { + "start": 298, + "end": 299, + "ctxt": 0 + }, + "decorators": [], + "pat": { + "type": "Identifier", + "span": { + "start": 298, + "end": 299, + "ctxt": 0 + }, + "value": "b", + "optional": false, + "typeAnnotation": null + } + } + ], + "decorators": [], + "span": { + "start": 284, + "end": 303, + "ctxt": 0 + }, + "body": { + "type": "BlockStatement", + "span": { + "start": 301, + "end": 303, + "ctxt": 0 + }, + "stmts": [] + }, + "generator": false, + "async": false, + "typeParameters": null, + "returnType": null + } + ], + "interpreter": null +} diff --git a/crates/swc_ecma_parser/tests/tsc/importTag6.ts b/crates/swc_ecma_parser/tests/tsc/importTag6.ts new file mode 100644 index 000000000000..2d6470c3ff55 --- /dev/null +++ b/crates/swc_ecma_parser/tests/tsc/importTag6.ts @@ -0,0 +1,25 @@ +// @checkJs: true +// @allowJs: true +// @noEmit: true + +// @filename: /types.ts +export interface A { + a: number; +} +export interface B { + a: number; +} + +// @filename: /foo.js +/** + * @import { + * A, + * B, + * } from "./types" + */ + +/** + * @param { A } a + * @param { B } b + */ +function f(a, b) {} diff --git a/crates/swc_ecma_parser/tests/tsc/importTag7.json b/crates/swc_ecma_parser/tests/tsc/importTag7.json new file mode 100644 index 000000000000..7e589f39fc04 --- /dev/null +++ b/crates/swc_ecma_parser/tests/tsc/importTag7.json @@ -0,0 +1,246 @@ +{ + "type": "Module", + "span": { + "start": 79, + "end": 291, + "ctxt": 0 + }, + "body": [ + { + "type": "ExportDeclaration", + "span": { + "start": 79, + "end": 116, + "ctxt": 0 + }, + "declaration": { + "type": "TsInterfaceDeclaration", + "span": { + "start": 86, + "end": 116, + "ctxt": 0 + }, + "id": { + "type": "Identifier", + "span": { + "start": 96, + "end": 97, + "ctxt": 0 + }, + "value": "A", + "optional": false + }, + "declare": false, + "typeParams": null, + "extends": [], + "body": { + "type": "TsInterfaceBody", + "span": { + "start": 98, + "end": 116, + "ctxt": 0 + }, + "body": [ + { + "type": "TsPropertySignature", + "span": { + "start": 104, + "end": 114, + "ctxt": 0 + }, + "readonly": false, + "key": { + "type": "Identifier", + "span": { + "start": 104, + "end": 105, + "ctxt": 0 + }, + "value": "a", + "optional": false + }, + "computed": false, + "optional": false, + "init": null, + "params": [], + "typeAnnotation": { + "type": "TsTypeAnnotation", + "span": { + "start": 105, + "end": 113, + "ctxt": 0 + }, + "typeAnnotation": { + "type": "TsKeywordType", + "span": { + "start": 107, + "end": 113, + "ctxt": 0 + }, + "kind": "number" + } + }, + "typeParams": null + } + ] + } + } + }, + { + "type": "ExportDeclaration", + "span": { + "start": 117, + "end": 154, + "ctxt": 0 + }, + "declaration": { + "type": "TsInterfaceDeclaration", + "span": { + "start": 124, + "end": 154, + "ctxt": 0 + }, + "id": { + "type": "Identifier", + "span": { + "start": 134, + "end": 135, + "ctxt": 0 + }, + "value": "B", + "optional": false + }, + "declare": false, + "typeParams": null, + "extends": [], + "body": { + "type": "TsInterfaceBody", + "span": { + "start": 136, + "end": 154, + "ctxt": 0 + }, + "body": [ + { + "type": "TsPropertySignature", + "span": { + "start": 142, + "end": 152, + "ctxt": 0 + }, + "readonly": false, + "key": { + "type": "Identifier", + "span": { + "start": 142, + "end": 143, + "ctxt": 0 + }, + "value": "a", + "optional": false + }, + "computed": false, + "optional": false, + "init": null, + "params": [], + "typeAnnotation": { + "type": "TsTypeAnnotation", + "span": { + "start": 143, + "end": 151, + "ctxt": 0 + }, + "typeAnnotation": { + "type": "TsKeywordType", + "span": { + "start": 145, + "end": 151, + "ctxt": 0 + }, + "kind": "number" + } + }, + "typeParams": null + } + ] + } + } + }, + { + "type": "FunctionDeclaration", + "identifier": { + "type": "Identifier", + "span": { + "start": 281, + "end": 282, + "ctxt": 0 + }, + "value": "f", + "optional": false + }, + "declare": false, + "params": [ + { + "type": "Parameter", + "span": { + "start": 283, + "end": 284, + "ctxt": 0 + }, + "decorators": [], + "pat": { + "type": "Identifier", + "span": { + "start": 283, + "end": 284, + "ctxt": 0 + }, + "value": "a", + "optional": false, + "typeAnnotation": null + } + }, + { + "type": "Parameter", + "span": { + "start": 286, + "end": 287, + "ctxt": 0 + }, + "decorators": [], + "pat": { + "type": "Identifier", + "span": { + "start": 286, + "end": 287, + "ctxt": 0 + }, + "value": "b", + "optional": false, + "typeAnnotation": null + } + } + ], + "decorators": [], + "span": { + "start": 272, + "end": 291, + "ctxt": 0 + }, + "body": { + "type": "BlockStatement", + "span": { + "start": 289, + "end": 291, + "ctxt": 0 + }, + "stmts": [] + }, + "generator": false, + "async": false, + "typeParameters": null, + "returnType": null + } + ], + "interpreter": null +} diff --git a/crates/swc_ecma_parser/tests/tsc/importTag7.ts b/crates/swc_ecma_parser/tests/tsc/importTag7.ts new file mode 100644 index 000000000000..d6643e411f26 --- /dev/null +++ b/crates/swc_ecma_parser/tests/tsc/importTag7.ts @@ -0,0 +1,24 @@ +// @checkJs: true +// @allowJs: true +// @noEmit: true + +// @filename: /types.ts +export interface A { + a: number; +} +export interface B { + a: number; +} + +// @filename: /foo.js +/** + * @import { + * A, + * B } from "./types" + */ + +/** + * @param { A } a + * @param { B } b + */ +function f(a, b) {} diff --git a/crates/swc_ecma_parser/tests/tsc/importTag8.json b/crates/swc_ecma_parser/tests/tsc/importTag8.json new file mode 100644 index 000000000000..7e589f39fc04 --- /dev/null +++ b/crates/swc_ecma_parser/tests/tsc/importTag8.json @@ -0,0 +1,246 @@ +{ + "type": "Module", + "span": { + "start": 79, + "end": 291, + "ctxt": 0 + }, + "body": [ + { + "type": "ExportDeclaration", + "span": { + "start": 79, + "end": 116, + "ctxt": 0 + }, + "declaration": { + "type": "TsInterfaceDeclaration", + "span": { + "start": 86, + "end": 116, + "ctxt": 0 + }, + "id": { + "type": "Identifier", + "span": { + "start": 96, + "end": 97, + "ctxt": 0 + }, + "value": "A", + "optional": false + }, + "declare": false, + "typeParams": null, + "extends": [], + "body": { + "type": "TsInterfaceBody", + "span": { + "start": 98, + "end": 116, + "ctxt": 0 + }, + "body": [ + { + "type": "TsPropertySignature", + "span": { + "start": 104, + "end": 114, + "ctxt": 0 + }, + "readonly": false, + "key": { + "type": "Identifier", + "span": { + "start": 104, + "end": 105, + "ctxt": 0 + }, + "value": "a", + "optional": false + }, + "computed": false, + "optional": false, + "init": null, + "params": [], + "typeAnnotation": { + "type": "TsTypeAnnotation", + "span": { + "start": 105, + "end": 113, + "ctxt": 0 + }, + "typeAnnotation": { + "type": "TsKeywordType", + "span": { + "start": 107, + "end": 113, + "ctxt": 0 + }, + "kind": "number" + } + }, + "typeParams": null + } + ] + } + } + }, + { + "type": "ExportDeclaration", + "span": { + "start": 117, + "end": 154, + "ctxt": 0 + }, + "declaration": { + "type": "TsInterfaceDeclaration", + "span": { + "start": 124, + "end": 154, + "ctxt": 0 + }, + "id": { + "type": "Identifier", + "span": { + "start": 134, + "end": 135, + "ctxt": 0 + }, + "value": "B", + "optional": false + }, + "declare": false, + "typeParams": null, + "extends": [], + "body": { + "type": "TsInterfaceBody", + "span": { + "start": 136, + "end": 154, + "ctxt": 0 + }, + "body": [ + { + "type": "TsPropertySignature", + "span": { + "start": 142, + "end": 152, + "ctxt": 0 + }, + "readonly": false, + "key": { + "type": "Identifier", + "span": { + "start": 142, + "end": 143, + "ctxt": 0 + }, + "value": "a", + "optional": false + }, + "computed": false, + "optional": false, + "init": null, + "params": [], + "typeAnnotation": { + "type": "TsTypeAnnotation", + "span": { + "start": 143, + "end": 151, + "ctxt": 0 + }, + "typeAnnotation": { + "type": "TsKeywordType", + "span": { + "start": 145, + "end": 151, + "ctxt": 0 + }, + "kind": "number" + } + }, + "typeParams": null + } + ] + } + } + }, + { + "type": "FunctionDeclaration", + "identifier": { + "type": "Identifier", + "span": { + "start": 281, + "end": 282, + "ctxt": 0 + }, + "value": "f", + "optional": false + }, + "declare": false, + "params": [ + { + "type": "Parameter", + "span": { + "start": 283, + "end": 284, + "ctxt": 0 + }, + "decorators": [], + "pat": { + "type": "Identifier", + "span": { + "start": 283, + "end": 284, + "ctxt": 0 + }, + "value": "a", + "optional": false, + "typeAnnotation": null + } + }, + { + "type": "Parameter", + "span": { + "start": 286, + "end": 287, + "ctxt": 0 + }, + "decorators": [], + "pat": { + "type": "Identifier", + "span": { + "start": 286, + "end": 287, + "ctxt": 0 + }, + "value": "b", + "optional": false, + "typeAnnotation": null + } + } + ], + "decorators": [], + "span": { + "start": 272, + "end": 291, + "ctxt": 0 + }, + "body": { + "type": "BlockStatement", + "span": { + "start": 289, + "end": 291, + "ctxt": 0 + }, + "stmts": [] + }, + "generator": false, + "async": false, + "typeParameters": null, + "returnType": null + } + ], + "interpreter": null +} diff --git a/crates/swc_ecma_parser/tests/tsc/importTag8.ts b/crates/swc_ecma_parser/tests/tsc/importTag8.ts new file mode 100644 index 000000000000..9832c5485852 --- /dev/null +++ b/crates/swc_ecma_parser/tests/tsc/importTag8.ts @@ -0,0 +1,24 @@ +// @checkJs: true +// @allowJs: true +// @noEmit: true + +// @filename: /types.ts +export interface A { + a: number; +} +export interface B { + a: number; +} + +// @filename: /foo.js +/** + * @import + * { A, B } + * from "./types" + */ + +/** + * @param { A } a + * @param { B } b + */ +function f(a, b) {} diff --git a/crates/swc_ecma_parser/tests/tsc/importTag9.json b/crates/swc_ecma_parser/tests/tsc/importTag9.json new file mode 100644 index 000000000000..f028480fe28e --- /dev/null +++ b/crates/swc_ecma_parser/tests/tsc/importTag9.json @@ -0,0 +1,246 @@ +{ + "type": "Module", + "span": { + "start": 79, + "end": 305, + "ctxt": 0 + }, + "body": [ + { + "type": "ExportDeclaration", + "span": { + "start": 79, + "end": 116, + "ctxt": 0 + }, + "declaration": { + "type": "TsInterfaceDeclaration", + "span": { + "start": 86, + "end": 116, + "ctxt": 0 + }, + "id": { + "type": "Identifier", + "span": { + "start": 96, + "end": 97, + "ctxt": 0 + }, + "value": "A", + "optional": false + }, + "declare": false, + "typeParams": null, + "extends": [], + "body": { + "type": "TsInterfaceBody", + "span": { + "start": 98, + "end": 116, + "ctxt": 0 + }, + "body": [ + { + "type": "TsPropertySignature", + "span": { + "start": 104, + "end": 114, + "ctxt": 0 + }, + "readonly": false, + "key": { + "type": "Identifier", + "span": { + "start": 104, + "end": 105, + "ctxt": 0 + }, + "value": "a", + "optional": false + }, + "computed": false, + "optional": false, + "init": null, + "params": [], + "typeAnnotation": { + "type": "TsTypeAnnotation", + "span": { + "start": 105, + "end": 113, + "ctxt": 0 + }, + "typeAnnotation": { + "type": "TsKeywordType", + "span": { + "start": 107, + "end": 113, + "ctxt": 0 + }, + "kind": "number" + } + }, + "typeParams": null + } + ] + } + } + }, + { + "type": "ExportDeclaration", + "span": { + "start": 117, + "end": 154, + "ctxt": 0 + }, + "declaration": { + "type": "TsInterfaceDeclaration", + "span": { + "start": 124, + "end": 154, + "ctxt": 0 + }, + "id": { + "type": "Identifier", + "span": { + "start": 134, + "end": 135, + "ctxt": 0 + }, + "value": "B", + "optional": false + }, + "declare": false, + "typeParams": null, + "extends": [], + "body": { + "type": "TsInterfaceBody", + "span": { + "start": 136, + "end": 154, + "ctxt": 0 + }, + "body": [ + { + "type": "TsPropertySignature", + "span": { + "start": 142, + "end": 152, + "ctxt": 0 + }, + "readonly": false, + "key": { + "type": "Identifier", + "span": { + "start": 142, + "end": 143, + "ctxt": 0 + }, + "value": "a", + "optional": false + }, + "computed": false, + "optional": false, + "init": null, + "params": [], + "typeAnnotation": { + "type": "TsTypeAnnotation", + "span": { + "start": 143, + "end": 151, + "ctxt": 0 + }, + "typeAnnotation": { + "type": "TsKeywordType", + "span": { + "start": 145, + "end": 151, + "ctxt": 0 + }, + "kind": "number" + } + }, + "typeParams": null + } + ] + } + } + }, + { + "type": "FunctionDeclaration", + "identifier": { + "type": "Identifier", + "span": { + "start": 295, + "end": 296, + "ctxt": 0 + }, + "value": "f", + "optional": false + }, + "declare": false, + "params": [ + { + "type": "Parameter", + "span": { + "start": 297, + "end": 298, + "ctxt": 0 + }, + "decorators": [], + "pat": { + "type": "Identifier", + "span": { + "start": 297, + "end": 298, + "ctxt": 0 + }, + "value": "a", + "optional": false, + "typeAnnotation": null + } + }, + { + "type": "Parameter", + "span": { + "start": 300, + "end": 301, + "ctxt": 0 + }, + "decorators": [], + "pat": { + "type": "Identifier", + "span": { + "start": 300, + "end": 301, + "ctxt": 0 + }, + "value": "b", + "optional": false, + "typeAnnotation": null + } + } + ], + "decorators": [], + "span": { + "start": 286, + "end": 305, + "ctxt": 0 + }, + "body": { + "type": "BlockStatement", + "span": { + "start": 303, + "end": 305, + "ctxt": 0 + }, + "stmts": [] + }, + "generator": false, + "async": false, + "typeParameters": null, + "returnType": null + } + ], + "interpreter": null +} diff --git a/crates/swc_ecma_parser/tests/tsc/importTag9.ts b/crates/swc_ecma_parser/tests/tsc/importTag9.ts new file mode 100644 index 000000000000..6cf733d5e83d --- /dev/null +++ b/crates/swc_ecma_parser/tests/tsc/importTag9.ts @@ -0,0 +1,24 @@ +// @checkJs: true +// @allowJs: true +// @noEmit: true + +// @filename: /types.ts +export interface A { + a: number; +} +export interface B { + a: number; +} + +// @filename: /foo.js +/** + * @import + * * as types + * from "./types" + */ + +/** + * @param { types.A } a + * @param { types.B } b + */ +function f(a, b) {} diff --git a/crates/swc_ecma_parser/tests/tsc/inferringClassMembersFromAssignments.json b/crates/swc_ecma_parser/tests/tsc/inferringClassMembersFromAssignments.json index f150ef3e33c7..9c9e3f7d632b 100644 --- a/crates/swc_ecma_parser/tests/tsc/inferringClassMembersFromAssignments.json +++ b/crates/swc_ecma_parser/tests/tsc/inferringClassMembersFromAssignments.json @@ -1,8 +1,8 @@ { "type": "Script", "span": { - "start": 127, - "end": 3346, + "start": 131, + "end": 3350, "ctxt": 0 }, "body": [ @@ -11,8 +11,8 @@ "identifier": { "type": "Identifier", "span": { - "start": 133, - "end": 134, + "start": 137, + "end": 138, "ctxt": 0 }, "value": "C", @@ -20,8 +20,8 @@ }, "declare": false, "span": { - "start": 127, - "end": 2382, + "start": 131, + "end": 2386, "ctxt": 0 }, "decorators": [], @@ -29,15 +29,15 @@ { "type": "Constructor", "span": { - "start": 141, - "end": 333, + "start": 145, + "end": 337, "ctxt": 0 }, "key": { "type": "Identifier", "span": { - "start": 141, - "end": 152, + "start": 145, + "end": 156, "ctxt": 0 }, "value": "constructor", @@ -47,37 +47,37 @@ "body": { "type": "BlockStatement", "span": { - "start": 155, - "end": 333, + "start": 159, + "end": 337, "ctxt": 0 }, "stmts": [ { "type": "IfStatement", "span": { - "start": 165, - "end": 298, + "start": 169, + "end": 302, "ctxt": 0 }, "test": { "type": "CallExpression", "span": { - "start": 169, - "end": 182, + "start": 173, + "end": 186, "ctxt": 0 }, "callee": { "type": "MemberExpression", "span": { - "start": 169, - "end": 180, + "start": 173, + "end": 184, "ctxt": 0 }, "object": { "type": "Identifier", "span": { - "start": 169, - "end": 173, + "start": 173, + "end": 177, "ctxt": 0 }, "value": "Math", @@ -86,8 +86,8 @@ "property": { "type": "Identifier", "span": { - "start": 174, - "end": 180, + "start": 178, + "end": 184, "ctxt": 0 }, "value": "random", @@ -100,46 +100,46 @@ "consequent": { "type": "BlockStatement", "span": { - "start": 184, - "end": 231, + "start": 188, + "end": 235, "ctxt": 0 }, "stmts": [ { "type": "ExpressionStatement", "span": { - "start": 198, - "end": 221, + "start": 202, + "end": 225, "ctxt": 0 }, "expression": { "type": "AssignmentExpression", "span": { - "start": 198, - "end": 220, + "start": 202, + "end": 224, "ctxt": 0 }, "operator": "=", "left": { "type": "MemberExpression", "span": { - "start": 198, - "end": 216, + "start": 202, + "end": 220, "ctxt": 0 }, "object": { "type": "ThisExpression", "span": { - "start": 198, - "end": 202, + "start": 202, + "end": 206, "ctxt": 0 } }, "property": { "type": "Identifier", "span": { - "start": 203, - "end": 216, + "start": 207, + "end": 220, "ctxt": 0 }, "value": "inConstructor", @@ -149,8 +149,8 @@ "right": { "type": "NumericLiteral", "span": { - "start": 219, - "end": 220, + "start": 223, + "end": 224, "ctxt": 0 }, "value": 0.0, @@ -163,46 +163,46 @@ "alternate": { "type": "BlockStatement", "span": { - "start": 245, - "end": 298, + "start": 249, + "end": 302, "ctxt": 0 }, "stmts": [ { "type": "ExpressionStatement", "span": { - "start": 259, - "end": 288, + "start": 263, + "end": 292, "ctxt": 0 }, "expression": { "type": "AssignmentExpression", "span": { - "start": 259, - "end": 288, + "start": 263, + "end": 292, "ctxt": 0 }, "operator": "=", "left": { "type": "MemberExpression", "span": { - "start": 259, - "end": 277, + "start": 263, + "end": 281, "ctxt": 0 }, "object": { "type": "ThisExpression", "span": { - "start": 259, - "end": 263, + "start": 263, + "end": 267, "ctxt": 0 } }, "property": { "type": "Identifier", "span": { - "start": 264, - "end": 277, + "start": 268, + "end": 281, "ctxt": 0 }, "value": "inConstructor", @@ -212,8 +212,8 @@ "right": { "type": "StringLiteral", "span": { - "start": 280, - "end": 288, + "start": 284, + "end": 292, "ctxt": 0 }, "value": "string", @@ -227,38 +227,38 @@ { "type": "ExpressionStatement", "span": { - "start": 307, - "end": 327, + "start": 311, + "end": 331, "ctxt": 0 }, "expression": { "type": "AssignmentExpression", "span": { - "start": 307, - "end": 326, + "start": 311, + "end": 330, "ctxt": 0 }, "operator": "=", "left": { "type": "MemberExpression", "span": { - "start": 307, - "end": 322, + "start": 311, + "end": 326, "ctxt": 0 }, "object": { "type": "ThisExpression", "span": { - "start": 307, - "end": 311, + "start": 311, + "end": 315, "ctxt": 0 } }, "property": { "type": "Identifier", "span": { - "start": 312, - "end": 322, + "start": 316, + "end": 326, "ctxt": 0 }, "value": "inMultiple", @@ -268,8 +268,8 @@ "right": { "type": "NumericLiteral", "span": { - "start": 325, - "end": 326, + "start": 329, + "end": 330, "ctxt": 0 }, "value": 0.0, @@ -285,15 +285,15 @@ { "type": "ClassMethod", "span": { - "start": 338, - "end": 877, + "start": 342, + "end": 881, "ctxt": 0 }, "key": { "type": "Identifier", "span": { - "start": 338, - "end": 344, + "start": 342, + "end": 348, "ctxt": 0 }, "value": "method", @@ -303,44 +303,44 @@ "params": [], "decorators": [], "span": { - "start": 338, - "end": 877, + "start": 342, + "end": 881, "ctxt": 0 }, "body": { "type": "BlockStatement", "span": { - "start": 347, - "end": 877, + "start": 351, + "end": 881, "ctxt": 0 }, "stmts": [ { "type": "IfStatement", "span": { - "start": 357, - "end": 569, + "start": 361, + "end": 573, "ctxt": 0 }, "test": { "type": "CallExpression", "span": { - "start": 361, - "end": 374, + "start": 365, + "end": 378, "ctxt": 0 }, "callee": { "type": "MemberExpression", "span": { - "start": 361, - "end": 372, + "start": 365, + "end": 376, "ctxt": 0 }, "object": { "type": "Identifier", "span": { - "start": 361, - "end": 365, + "start": 365, + "end": 369, "ctxt": 0 }, "value": "Math", @@ -349,8 +349,8 @@ "property": { "type": "Identifier", "span": { - "start": 366, - "end": 372, + "start": 370, + "end": 376, "ctxt": 0 }, "value": "random", @@ -363,46 +363,46 @@ "consequent": { "type": "BlockStatement", "span": { - "start": 376, - "end": 460, + "start": 380, + "end": 464, "ctxt": 0 }, "stmts": [ { "type": "ExpressionStatement", "span": { - "start": 390, - "end": 408, + "start": 394, + "end": 412, "ctxt": 0 }, "expression": { "type": "AssignmentExpression", "span": { - "start": 390, - "end": 407, + "start": 394, + "end": 411, "ctxt": 0 }, "operator": "=", "left": { "type": "MemberExpression", "span": { - "start": 390, - "end": 403, + "start": 394, + "end": 407, "ctxt": 0 }, "object": { "type": "ThisExpression", "span": { - "start": 390, - "end": 394, + "start": 394, + "end": 398, "ctxt": 0 } }, "property": { "type": "Identifier", "span": { - "start": 395, - "end": 403, + "start": 399, + "end": 407, "ctxt": 0 }, "value": "inMethod", @@ -412,8 +412,8 @@ "right": { "type": "NumericLiteral", "span": { - "start": 406, - "end": 407, + "start": 410, + "end": 411, "ctxt": 0 }, "value": 0.0, @@ -424,38 +424,38 @@ { "type": "ExpressionStatement", "span": { - "start": 421, - "end": 450, + "start": 425, + "end": 454, "ctxt": 0 }, "expression": { "type": "AssignmentExpression", "span": { - "start": 421, - "end": 449, + "start": 425, + "end": 453, "ctxt": 0 }, "operator": "=", "left": { "type": "MemberExpression", "span": { - "start": 421, - "end": 442, + "start": 425, + "end": 446, "ctxt": 0 }, "object": { "type": "ThisExpression", "span": { - "start": 421, - "end": 425, + "start": 425, + "end": 429, "ctxt": 0 } }, "property": { "type": "Identifier", "span": { - "start": 426, - "end": 442, + "start": 430, + "end": 446, "ctxt": 0 }, "value": "inMethodNullable", @@ -465,8 +465,8 @@ "right": { "type": "NullLiteral", "span": { - "start": 445, - "end": 449, + "start": 449, + "end": 453, "ctxt": 0 } } @@ -477,46 +477,46 @@ "alternate": { "type": "BlockStatement", "span": { - "start": 474, - "end": 569, + "start": 478, + "end": 573, "ctxt": 0 }, "stmts": [ { "type": "ExpressionStatement", "span": { - "start": 488, - "end": 512, + "start": 492, + "end": 516, "ctxt": 0 }, "expression": { "type": "AssignmentExpression", "span": { - "start": 488, - "end": 512, + "start": 492, + "end": 516, "ctxt": 0 }, "operator": "=", "left": { "type": "MemberExpression", "span": { - "start": 488, - "end": 501, + "start": 492, + "end": 505, "ctxt": 0 }, "object": { "type": "ThisExpression", "span": { - "start": 488, - "end": 492, + "start": 492, + "end": 496, "ctxt": 0 } }, "property": { "type": "Identifier", "span": { - "start": 493, - "end": 501, + "start": 497, + "end": 505, "ctxt": 0 }, "value": "inMethod", @@ -526,8 +526,8 @@ "right": { "type": "StringLiteral", "span": { - "start": 504, - "end": 512, + "start": 508, + "end": 516, "ctxt": 0 }, "value": "string", @@ -538,38 +538,38 @@ { "type": "ExpressionStatement", "span": { - "start": 525, - "end": 559, + "start": 529, + "end": 563, "ctxt": 0 }, "expression": { "type": "AssignmentExpression", "span": { - "start": 525, - "end": 558, + "start": 529, + "end": 562, "ctxt": 0 }, "operator": "=", "left": { "type": "MemberExpression", "span": { - "start": 525, - "end": 546, + "start": 529, + "end": 550, "ctxt": 0 }, "object": { "type": "ThisExpression", "span": { - "start": 525, - "end": 529, + "start": 529, + "end": 533, "ctxt": 0 } }, "property": { "type": "Identifier", "span": { - "start": 530, - "end": 546, + "start": 534, + "end": 550, "ctxt": 0 }, "value": "inMethodNullable", @@ -579,8 +579,8 @@ "right": { "type": "Identifier", "span": { - "start": 549, - "end": 558, + "start": 553, + "end": 562, "ctxt": 0 }, "value": "undefined", @@ -594,38 +594,38 @@ { "type": "ExpressionStatement", "span": { - "start": 578, - "end": 605, + "start": 582, + "end": 609, "ctxt": 0 }, "expression": { "type": "AssignmentExpression", "span": { - "start": 578, - "end": 604, + "start": 582, + "end": 608, "ctxt": 0 }, "operator": "=", "left": { "type": "MemberExpression", "span": { - "start": 578, - "end": 593, + "start": 582, + "end": 597, "ctxt": 0 }, "object": { "type": "ThisExpression", "span": { - "start": 578, - "end": 582, + "start": 582, + "end": 586, "ctxt": 0 } }, "property": { "type": "Identifier", "span": { - "start": 583, - "end": 593, + "start": 587, + "end": 597, "ctxt": 0 }, "value": "inMultiple", @@ -635,8 +635,8 @@ "right": { "type": "StringLiteral", "span": { - "start": 596, - "end": 604, + "start": 600, + "end": 608, "ctxt": 0 }, "value": "string", @@ -647,38 +647,38 @@ { "type": "ExpressionStatement", "span": { - "start": 614, - "end": 648, + "start": 618, + "end": 652, "ctxt": 0 }, "expression": { "type": "AssignmentExpression", "span": { - "start": 614, - "end": 647, + "start": 618, + "end": 651, "ctxt": 0 }, "operator": "=", "left": { "type": "MemberExpression", "span": { - "start": 614, - "end": 636, + "start": 618, + "end": 640, "ctxt": 0 }, "object": { "type": "ThisExpression", "span": { - "start": 614, - "end": 618, + "start": 618, + "end": 622, "ctxt": 0 } }, "property": { "type": "Identifier", "span": { - "start": 619, - "end": 636, + "start": 623, + "end": 640, "ctxt": 0 }, "value": "inMultipleMethods", @@ -688,8 +688,8 @@ "right": { "type": "StringLiteral", "span": { - "start": 639, - "end": 647, + "start": 643, + "end": 651, "ctxt": 0 }, "value": "string", @@ -700,8 +700,8 @@ { "type": "VariableDeclaration", "span": { - "start": 658, - "end": 871, + "start": 662, + "end": 875, "ctxt": 0 }, "kind": "var", @@ -710,15 +710,15 @@ { "type": "VariableDeclarator", "span": { - "start": 662, - "end": 870, + "start": 666, + "end": 874, "ctxt": 0 }, "id": { "type": "Identifier", "span": { - "start": 662, - "end": 668, + "start": 666, + "end": 672, "ctxt": 0 }, "value": "action", @@ -728,45 +728,45 @@ "init": { "type": "ArrowFunctionExpression", "span": { - "start": 671, - "end": 870, + "start": 675, + "end": 874, "ctxt": 0 }, "params": [], "body": { "type": "BlockStatement", "span": { - "start": 677, - "end": 870, + "start": 681, + "end": 874, "ctxt": 0 }, "stmts": [ { "type": "IfStatement", "span": { - "start": 691, - "end": 860, + "start": 695, + "end": 864, "ctxt": 0 }, "test": { "type": "CallExpression", "span": { - "start": 695, - "end": 708, + "start": 699, + "end": 712, "ctxt": 0 }, "callee": { "type": "MemberExpression", "span": { - "start": 695, - "end": 706, + "start": 699, + "end": 710, "ctxt": 0 }, "object": { "type": "Identifier", "span": { - "start": 695, - "end": 699, + "start": 699, + "end": 703, "ctxt": 0 }, "value": "Math", @@ -775,8 +775,8 @@ "property": { "type": "Identifier", "span": { - "start": 700, - "end": 706, + "start": 704, + "end": 710, "ctxt": 0 }, "value": "random", @@ -789,46 +789,46 @@ "consequent": { "type": "BlockStatement", "span": { - "start": 710, - "end": 773, + "start": 714, + "end": 777, "ctxt": 0 }, "stmts": [ { "type": "ExpressionStatement", "span": { - "start": 728, - "end": 759, + "start": 732, + "end": 763, "ctxt": 0 }, "expression": { "type": "AssignmentExpression", "span": { - "start": 728, - "end": 758, + "start": 732, + "end": 762, "ctxt": 0 }, "operator": "=", "left": { "type": "MemberExpression", "span": { - "start": 728, - "end": 754, + "start": 732, + "end": 758, "ctxt": 0 }, "object": { "type": "ThisExpression", "span": { - "start": 728, - "end": 732, + "start": 732, + "end": 736, "ctxt": 0 } }, "property": { "type": "Identifier", "span": { - "start": 733, - "end": 754, + "start": 737, + "end": 758, "ctxt": 0 }, "value": "inNestedArrowFunction", @@ -838,8 +838,8 @@ "right": { "type": "NumericLiteral", "span": { - "start": 757, - "end": 758, + "start": 761, + "end": 762, "ctxt": 0 }, "value": 0.0, @@ -852,46 +852,46 @@ "alternate": { "type": "BlockStatement", "span": { - "start": 791, - "end": 860, + "start": 795, + "end": 864, "ctxt": 0 }, "stmts": [ { "type": "ExpressionStatement", "span": { - "start": 809, - "end": 846, + "start": 813, + "end": 850, "ctxt": 0 }, "expression": { "type": "AssignmentExpression", "span": { - "start": 809, - "end": 846, + "start": 813, + "end": 850, "ctxt": 0 }, "operator": "=", "left": { "type": "MemberExpression", "span": { - "start": 809, - "end": 835, + "start": 813, + "end": 839, "ctxt": 0 }, "object": { "type": "ThisExpression", "span": { - "start": 809, - "end": 813, + "start": 813, + "end": 817, "ctxt": 0 } }, "property": { "type": "Identifier", "span": { - "start": 814, - "end": 835, + "start": 818, + "end": 839, "ctxt": 0 }, "value": "inNestedArrowFunction", @@ -901,8 +901,8 @@ "right": { "type": "StringLiteral", "span": { - "start": 838, - "end": 846, + "start": 842, + "end": 850, "ctxt": 0 }, "value": "string", @@ -941,15 +941,15 @@ { "type": "ClassMethod", "span": { - "start": 882, - "end": 1100, + "start": 886, + "end": 1104, "ctxt": 0 }, "key": { "type": "Identifier", "span": { - "start": 882, - "end": 885, + "start": 886, + "end": 889, "ctxt": 0 }, "value": "get", @@ -959,44 +959,44 @@ "params": [], "decorators": [], "span": { - "start": 882, - "end": 1100, + "start": 886, + "end": 1104, "ctxt": 0 }, "body": { "type": "BlockStatement", "span": { - "start": 888, - "end": 1100, + "start": 892, + "end": 1104, "ctxt": 0 }, "stmts": [ { "type": "IfStatement", "span": { - "start": 898, - "end": 1021, + "start": 902, + "end": 1025, "ctxt": 0 }, "test": { "type": "CallExpression", "span": { - "start": 902, - "end": 915, + "start": 906, + "end": 919, "ctxt": 0 }, "callee": { "type": "MemberExpression", "span": { - "start": 902, - "end": 913, + "start": 906, + "end": 917, "ctxt": 0 }, "object": { "type": "Identifier", "span": { - "start": 902, - "end": 906, + "start": 906, + "end": 910, "ctxt": 0 }, "value": "Math", @@ -1005,8 +1005,8 @@ "property": { "type": "Identifier", "span": { - "start": 907, - "end": 913, + "start": 911, + "end": 917, "ctxt": 0 }, "value": "random", @@ -1019,46 +1019,46 @@ "consequent": { "type": "BlockStatement", "span": { - "start": 917, - "end": 959, + "start": 921, + "end": 963, "ctxt": 0 }, "stmts": [ { "type": "ExpressionStatement", "span": { - "start": 931, - "end": 949, + "start": 935, + "end": 953, "ctxt": 0 }, "expression": { "type": "AssignmentExpression", "span": { - "start": 931, - "end": 948, + "start": 935, + "end": 952, "ctxt": 0 }, "operator": "=", "left": { "type": "MemberExpression", "span": { - "start": 931, - "end": 944, + "start": 935, + "end": 948, "ctxt": 0 }, "object": { "type": "ThisExpression", "span": { - "start": 931, - "end": 935, + "start": 935, + "end": 939, "ctxt": 0 } }, "property": { "type": "Identifier", "span": { - "start": 936, - "end": 944, + "start": 940, + "end": 948, "ctxt": 0 }, "value": "inGetter", @@ -1068,8 +1068,8 @@ "right": { "type": "NumericLiteral", "span": { - "start": 947, - "end": 948, + "start": 951, + "end": 952, "ctxt": 0 }, "value": 0.0, @@ -1082,46 +1082,46 @@ "alternate": { "type": "BlockStatement", "span": { - "start": 973, - "end": 1021, + "start": 977, + "end": 1025, "ctxt": 0 }, "stmts": [ { "type": "ExpressionStatement", "span": { - "start": 987, - "end": 1011, + "start": 991, + "end": 1015, "ctxt": 0 }, "expression": { "type": "AssignmentExpression", "span": { - "start": 987, - "end": 1011, + "start": 991, + "end": 1015, "ctxt": 0 }, "operator": "=", "left": { "type": "MemberExpression", "span": { - "start": 987, - "end": 1000, + "start": 991, + "end": 1004, "ctxt": 0 }, "object": { "type": "ThisExpression", "span": { - "start": 987, - "end": 991, + "start": 991, + "end": 995, "ctxt": 0 } }, "property": { "type": "Identifier", "span": { - "start": 992, - "end": 1000, + "start": 996, + "end": 1004, "ctxt": 0 }, "value": "inGetter", @@ -1131,8 +1131,8 @@ "right": { "type": "StringLiteral", "span": { - "start": 1003, - "end": 1011, + "start": 1007, + "end": 1015, "ctxt": 0 }, "value": "string", @@ -1146,38 +1146,38 @@ { "type": "ExpressionStatement", "span": { - "start": 1030, - "end": 1054, + "start": 1034, + "end": 1058, "ctxt": 0 }, "expression": { "type": "AssignmentExpression", "span": { - "start": 1030, - "end": 1053, + "start": 1034, + "end": 1057, "ctxt": 0 }, "operator": "=", "left": { "type": "MemberExpression", "span": { - "start": 1030, - "end": 1045, + "start": 1034, + "end": 1049, "ctxt": 0 }, "object": { "type": "ThisExpression", "span": { - "start": 1030, - "end": 1034, + "start": 1034, + "end": 1038, "ctxt": 0 } }, "property": { "type": "Identifier", "span": { - "start": 1035, - "end": 1045, + "start": 1039, + "end": 1049, "ctxt": 0 }, "value": "inMultiple", @@ -1187,8 +1187,8 @@ "right": { "type": "BooleanLiteral", "span": { - "start": 1048, - "end": 1053, + "start": 1052, + "end": 1057, "ctxt": 0 }, "value": false @@ -1198,38 +1198,38 @@ { "type": "ExpressionStatement", "span": { - "start": 1063, - "end": 1094, + "start": 1067, + "end": 1098, "ctxt": 0 }, "expression": { "type": "AssignmentExpression", "span": { - "start": 1063, - "end": 1093, + "start": 1067, + "end": 1097, "ctxt": 0 }, "operator": "=", "left": { "type": "MemberExpression", "span": { - "start": 1063, - "end": 1085, + "start": 1067, + "end": 1089, "ctxt": 0 }, "object": { "type": "ThisExpression", "span": { - "start": 1063, - "end": 1067, + "start": 1067, + "end": 1071, "ctxt": 0 } }, "property": { "type": "Identifier", "span": { - "start": 1068, - "end": 1085, + "start": 1072, + "end": 1089, "ctxt": 0 }, "value": "inMultipleMethods", @@ -1239,8 +1239,8 @@ "right": { "type": "BooleanLiteral", "span": { - "start": 1088, - "end": 1093, + "start": 1092, + "end": 1097, "ctxt": 0 }, "value": false @@ -1264,15 +1264,15 @@ { "type": "ClassMethod", "span": { - "start": 1105, - "end": 1250, + "start": 1109, + "end": 1254, "ctxt": 0 }, "key": { "type": "Identifier", "span": { - "start": 1105, - "end": 1108, + "start": 1109, + "end": 1112, "ctxt": 0 }, "value": "set", @@ -1282,44 +1282,44 @@ "params": [], "decorators": [], "span": { - "start": 1105, - "end": 1250, + "start": 1109, + "end": 1254, "ctxt": 0 }, "body": { "type": "BlockStatement", "span": { - "start": 1111, - "end": 1250, + "start": 1115, + "end": 1254, "ctxt": 0 }, "stmts": [ { "type": "IfStatement", "span": { - "start": 1121, - "end": 1244, + "start": 1125, + "end": 1248, "ctxt": 0 }, "test": { "type": "CallExpression", "span": { - "start": 1125, - "end": 1138, + "start": 1129, + "end": 1142, "ctxt": 0 }, "callee": { "type": "MemberExpression", "span": { - "start": 1125, - "end": 1136, + "start": 1129, + "end": 1140, "ctxt": 0 }, "object": { "type": "Identifier", "span": { - "start": 1125, - "end": 1129, + "start": 1129, + "end": 1133, "ctxt": 0 }, "value": "Math", @@ -1328,8 +1328,8 @@ "property": { "type": "Identifier", "span": { - "start": 1130, - "end": 1136, + "start": 1134, + "end": 1140, "ctxt": 0 }, "value": "random", @@ -1342,46 +1342,46 @@ "consequent": { "type": "BlockStatement", "span": { - "start": 1140, - "end": 1182, + "start": 1144, + "end": 1186, "ctxt": 0 }, "stmts": [ { "type": "ExpressionStatement", "span": { - "start": 1154, - "end": 1172, + "start": 1158, + "end": 1176, "ctxt": 0 }, "expression": { "type": "AssignmentExpression", "span": { - "start": 1154, - "end": 1171, + "start": 1158, + "end": 1175, "ctxt": 0 }, "operator": "=", "left": { "type": "MemberExpression", "span": { - "start": 1154, - "end": 1167, + "start": 1158, + "end": 1171, "ctxt": 0 }, "object": { "type": "ThisExpression", "span": { - "start": 1154, - "end": 1158, + "start": 1158, + "end": 1162, "ctxt": 0 } }, "property": { "type": "Identifier", "span": { - "start": 1159, - "end": 1167, + "start": 1163, + "end": 1171, "ctxt": 0 }, "value": "inSetter", @@ -1391,8 +1391,8 @@ "right": { "type": "NumericLiteral", "span": { - "start": 1170, - "end": 1171, + "start": 1174, + "end": 1175, "ctxt": 0 }, "value": 0.0, @@ -1405,46 +1405,46 @@ "alternate": { "type": "BlockStatement", "span": { - "start": 1196, - "end": 1244, + "start": 1200, + "end": 1248, "ctxt": 0 }, "stmts": [ { "type": "ExpressionStatement", "span": { - "start": 1210, - "end": 1234, + "start": 1214, + "end": 1238, "ctxt": 0 }, "expression": { "type": "AssignmentExpression", "span": { - "start": 1210, - "end": 1234, + "start": 1214, + "end": 1238, "ctxt": 0 }, "operator": "=", "left": { "type": "MemberExpression", "span": { - "start": 1210, - "end": 1223, + "start": 1214, + "end": 1227, "ctxt": 0 }, "object": { "type": "ThisExpression", "span": { - "start": 1210, - "end": 1214, + "start": 1214, + "end": 1218, "ctxt": 0 } }, "property": { "type": "Identifier", "span": { - "start": 1215, - "end": 1223, + "start": 1219, + "end": 1227, "ctxt": 0 }, "value": "inSetter", @@ -1454,8 +1454,8 @@ "right": { "type": "StringLiteral", "span": { - "start": 1226, - "end": 1234, + "start": 1230, + "end": 1238, "ctxt": 0 }, "value": "string", @@ -1483,15 +1483,15 @@ { "type": "ClassProperty", "span": { - "start": 1255, - "end": 1433, + "start": 1259, + "end": 1437, "ctxt": 0 }, "key": { "type": "Identifier", "span": { - "start": 1255, - "end": 1259, + "start": 1259, + "end": 1263, "ctxt": 0 }, "value": "prop", @@ -1500,45 +1500,45 @@ "value": { "type": "ArrowFunctionExpression", "span": { - "start": 1262, - "end": 1433, + "start": 1266, + "end": 1437, "ctxt": 0 }, "params": [], "body": { "type": "BlockStatement", "span": { - "start": 1268, - "end": 1433, + "start": 1272, + "end": 1437, "ctxt": 0 }, "stmts": [ { "type": "IfStatement", "span": { - "start": 1278, - "end": 1427, + "start": 1282, + "end": 1431, "ctxt": 0 }, "test": { "type": "CallExpression", "span": { - "start": 1282, - "end": 1295, + "start": 1286, + "end": 1299, "ctxt": 0 }, "callee": { "type": "MemberExpression", "span": { - "start": 1282, - "end": 1293, + "start": 1286, + "end": 1297, "ctxt": 0 }, "object": { "type": "Identifier", "span": { - "start": 1282, - "end": 1286, + "start": 1286, + "end": 1290, "ctxt": 0 }, "value": "Math", @@ -1547,8 +1547,8 @@ "property": { "type": "Identifier", "span": { - "start": 1287, - "end": 1293, + "start": 1291, + "end": 1297, "ctxt": 0 }, "value": "random", @@ -1561,46 +1561,46 @@ "consequent": { "type": "BlockStatement", "span": { - "start": 1297, - "end": 1352, + "start": 1301, + "end": 1356, "ctxt": 0 }, "stmts": [ { "type": "ExpressionStatement", "span": { - "start": 1311, - "end": 1342, + "start": 1315, + "end": 1346, "ctxt": 0 }, "expression": { "type": "AssignmentExpression", "span": { - "start": 1311, - "end": 1341, + "start": 1315, + "end": 1345, "ctxt": 0 }, "operator": "=", "left": { "type": "MemberExpression", "span": { - "start": 1311, - "end": 1337, + "start": 1315, + "end": 1341, "ctxt": 0 }, "object": { "type": "ThisExpression", "span": { - "start": 1311, - "end": 1315, + "start": 1315, + "end": 1319, "ctxt": 0 } }, "property": { "type": "Identifier", "span": { - "start": 1316, - "end": 1337, + "start": 1320, + "end": 1341, "ctxt": 0 }, "value": "inPropertyDeclaration", @@ -1610,8 +1610,8 @@ "right": { "type": "NumericLiteral", "span": { - "start": 1340, - "end": 1341, + "start": 1344, + "end": 1345, "ctxt": 0 }, "value": 0.0, @@ -1624,46 +1624,46 @@ "alternate": { "type": "BlockStatement", "span": { - "start": 1366, - "end": 1427, + "start": 1370, + "end": 1431, "ctxt": 0 }, "stmts": [ { "type": "ExpressionStatement", "span": { - "start": 1380, - "end": 1417, + "start": 1384, + "end": 1421, "ctxt": 0 }, "expression": { "type": "AssignmentExpression", "span": { - "start": 1380, - "end": 1417, + "start": 1384, + "end": 1421, "ctxt": 0 }, "operator": "=", "left": { "type": "MemberExpression", "span": { - "start": 1380, - "end": 1406, + "start": 1384, + "end": 1410, "ctxt": 0 }, "object": { "type": "ThisExpression", "span": { - "start": 1380, - "end": 1384, + "start": 1384, + "end": 1388, "ctxt": 0 } }, "property": { "type": "Identifier", "span": { - "start": 1385, - "end": 1406, + "start": 1389, + "end": 1410, "ctxt": 0 }, "value": "inPropertyDeclaration", @@ -1673,8 +1673,8 @@ "right": { "type": "StringLiteral", "span": { - "start": 1409, - "end": 1417, + "start": 1413, + "end": 1421, "ctxt": 0 }, "value": "string", @@ -1706,15 +1706,15 @@ { "type": "ClassMethod", "span": { - "start": 1438, - "end": 1840, + "start": 1442, + "end": 1844, "ctxt": 0 }, "key": { "type": "Identifier", "span": { - "start": 1445, - "end": 1451, + "start": 1449, + "end": 1455, "ctxt": 0 }, "value": "method", @@ -1724,44 +1724,44 @@ "params": [], "decorators": [], "span": { - "start": 1438, - "end": 1840, + "start": 1442, + "end": 1844, "ctxt": 0 }, "body": { "type": "BlockStatement", "span": { - "start": 1454, - "end": 1840, + "start": 1458, + "end": 1844, "ctxt": 0 }, "stmts": [ { "type": "IfStatement", "span": { - "start": 1464, - "end": 1599, + "start": 1468, + "end": 1603, "ctxt": 0 }, "test": { "type": "CallExpression", "span": { - "start": 1468, - "end": 1481, + "start": 1472, + "end": 1485, "ctxt": 0 }, "callee": { "type": "MemberExpression", "span": { - "start": 1468, - "end": 1479, + "start": 1472, + "end": 1483, "ctxt": 0 }, "object": { "type": "Identifier", "span": { - "start": 1468, - "end": 1472, + "start": 1472, + "end": 1476, "ctxt": 0 }, "value": "Math", @@ -1770,8 +1770,8 @@ "property": { "type": "Identifier", "span": { - "start": 1473, - "end": 1479, + "start": 1477, + "end": 1483, "ctxt": 0 }, "value": "random", @@ -1784,46 +1784,46 @@ "consequent": { "type": "BlockStatement", "span": { - "start": 1483, - "end": 1531, + "start": 1487, + "end": 1535, "ctxt": 0 }, "stmts": [ { "type": "ExpressionStatement", "span": { - "start": 1497, - "end": 1521, + "start": 1501, + "end": 1525, "ctxt": 0 }, "expression": { "type": "AssignmentExpression", "span": { - "start": 1497, - "end": 1520, + "start": 1501, + "end": 1524, "ctxt": 0 }, "operator": "=", "left": { "type": "MemberExpression", "span": { - "start": 1497, - "end": 1516, + "start": 1501, + "end": 1520, "ctxt": 0 }, "object": { "type": "ThisExpression", "span": { - "start": 1497, - "end": 1501, + "start": 1501, + "end": 1505, "ctxt": 0 } }, "property": { "type": "Identifier", "span": { - "start": 1502, - "end": 1516, + "start": 1506, + "end": 1520, "ctxt": 0 }, "value": "inStaticMethod", @@ -1833,8 +1833,8 @@ "right": { "type": "NumericLiteral", "span": { - "start": 1519, - "end": 1520, + "start": 1523, + "end": 1524, "ctxt": 0 }, "value": 0.0, @@ -1847,46 +1847,46 @@ "alternate": { "type": "BlockStatement", "span": { - "start": 1545, - "end": 1599, + "start": 1549, + "end": 1603, "ctxt": 0 }, "stmts": [ { "type": "ExpressionStatement", "span": { - "start": 1559, - "end": 1589, + "start": 1563, + "end": 1593, "ctxt": 0 }, "expression": { "type": "AssignmentExpression", "span": { - "start": 1559, - "end": 1589, + "start": 1563, + "end": 1593, "ctxt": 0 }, "operator": "=", "left": { "type": "MemberExpression", "span": { - "start": 1559, - "end": 1578, + "start": 1563, + "end": 1582, "ctxt": 0 }, "object": { "type": "ThisExpression", "span": { - "start": 1559, - "end": 1563, + "start": 1563, + "end": 1567, "ctxt": 0 } }, "property": { "type": "Identifier", "span": { - "start": 1564, - "end": 1578, + "start": 1568, + "end": 1582, "ctxt": 0 }, "value": "inStaticMethod", @@ -1896,8 +1896,8 @@ "right": { "type": "StringLiteral", "span": { - "start": 1581, - "end": 1589, + "start": 1585, + "end": 1593, "ctxt": 0 }, "value": "string", @@ -1911,8 +1911,8 @@ { "type": "VariableDeclaration", "span": { - "start": 1609, - "end": 1834, + "start": 1613, + "end": 1838, "ctxt": 0 }, "kind": "var", @@ -1921,15 +1921,15 @@ { "type": "VariableDeclarator", "span": { - "start": 1613, - "end": 1833, + "start": 1617, + "end": 1837, "ctxt": 0 }, "id": { "type": "Identifier", "span": { - "start": 1613, - "end": 1619, + "start": 1617, + "end": 1623, "ctxt": 0 }, "value": "action", @@ -1939,45 +1939,45 @@ "init": { "type": "ArrowFunctionExpression", "span": { - "start": 1622, - "end": 1833, + "start": 1626, + "end": 1837, "ctxt": 0 }, "params": [], "body": { "type": "BlockStatement", "span": { - "start": 1628, - "end": 1833, + "start": 1632, + "end": 1837, "ctxt": 0 }, "stmts": [ { "type": "IfStatement", "span": { - "start": 1642, - "end": 1823, + "start": 1646, + "end": 1827, "ctxt": 0 }, "test": { "type": "CallExpression", "span": { - "start": 1646, - "end": 1659, + "start": 1650, + "end": 1663, "ctxt": 0 }, "callee": { "type": "MemberExpression", "span": { - "start": 1646, - "end": 1657, + "start": 1650, + "end": 1661, "ctxt": 0 }, "object": { "type": "Identifier", "span": { - "start": 1646, - "end": 1650, + "start": 1650, + "end": 1654, "ctxt": 0 }, "value": "Math", @@ -1986,8 +1986,8 @@ "property": { "type": "Identifier", "span": { - "start": 1651, - "end": 1657, + "start": 1655, + "end": 1661, "ctxt": 0 }, "value": "random", @@ -2000,46 +2000,46 @@ "consequent": { "type": "BlockStatement", "span": { - "start": 1661, - "end": 1730, + "start": 1665, + "end": 1734, "ctxt": 0 }, "stmts": [ { "type": "ExpressionStatement", "span": { - "start": 1679, - "end": 1716, + "start": 1683, + "end": 1720, "ctxt": 0 }, "expression": { "type": "AssignmentExpression", "span": { - "start": 1679, - "end": 1715, + "start": 1683, + "end": 1719, "ctxt": 0 }, "operator": "=", "left": { "type": "MemberExpression", "span": { - "start": 1679, - "end": 1711, + "start": 1683, + "end": 1715, "ctxt": 0 }, "object": { "type": "ThisExpression", "span": { - "start": 1679, - "end": 1683, + "start": 1683, + "end": 1687, "ctxt": 0 } }, "property": { "type": "Identifier", "span": { - "start": 1684, - "end": 1711, + "start": 1688, + "end": 1715, "ctxt": 0 }, "value": "inStaticNestedArrowFunction", @@ -2049,8 +2049,8 @@ "right": { "type": "NumericLiteral", "span": { - "start": 1714, - "end": 1715, + "start": 1718, + "end": 1719, "ctxt": 0 }, "value": 0.0, @@ -2063,46 +2063,46 @@ "alternate": { "type": "BlockStatement", "span": { - "start": 1748, - "end": 1823, + "start": 1752, + "end": 1827, "ctxt": 0 }, "stmts": [ { "type": "ExpressionStatement", "span": { - "start": 1766, - "end": 1809, + "start": 1770, + "end": 1813, "ctxt": 0 }, "expression": { "type": "AssignmentExpression", "span": { - "start": 1766, - "end": 1809, + "start": 1770, + "end": 1813, "ctxt": 0 }, "operator": "=", "left": { "type": "MemberExpression", "span": { - "start": 1766, - "end": 1798, + "start": 1770, + "end": 1802, "ctxt": 0 }, "object": { "type": "ThisExpression", "span": { - "start": 1766, - "end": 1770, + "start": 1770, + "end": 1774, "ctxt": 0 } }, "property": { "type": "Identifier", "span": { - "start": 1771, - "end": 1798, + "start": 1775, + "end": 1802, "ctxt": 0 }, "value": "inStaticNestedArrowFunction", @@ -2112,8 +2112,8 @@ "right": { "type": "StringLiteral", "span": { - "start": 1801, - "end": 1809, + "start": 1805, + "end": 1813, "ctxt": 0 }, "value": "string", @@ -2152,15 +2152,15 @@ { "type": "ClassMethod", "span": { - "start": 1845, - "end": 2009, + "start": 1849, + "end": 2013, "ctxt": 0 }, "key": { "type": "Identifier", "span": { - "start": 1852, - "end": 1855, + "start": 1856, + "end": 1859, "ctxt": 0 }, "value": "get", @@ -2170,44 +2170,44 @@ "params": [], "decorators": [], "span": { - "start": 1845, - "end": 2009, + "start": 1849, + "end": 2013, "ctxt": 0 }, "body": { "type": "BlockStatement", "span": { - "start": 1858, - "end": 2009, + "start": 1862, + "end": 2013, "ctxt": 0 }, "stmts": [ { "type": "IfStatement", "span": { - "start": 1868, - "end": 2003, + "start": 1872, + "end": 2007, "ctxt": 0 }, "test": { "type": "CallExpression", "span": { - "start": 1872, - "end": 1885, + "start": 1876, + "end": 1889, "ctxt": 0 }, "callee": { "type": "MemberExpression", "span": { - "start": 1872, - "end": 1883, + "start": 1876, + "end": 1887, "ctxt": 0 }, "object": { "type": "Identifier", "span": { - "start": 1872, - "end": 1876, + "start": 1876, + "end": 1880, "ctxt": 0 }, "value": "Math", @@ -2216,8 +2216,8 @@ "property": { "type": "Identifier", "span": { - "start": 1877, - "end": 1883, + "start": 1881, + "end": 1887, "ctxt": 0 }, "value": "random", @@ -2230,46 +2230,46 @@ "consequent": { "type": "BlockStatement", "span": { - "start": 1887, - "end": 1935, + "start": 1891, + "end": 1939, "ctxt": 0 }, "stmts": [ { "type": "ExpressionStatement", "span": { - "start": 1901, - "end": 1925, + "start": 1905, + "end": 1929, "ctxt": 0 }, "expression": { "type": "AssignmentExpression", "span": { - "start": 1901, - "end": 1924, + "start": 1905, + "end": 1928, "ctxt": 0 }, "operator": "=", "left": { "type": "MemberExpression", "span": { - "start": 1901, - "end": 1920, + "start": 1905, + "end": 1924, "ctxt": 0 }, "object": { "type": "ThisExpression", "span": { - "start": 1901, - "end": 1905, + "start": 1905, + "end": 1909, "ctxt": 0 } }, "property": { "type": "Identifier", "span": { - "start": 1906, - "end": 1920, + "start": 1910, + "end": 1924, "ctxt": 0 }, "value": "inStaticGetter", @@ -2279,8 +2279,8 @@ "right": { "type": "NumericLiteral", "span": { - "start": 1923, - "end": 1924, + "start": 1927, + "end": 1928, "ctxt": 0 }, "value": 0.0, @@ -2293,46 +2293,46 @@ "alternate": { "type": "BlockStatement", "span": { - "start": 1949, - "end": 2003, + "start": 1953, + "end": 2007, "ctxt": 0 }, "stmts": [ { "type": "ExpressionStatement", "span": { - "start": 1963, - "end": 1993, + "start": 1967, + "end": 1997, "ctxt": 0 }, "expression": { "type": "AssignmentExpression", "span": { - "start": 1963, - "end": 1993, + "start": 1967, + "end": 1997, "ctxt": 0 }, "operator": "=", "left": { "type": "MemberExpression", "span": { - "start": 1963, - "end": 1982, + "start": 1967, + "end": 1986, "ctxt": 0 }, "object": { "type": "ThisExpression", "span": { - "start": 1963, - "end": 1967, + "start": 1967, + "end": 1971, "ctxt": 0 } }, "property": { "type": "Identifier", "span": { - "start": 1968, - "end": 1982, + "start": 1972, + "end": 1986, "ctxt": 0 }, "value": "inStaticGetter", @@ -2342,8 +2342,8 @@ "right": { "type": "StringLiteral", "span": { - "start": 1985, - "end": 1993, + "start": 1989, + "end": 1997, "ctxt": 0 }, "value": "string", @@ -2371,15 +2371,15 @@ { "type": "ClassMethod", "span": { - "start": 2014, - "end": 2178, + "start": 2018, + "end": 2182, "ctxt": 0 }, "key": { "type": "Identifier", "span": { - "start": 2021, - "end": 2024, + "start": 2025, + "end": 2028, "ctxt": 0 }, "value": "set", @@ -2389,44 +2389,44 @@ "params": [], "decorators": [], "span": { - "start": 2014, - "end": 2178, + "start": 2018, + "end": 2182, "ctxt": 0 }, "body": { "type": "BlockStatement", "span": { - "start": 2027, - "end": 2178, + "start": 2031, + "end": 2182, "ctxt": 0 }, "stmts": [ { "type": "IfStatement", "span": { - "start": 2037, - "end": 2172, + "start": 2041, + "end": 2176, "ctxt": 0 }, "test": { "type": "CallExpression", "span": { - "start": 2041, - "end": 2054, + "start": 2045, + "end": 2058, "ctxt": 0 }, "callee": { "type": "MemberExpression", "span": { - "start": 2041, - "end": 2052, + "start": 2045, + "end": 2056, "ctxt": 0 }, "object": { "type": "Identifier", "span": { - "start": 2041, - "end": 2045, + "start": 2045, + "end": 2049, "ctxt": 0 }, "value": "Math", @@ -2435,8 +2435,8 @@ "property": { "type": "Identifier", "span": { - "start": 2046, - "end": 2052, + "start": 2050, + "end": 2056, "ctxt": 0 }, "value": "random", @@ -2449,46 +2449,46 @@ "consequent": { "type": "BlockStatement", "span": { - "start": 2056, - "end": 2104, + "start": 2060, + "end": 2108, "ctxt": 0 }, "stmts": [ { "type": "ExpressionStatement", "span": { - "start": 2070, - "end": 2094, + "start": 2074, + "end": 2098, "ctxt": 0 }, "expression": { "type": "AssignmentExpression", "span": { - "start": 2070, - "end": 2093, + "start": 2074, + "end": 2097, "ctxt": 0 }, "operator": "=", "left": { "type": "MemberExpression", "span": { - "start": 2070, - "end": 2089, + "start": 2074, + "end": 2093, "ctxt": 0 }, "object": { "type": "ThisExpression", "span": { - "start": 2070, - "end": 2074, + "start": 2074, + "end": 2078, "ctxt": 0 } }, "property": { "type": "Identifier", "span": { - "start": 2075, - "end": 2089, + "start": 2079, + "end": 2093, "ctxt": 0 }, "value": "inStaticSetter", @@ -2498,8 +2498,8 @@ "right": { "type": "NumericLiteral", "span": { - "start": 2092, - "end": 2093, + "start": 2096, + "end": 2097, "ctxt": 0 }, "value": 0.0, @@ -2512,46 +2512,46 @@ "alternate": { "type": "BlockStatement", "span": { - "start": 2118, - "end": 2172, + "start": 2122, + "end": 2176, "ctxt": 0 }, "stmts": [ { "type": "ExpressionStatement", "span": { - "start": 2132, - "end": 2162, + "start": 2136, + "end": 2166, "ctxt": 0 }, "expression": { "type": "AssignmentExpression", "span": { - "start": 2132, - "end": 2162, + "start": 2136, + "end": 2166, "ctxt": 0 }, "operator": "=", "left": { "type": "MemberExpression", "span": { - "start": 2132, - "end": 2151, + "start": 2136, + "end": 2155, "ctxt": 0 }, "object": { "type": "ThisExpression", "span": { - "start": 2132, - "end": 2136, + "start": 2136, + "end": 2140, "ctxt": 0 } }, "property": { "type": "Identifier", "span": { - "start": 2137, - "end": 2151, + "start": 2141, + "end": 2155, "ctxt": 0 }, "value": "inStaticSetter", @@ -2561,8 +2561,8 @@ "right": { "type": "StringLiteral", "span": { - "start": 2154, - "end": 2162, + "start": 2158, + "end": 2166, "ctxt": 0 }, "value": "string", @@ -2590,15 +2590,15 @@ { "type": "ClassProperty", "span": { - "start": 2183, - "end": 2380, + "start": 2187, + "end": 2384, "ctxt": 0 }, "key": { "type": "Identifier", "span": { - "start": 2190, - "end": 2194, + "start": 2194, + "end": 2198, "ctxt": 0 }, "value": "prop", @@ -2607,45 +2607,45 @@ "value": { "type": "ArrowFunctionExpression", "span": { - "start": 2197, - "end": 2380, + "start": 2201, + "end": 2384, "ctxt": 0 }, "params": [], "body": { "type": "BlockStatement", "span": { - "start": 2203, - "end": 2380, + "start": 2207, + "end": 2384, "ctxt": 0 }, "stmts": [ { "type": "IfStatement", "span": { - "start": 2213, - "end": 2374, + "start": 2217, + "end": 2378, "ctxt": 0 }, "test": { "type": "CallExpression", "span": { - "start": 2217, - "end": 2230, + "start": 2221, + "end": 2234, "ctxt": 0 }, "callee": { "type": "MemberExpression", "span": { - "start": 2217, - "end": 2228, + "start": 2221, + "end": 2232, "ctxt": 0 }, "object": { "type": "Identifier", "span": { - "start": 2217, - "end": 2221, + "start": 2221, + "end": 2225, "ctxt": 0 }, "value": "Math", @@ -2654,8 +2654,8 @@ "property": { "type": "Identifier", "span": { - "start": 2222, - "end": 2228, + "start": 2226, + "end": 2232, "ctxt": 0 }, "value": "random", @@ -2668,46 +2668,46 @@ "consequent": { "type": "BlockStatement", "span": { - "start": 2232, - "end": 2293, + "start": 2236, + "end": 2297, "ctxt": 0 }, "stmts": [ { "type": "ExpressionStatement", "span": { - "start": 2246, - "end": 2283, + "start": 2250, + "end": 2287, "ctxt": 0 }, "expression": { "type": "AssignmentExpression", "span": { - "start": 2246, - "end": 2282, + "start": 2250, + "end": 2286, "ctxt": 0 }, "operator": "=", "left": { "type": "MemberExpression", "span": { - "start": 2246, - "end": 2278, + "start": 2250, + "end": 2282, "ctxt": 0 }, "object": { "type": "ThisExpression", "span": { - "start": 2246, - "end": 2250, + "start": 2250, + "end": 2254, "ctxt": 0 } }, "property": { "type": "Identifier", "span": { - "start": 2251, - "end": 2278, + "start": 2255, + "end": 2282, "ctxt": 0 }, "value": "inStaticPropertyDeclaration", @@ -2717,8 +2717,8 @@ "right": { "type": "NumericLiteral", "span": { - "start": 2281, - "end": 2282, + "start": 2285, + "end": 2286, "ctxt": 0 }, "value": 0.0, @@ -2731,46 +2731,46 @@ "alternate": { "type": "BlockStatement", "span": { - "start": 2307, - "end": 2374, + "start": 2311, + "end": 2378, "ctxt": 0 }, "stmts": [ { "type": "ExpressionStatement", "span": { - "start": 2321, - "end": 2364, + "start": 2325, + "end": 2368, "ctxt": 0 }, "expression": { "type": "AssignmentExpression", "span": { - "start": 2321, - "end": 2364, + "start": 2325, + "end": 2368, "ctxt": 0 }, "operator": "=", "left": { "type": "MemberExpression", "span": { - "start": 2321, - "end": 2353, + "start": 2325, + "end": 2357, "ctxt": 0 }, "object": { "type": "ThisExpression", "span": { - "start": 2321, - "end": 2325, + "start": 2325, + "end": 2329, "ctxt": 0 } }, "property": { "type": "Identifier", "span": { - "start": 2326, - "end": 2353, + "start": 2330, + "end": 2357, "ctxt": 0 }, "value": "inStaticPropertyDeclaration", @@ -2780,8 +2780,8 @@ "right": { "type": "StringLiteral", "span": { - "start": 2356, - "end": 2364, + "start": 2360, + "end": 2368, "ctxt": 0 }, "value": "string", @@ -2820,8 +2820,8 @@ { "type": "VariableDeclaration", "span": { - "start": 2403, - "end": 2419, + "start": 2407, + "end": 2423, "ctxt": 0 }, "kind": "var", @@ -2830,15 +2830,15 @@ { "type": "VariableDeclarator", "span": { - "start": 2407, - "end": 2418, + "start": 2411, + "end": 2422, "ctxt": 0 }, "id": { "type": "Identifier", "span": { - "start": 2407, - "end": 2408, + "start": 2411, + "end": 2412, "ctxt": 0 }, "value": "c", @@ -2848,15 +2848,15 @@ "init": { "type": "NewExpression", "span": { - "start": 2411, - "end": 2418, + "start": 2415, + "end": 2422, "ctxt": 0 }, "callee": { "type": "Identifier", "span": { - "start": 2415, - "end": 2416, + "start": 2419, + "end": 2420, "ctxt": 0 }, "value": "C", @@ -2872,8 +2872,8 @@ { "type": "VariableDeclaration", "span": { - "start": 2421, - "end": 2457, + "start": 2425, + "end": 2461, "ctxt": 0 }, "kind": "var", @@ -2882,15 +2882,15 @@ { "type": "VariableDeclarator", "span": { - "start": 2425, - "end": 2456, + "start": 2429, + "end": 2460, "ctxt": 0 }, "id": { "type": "Identifier", "span": { - "start": 2425, - "end": 2439, + "start": 2429, + "end": 2443, "ctxt": 0 }, "value": "stringOrNumber", @@ -2898,23 +2898,23 @@ "typeAnnotation": { "type": "TsTypeAnnotation", "span": { - "start": 2439, - "end": 2456, + "start": 2443, + "end": 2460, "ctxt": 0 }, "typeAnnotation": { "type": "TsUnionType", "span": { - "start": 2441, - "end": 2456, + "start": 2445, + "end": 2460, "ctxt": 0 }, "types": [ { "type": "TsKeywordType", "span": { - "start": 2441, - "end": 2447, + "start": 2445, + "end": 2451, "ctxt": 0 }, "kind": "string" @@ -2922,8 +2922,8 @@ { "type": "TsKeywordType", "span": { - "start": 2450, - "end": 2456, + "start": 2454, + "end": 2460, "ctxt": 0 }, "kind": "number" @@ -2940,8 +2940,8 @@ { "type": "VariableDeclaration", "span": { - "start": 2458, - "end": 2495, + "start": 2462, + "end": 2499, "ctxt": 0 }, "kind": "var", @@ -2950,15 +2950,15 @@ { "type": "VariableDeclarator", "span": { - "start": 2462, - "end": 2494, + "start": 2466, + "end": 2498, "ctxt": 0 }, "id": { "type": "Identifier", "span": { - "start": 2462, - "end": 2476, + "start": 2466, + "end": 2480, "ctxt": 0 }, "value": "stringOrNumber", @@ -2968,15 +2968,15 @@ "init": { "type": "MemberExpression", "span": { - "start": 2479, - "end": 2494, + "start": 2483, + "end": 2498, "ctxt": 0 }, "object": { "type": "Identifier", "span": { - "start": 2479, - "end": 2480, + "start": 2483, + "end": 2484, "ctxt": 0 }, "value": "c", @@ -2985,8 +2985,8 @@ "property": { "type": "Identifier", "span": { - "start": 2481, - "end": 2494, + "start": 2485, + "end": 2498, "ctxt": 0 }, "value": "inConstructor", @@ -3000,8 +3000,8 @@ { "type": "VariableDeclaration", "span": { - "start": 2497, - "end": 2556, + "start": 2501, + "end": 2560, "ctxt": 0 }, "kind": "var", @@ -3010,15 +3010,15 @@ { "type": "VariableDeclarator", "span": { - "start": 2501, - "end": 2555, + "start": 2505, + "end": 2559, "ctxt": 0 }, "id": { "type": "Identifier", "span": { - "start": 2501, - "end": 2526, + "start": 2505, + "end": 2530, "ctxt": 0 }, "value": "stringOrNumberOrUndefined", @@ -3026,23 +3026,23 @@ "typeAnnotation": { "type": "TsTypeAnnotation", "span": { - "start": 2526, - "end": 2555, + "start": 2530, + "end": 2559, "ctxt": 0 }, "typeAnnotation": { "type": "TsUnionType", "span": { - "start": 2528, - "end": 2555, + "start": 2532, + "end": 2559, "ctxt": 0 }, "types": [ { "type": "TsKeywordType", "span": { - "start": 2528, - "end": 2534, + "start": 2532, + "end": 2538, "ctxt": 0 }, "kind": "string" @@ -3050,8 +3050,8 @@ { "type": "TsKeywordType", "span": { - "start": 2537, - "end": 2543, + "start": 2541, + "end": 2547, "ctxt": 0 }, "kind": "number" @@ -3059,8 +3059,8 @@ { "type": "TsKeywordType", "span": { - "start": 2546, - "end": 2555, + "start": 2550, + "end": 2559, "ctxt": 0 }, "kind": "undefined" @@ -3077,8 +3077,8 @@ { "type": "VariableDeclaration", "span": { - "start": 2558, - "end": 2601, + "start": 2562, + "end": 2605, "ctxt": 0 }, "kind": "var", @@ -3087,15 +3087,15 @@ { "type": "VariableDeclarator", "span": { - "start": 2562, - "end": 2600, + "start": 2566, + "end": 2604, "ctxt": 0 }, "id": { "type": "Identifier", "span": { - "start": 2562, - "end": 2587, + "start": 2566, + "end": 2591, "ctxt": 0 }, "value": "stringOrNumberOrUndefined", @@ -3105,15 +3105,15 @@ "init": { "type": "MemberExpression", "span": { - "start": 2590, - "end": 2600, + "start": 2594, + "end": 2604, "ctxt": 0 }, "object": { "type": "Identifier", "span": { - "start": 2590, - "end": 2591, + "start": 2594, + "end": 2595, "ctxt": 0 }, "value": "c", @@ -3122,8 +3122,8 @@ "property": { "type": "Identifier", "span": { - "start": 2592, - "end": 2600, + "start": 2596, + "end": 2604, "ctxt": 0 }, "value": "inMethod", @@ -3137,8 +3137,8 @@ { "type": "VariableDeclaration", "span": { - "start": 2602, - "end": 2645, + "start": 2606, + "end": 2649, "ctxt": 0 }, "kind": "var", @@ -3147,15 +3147,15 @@ { "type": "VariableDeclarator", "span": { - "start": 2606, - "end": 2644, + "start": 2610, + "end": 2648, "ctxt": 0 }, "id": { "type": "Identifier", "span": { - "start": 2606, - "end": 2631, + "start": 2610, + "end": 2635, "ctxt": 0 }, "value": "stringOrNumberOrUndefined", @@ -3165,15 +3165,15 @@ "init": { "type": "MemberExpression", "span": { - "start": 2634, - "end": 2644, + "start": 2638, + "end": 2648, "ctxt": 0 }, "object": { "type": "Identifier", "span": { - "start": 2634, - "end": 2635, + "start": 2638, + "end": 2639, "ctxt": 0 }, "value": "c", @@ -3182,8 +3182,8 @@ "property": { "type": "Identifier", "span": { - "start": 2636, - "end": 2644, + "start": 2640, + "end": 2648, "ctxt": 0 }, "value": "inGetter", @@ -3197,8 +3197,8 @@ { "type": "VariableDeclaration", "span": { - "start": 2646, - "end": 2689, + "start": 2650, + "end": 2693, "ctxt": 0 }, "kind": "var", @@ -3207,15 +3207,15 @@ { "type": "VariableDeclarator", "span": { - "start": 2650, - "end": 2688, + "start": 2654, + "end": 2692, "ctxt": 0 }, "id": { "type": "Identifier", "span": { - "start": 2650, - "end": 2675, + "start": 2654, + "end": 2679, "ctxt": 0 }, "value": "stringOrNumberOrUndefined", @@ -3225,15 +3225,15 @@ "init": { "type": "MemberExpression", "span": { - "start": 2678, - "end": 2688, + "start": 2682, + "end": 2692, "ctxt": 0 }, "object": { "type": "Identifier", "span": { - "start": 2678, - "end": 2679, + "start": 2682, + "end": 2683, "ctxt": 0 }, "value": "c", @@ -3242,8 +3242,8 @@ "property": { "type": "Identifier", "span": { - "start": 2680, - "end": 2688, + "start": 2684, + "end": 2692, "ctxt": 0 }, "value": "inSetter", @@ -3257,8 +3257,8 @@ { "type": "VariableDeclaration", "span": { - "start": 2690, - "end": 2746, + "start": 2694, + "end": 2750, "ctxt": 0 }, "kind": "var", @@ -3267,15 +3267,15 @@ { "type": "VariableDeclarator", "span": { - "start": 2694, - "end": 2745, + "start": 2698, + "end": 2749, "ctxt": 0 }, "id": { "type": "Identifier", "span": { - "start": 2694, - "end": 2719, + "start": 2698, + "end": 2723, "ctxt": 0 }, "value": "stringOrNumberOrUndefined", @@ -3285,15 +3285,15 @@ "init": { "type": "MemberExpression", "span": { - "start": 2722, - "end": 2745, + "start": 2726, + "end": 2749, "ctxt": 0 }, "object": { "type": "Identifier", "span": { - "start": 2722, - "end": 2723, + "start": 2726, + "end": 2727, "ctxt": 0 }, "value": "c", @@ -3302,8 +3302,8 @@ "property": { "type": "Identifier", "span": { - "start": 2724, - "end": 2745, + "start": 2728, + "end": 2749, "ctxt": 0 }, "value": "inPropertyDeclaration", @@ -3317,8 +3317,8 @@ { "type": "VariableDeclaration", "span": { - "start": 2747, - "end": 2802, + "start": 2751, + "end": 2806, "ctxt": 0 }, "kind": "var", @@ -3327,15 +3327,15 @@ { "type": "VariableDeclarator", "span": { - "start": 2751, - "end": 2802, + "start": 2755, + "end": 2806, "ctxt": 0 }, "id": { "type": "Identifier", "span": { - "start": 2751, - "end": 2776, + "start": 2755, + "end": 2780, "ctxt": 0 }, "value": "stringOrNumberOrUndefined", @@ -3345,15 +3345,15 @@ "init": { "type": "MemberExpression", "span": { - "start": 2779, - "end": 2802, + "start": 2783, + "end": 2806, "ctxt": 0 }, "object": { "type": "Identifier", "span": { - "start": 2779, - "end": 2780, + "start": 2783, + "end": 2784, "ctxt": 0 }, "value": "c", @@ -3362,8 +3362,8 @@ "property": { "type": "Identifier", "span": { - "start": 2781, - "end": 2802, + "start": 2785, + "end": 2806, "ctxt": 0 }, "value": "inNestedArrowFunction", @@ -3377,8 +3377,8 @@ { "type": "VariableDeclaration", "span": { - "start": 2804, - "end": 2859, + "start": 2808, + "end": 2863, "ctxt": 0 }, "kind": "var", @@ -3387,15 +3387,15 @@ { "type": "VariableDeclarator", "span": { - "start": 2808, - "end": 2858, + "start": 2812, + "end": 2862, "ctxt": 0 }, "id": { "type": "Identifier", "span": { - "start": 2808, - "end": 2831, + "start": 2812, + "end": 2835, "ctxt": 0 }, "value": "stringOrNumberOrBoolean", @@ -3403,23 +3403,23 @@ "typeAnnotation": { "type": "TsTypeAnnotation", "span": { - "start": 2831, - "end": 2858, + "start": 2835, + "end": 2862, "ctxt": 0 }, "typeAnnotation": { "type": "TsUnionType", "span": { - "start": 2833, - "end": 2858, + "start": 2837, + "end": 2862, "ctxt": 0 }, "types": [ { "type": "TsKeywordType", "span": { - "start": 2833, - "end": 2839, + "start": 2837, + "end": 2843, "ctxt": 0 }, "kind": "string" @@ -3427,8 +3427,8 @@ { "type": "TsKeywordType", "span": { - "start": 2842, - "end": 2848, + "start": 2846, + "end": 2852, "ctxt": 0 }, "kind": "number" @@ -3436,8 +3436,8 @@ { "type": "TsKeywordType", "span": { - "start": 2851, - "end": 2858, + "start": 2855, + "end": 2862, "ctxt": 0 }, "kind": "boolean" @@ -3454,8 +3454,8 @@ { "type": "VariableDeclaration", "span": { - "start": 2861, - "end": 2880, + "start": 2865, + "end": 2884, "ctxt": 0 }, "kind": "var", @@ -3464,15 +3464,15 @@ { "type": "VariableDeclarator", "span": { - "start": 2865, - "end": 2879, + "start": 2869, + "end": 2883, "ctxt": 0 }, "id": { "type": "Identifier", "span": { - "start": 2865, - "end": 2871, + "start": 2869, + "end": 2875, "ctxt": 0 }, "value": "number", @@ -3480,15 +3480,15 @@ "typeAnnotation": { "type": "TsTypeAnnotation", "span": { - "start": 2871, - "end": 2879, + "start": 2875, + "end": 2883, "ctxt": 0 }, "typeAnnotation": { "type": "TsKeywordType", "span": { - "start": 2873, - "end": 2879, + "start": 2877, + "end": 2883, "ctxt": 0 }, "kind": "number" @@ -3503,8 +3503,8 @@ { "type": "VariableDeclaration", "span": { - "start": 2881, - "end": 2907, + "start": 2885, + "end": 2911, "ctxt": 0 }, "kind": "var", @@ -3513,15 +3513,15 @@ { "type": "VariableDeclarator", "span": { - "start": 2885, - "end": 2906, + "start": 2889, + "end": 2910, "ctxt": 0 }, "id": { "type": "Identifier", "span": { - "start": 2885, - "end": 2891, + "start": 2889, + "end": 2895, "ctxt": 0 }, "value": "number", @@ -3531,15 +3531,15 @@ "init": { "type": "MemberExpression", "span": { - "start": 2894, - "end": 2906, + "start": 2898, + "end": 2910, "ctxt": 0 }, "object": { "type": "Identifier", "span": { - "start": 2894, - "end": 2895, + "start": 2898, + "end": 2899, "ctxt": 0 }, "value": "c", @@ -3548,8 +3548,8 @@ "property": { "type": "Identifier", "span": { - "start": 2896, - "end": 2906, + "start": 2900, + "end": 2910, "ctxt": 0 }, "value": "inMultiple", @@ -3563,8 +3563,8 @@ { "type": "VariableDeclaration", "span": { - "start": 2908, - "end": 2970, + "start": 2912, + "end": 2974, "ctxt": 0 }, "kind": "var", @@ -3573,15 +3573,15 @@ { "type": "VariableDeclarator", "span": { - "start": 2912, - "end": 2969, + "start": 2916, + "end": 2973, "ctxt": 0 }, "id": { "type": "Identifier", "span": { - "start": 2912, - "end": 2938, + "start": 2916, + "end": 2942, "ctxt": 0 }, "value": "stringOrBooleanOrUndefined", @@ -3589,23 +3589,23 @@ "typeAnnotation": { "type": "TsTypeAnnotation", "span": { - "start": 2939, - "end": 2969, + "start": 2943, + "end": 2973, "ctxt": 0 }, "typeAnnotation": { "type": "TsUnionType", "span": { - "start": 2941, - "end": 2969, + "start": 2945, + "end": 2973, "ctxt": 0 }, "types": [ { "type": "TsKeywordType", "span": { - "start": 2941, - "end": 2947, + "start": 2945, + "end": 2951, "ctxt": 0 }, "kind": "string" @@ -3613,8 +3613,8 @@ { "type": "TsKeywordType", "span": { - "start": 2950, - "end": 2957, + "start": 2954, + "end": 2961, "ctxt": 0 }, "kind": "boolean" @@ -3622,8 +3622,8 @@ { "type": "TsKeywordType", "span": { - "start": 2960, - "end": 2969, + "start": 2964, + "end": 2973, "ctxt": 0 }, "kind": "undefined" @@ -3640,8 +3640,8 @@ { "type": "VariableDeclaration", "span": { - "start": 2971, - "end": 3024, + "start": 2975, + "end": 3028, "ctxt": 0 }, "kind": "var", @@ -3650,15 +3650,15 @@ { "type": "VariableDeclarator", "span": { - "start": 2975, - "end": 3023, + "start": 2979, + "end": 3027, "ctxt": 0 }, "id": { "type": "Identifier", "span": { - "start": 2975, - "end": 3001, + "start": 2979, + "end": 3005, "ctxt": 0 }, "value": "stringOrBooleanOrUndefined", @@ -3668,15 +3668,15 @@ "init": { "type": "MemberExpression", "span": { - "start": 3004, - "end": 3023, + "start": 3008, + "end": 3027, "ctxt": 0 }, "object": { "type": "Identifier", "span": { - "start": 3004, - "end": 3005, + "start": 3008, + "end": 3009, "ctxt": 0 }, "value": "c", @@ -3685,8 +3685,8 @@ "property": { "type": "Identifier", "span": { - "start": 3006, - "end": 3023, + "start": 3010, + "end": 3027, "ctxt": 0 }, "value": "inMultipleMethods", @@ -3700,8 +3700,8 @@ { "type": "VariableDeclaration", "span": { - "start": 3025, - "end": 3038, + "start": 3029, + "end": 3042, "ctxt": 0 }, "kind": "var", @@ -3710,15 +3710,15 @@ { "type": "VariableDeclarator", "span": { - "start": 3029, - "end": 3037, + "start": 3033, + "end": 3041, "ctxt": 0 }, "id": { "type": "Identifier", "span": { - "start": 3029, - "end": 3032, + "start": 3033, + "end": 3036, "ctxt": 0 }, "value": "any", @@ -3726,15 +3726,15 @@ "typeAnnotation": { "type": "TsTypeAnnotation", "span": { - "start": 3032, - "end": 3037, + "start": 3036, + "end": 3041, "ctxt": 0 }, "typeAnnotation": { "type": "TsKeywordType", "span": { - "start": 3034, - "end": 3037, + "start": 3038, + "end": 3041, "ctxt": 0 }, "kind": "any" @@ -3749,8 +3749,8 @@ { "type": "VariableDeclaration", "span": { - "start": 3039, - "end": 3068, + "start": 3043, + "end": 3072, "ctxt": 0 }, "kind": "var", @@ -3759,15 +3759,15 @@ { "type": "VariableDeclarator", "span": { - "start": 3043, - "end": 3067, + "start": 3047, + "end": 3071, "ctxt": 0 }, "id": { "type": "Identifier", "span": { - "start": 3043, - "end": 3046, + "start": 3047, + "end": 3050, "ctxt": 0 }, "value": "any", @@ -3777,15 +3777,15 @@ "init": { "type": "MemberExpression", "span": { - "start": 3049, - "end": 3067, + "start": 3053, + "end": 3071, "ctxt": 0 }, "object": { "type": "Identifier", "span": { - "start": 3049, - "end": 3050, + "start": 3053, + "end": 3054, "ctxt": 0 }, "value": "c", @@ -3794,8 +3794,8 @@ "property": { "type": "Identifier", "span": { - "start": 3051, - "end": 3067, + "start": 3055, + "end": 3071, "ctxt": 0 }, "value": "inMethodNullable", @@ -3809,8 +3809,8 @@ { "type": "VariableDeclaration", "span": { - "start": 3071, - "end": 3120, + "start": 3075, + "end": 3124, "ctxt": 0 }, "kind": "var", @@ -3819,15 +3819,15 @@ { "type": "VariableDeclarator", "span": { - "start": 3075, - "end": 3119, + "start": 3079, + "end": 3123, "ctxt": 0 }, "id": { "type": "Identifier", "span": { - "start": 3075, - "end": 3100, + "start": 3079, + "end": 3104, "ctxt": 0 }, "value": "stringOrNumberOrUndefined", @@ -3837,15 +3837,15 @@ "init": { "type": "MemberExpression", "span": { - "start": 3103, - "end": 3119, + "start": 3107, + "end": 3123, "ctxt": 0 }, "object": { "type": "Identifier", "span": { - "start": 3103, - "end": 3104, + "start": 3107, + "end": 3108, "ctxt": 0 }, "value": "C", @@ -3854,8 +3854,8 @@ "property": { "type": "Identifier", "span": { - "start": 3105, - "end": 3119, + "start": 3109, + "end": 3123, "ctxt": 0 }, "value": "inStaticMethod", @@ -3869,8 +3869,8 @@ { "type": "VariableDeclaration", "span": { - "start": 3121, - "end": 3170, + "start": 3125, + "end": 3174, "ctxt": 0 }, "kind": "var", @@ -3879,15 +3879,15 @@ { "type": "VariableDeclarator", "span": { - "start": 3125, - "end": 3169, + "start": 3129, + "end": 3173, "ctxt": 0 }, "id": { "type": "Identifier", "span": { - "start": 3125, - "end": 3150, + "start": 3129, + "end": 3154, "ctxt": 0 }, "value": "stringOrNumberOrUndefined", @@ -3897,15 +3897,15 @@ "init": { "type": "MemberExpression", "span": { - "start": 3153, - "end": 3169, + "start": 3157, + "end": 3173, "ctxt": 0 }, "object": { "type": "Identifier", "span": { - "start": 3153, - "end": 3154, + "start": 3157, + "end": 3158, "ctxt": 0 }, "value": "C", @@ -3914,8 +3914,8 @@ "property": { "type": "Identifier", "span": { - "start": 3155, - "end": 3169, + "start": 3159, + "end": 3173, "ctxt": 0 }, "value": "inStaticGetter", @@ -3929,8 +3929,8 @@ { "type": "VariableDeclaration", "span": { - "start": 3171, - "end": 3220, + "start": 3175, + "end": 3224, "ctxt": 0 }, "kind": "var", @@ -3939,15 +3939,15 @@ { "type": "VariableDeclarator", "span": { - "start": 3175, - "end": 3219, + "start": 3179, + "end": 3223, "ctxt": 0 }, "id": { "type": "Identifier", "span": { - "start": 3175, - "end": 3200, + "start": 3179, + "end": 3204, "ctxt": 0 }, "value": "stringOrNumberOrUndefined", @@ -3957,15 +3957,15 @@ "init": { "type": "MemberExpression", "span": { - "start": 3203, - "end": 3219, + "start": 3207, + "end": 3223, "ctxt": 0 }, "object": { "type": "Identifier", "span": { - "start": 3203, - "end": 3204, + "start": 3207, + "end": 3208, "ctxt": 0 }, "value": "C", @@ -3974,8 +3974,8 @@ "property": { "type": "Identifier", "span": { - "start": 3205, - "end": 3219, + "start": 3209, + "end": 3223, "ctxt": 0 }, "value": "inStaticSetter", @@ -3989,8 +3989,8 @@ { "type": "VariableDeclaration", "span": { - "start": 3221, - "end": 3283, + "start": 3225, + "end": 3287, "ctxt": 0 }, "kind": "var", @@ -3999,15 +3999,15 @@ { "type": "VariableDeclarator", "span": { - "start": 3225, - "end": 3282, + "start": 3229, + "end": 3286, "ctxt": 0 }, "id": { "type": "Identifier", "span": { - "start": 3225, - "end": 3250, + "start": 3229, + "end": 3254, "ctxt": 0 }, "value": "stringOrNumberOrUndefined", @@ -4017,15 +4017,15 @@ "init": { "type": "MemberExpression", "span": { - "start": 3253, - "end": 3282, + "start": 3257, + "end": 3286, "ctxt": 0 }, "object": { "type": "Identifier", "span": { - "start": 3253, - "end": 3254, + "start": 3257, + "end": 3258, "ctxt": 0 }, "value": "C", @@ -4034,8 +4034,8 @@ "property": { "type": "Identifier", "span": { - "start": 3255, - "end": 3282, + "start": 3259, + "end": 3286, "ctxt": 0 }, "value": "inStaticPropertyDeclaration", @@ -4049,8 +4049,8 @@ { "type": "VariableDeclaration", "span": { - "start": 3284, - "end": 3346, + "start": 3288, + "end": 3350, "ctxt": 0 }, "kind": "var", @@ -4059,15 +4059,15 @@ { "type": "VariableDeclarator", "span": { - "start": 3288, - "end": 3345, + "start": 3292, + "end": 3349, "ctxt": 0 }, "id": { "type": "Identifier", "span": { - "start": 3288, - "end": 3313, + "start": 3292, + "end": 3317, "ctxt": 0 }, "value": "stringOrNumberOrUndefined", @@ -4077,15 +4077,15 @@ "init": { "type": "MemberExpression", "span": { - "start": 3316, - "end": 3345, + "start": 3320, + "end": 3349, "ctxt": 0 }, "object": { "type": "Identifier", "span": { - "start": 3316, - "end": 3317, + "start": 3320, + "end": 3321, "ctxt": 0 }, "value": "C", @@ -4094,8 +4094,8 @@ "property": { "type": "Identifier", "span": { - "start": 3318, - "end": 3345, + "start": 3322, + "end": 3349, "ctxt": 0 }, "value": "inStaticNestedArrowFunction", diff --git a/crates/swc_ecma_parser/tests/tsc/inferringClassMembersFromAssignments.ts b/crates/swc_ecma_parser/tests/tsc/inferringClassMembersFromAssignments.ts index b6c12be64074..69c3f789be9c 100644 --- a/crates/swc_ecma_parser/tests/tsc/inferringClassMembersFromAssignments.ts +++ b/crates/swc_ecma_parser/tests/tsc/inferringClassMembersFromAssignments.ts @@ -1,4 +1,4 @@ -// @out: output.js +// @outFile: output.js // @allowJs: true // @checkJs: true // @noImplicitAny: true diff --git a/crates/swc_ecma_parser/tests/tsc/instanceofOperatorWithRHSHasSymbolHasInstance.json b/crates/swc_ecma_parser/tests/tsc/instanceofOperatorWithRHSHasSymbolHasInstance.json index d31d17dc0239..3bf54e60704e 100644 --- a/crates/swc_ecma_parser/tests/tsc/instanceofOperatorWithRHSHasSymbolHasInstance.json +++ b/crates/swc_ecma_parser/tests/tsc/instanceofOperatorWithRHSHasSymbolHasInstance.json @@ -2,7 +2,7 @@ "type": "Script", "span": { "start": 37, - "end": 4138, + "end": 4643, "ctxt": 0 }, "body": [ @@ -7838,6 +7838,787 @@ ] }, "alternate": null + }, + { + "type": "TsInterfaceDeclaration", + "span": { + "start": 4214, + "end": 4283, + "ctxt": 0 + }, + "id": { + "type": "Identifier", + "span": { + "start": 4224, + "end": 4237, + "ctxt": 0 + }, + "value": "HasInstanceOf", + "optional": false + }, + "declare": false, + "typeParams": null, + "extends": [], + "body": { + "type": "TsInterfaceBody", + "span": { + "start": 4238, + "end": 4283, + "ctxt": 0 + }, + "body": [ + { + "type": "TsMethodSignature", + "span": { + "start": 4240, + "end": 4281, + "ctxt": 0 + }, + "readonly": false, + "key": { + "type": "MemberExpression", + "span": { + "start": 4241, + "end": 4259, + "ctxt": 0 + }, + "object": { + "type": "Identifier", + "span": { + "start": 4241, + "end": 4247, + "ctxt": 0 + }, + "value": "Symbol", + "optional": false + }, + "property": { + "type": "Identifier", + "span": { + "start": 4248, + "end": 4259, + "ctxt": 0 + }, + "value": "hasInstance", + "optional": false + } + }, + "computed": true, + "optional": false, + "params": [ + { + "type": "Identifier", + "span": { + "start": 4261, + "end": 4271, + "ctxt": 0 + }, + "value": "x", + "optional": false, + "typeAnnotation": { + "type": "TsTypeAnnotation", + "span": { + "start": 4262, + "end": 4271, + "ctxt": 0 + }, + "typeAnnotation": { + "type": "TsKeywordType", + "span": { + "start": 4264, + "end": 4271, + "ctxt": 0 + }, + "kind": "unknown" + } + } + } + ], + "typeAnn": { + "type": "TsTypeAnnotation", + "span": { + "start": 4272, + "end": 4281, + "ctxt": 0 + }, + "typeAnnotation": { + "type": "TsKeywordType", + "span": { + "start": 4274, + "end": 4281, + "ctxt": 0 + }, + "kind": "boolean" + } + }, + "typeParams": null + } + ] + } + }, + { + "type": "TsTypeAliasDeclaration", + "span": { + "start": 4284, + "end": 4320, + "ctxt": 0 + }, + "declare": false, + "id": { + "type": "Identifier", + "span": { + "start": 4289, + "end": 4294, + "ctxt": 0 + }, + "value": "Rhs14", + "optional": false + }, + "typeParams": null, + "typeAnnotation": { + "type": "TsIntersectionType", + "span": { + "start": 4297, + "end": 4319, + "ctxt": 0 + }, + "types": [ + { + "type": "TsTypeReference", + "span": { + "start": 4297, + "end": 4310, + "ctxt": 0 + }, + "typeName": { + "type": "Identifier", + "span": { + "start": 4297, + "end": 4310, + "ctxt": 0 + }, + "value": "HasInstanceOf", + "optional": false + }, + "typeParams": null + }, + { + "type": "TsKeywordType", + "span": { + "start": 4313, + "end": 4319, + "ctxt": 0 + }, + "kind": "object" + } + ] + } + }, + { + "type": "VariableDeclaration", + "span": { + "start": 4321, + "end": 4348, + "ctxt": 0 + }, + "kind": "const", + "declare": true, + "declarations": [ + { + "type": "VariableDeclarator", + "span": { + "start": 4335, + "end": 4347, + "ctxt": 0 + }, + "id": { + "type": "Identifier", + "span": { + "start": 4335, + "end": 4340, + "ctxt": 0 + }, + "value": "rhs14", + "optional": false, + "typeAnnotation": { + "type": "TsTypeAnnotation", + "span": { + "start": 4340, + "end": 4347, + "ctxt": 0 + }, + "typeAnnotation": { + "type": "TsTypeReference", + "span": { + "start": 4342, + "end": 4347, + "ctxt": 0 + }, + "typeName": { + "type": "Identifier", + "span": { + "start": 4342, + "end": 4347, + "ctxt": 0 + }, + "value": "Rhs14", + "optional": false + }, + "typeParams": null + } + } + }, + "init": null, + "definite": false + } + ] + }, + { + "type": "ExpressionStatement", + "span": { + "start": 4349, + "end": 4379, + "ctxt": 0 + }, + "expression": { + "type": "BinaryExpression", + "span": { + "start": 4349, + "end": 4378, + "ctxt": 0 + }, + "operator": "&&", + "left": { + "type": "BinaryExpression", + "span": { + "start": 4349, + "end": 4370, + "ctxt": 0 + }, + "operator": "instanceof", + "left": { + "type": "Identifier", + "span": { + "start": 4349, + "end": 4353, + "ctxt": 0 + }, + "value": "lhs0", + "optional": false + }, + "right": { + "type": "Identifier", + "span": { + "start": 4365, + "end": 4370, + "ctxt": 0 + }, + "value": "rhs14", + "optional": false + } + }, + "right": { + "type": "Identifier", + "span": { + "start": 4374, + "end": 4378, + "ctxt": 0 + }, + "value": "lhs0", + "optional": false + } + } + }, + { + "type": "TsInterfaceDeclaration", + "span": { + "start": 4392, + "end": 4465, + "ctxt": 0 + }, + "id": { + "type": "Identifier", + "span": { + "start": 4402, + "end": 4416, + "ctxt": 0 + }, + "value": "HasInstanceOf1", + "optional": false + }, + "declare": false, + "typeParams": null, + "extends": [], + "body": { + "type": "TsInterfaceBody", + "span": { + "start": 4417, + "end": 4465, + "ctxt": 0 + }, + "body": [ + { + "type": "TsMethodSignature", + "span": { + "start": 4419, + "end": 4463, + "ctxt": 0 + }, + "readonly": false, + "key": { + "type": "MemberExpression", + "span": { + "start": 4420, + "end": 4438, + "ctxt": 0 + }, + "object": { + "type": "Identifier", + "span": { + "start": 4420, + "end": 4426, + "ctxt": 0 + }, + "value": "Symbol", + "optional": false + }, + "property": { + "type": "Identifier", + "span": { + "start": 4427, + "end": 4438, + "ctxt": 0 + }, + "value": "hasInstance", + "optional": false + } + }, + "computed": true, + "optional": false, + "params": [ + { + "type": "Identifier", + "span": { + "start": 4440, + "end": 4450, + "ctxt": 0 + }, + "value": "x", + "optional": false, + "typeAnnotation": { + "type": "TsTypeAnnotation", + "span": { + "start": 4441, + "end": 4450, + "ctxt": 0 + }, + "typeAnnotation": { + "type": "TsKeywordType", + "span": { + "start": 4443, + "end": 4450, + "ctxt": 0 + }, + "kind": "unknown" + } + } + } + ], + "typeAnn": { + "type": "TsTypeAnnotation", + "span": { + "start": 4451, + "end": 4463, + "ctxt": 0 + }, + "typeAnnotation": { + "type": "TsTypePredicate", + "span": { + "start": 4453, + "end": 4463, + "ctxt": 0 + }, + "asserts": false, + "paramName": { + "type": "Identifier", + "span": { + "start": 4453, + "end": 4454, + "ctxt": 0 + }, + "value": "x", + "optional": false + }, + "typeAnnotation": { + "type": "TsTypeAnnotation", + "span": { + "start": 4458, + "end": 4463, + "ctxt": 0 + }, + "typeAnnotation": { + "type": "TsTypeReference", + "span": { + "start": 4458, + "end": 4463, + "ctxt": 0 + }, + "typeName": { + "type": "Identifier", + "span": { + "start": 4458, + "end": 4463, + "ctxt": 0 + }, + "value": "Point", + "optional": false + }, + "typeParams": null + } + } + } + }, + "typeParams": null + } + ] + } + }, + { + "type": "TsInterfaceDeclaration", + "span": { + "start": 4466, + "end": 4538, + "ctxt": 0 + }, + "id": { + "type": "Identifier", + "span": { + "start": 4476, + "end": 4490, + "ctxt": 0 + }, + "value": "HasInstanceOf2", + "optional": false + }, + "declare": false, + "typeParams": null, + "extends": [], + "body": { + "type": "TsInterfaceBody", + "span": { + "start": 4491, + "end": 4538, + "ctxt": 0 + }, + "body": [ + { + "type": "TsMethodSignature", + "span": { + "start": 4493, + "end": 4536, + "ctxt": 0 + }, + "readonly": false, + "key": { + "type": "MemberExpression", + "span": { + "start": 4494, + "end": 4512, + "ctxt": 0 + }, + "object": { + "type": "Identifier", + "span": { + "start": 4494, + "end": 4500, + "ctxt": 0 + }, + "value": "Symbol", + "optional": false + }, + "property": { + "type": "Identifier", + "span": { + "start": 4501, + "end": 4512, + "ctxt": 0 + }, + "value": "hasInstance", + "optional": false + } + }, + "computed": true, + "optional": false, + "params": [ + { + "type": "Identifier", + "span": { + "start": 4514, + "end": 4524, + "ctxt": 0 + }, + "value": "x", + "optional": false, + "typeAnnotation": { + "type": "TsTypeAnnotation", + "span": { + "start": 4515, + "end": 4524, + "ctxt": 0 + }, + "typeAnnotation": { + "type": "TsKeywordType", + "span": { + "start": 4517, + "end": 4524, + "ctxt": 0 + }, + "kind": "unknown" + } + } + } + ], + "typeAnn": { + "type": "TsTypeAnnotation", + "span": { + "start": 4525, + "end": 4536, + "ctxt": 0 + }, + "typeAnnotation": { + "type": "TsTypePredicate", + "span": { + "start": 4527, + "end": 4536, + "ctxt": 0 + }, + "asserts": false, + "paramName": { + "type": "Identifier", + "span": { + "start": 4527, + "end": 4528, + "ctxt": 0 + }, + "value": "x", + "optional": false + }, + "typeAnnotation": { + "type": "TsTypeAnnotation", + "span": { + "start": 4532, + "end": 4536, + "ctxt": 0 + }, + "typeAnnotation": { + "type": "TsTypeReference", + "span": { + "start": 4532, + "end": 4536, + "ctxt": 0 + }, + "typeName": { + "type": "Identifier", + "span": { + "start": 4532, + "end": 4536, + "ctxt": 0 + }, + "value": "Line", + "optional": false + }, + "typeParams": null + } + } + } + }, + "typeParams": null + } + ] + } + }, + { + "type": "TsTypeAliasDeclaration", + "span": { + "start": 4539, + "end": 4584, + "ctxt": 0 + }, + "declare": false, + "id": { + "type": "Identifier", + "span": { + "start": 4544, + "end": 4549, + "ctxt": 0 + }, + "value": "Rhs15", + "optional": false + }, + "typeParams": null, + "typeAnnotation": { + "type": "TsUnionType", + "span": { + "start": 4552, + "end": 4583, + "ctxt": 0 + }, + "types": [ + { + "type": "TsTypeReference", + "span": { + "start": 4552, + "end": 4566, + "ctxt": 0 + }, + "typeName": { + "type": "Identifier", + "span": { + "start": 4552, + "end": 4566, + "ctxt": 0 + }, + "value": "HasInstanceOf1", + "optional": false + }, + "typeParams": null + }, + { + "type": "TsTypeReference", + "span": { + "start": 4569, + "end": 4583, + "ctxt": 0 + }, + "typeName": { + "type": "Identifier", + "span": { + "start": 4569, + "end": 4583, + "ctxt": 0 + }, + "value": "HasInstanceOf2", + "optional": false + }, + "typeParams": null + } + ] + } + }, + { + "type": "VariableDeclaration", + "span": { + "start": 4585, + "end": 4612, + "ctxt": 0 + }, + "kind": "const", + "declare": true, + "declarations": [ + { + "type": "VariableDeclarator", + "span": { + "start": 4599, + "end": 4611, + "ctxt": 0 + }, + "id": { + "type": "Identifier", + "span": { + "start": 4599, + "end": 4604, + "ctxt": 0 + }, + "value": "rhs15", + "optional": false, + "typeAnnotation": { + "type": "TsTypeAnnotation", + "span": { + "start": 4604, + "end": 4611, + "ctxt": 0 + }, + "typeAnnotation": { + "type": "TsTypeReference", + "span": { + "start": 4606, + "end": 4611, + "ctxt": 0 + }, + "typeName": { + "type": "Identifier", + "span": { + "start": 4606, + "end": 4611, + "ctxt": 0 + }, + "value": "Rhs15", + "optional": false + }, + "typeParams": null + } + } + }, + "init": null, + "definite": false + } + ] + }, + { + "type": "ExpressionStatement", + "span": { + "start": 4613, + "end": 4643, + "ctxt": 0 + }, + "expression": { + "type": "BinaryExpression", + "span": { + "start": 4613, + "end": 4642, + "ctxt": 0 + }, + "operator": "&&", + "left": { + "type": "BinaryExpression", + "span": { + "start": 4613, + "end": 4634, + "ctxt": 0 + }, + "operator": "instanceof", + "left": { + "type": "Identifier", + "span": { + "start": 4613, + "end": 4617, + "ctxt": 0 + }, + "value": "lhs0", + "optional": false + }, + "right": { + "type": "Identifier", + "span": { + "start": 4629, + "end": 4634, + "ctxt": 0 + }, + "value": "rhs15", + "optional": false + } + }, + "right": { + "type": "Identifier", + "span": { + "start": 4638, + "end": 4642, + "ctxt": 0 + }, + "value": "lhs0", + "optional": false + } + } } ], "interpreter": null diff --git a/crates/swc_ecma_parser/tests/tsc/instanceofOperatorWithRHSHasSymbolHasInstance.ts b/crates/swc_ecma_parser/tests/tsc/instanceofOperatorWithRHSHasSymbolHasInstance.ts index 0a849cc21399..100b04727e0f 100644 --- a/crates/swc_ecma_parser/tests/tsc/instanceofOperatorWithRHSHasSymbolHasInstance.ts +++ b/crates/swc_ecma_parser/tests/tsc/instanceofOperatorWithRHSHasSymbolHasInstance.ts @@ -115,4 +115,20 @@ if (obj instanceof A) { } if (obj instanceof B) { obj; // B -} \ No newline at end of file +} + +// intersections +// https://github.com/microsoft/TypeScript/issues/56536 + +interface HasInstanceOf { [Symbol.hasInstance](x: unknown): boolean } +type Rhs14 = HasInstanceOf & object; +declare const rhs14: Rhs14; +lhs0 instanceof rhs14 && lhs0; + +// unions + +interface HasInstanceOf1 { [Symbol.hasInstance](x: unknown): x is Point } +interface HasInstanceOf2 { [Symbol.hasInstance](x: unknown): x is Line } +type Rhs15 = HasInstanceOf1 | HasInstanceOf2; +declare const rhs15: Rhs15; +lhs0 instanceof rhs15 && lhs0; diff --git a/crates/swc_ecma_parser/tests/tsc/intlDateTimeFormatRangeES2021.json b/crates/swc_ecma_parser/tests/tsc/intlDateTimeFormatRangeES2021.json new file mode 100644 index 000000000000..5707477e6b4d --- /dev/null +++ b/crates/swc_ecma_parser/tests/tsc/intlDateTimeFormatRangeES2021.json @@ -0,0 +1,283 @@ +{ + "type": "Script", + "span": { + "start": 18, + "end": 162, + "ctxt": 0 + }, + "body": [ + { + "type": "ExpressionStatement", + "span": { + "start": 18, + "end": 81, + "ctxt": 0 + }, + "expression": { + "type": "CallExpression", + "span": { + "start": 18, + "end": 80, + "ctxt": 0 + }, + "callee": { + "type": "MemberExpression", + "span": { + "start": 18, + "end": 55, + "ctxt": 0 + }, + "object": { + "type": "NewExpression", + "span": { + "start": 18, + "end": 43, + "ctxt": 0 + }, + "callee": { + "type": "MemberExpression", + "span": { + "start": 22, + "end": 41, + "ctxt": 0 + }, + "object": { + "type": "Identifier", + "span": { + "start": 22, + "end": 26, + "ctxt": 0 + }, + "value": "Intl", + "optional": false + }, + "property": { + "type": "Identifier", + "span": { + "start": 27, + "end": 41, + "ctxt": 0 + }, + "value": "DateTimeFormat", + "optional": false + } + }, + "arguments": [], + "typeArguments": null + }, + "property": { + "type": "Identifier", + "span": { + "start": 44, + "end": 55, + "ctxt": 0 + }, + "value": "formatRange", + "optional": false + } + }, + "arguments": [ + { + "spread": null, + "expression": { + "type": "NewExpression", + "span": { + "start": 56, + "end": 67, + "ctxt": 0 + }, + "callee": { + "type": "Identifier", + "span": { + "start": 60, + "end": 64, + "ctxt": 0 + }, + "value": "Date", + "optional": false + }, + "arguments": [ + { + "spread": null, + "expression": { + "type": "NumericLiteral", + "span": { + "start": 65, + "end": 66, + "ctxt": 0 + }, + "value": 0.0, + "raw": "0" + } + } + ], + "typeArguments": null + } + }, + { + "spread": null, + "expression": { + "type": "NewExpression", + "span": { + "start": 69, + "end": 79, + "ctxt": 0 + }, + "callee": { + "type": "Identifier", + "span": { + "start": 73, + "end": 77, + "ctxt": 0 + }, + "value": "Date", + "optional": false + }, + "arguments": [], + "typeArguments": null + } + } + ], + "typeArguments": null + } + }, + { + "type": "VariableDeclaration", + "span": { + "start": 82, + "end": 162, + "ctxt": 0 + }, + "kind": "const", + "declare": false, + "declarations": [ + { + "type": "VariableDeclarator", + "span": { + "start": 88, + "end": 161, + "ctxt": 0 + }, + "id": { + "type": "ArrayPattern", + "span": { + "start": 88, + "end": 96, + "ctxt": 0 + }, + "elements": [ + { + "type": "Identifier", + "span": { + "start": 90, + "end": 94, + "ctxt": 0 + }, + "value": "part", + "optional": false, + "typeAnnotation": null + } + ], + "optional": false, + "typeAnnotation": null + }, + "init": { + "type": "CallExpression", + "span": { + "start": 99, + "end": 161, + "ctxt": 0 + }, + "callee": { + "type": "MemberExpression", + "span": { + "start": 99, + "end": 143, + "ctxt": 0 + }, + "object": { + "type": "NewExpression", + "span": { + "start": 99, + "end": 124, + "ctxt": 0 + }, + "callee": { + "type": "MemberExpression", + "span": { + "start": 103, + "end": 122, + "ctxt": 0 + }, + "object": { + "type": "Identifier", + "span": { + "start": 103, + "end": 107, + "ctxt": 0 + }, + "value": "Intl", + "optional": false + }, + "property": { + "type": "Identifier", + "span": { + "start": 108, + "end": 122, + "ctxt": 0 + }, + "value": "DateTimeFormat", + "optional": false + } + }, + "arguments": [], + "typeArguments": null + }, + "property": { + "type": "Identifier", + "span": { + "start": 125, + "end": 143, + "ctxt": 0 + }, + "value": "formatRangeToParts", + "optional": false + } + }, + "arguments": [ + { + "spread": null, + "expression": { + "type": "NumericLiteral", + "span": { + "start": 144, + "end": 148, + "ctxt": 0 + }, + "value": 1000.0, + "raw": "1000" + } + }, + { + "spread": null, + "expression": { + "type": "NumericLiteral", + "span": { + "start": 150, + "end": 160, + "ctxt": 0 + }, + "value": 1000000000.0, + "raw": "1000000000" + } + } + ], + "typeArguments": null + }, + "definite": false + } + ] + } + ], + "interpreter": null +} diff --git a/crates/swc_ecma_parser/tests/tsc/intlDateTimeFormatRangeES2021.ts b/crates/swc_ecma_parser/tests/tsc/intlDateTimeFormatRangeES2021.ts new file mode 100644 index 000000000000..f3a8d50aaa81 --- /dev/null +++ b/crates/swc_ecma_parser/tests/tsc/intlDateTimeFormatRangeES2021.ts @@ -0,0 +1,4 @@ +// @lib: es2021 + +new Intl.DateTimeFormat().formatRange(new Date(0), new Date()); +const [ part ] = new Intl.DateTimeFormat().formatRangeToParts(1000, 1000000000); diff --git a/crates/swc_ecma_parser/tests/tsc/intlNumberFormatES2020.json b/crates/swc_ecma_parser/tests/tsc/intlNumberFormatES2020.json new file mode 100644 index 000000000000..b276b80a5190 --- /dev/null +++ b/crates/swc_ecma_parser/tests/tsc/intlNumberFormatES2020.json @@ -0,0 +1,1238 @@ +{ + "type": "Script", + "span": { + "start": 80, + "end": 966, + "ctxt": 0 + }, + "body": [ + { + "type": "VariableDeclaration", + "span": { + "start": 80, + "end": 170, + "ctxt": 0 + }, + "kind": "const", + "declare": false, + "declarations": [ + { + "type": "VariableDeclarator", + "span": { + "start": 86, + "end": 169, + "ctxt": 0 + }, + "id": { + "type": "ObjectPattern", + "span": { + "start": 86, + "end": 118, + "ctxt": 0 + }, + "properties": [ + { + "type": "AssignmentPatternProperty", + "span": { + "start": 88, + "end": 96, + "ctxt": 0 + }, + "key": { + "type": "Identifier", + "span": { + "start": 88, + "end": 96, + "ctxt": 0 + }, + "value": "notation", + "optional": false, + "typeAnnotation": null + }, + "value": null + }, + { + "type": "AssignmentPatternProperty", + "span": { + "start": 98, + "end": 103, + "ctxt": 0 + }, + "key": { + "type": "Identifier", + "span": { + "start": 98, + "end": 103, + "ctxt": 0 + }, + "value": "style", + "optional": false, + "typeAnnotation": null + }, + "value": null + }, + { + "type": "AssignmentPatternProperty", + "span": { + "start": 105, + "end": 116, + "ctxt": 0 + }, + "key": { + "type": "Identifier", + "span": { + "start": 105, + "end": 116, + "ctxt": 0 + }, + "value": "signDisplay", + "optional": false, + "typeAnnotation": null + }, + "value": null + } + ], + "optional": false, + "typeAnnotation": null + }, + "init": { + "type": "CallExpression", + "span": { + "start": 121, + "end": 169, + "ctxt": 0 + }, + "callee": { + "type": "MemberExpression", + "span": { + "start": 121, + "end": 167, + "ctxt": 0 + }, + "object": { + "type": "NewExpression", + "span": { + "start": 121, + "end": 151, + "ctxt": 0 + }, + "callee": { + "type": "MemberExpression", + "span": { + "start": 125, + "end": 142, + "ctxt": 0 + }, + "object": { + "type": "Identifier", + "span": { + "start": 125, + "end": 129, + "ctxt": 0 + }, + "value": "Intl", + "optional": false + }, + "property": { + "type": "Identifier", + "span": { + "start": 130, + "end": 142, + "ctxt": 0 + }, + "value": "NumberFormat", + "optional": false + } + }, + "arguments": [ + { + "spread": null, + "expression": { + "type": "StringLiteral", + "span": { + "start": 143, + "end": 150, + "ctxt": 0 + }, + "value": "en-NZ", + "raw": "'en-NZ'" + } + } + ], + "typeArguments": null + }, + "property": { + "type": "Identifier", + "span": { + "start": 152, + "end": 167, + "ctxt": 0 + }, + "value": "resolvedOptions", + "optional": false + } + }, + "arguments": [], + "typeArguments": null + }, + "definite": false + } + ] + }, + { + "type": "ExpressionStatement", + "span": { + "start": 189, + "end": 224, + "ctxt": 0 + }, + "expression": { + "type": "NewExpression", + "span": { + "start": 189, + "end": 223, + "ctxt": 0 + }, + "callee": { + "type": "MemberExpression", + "span": { + "start": 193, + "end": 210, + "ctxt": 0 + }, + "object": { + "type": "Identifier", + "span": { + "start": 193, + "end": 197, + "ctxt": 0 + }, + "value": "Intl", + "optional": false + }, + "property": { + "type": "Identifier", + "span": { + "start": 198, + "end": 210, + "ctxt": 0 + }, + "value": "NumberFormat", + "optional": false + } + }, + "arguments": [ + { + "spread": null, + "expression": { + "type": "StringLiteral", + "span": { + "start": 211, + "end": 218, + "ctxt": 0 + }, + "value": "en-NZ", + "raw": "'en-NZ'" + } + }, + { + "spread": null, + "expression": { + "type": "ObjectExpression", + "span": { + "start": 220, + "end": 222, + "ctxt": 0 + }, + "properties": [] + } + } + ], + "typeArguments": null + } + }, + { + "type": "ExpressionStatement", + "span": { + "start": 255, + "end": 315, + "ctxt": 0 + }, + "expression": { + "type": "NewExpression", + "span": { + "start": 255, + "end": 314, + "ctxt": 0 + }, + "callee": { + "type": "MemberExpression", + "span": { + "start": 259, + "end": 276, + "ctxt": 0 + }, + "object": { + "type": "Identifier", + "span": { + "start": 259, + "end": 263, + "ctxt": 0 + }, + "value": "Intl", + "optional": false + }, + "property": { + "type": "Identifier", + "span": { + "start": 264, + "end": 276, + "ctxt": 0 + }, + "value": "NumberFormat", + "optional": false + } + }, + "arguments": [ + { + "spread": null, + "expression": { + "type": "StringLiteral", + "span": { + "start": 277, + "end": 284, + "ctxt": 0 + }, + "value": "en-NZ", + "raw": "'en-NZ'" + } + }, + { + "spread": null, + "expression": { + "type": "ObjectExpression", + "span": { + "start": 286, + "end": 313, + "ctxt": 0 + }, + "properties": [ + { + "type": "KeyValueProperty", + "key": { + "type": "Identifier", + "span": { + "start": 288, + "end": 303, + "ctxt": 0 + }, + "value": "numberingSystem", + "optional": false + }, + "value": { + "type": "StringLiteral", + "span": { + "start": 305, + "end": 311, + "ctxt": 0 + }, + "value": "arab", + "raw": "'arab'" + } + } + ] + } + } + ], + "typeArguments": null + } + }, + { + "type": "VariableDeclaration", + "span": { + "start": 329, + "end": 481, + "ctxt": 0 + }, + "kind": "const", + "declare": false, + "declarations": [ + { + "type": "VariableDeclarator", + "span": { + "start": 335, + "end": 480, + "ctxt": 0 + }, + "id": { + "type": "ObjectPattern", + "span": { + "start": 335, + "end": 361, + "ctxt": 0 + }, + "properties": [ + { + "type": "AssignmentPatternProperty", + "span": { + "start": 337, + "end": 345, + "ctxt": 0 + }, + "key": { + "type": "Identifier", + "span": { + "start": 337, + "end": 345, + "ctxt": 0 + }, + "value": "currency", + "optional": false, + "typeAnnotation": null + }, + "value": null + }, + { + "type": "AssignmentPatternProperty", + "span": { + "start": 347, + "end": 359, + "ctxt": 0 + }, + "key": { + "type": "Identifier", + "span": { + "start": 347, + "end": 359, + "ctxt": 0 + }, + "value": "currencySign", + "optional": false, + "typeAnnotation": null + }, + "value": null + } + ], + "optional": false, + "typeAnnotation": null + }, + "init": { + "type": "CallExpression", + "span": { + "start": 364, + "end": 480, + "ctxt": 0 + }, + "callee": { + "type": "MemberExpression", + "span": { + "start": 364, + "end": 478, + "ctxt": 0 + }, + "object": { + "type": "NewExpression", + "span": { + "start": 364, + "end": 462, + "ctxt": 0 + }, + "callee": { + "type": "MemberExpression", + "span": { + "start": 368, + "end": 385, + "ctxt": 0 + }, + "object": { + "type": "Identifier", + "span": { + "start": 368, + "end": 372, + "ctxt": 0 + }, + "value": "Intl", + "optional": false + }, + "property": { + "type": "Identifier", + "span": { + "start": 373, + "end": 385, + "ctxt": 0 + }, + "value": "NumberFormat", + "optional": false + } + }, + "arguments": [ + { + "spread": null, + "expression": { + "type": "StringLiteral", + "span": { + "start": 386, + "end": 393, + "ctxt": 0 + }, + "value": "en-NZ", + "raw": "'en-NZ'" + } + }, + { + "spread": null, + "expression": { + "type": "ObjectExpression", + "span": { + "start": 395, + "end": 461, + "ctxt": 0 + }, + "properties": [ + { + "type": "KeyValueProperty", + "key": { + "type": "Identifier", + "span": { + "start": 397, + "end": 402, + "ctxt": 0 + }, + "value": "style", + "optional": false + }, + "value": { + "type": "StringLiteral", + "span": { + "start": 404, + "end": 414, + "ctxt": 0 + }, + "value": "currency", + "raw": "'currency'" + } + }, + { + "type": "KeyValueProperty", + "key": { + "type": "Identifier", + "span": { + "start": 416, + "end": 424, + "ctxt": 0 + }, + "value": "currency", + "optional": false + }, + "value": { + "type": "StringLiteral", + "span": { + "start": 426, + "end": 431, + "ctxt": 0 + }, + "value": "NZD", + "raw": "'NZD'" + } + }, + { + "type": "KeyValueProperty", + "key": { + "type": "Identifier", + "span": { + "start": 433, + "end": 445, + "ctxt": 0 + }, + "value": "currencySign", + "optional": false + }, + "value": { + "type": "StringLiteral", + "span": { + "start": 447, + "end": 459, + "ctxt": 0 + }, + "value": "accounting", + "raw": "'accounting'" + } + } + ] + } + } + ], + "typeArguments": null + }, + "property": { + "type": "Identifier", + "span": { + "start": 463, + "end": 478, + "ctxt": 0 + }, + "value": "resolvedOptions", + "optional": false + } + }, + "arguments": [], + "typeArguments": null + }, + "definite": false + } + ] + }, + { + "type": "VariableDeclaration", + "span": { + "start": 492, + "end": 631, + "ctxt": 0 + }, + "kind": "const", + "declare": false, + "declarations": [ + { + "type": "VariableDeclarator", + "span": { + "start": 498, + "end": 630, + "ctxt": 0 + }, + "id": { + "type": "ObjectPattern", + "span": { + "start": 498, + "end": 519, + "ctxt": 0 + }, + "properties": [ + { + "type": "AssignmentPatternProperty", + "span": { + "start": 500, + "end": 504, + "ctxt": 0 + }, + "key": { + "type": "Identifier", + "span": { + "start": 500, + "end": 504, + "ctxt": 0 + }, + "value": "unit", + "optional": false, + "typeAnnotation": null + }, + "value": null + }, + { + "type": "AssignmentPatternProperty", + "span": { + "start": 506, + "end": 517, + "ctxt": 0 + }, + "key": { + "type": "Identifier", + "span": { + "start": 506, + "end": 517, + "ctxt": 0 + }, + "value": "unitDisplay", + "optional": false, + "typeAnnotation": null + }, + "value": null + } + ], + "optional": false, + "typeAnnotation": null + }, + "init": { + "type": "CallExpression", + "span": { + "start": 522, + "end": 630, + "ctxt": 0 + }, + "callee": { + "type": "MemberExpression", + "span": { + "start": 522, + "end": 628, + "ctxt": 0 + }, + "object": { + "type": "NewExpression", + "span": { + "start": 522, + "end": 612, + "ctxt": 0 + }, + "callee": { + "type": "MemberExpression", + "span": { + "start": 526, + "end": 543, + "ctxt": 0 + }, + "object": { + "type": "Identifier", + "span": { + "start": 526, + "end": 530, + "ctxt": 0 + }, + "value": "Intl", + "optional": false + }, + "property": { + "type": "Identifier", + "span": { + "start": 531, + "end": 543, + "ctxt": 0 + }, + "value": "NumberFormat", + "optional": false + } + }, + "arguments": [ + { + "spread": null, + "expression": { + "type": "StringLiteral", + "span": { + "start": 544, + "end": 551, + "ctxt": 0 + }, + "value": "en-NZ", + "raw": "'en-NZ'" + } + }, + { + "spread": null, + "expression": { + "type": "ObjectExpression", + "span": { + "start": 553, + "end": 611, + "ctxt": 0 + }, + "properties": [ + { + "type": "KeyValueProperty", + "key": { + "type": "Identifier", + "span": { + "start": 555, + "end": 560, + "ctxt": 0 + }, + "value": "style", + "optional": false + }, + "value": { + "type": "StringLiteral", + "span": { + "start": 562, + "end": 568, + "ctxt": 0 + }, + "value": "unit", + "raw": "'unit'" + } + }, + { + "type": "KeyValueProperty", + "key": { + "type": "Identifier", + "span": { + "start": 570, + "end": 574, + "ctxt": 0 + }, + "value": "unit", + "optional": false + }, + "value": { + "type": "StringLiteral", + "span": { + "start": 576, + "end": 586, + "ctxt": 0 + }, + "value": "kilogram", + "raw": "'kilogram'" + } + }, + { + "type": "KeyValueProperty", + "key": { + "type": "Identifier", + "span": { + "start": 588, + "end": 599, + "ctxt": 0 + }, + "value": "unitDisplay", + "optional": false + }, + "value": { + "type": "StringLiteral", + "span": { + "start": 601, + "end": 609, + "ctxt": 0 + }, + "value": "narrow", + "raw": "'narrow'" + } + } + ] + } + } + ], + "typeArguments": null + }, + "property": { + "type": "Identifier", + "span": { + "start": 613, + "end": 628, + "ctxt": 0 + }, + "value": "resolvedOptions", + "optional": false + } + }, + "arguments": [], + "typeArguments": null + }, + "definite": false + } + ] + }, + { + "type": "VariableDeclaration", + "span": { + "start": 644, + "end": 769, + "ctxt": 0 + }, + "kind": "const", + "declare": false, + "declarations": [ + { + "type": "VariableDeclarator", + "span": { + "start": 650, + "end": 768, + "ctxt": 0 + }, + "id": { + "type": "ObjectPattern", + "span": { + "start": 650, + "end": 668, + "ctxt": 0 + }, + "properties": [ + { + "type": "AssignmentPatternProperty", + "span": { + "start": 652, + "end": 666, + "ctxt": 0 + }, + "key": { + "type": "Identifier", + "span": { + "start": 652, + "end": 666, + "ctxt": 0 + }, + "value": "compactDisplay", + "optional": false, + "typeAnnotation": null + }, + "value": null + } + ], + "optional": false, + "typeAnnotation": null + }, + "init": { + "type": "CallExpression", + "span": { + "start": 671, + "end": 768, + "ctxt": 0 + }, + "callee": { + "type": "MemberExpression", + "span": { + "start": 671, + "end": 766, + "ctxt": 0 + }, + "object": { + "type": "NewExpression", + "span": { + "start": 671, + "end": 750, + "ctxt": 0 + }, + "callee": { + "type": "MemberExpression", + "span": { + "start": 675, + "end": 692, + "ctxt": 0 + }, + "object": { + "type": "Identifier", + "span": { + "start": 675, + "end": 679, + "ctxt": 0 + }, + "value": "Intl", + "optional": false + }, + "property": { + "type": "Identifier", + "span": { + "start": 680, + "end": 692, + "ctxt": 0 + }, + "value": "NumberFormat", + "optional": false + } + }, + "arguments": [ + { + "spread": null, + "expression": { + "type": "StringLiteral", + "span": { + "start": 693, + "end": 700, + "ctxt": 0 + }, + "value": "en-NZ", + "raw": "'en-NZ'" + } + }, + { + "spread": null, + "expression": { + "type": "ObjectExpression", + "span": { + "start": 702, + "end": 749, + "ctxt": 0 + }, + "properties": [ + { + "type": "KeyValueProperty", + "key": { + "type": "Identifier", + "span": { + "start": 704, + "end": 712, + "ctxt": 0 + }, + "value": "notation", + "optional": false + }, + "value": { + "type": "StringLiteral", + "span": { + "start": 714, + "end": 723, + "ctxt": 0 + }, + "value": "compact", + "raw": "'compact'" + } + }, + { + "type": "KeyValueProperty", + "key": { + "type": "Identifier", + "span": { + "start": 725, + "end": 739, + "ctxt": 0 + }, + "value": "compactDisplay", + "optional": false + }, + "value": { + "type": "StringLiteral", + "span": { + "start": 741, + "end": 747, + "ctxt": 0 + }, + "value": "long", + "raw": "'long'" + } + } + ] + } + } + ], + "typeArguments": null + }, + "property": { + "type": "Identifier", + "span": { + "start": 751, + "end": 766, + "ctxt": 0 + }, + "value": "resolvedOptions", + "optional": false + } + }, + "arguments": [], + "typeArguments": null + }, + "definite": false + } + ] + }, + { + "type": "ExpressionStatement", + "span": { + "start": 787, + "end": 845, + "ctxt": 0 + }, + "expression": { + "type": "NewExpression", + "span": { + "start": 787, + "end": 844, + "ctxt": 0 + }, + "callee": { + "type": "MemberExpression", + "span": { + "start": 791, + "end": 808, + "ctxt": 0 + }, + "object": { + "type": "Identifier", + "span": { + "start": 791, + "end": 795, + "ctxt": 0 + }, + "value": "Intl", + "optional": false + }, + "property": { + "type": "Identifier", + "span": { + "start": 796, + "end": 808, + "ctxt": 0 + }, + "value": "NumberFormat", + "optional": false + } + }, + "arguments": [ + { + "spread": null, + "expression": { + "type": "StringLiteral", + "span": { + "start": 809, + "end": 816, + "ctxt": 0 + }, + "value": "en-NZ", + "raw": "'en-NZ'" + } + }, + { + "spread": null, + "expression": { + "type": "ObjectExpression", + "span": { + "start": 818, + "end": 843, + "ctxt": 0 + }, + "properties": [ + { + "type": "KeyValueProperty", + "key": { + "type": "Identifier", + "span": { + "start": 820, + "end": 831, + "ctxt": 0 + }, + "value": "signDisplay", + "optional": false + }, + "value": { + "type": "StringLiteral", + "span": { + "start": 833, + "end": 841, + "ctxt": 0 + }, + "value": "always", + "raw": "'always'" + } + } + ] + } + } + ], + "typeArguments": null + } + }, + { + "type": "VariableDeclaration", + "span": { + "start": 889, + "end": 966, + "ctxt": 0 + }, + "kind": "const", + "declare": false, + "declarations": [ + { + "type": "VariableDeclarator", + "span": { + "start": 895, + "end": 965, + "ctxt": 0 + }, + "id": { + "type": "Identifier", + "span": { + "start": 895, + "end": 900, + "ctxt": 0 + }, + "value": "types", + "optional": false, + "typeAnnotation": { + "type": "TsTypeAnnotation", + "span": { + "start": 900, + "end": 930, + "ctxt": 0 + }, + "typeAnnotation": { + "type": "TsArrayType", + "span": { + "start": 902, + "end": 930, + "ctxt": 0 + }, + "elemType": { + "type": "TsTypeReference", + "span": { + "start": 902, + "end": 928, + "ctxt": 0 + }, + "typeName": { + "type": "TsQualifiedName", + "left": { + "type": "Identifier", + "span": { + "start": 902, + "end": 906, + "ctxt": 0 + }, + "value": "Intl", + "optional": false + }, + "right": { + "type": "Identifier", + "span": { + "start": 907, + "end": 928, + "ctxt": 0 + }, + "value": "NumberFormatPartTypes", + "optional": false + } + }, + "typeParams": null + } + } + } + }, + "init": { + "type": "ArrayExpression", + "span": { + "start": 933, + "end": 965, + "ctxt": 0 + }, + "elements": [ + { + "spread": null, + "expression": { + "type": "StringLiteral", + "span": { + "start": 935, + "end": 944, + "ctxt": 0 + }, + "value": "compact", + "raw": "'compact'" + } + }, + { + "spread": null, + "expression": { + "type": "StringLiteral", + "span": { + "start": 946, + "end": 952, + "ctxt": 0 + }, + "value": "unit", + "raw": "'unit'" + } + }, + { + "spread": null, + "expression": { + "type": "StringLiteral", + "span": { + "start": 954, + "end": 963, + "ctxt": 0 + }, + "value": "unknown", + "raw": "'unknown'" + } + } + ] + }, + "definite": false + } + ] + } + ], + "interpreter": null +} diff --git a/crates/swc_ecma_parser/tests/tsc/intlNumberFormatES2020.ts b/crates/swc_ecma_parser/tests/tsc/intlNumberFormatES2020.ts new file mode 100644 index 000000000000..a69160c246a0 --- /dev/null +++ b/crates/swc_ecma_parser/tests/tsc/intlNumberFormatES2020.ts @@ -0,0 +1,26 @@ +// @target: es2020 +// @strict: true + +// New/updated resolved options in ES2020 +const { notation, style, signDisplay } = new Intl.NumberFormat('en-NZ').resolvedOptions(); + +// Empty options +new Intl.NumberFormat('en-NZ', {}); + +// Override numbering system +new Intl.NumberFormat('en-NZ', { numberingSystem: 'arab' }); + +// Currency +const { currency, currencySign } = new Intl.NumberFormat('en-NZ', { style: 'currency', currency: 'NZD', currencySign: 'accounting' }).resolvedOptions(); + +// Units +const { unit, unitDisplay } = new Intl.NumberFormat('en-NZ', { style: 'unit', unit: 'kilogram', unitDisplay: 'narrow' }).resolvedOptions(); + +// Compact +const { compactDisplay } = new Intl.NumberFormat('en-NZ', { notation: 'compact', compactDisplay: 'long' }).resolvedOptions(); + +// Sign display +new Intl.NumberFormat('en-NZ', { signDisplay: 'always' }); + +// New additions to NumberFormatPartTypes +const types: Intl.NumberFormatPartTypes[] = [ 'compact', 'unit', 'unknown' ]; diff --git a/crates/swc_ecma_parser/tests/tsc/intlNumberFormatES2023.json b/crates/swc_ecma_parser/tests/tsc/intlNumberFormatES2023.json new file mode 100644 index 000000000000..95185ce4dd90 --- /dev/null +++ b/crates/swc_ecma_parser/tests/tsc/intlNumberFormatES2023.json @@ -0,0 +1,2064 @@ +{ + "type": "Script", + "span": { + "start": 149, + "end": 1442, + "ctxt": 0 + }, + "body": [ + { + "type": "VariableDeclaration", + "span": { + "start": 149, + "end": 295, + "ctxt": 0 + }, + "kind": "const", + "declare": false, + "declarations": [ + { + "type": "VariableDeclarator", + "span": { + "start": 155, + "end": 294, + "ctxt": 0 + }, + "id": { + "type": "ObjectPattern", + "span": { + "start": 155, + "end": 242, + "ctxt": 0 + }, + "properties": [ + { + "type": "AssignmentPatternProperty", + "span": { + "start": 157, + "end": 173, + "ctxt": 0 + }, + "key": { + "type": "Identifier", + "span": { + "start": 157, + "end": 173, + "ctxt": 0 + }, + "value": "roundingPriority", + "optional": false, + "typeAnnotation": null + }, + "value": null + }, + { + "type": "AssignmentPatternProperty", + "span": { + "start": 175, + "end": 187, + "ctxt": 0 + }, + "key": { + "type": "Identifier", + "span": { + "start": 175, + "end": 187, + "ctxt": 0 + }, + "value": "roundingMode", + "optional": false, + "typeAnnotation": null + }, + "value": null + }, + { + "type": "AssignmentPatternProperty", + "span": { + "start": 189, + "end": 206, + "ctxt": 0 + }, + "key": { + "type": "Identifier", + "span": { + "start": 189, + "end": 206, + "ctxt": 0 + }, + "value": "roundingIncrement", + "optional": false, + "typeAnnotation": null + }, + "value": null + }, + { + "type": "AssignmentPatternProperty", + "span": { + "start": 208, + "end": 227, + "ctxt": 0 + }, + "key": { + "type": "Identifier", + "span": { + "start": 208, + "end": 227, + "ctxt": 0 + }, + "value": "trailingZeroDisplay", + "optional": false, + "typeAnnotation": null + }, + "value": null + }, + { + "type": "AssignmentPatternProperty", + "span": { + "start": 229, + "end": 240, + "ctxt": 0 + }, + "key": { + "type": "Identifier", + "span": { + "start": 229, + "end": 240, + "ctxt": 0 + }, + "value": "useGrouping", + "optional": false, + "typeAnnotation": null + }, + "value": null + } + ], + "optional": false, + "typeAnnotation": null + }, + "init": { + "type": "CallExpression", + "span": { + "start": 246, + "end": 294, + "ctxt": 0 + }, + "callee": { + "type": "MemberExpression", + "span": { + "start": 246, + "end": 292, + "ctxt": 0 + }, + "object": { + "type": "NewExpression", + "span": { + "start": 246, + "end": 276, + "ctxt": 0 + }, + "callee": { + "type": "MemberExpression", + "span": { + "start": 250, + "end": 267, + "ctxt": 0 + }, + "object": { + "type": "Identifier", + "span": { + "start": 250, + "end": 254, + "ctxt": 0 + }, + "value": "Intl", + "optional": false + }, + "property": { + "type": "Identifier", + "span": { + "start": 255, + "end": 267, + "ctxt": 0 + }, + "value": "NumberFormat", + "optional": false + } + }, + "arguments": [ + { + "spread": null, + "expression": { + "type": "StringLiteral", + "span": { + "start": 268, + "end": 275, + "ctxt": 0 + }, + "value": "en-GB", + "raw": "'en-GB'" + } + } + ], + "typeArguments": null + }, + "property": { + "type": "Identifier", + "span": { + "start": 277, + "end": 292, + "ctxt": 0 + }, + "value": "resolvedOptions", + "optional": false + } + }, + "arguments": [], + "typeArguments": null + }, + "definite": false + } + ] + }, + { + "type": "ExpressionStatement", + "span": { + "start": 314, + "end": 349, + "ctxt": 0 + }, + "expression": { + "type": "NewExpression", + "span": { + "start": 314, + "end": 348, + "ctxt": 0 + }, + "callee": { + "type": "MemberExpression", + "span": { + "start": 318, + "end": 335, + "ctxt": 0 + }, + "object": { + "type": "Identifier", + "span": { + "start": 318, + "end": 322, + "ctxt": 0 + }, + "value": "Intl", + "optional": false + }, + "property": { + "type": "Identifier", + "span": { + "start": 323, + "end": 335, + "ctxt": 0 + }, + "value": "NumberFormat", + "optional": false + } + }, + "arguments": [ + { + "spread": null, + "expression": { + "type": "StringLiteral", + "span": { + "start": 336, + "end": 343, + "ctxt": 0 + }, + "value": "en-GB", + "raw": "'en-GB'" + } + }, + { + "spread": null, + "expression": { + "type": "ObjectExpression", + "span": { + "start": 345, + "end": 347, + "ctxt": 0 + }, + "properties": [] + } + } + ], + "typeArguments": null + } + }, + { + "type": "ExpressionStatement", + "span": { + "start": 363, + "end": 480, + "ctxt": 0 + }, + "expression": { + "type": "NewExpression", + "span": { + "start": 363, + "end": 479, + "ctxt": 0 + }, + "callee": { + "type": "MemberExpression", + "span": { + "start": 367, + "end": 384, + "ctxt": 0 + }, + "object": { + "type": "Identifier", + "span": { + "start": 367, + "end": 371, + "ctxt": 0 + }, + "value": "Intl", + "optional": false + }, + "property": { + "type": "Identifier", + "span": { + "start": 372, + "end": 384, + "ctxt": 0 + }, + "value": "NumberFormat", + "optional": false + } + }, + "arguments": [ + { + "spread": null, + "expression": { + "type": "StringLiteral", + "span": { + "start": 385, + "end": 392, + "ctxt": 0 + }, + "value": "en-GB", + "raw": "'en-GB'" + } + }, + { + "spread": null, + "expression": { + "type": "ObjectExpression", + "span": { + "start": 394, + "end": 478, + "ctxt": 0 + }, + "properties": [ + { + "type": "KeyValueProperty", + "key": { + "type": "Identifier", + "span": { + "start": 396, + "end": 412, + "ctxt": 0 + }, + "value": "roundingPriority", + "optional": false + }, + "value": { + "type": "StringLiteral", + "span": { + "start": 414, + "end": 429, + "ctxt": 0 + }, + "value": "lessPrecision", + "raw": "'lessPrecision'" + } + }, + { + "type": "KeyValueProperty", + "key": { + "type": "Identifier", + "span": { + "start": 431, + "end": 448, + "ctxt": 0 + }, + "value": "roundingIncrement", + "optional": false + }, + "value": { + "type": "NumericLiteral", + "span": { + "start": 450, + "end": 453, + "ctxt": 0 + }, + "value": 100.0, + "raw": "100" + } + }, + { + "type": "KeyValueProperty", + "key": { + "type": "Identifier", + "span": { + "start": 455, + "end": 467, + "ctxt": 0 + }, + "value": "roundingMode", + "optional": false + }, + "value": { + "type": "StringLiteral", + "span": { + "start": 469, + "end": 476, + "ctxt": 0 + }, + "value": "trunc", + "raw": "'trunc'" + } + } + ] + } + } + ], + "typeArguments": null + } + }, + { + "type": "VariableDeclaration", + "span": { + "start": 508, + "end": 610, + "ctxt": 0 + }, + "kind": "const", + "declare": false, + "declarations": [ + { + "type": "VariableDeclarator", + "span": { + "start": 514, + "end": 609, + "ctxt": 0 + }, + "id": { + "type": "ObjectPattern", + "span": { + "start": 514, + "end": 529, + "ctxt": 0 + }, + "properties": [ + { + "type": "AssignmentPatternProperty", + "span": { + "start": 516, + "end": 527, + "ctxt": 0 + }, + "key": { + "type": "Identifier", + "span": { + "start": 516, + "end": 527, + "ctxt": 0 + }, + "value": "signDisplay", + "optional": false, + "typeAnnotation": null + }, + "value": null + } + ], + "optional": false, + "typeAnnotation": null + }, + "init": { + "type": "CallExpression", + "span": { + "start": 532, + "end": 609, + "ctxt": 0 + }, + "callee": { + "type": "MemberExpression", + "span": { + "start": 532, + "end": 607, + "ctxt": 0 + }, + "object": { + "type": "NewExpression", + "span": { + "start": 532, + "end": 591, + "ctxt": 0 + }, + "callee": { + "type": "MemberExpression", + "span": { + "start": 536, + "end": 553, + "ctxt": 0 + }, + "object": { + "type": "Identifier", + "span": { + "start": 536, + "end": 540, + "ctxt": 0 + }, + "value": "Intl", + "optional": false + }, + "property": { + "type": "Identifier", + "span": { + "start": 541, + "end": 553, + "ctxt": 0 + }, + "value": "NumberFormat", + "optional": false + } + }, + "arguments": [ + { + "spread": null, + "expression": { + "type": "StringLiteral", + "span": { + "start": 554, + "end": 561, + "ctxt": 0 + }, + "value": "en-GB", + "raw": "'en-GB'" + } + }, + { + "spread": null, + "expression": { + "type": "ObjectExpression", + "span": { + "start": 563, + "end": 590, + "ctxt": 0 + }, + "properties": [ + { + "type": "KeyValueProperty", + "key": { + "type": "Identifier", + "span": { + "start": 565, + "end": 576, + "ctxt": 0 + }, + "value": "signDisplay", + "optional": false + }, + "value": { + "type": "StringLiteral", + "span": { + "start": 578, + "end": 588, + "ctxt": 0 + }, + "value": "negative", + "raw": "'negative'" + } + } + ] + } + } + ], + "typeArguments": null + }, + "property": { + "type": "Identifier", + "span": { + "start": 592, + "end": 607, + "ctxt": 0 + }, + "value": "resolvedOptions", + "optional": false + } + }, + "arguments": [], + "typeArguments": null + }, + "definite": false + } + ] + }, + { + "type": "ExpressionStatement", + "span": { + "start": 638, + "end": 692, + "ctxt": 0 + }, + "expression": { + "type": "NewExpression", + "span": { + "start": 638, + "end": 691, + "ctxt": 0 + }, + "callee": { + "type": "MemberExpression", + "span": { + "start": 642, + "end": 659, + "ctxt": 0 + }, + "object": { + "type": "Identifier", + "span": { + "start": 642, + "end": 646, + "ctxt": 0 + }, + "value": "Intl", + "optional": false + }, + "property": { + "type": "Identifier", + "span": { + "start": 647, + "end": 659, + "ctxt": 0 + }, + "value": "NumberFormat", + "optional": false + } + }, + "arguments": [ + { + "spread": null, + "expression": { + "type": "StringLiteral", + "span": { + "start": 660, + "end": 667, + "ctxt": 0 + }, + "value": "en-GB", + "raw": "'en-GB'" + } + }, + { + "spread": null, + "expression": { + "type": "ObjectExpression", + "span": { + "start": 669, + "end": 690, + "ctxt": 0 + }, + "properties": [ + { + "type": "KeyValueProperty", + "key": { + "type": "Identifier", + "span": { + "start": 671, + "end": 682, + "ctxt": 0 + }, + "value": "useGrouping", + "optional": false + }, + "value": { + "type": "BooleanLiteral", + "span": { + "start": 684, + "end": 688, + "ctxt": 0 + }, + "value": true + } + } + ] + } + } + ], + "typeArguments": null + } + }, + { + "type": "ExpressionStatement", + "span": { + "start": 693, + "end": 749, + "ctxt": 0 + }, + "expression": { + "type": "NewExpression", + "span": { + "start": 693, + "end": 748, + "ctxt": 0 + }, + "callee": { + "type": "MemberExpression", + "span": { + "start": 697, + "end": 714, + "ctxt": 0 + }, + "object": { + "type": "Identifier", + "span": { + "start": 697, + "end": 701, + "ctxt": 0 + }, + "value": "Intl", + "optional": false + }, + "property": { + "type": "Identifier", + "span": { + "start": 702, + "end": 714, + "ctxt": 0 + }, + "value": "NumberFormat", + "optional": false + } + }, + "arguments": [ + { + "spread": null, + "expression": { + "type": "StringLiteral", + "span": { + "start": 715, + "end": 722, + "ctxt": 0 + }, + "value": "en-GB", + "raw": "'en-GB'" + } + }, + { + "spread": null, + "expression": { + "type": "ObjectExpression", + "span": { + "start": 724, + "end": 747, + "ctxt": 0 + }, + "properties": [ + { + "type": "KeyValueProperty", + "key": { + "type": "Identifier", + "span": { + "start": 726, + "end": 737, + "ctxt": 0 + }, + "value": "useGrouping", + "optional": false + }, + "value": { + "type": "StringLiteral", + "span": { + "start": 739, + "end": 745, + "ctxt": 0 + }, + "value": "true", + "raw": "'true'" + } + } + ] + } + } + ], + "typeArguments": null + } + }, + { + "type": "ExpressionStatement", + "span": { + "start": 750, + "end": 808, + "ctxt": 0 + }, + "expression": { + "type": "NewExpression", + "span": { + "start": 750, + "end": 807, + "ctxt": 0 + }, + "callee": { + "type": "MemberExpression", + "span": { + "start": 754, + "end": 771, + "ctxt": 0 + }, + "object": { + "type": "Identifier", + "span": { + "start": 754, + "end": 758, + "ctxt": 0 + }, + "value": "Intl", + "optional": false + }, + "property": { + "type": "Identifier", + "span": { + "start": 759, + "end": 771, + "ctxt": 0 + }, + "value": "NumberFormat", + "optional": false + } + }, + "arguments": [ + { + "spread": null, + "expression": { + "type": "StringLiteral", + "span": { + "start": 772, + "end": 779, + "ctxt": 0 + }, + "value": "en-GB", + "raw": "'en-GB'" + } + }, + { + "spread": null, + "expression": { + "type": "ObjectExpression", + "span": { + "start": 781, + "end": 806, + "ctxt": 0 + }, + "properties": [ + { + "type": "KeyValueProperty", + "key": { + "type": "Identifier", + "span": { + "start": 783, + "end": 794, + "ctxt": 0 + }, + "value": "useGrouping", + "optional": false + }, + "value": { + "type": "StringLiteral", + "span": { + "start": 796, + "end": 804, + "ctxt": 0 + }, + "value": "always", + "raw": "'always'" + } + } + ] + } + } + ], + "typeArguments": null + } + }, + { + "type": "ExpressionStatement", + "span": { + "start": 825, + "end": 877, + "ctxt": 0 + }, + "expression": { + "type": "CallExpression", + "span": { + "start": 825, + "end": 876, + "ctxt": 0 + }, + "callee": { + "type": "MemberExpression", + "span": { + "start": 825, + "end": 867, + "ctxt": 0 + }, + "object": { + "type": "NewExpression", + "span": { + "start": 825, + "end": 855, + "ctxt": 0 + }, + "callee": { + "type": "MemberExpression", + "span": { + "start": 829, + "end": 846, + "ctxt": 0 + }, + "object": { + "type": "Identifier", + "span": { + "start": 829, + "end": 833, + "ctxt": 0 + }, + "value": "Intl", + "optional": false + }, + "property": { + "type": "Identifier", + "span": { + "start": 834, + "end": 846, + "ctxt": 0 + }, + "value": "NumberFormat", + "optional": false + } + }, + "arguments": [ + { + "spread": null, + "expression": { + "type": "StringLiteral", + "span": { + "start": 847, + "end": 854, + "ctxt": 0 + }, + "value": "en-GB", + "raw": "'en-GB'" + } + } + ], + "typeArguments": null + }, + "property": { + "type": "Identifier", + "span": { + "start": 856, + "end": 867, + "ctxt": 0 + }, + "value": "formatRange", + "optional": false + } + }, + "arguments": [ + { + "spread": null, + "expression": { + "type": "NumericLiteral", + "span": { + "start": 868, + "end": 870, + "ctxt": 0 + }, + "value": 10.0, + "raw": "10" + } + }, + { + "spread": null, + "expression": { + "type": "NumericLiteral", + "span": { + "start": 872, + "end": 875, + "ctxt": 0 + }, + "value": 100.0, + "raw": "100" + } + } + ], + "typeArguments": null + } + }, + { + "type": "ExpressionStatement", + "span": { + "start": 878, + "end": 933, + "ctxt": 0 + }, + "expression": { + "type": "CallExpression", + "span": { + "start": 878, + "end": 932, + "ctxt": 0 + }, + "callee": { + "type": "MemberExpression", + "span": { + "start": 878, + "end": 920, + "ctxt": 0 + }, + "object": { + "type": "NewExpression", + "span": { + "start": 878, + "end": 908, + "ctxt": 0 + }, + "callee": { + "type": "MemberExpression", + "span": { + "start": 882, + "end": 899, + "ctxt": 0 + }, + "object": { + "type": "Identifier", + "span": { + "start": 882, + "end": 886, + "ctxt": 0 + }, + "value": "Intl", + "optional": false + }, + "property": { + "type": "Identifier", + "span": { + "start": 887, + "end": 899, + "ctxt": 0 + }, + "value": "NumberFormat", + "optional": false + } + }, + "arguments": [ + { + "spread": null, + "expression": { + "type": "StringLiteral", + "span": { + "start": 900, + "end": 907, + "ctxt": 0 + }, + "value": "en-GB", + "raw": "'en-GB'" + } + } + ], + "typeArguments": null + }, + "property": { + "type": "Identifier", + "span": { + "start": 909, + "end": 920, + "ctxt": 0 + }, + "value": "formatRange", + "optional": false + } + }, + "arguments": [ + { + "spread": null, + "expression": { + "type": "BigIntLiteral", + "span": { + "start": 921, + "end": 924, + "ctxt": 0 + }, + "value": [ + 1, + [ + 10 + ] + ], + "raw": "10n" + } + }, + { + "spread": null, + "expression": { + "type": "BigIntLiteral", + "span": { + "start": 926, + "end": 931, + "ctxt": 0 + }, + "value": [ + 1, + [ + 1000 + ] + ], + "raw": "1000n" + } + } + ], + "typeArguments": null + } + }, + { + "type": "ExpressionStatement", + "span": { + "start": 934, + "end": 997, + "ctxt": 0 + }, + "expression": { + "type": "MemberExpression", + "span": { + "start": 934, + "end": 996, + "ctxt": 0 + }, + "object": { + "type": "CallExpression", + "span": { + "start": 934, + "end": 993, + "ctxt": 0 + }, + "callee": { + "type": "MemberExpression", + "span": { + "start": 934, + "end": 983, + "ctxt": 0 + }, + "object": { + "type": "NewExpression", + "span": { + "start": 934, + "end": 964, + "ctxt": 0 + }, + "callee": { + "type": "MemberExpression", + "span": { + "start": 938, + "end": 955, + "ctxt": 0 + }, + "object": { + "type": "Identifier", + "span": { + "start": 938, + "end": 942, + "ctxt": 0 + }, + "value": "Intl", + "optional": false + }, + "property": { + "type": "Identifier", + "span": { + "start": 943, + "end": 955, + "ctxt": 0 + }, + "value": "NumberFormat", + "optional": false + } + }, + "arguments": [ + { + "spread": null, + "expression": { + "type": "StringLiteral", + "span": { + "start": 956, + "end": 963, + "ctxt": 0 + }, + "value": "en-GB", + "raw": "'en-GB'" + } + } + ], + "typeArguments": null + }, + "property": { + "type": "Identifier", + "span": { + "start": 965, + "end": 983, + "ctxt": 0 + }, + "value": "formatRangeToParts", + "optional": false + } + }, + "arguments": [ + { + "spread": null, + "expression": { + "type": "NumericLiteral", + "span": { + "start": 984, + "end": 986, + "ctxt": 0 + }, + "value": 10.0, + "raw": "10" + } + }, + { + "spread": null, + "expression": { + "type": "NumericLiteral", + "span": { + "start": 988, + "end": 992, + "ctxt": 0 + }, + "value": 1000.0, + "raw": "1000" + } + } + ], + "typeArguments": null + }, + "property": { + "type": "Computed", + "span": { + "start": 993, + "end": 996, + "ctxt": 0 + }, + "expression": { + "type": "NumericLiteral", + "span": { + "start": 994, + "end": 995, + "ctxt": 0 + }, + "value": 0.0, + "raw": "0" + } + } + } + }, + { + "type": "ExpressionStatement", + "span": { + "start": 998, + "end": 1063, + "ctxt": 0 + }, + "expression": { + "type": "MemberExpression", + "span": { + "start": 998, + "end": 1062, + "ctxt": 0 + }, + "object": { + "type": "CallExpression", + "span": { + "start": 998, + "end": 1059, + "ctxt": 0 + }, + "callee": { + "type": "MemberExpression", + "span": { + "start": 998, + "end": 1047, + "ctxt": 0 + }, + "object": { + "type": "NewExpression", + "span": { + "start": 998, + "end": 1028, + "ctxt": 0 + }, + "callee": { + "type": "MemberExpression", + "span": { + "start": 1002, + "end": 1019, + "ctxt": 0 + }, + "object": { + "type": "Identifier", + "span": { + "start": 1002, + "end": 1006, + "ctxt": 0 + }, + "value": "Intl", + "optional": false + }, + "property": { + "type": "Identifier", + "span": { + "start": 1007, + "end": 1019, + "ctxt": 0 + }, + "value": "NumberFormat", + "optional": false + } + }, + "arguments": [ + { + "spread": null, + "expression": { + "type": "StringLiteral", + "span": { + "start": 1020, + "end": 1027, + "ctxt": 0 + }, + "value": "en-GB", + "raw": "'en-GB'" + } + } + ], + "typeArguments": null + }, + "property": { + "type": "Identifier", + "span": { + "start": 1029, + "end": 1047, + "ctxt": 0 + }, + "value": "formatRangeToParts", + "optional": false + } + }, + "arguments": [ + { + "spread": null, + "expression": { + "type": "BigIntLiteral", + "span": { + "start": 1048, + "end": 1051, + "ctxt": 0 + }, + "value": [ + 1, + [ + 10 + ] + ], + "raw": "10n" + } + }, + { + "spread": null, + "expression": { + "type": "BigIntLiteral", + "span": { + "start": 1053, + "end": 1058, + "ctxt": 0 + }, + "value": [ + 1, + [ + 1000 + ] + ], + "raw": "1000n" + } + } + ], + "typeArguments": null + }, + "property": { + "type": "Computed", + "span": { + "start": 1059, + "end": 1062, + "ctxt": 0 + }, + "expression": { + "type": "NumericLiteral", + "span": { + "start": 1060, + "end": 1061, + "ctxt": 0 + }, + "value": 0.0, + "raw": "0" + } + } + } + }, + { + "type": "ExpressionStatement", + "span": { + "start": 1105, + "end": 1155, + "ctxt": 0 + }, + "expression": { + "type": "CallExpression", + "span": { + "start": 1105, + "end": 1154, + "ctxt": 0 + }, + "callee": { + "type": "MemberExpression", + "span": { + "start": 1105, + "end": 1142, + "ctxt": 0 + }, + "object": { + "type": "NewExpression", + "span": { + "start": 1105, + "end": 1135, + "ctxt": 0 + }, + "callee": { + "type": "MemberExpression", + "span": { + "start": 1109, + "end": 1126, + "ctxt": 0 + }, + "object": { + "type": "Identifier", + "span": { + "start": 1109, + "end": 1113, + "ctxt": 0 + }, + "value": "Intl", + "optional": false + }, + "property": { + "type": "Identifier", + "span": { + "start": 1114, + "end": 1126, + "ctxt": 0 + }, + "value": "NumberFormat", + "optional": false + } + }, + "arguments": [ + { + "spread": null, + "expression": { + "type": "StringLiteral", + "span": { + "start": 1127, + "end": 1134, + "ctxt": 0 + }, + "value": "en-GB", + "raw": "'en-GB'" + } + } + ], + "typeArguments": null + }, + "property": { + "type": "Identifier", + "span": { + "start": 1136, + "end": 1142, + "ctxt": 0 + }, + "value": "format", + "optional": false + } + }, + "arguments": [ + { + "spread": null, + "expression": { + "type": "StringLiteral", + "span": { + "start": 1143, + "end": 1153, + "ctxt": 0 + }, + "value": "-12.3E-4", + "raw": "'-12.3E-4'" + } + } + ], + "typeArguments": null + } + }, + { + "type": "ExpressionStatement", + "span": { + "start": 1156, + "end": 1217, + "ctxt": 0 + }, + "expression": { + "type": "CallExpression", + "span": { + "start": 1156, + "end": 1216, + "ctxt": 0 + }, + "callee": { + "type": "MemberExpression", + "span": { + "start": 1156, + "end": 1198, + "ctxt": 0 + }, + "object": { + "type": "NewExpression", + "span": { + "start": 1156, + "end": 1186, + "ctxt": 0 + }, + "callee": { + "type": "MemberExpression", + "span": { + "start": 1160, + "end": 1177, + "ctxt": 0 + }, + "object": { + "type": "Identifier", + "span": { + "start": 1160, + "end": 1164, + "ctxt": 0 + }, + "value": "Intl", + "optional": false + }, + "property": { + "type": "Identifier", + "span": { + "start": 1165, + "end": 1177, + "ctxt": 0 + }, + "value": "NumberFormat", + "optional": false + } + }, + "arguments": [ + { + "spread": null, + "expression": { + "type": "StringLiteral", + "span": { + "start": 1178, + "end": 1185, + "ctxt": 0 + }, + "value": "en-GB", + "raw": "'en-GB'" + } + } + ], + "typeArguments": null + }, + "property": { + "type": "Identifier", + "span": { + "start": 1187, + "end": 1198, + "ctxt": 0 + }, + "value": "formatRange", + "optional": false + } + }, + "arguments": [ + { + "spread": null, + "expression": { + "type": "StringLiteral", + "span": { + "start": 1199, + "end": 1206, + "ctxt": 0 + }, + "value": "123.4", + "raw": "'123.4'" + } + }, + { + "spread": null, + "expression": { + "type": "StringLiteral", + "span": { + "start": 1208, + "end": 1215, + "ctxt": 0 + }, + "value": "567.8", + "raw": "'567.8'" + } + } + ], + "typeArguments": null + } + }, + { + "type": "ExpressionStatement", + "span": { + "start": 1218, + "end": 1287, + "ctxt": 0 + }, + "expression": { + "type": "CallExpression", + "span": { + "start": 1218, + "end": 1286, + "ctxt": 0 + }, + "callee": { + "type": "MemberExpression", + "span": { + "start": 1218, + "end": 1267, + "ctxt": 0 + }, + "object": { + "type": "NewExpression", + "span": { + "start": 1218, + "end": 1248, + "ctxt": 0 + }, + "callee": { + "type": "MemberExpression", + "span": { + "start": 1222, + "end": 1239, + "ctxt": 0 + }, + "object": { + "type": "Identifier", + "span": { + "start": 1222, + "end": 1226, + "ctxt": 0 + }, + "value": "Intl", + "optional": false + }, + "property": { + "type": "Identifier", + "span": { + "start": 1227, + "end": 1239, + "ctxt": 0 + }, + "value": "NumberFormat", + "optional": false + } + }, + "arguments": [ + { + "spread": null, + "expression": { + "type": "StringLiteral", + "span": { + "start": 1240, + "end": 1247, + "ctxt": 0 + }, + "value": "en-GB", + "raw": "'en-GB'" + } + } + ], + "typeArguments": null + }, + "property": { + "type": "Identifier", + "span": { + "start": 1249, + "end": 1267, + "ctxt": 0 + }, + "value": "formatRangeToParts", + "optional": false + } + }, + "arguments": [ + { + "spread": null, + "expression": { + "type": "StringLiteral", + "span": { + "start": 1268, + "end": 1276, + "ctxt": 0 + }, + "value": "123E-4", + "raw": "'123E-4'" + } + }, + { + "spread": null, + "expression": { + "type": "StringLiteral", + "span": { + "start": 1278, + "end": 1285, + "ctxt": 0 + }, + "value": "567E8", + "raw": "'567E8'" + } + } + ], + "typeArguments": null + } + }, + { + "type": "ExpressionStatement", + "span": { + "start": 1288, + "end": 1338, + "ctxt": 0 + }, + "expression": { + "type": "CallExpression", + "span": { + "start": 1288, + "end": 1337, + "ctxt": 0 + }, + "callee": { + "type": "MemberExpression", + "span": { + "start": 1288, + "end": 1325, + "ctxt": 0 + }, + "object": { + "type": "NewExpression", + "span": { + "start": 1288, + "end": 1318, + "ctxt": 0 + }, + "callee": { + "type": "MemberExpression", + "span": { + "start": 1292, + "end": 1309, + "ctxt": 0 + }, + "object": { + "type": "Identifier", + "span": { + "start": 1292, + "end": 1296, + "ctxt": 0 + }, + "value": "Intl", + "optional": false + }, + "property": { + "type": "Identifier", + "span": { + "start": 1297, + "end": 1309, + "ctxt": 0 + }, + "value": "NumberFormat", + "optional": false + } + }, + "arguments": [ + { + "spread": null, + "expression": { + "type": "StringLiteral", + "span": { + "start": 1310, + "end": 1317, + "ctxt": 0 + }, + "value": "en-GB", + "raw": "'en-GB'" + } + } + ], + "typeArguments": null + }, + "property": { + "type": "Identifier", + "span": { + "start": 1319, + "end": 1325, + "ctxt": 0 + }, + "value": "format", + "optional": false + } + }, + "arguments": [ + { + "spread": null, + "expression": { + "type": "StringLiteral", + "span": { + "start": 1326, + "end": 1336, + "ctxt": 0 + }, + "value": "Infinity", + "raw": "'Infinity'" + } + } + ], + "typeArguments": null + } + }, + { + "type": "ExpressionStatement", + "span": { + "start": 1339, + "end": 1390, + "ctxt": 0 + }, + "expression": { + "type": "CallExpression", + "span": { + "start": 1339, + "end": 1389, + "ctxt": 0 + }, + "callee": { + "type": "MemberExpression", + "span": { + "start": 1339, + "end": 1376, + "ctxt": 0 + }, + "object": { + "type": "NewExpression", + "span": { + "start": 1339, + "end": 1369, + "ctxt": 0 + }, + "callee": { + "type": "MemberExpression", + "span": { + "start": 1343, + "end": 1360, + "ctxt": 0 + }, + "object": { + "type": "Identifier", + "span": { + "start": 1343, + "end": 1347, + "ctxt": 0 + }, + "value": "Intl", + "optional": false + }, + "property": { + "type": "Identifier", + "span": { + "start": 1348, + "end": 1360, + "ctxt": 0 + }, + "value": "NumberFormat", + "optional": false + } + }, + "arguments": [ + { + "spread": null, + "expression": { + "type": "StringLiteral", + "span": { + "start": 1361, + "end": 1368, + "ctxt": 0 + }, + "value": "en-GB", + "raw": "'en-GB'" + } + } + ], + "typeArguments": null + }, + "property": { + "type": "Identifier", + "span": { + "start": 1370, + "end": 1376, + "ctxt": 0 + }, + "value": "format", + "optional": false + } + }, + "arguments": [ + { + "spread": null, + "expression": { + "type": "StringLiteral", + "span": { + "start": 1377, + "end": 1388, + "ctxt": 0 + }, + "value": "-Infinity", + "raw": "'-Infinity'" + } + } + ], + "typeArguments": null + } + }, + { + "type": "ExpressionStatement", + "span": { + "start": 1391, + "end": 1442, + "ctxt": 0 + }, + "expression": { + "type": "CallExpression", + "span": { + "start": 1391, + "end": 1441, + "ctxt": 0 + }, + "callee": { + "type": "MemberExpression", + "span": { + "start": 1391, + "end": 1428, + "ctxt": 0 + }, + "object": { + "type": "NewExpression", + "span": { + "start": 1391, + "end": 1421, + "ctxt": 0 + }, + "callee": { + "type": "MemberExpression", + "span": { + "start": 1395, + "end": 1412, + "ctxt": 0 + }, + "object": { + "type": "Identifier", + "span": { + "start": 1395, + "end": 1399, + "ctxt": 0 + }, + "value": "Intl", + "optional": false + }, + "property": { + "type": "Identifier", + "span": { + "start": 1400, + "end": 1412, + "ctxt": 0 + }, + "value": "NumberFormat", + "optional": false + } + }, + "arguments": [ + { + "spread": null, + "expression": { + "type": "StringLiteral", + "span": { + "start": 1413, + "end": 1420, + "ctxt": 0 + }, + "value": "en-GB", + "raw": "'en-GB'" + } + } + ], + "typeArguments": null + }, + "property": { + "type": "Identifier", + "span": { + "start": 1422, + "end": 1428, + "ctxt": 0 + }, + "value": "format", + "optional": false + } + }, + "arguments": [ + { + "spread": null, + "expression": { + "type": "StringLiteral", + "span": { + "start": 1429, + "end": 1440, + "ctxt": 0 + }, + "value": "+Infinity", + "raw": "'+Infinity'" + } + } + ], + "typeArguments": null + } + } + ], + "interpreter": null +} diff --git a/crates/swc_ecma_parser/tests/tsc/intlNumberFormatES2023.ts b/crates/swc_ecma_parser/tests/tsc/intlNumberFormatES2023.ts new file mode 100644 index 000000000000..fa6a7cf9804e --- /dev/null +++ b/crates/swc_ecma_parser/tests/tsc/intlNumberFormatES2023.ts @@ -0,0 +1,34 @@ +// @target: es2022 +// @lib: es2022,es2023.intl +// @strict: true + +// New / updated resolved options in ES2023, including type change for useGrouping +const { roundingPriority, roundingMode, roundingIncrement, trailingZeroDisplay, useGrouping } = new Intl.NumberFormat('en-GB').resolvedOptions(); + +// Empty options +new Intl.NumberFormat('en-GB', {}); + +// Rounding +new Intl.NumberFormat('en-GB', { roundingPriority: 'lessPrecision', roundingIncrement: 100, roundingMode: 'trunc' }); + +// Changes to signDisplay +const { signDisplay } = new Intl.NumberFormat('en-GB', { signDisplay: 'negative' }).resolvedOptions(); + +// Changes to useGrouping +new Intl.NumberFormat('en-GB', { useGrouping: true }); +new Intl.NumberFormat('en-GB', { useGrouping: 'true' }); +new Intl.NumberFormat('en-GB', { useGrouping: 'always' }); + +// formatRange +new Intl.NumberFormat('en-GB').formatRange(10, 100); +new Intl.NumberFormat('en-GB').formatRange(10n, 1000n); +new Intl.NumberFormat('en-GB').formatRangeToParts(10, 1000)[0]; +new Intl.NumberFormat('en-GB').formatRangeToParts(10n, 1000n)[0]; + +// Arbitrary-precision string arguments +new Intl.NumberFormat('en-GB').format('-12.3E-4'); +new Intl.NumberFormat('en-GB').formatRange('123.4', '567.8'); +new Intl.NumberFormat('en-GB').formatRangeToParts('123E-4', '567E8'); +new Intl.NumberFormat('en-GB').format('Infinity'); +new Intl.NumberFormat('en-GB').format('-Infinity'); +new Intl.NumberFormat('en-GB').format('+Infinity'); diff --git a/crates/swc_ecma_parser/tests/tsc/intlNumberFormatES5UseGrouping.json b/crates/swc_ecma_parser/tests/tsc/intlNumberFormatES5UseGrouping.json new file mode 100644 index 000000000000..77234ab309d7 --- /dev/null +++ b/crates/swc_ecma_parser/tests/tsc/intlNumberFormatES5UseGrouping.json @@ -0,0 +1,431 @@ +{ + "type": "Script", + "span": { + "start": 35, + "end": 312, + "ctxt": 0 + }, + "body": [ + { + "type": "ExpressionStatement", + "span": { + "start": 35, + "end": 89, + "ctxt": 0 + }, + "expression": { + "type": "NewExpression", + "span": { + "start": 35, + "end": 88, + "ctxt": 0 + }, + "callee": { + "type": "MemberExpression", + "span": { + "start": 39, + "end": 56, + "ctxt": 0 + }, + "object": { + "type": "Identifier", + "span": { + "start": 39, + "end": 43, + "ctxt": 0 + }, + "value": "Intl", + "optional": false + }, + "property": { + "type": "Identifier", + "span": { + "start": 44, + "end": 56, + "ctxt": 0 + }, + "value": "NumberFormat", + "optional": false + } + }, + "arguments": [ + { + "spread": null, + "expression": { + "type": "StringLiteral", + "span": { + "start": 57, + "end": 64, + "ctxt": 0 + }, + "value": "en-GB", + "raw": "'en-GB'" + } + }, + { + "spread": null, + "expression": { + "type": "ObjectExpression", + "span": { + "start": 66, + "end": 87, + "ctxt": 0 + }, + "properties": [ + { + "type": "KeyValueProperty", + "key": { + "type": "Identifier", + "span": { + "start": 68, + "end": 79, + "ctxt": 0 + }, + "value": "useGrouping", + "optional": false + }, + "value": { + "type": "BooleanLiteral", + "span": { + "start": 81, + "end": 85, + "ctxt": 0 + }, + "value": true + } + } + ] + } + } + ], + "typeArguments": null + } + }, + { + "type": "ExpressionStatement", + "span": { + "start": 90, + "end": 146, + "ctxt": 0 + }, + "expression": { + "type": "NewExpression", + "span": { + "start": 90, + "end": 145, + "ctxt": 0 + }, + "callee": { + "type": "MemberExpression", + "span": { + "start": 94, + "end": 111, + "ctxt": 0 + }, + "object": { + "type": "Identifier", + "span": { + "start": 94, + "end": 98, + "ctxt": 0 + }, + "value": "Intl", + "optional": false + }, + "property": { + "type": "Identifier", + "span": { + "start": 99, + "end": 111, + "ctxt": 0 + }, + "value": "NumberFormat", + "optional": false + } + }, + "arguments": [ + { + "spread": null, + "expression": { + "type": "StringLiteral", + "span": { + "start": 112, + "end": 119, + "ctxt": 0 + }, + "value": "en-GB", + "raw": "'en-GB'" + } + }, + { + "spread": null, + "expression": { + "type": "ObjectExpression", + "span": { + "start": 121, + "end": 144, + "ctxt": 0 + }, + "properties": [ + { + "type": "KeyValueProperty", + "key": { + "type": "Identifier", + "span": { + "start": 123, + "end": 134, + "ctxt": 0 + }, + "value": "useGrouping", + "optional": false + }, + "value": { + "type": "StringLiteral", + "span": { + "start": 136, + "end": 142, + "ctxt": 0 + }, + "value": "true", + "raw": "'true'" + } + } + ] + } + } + ], + "typeArguments": null + } + }, + { + "type": "ExpressionStatement", + "span": { + "start": 163, + "end": 221, + "ctxt": 0 + }, + "expression": { + "type": "NewExpression", + "span": { + "start": 163, + "end": 220, + "ctxt": 0 + }, + "callee": { + "type": "MemberExpression", + "span": { + "start": 167, + "end": 184, + "ctxt": 0 + }, + "object": { + "type": "Identifier", + "span": { + "start": 167, + "end": 171, + "ctxt": 0 + }, + "value": "Intl", + "optional": false + }, + "property": { + "type": "Identifier", + "span": { + "start": 172, + "end": 184, + "ctxt": 0 + }, + "value": "NumberFormat", + "optional": false + } + }, + "arguments": [ + { + "spread": null, + "expression": { + "type": "StringLiteral", + "span": { + "start": 185, + "end": 192, + "ctxt": 0 + }, + "value": "en-GB", + "raw": "'en-GB'" + } + }, + { + "spread": null, + "expression": { + "type": "ObjectExpression", + "span": { + "start": 194, + "end": 219, + "ctxt": 0 + }, + "properties": [ + { + "type": "KeyValueProperty", + "key": { + "type": "Identifier", + "span": { + "start": 196, + "end": 207, + "ctxt": 0 + }, + "value": "useGrouping", + "optional": false + }, + "value": { + "type": "StringLiteral", + "span": { + "start": 209, + "end": 217, + "ctxt": 0 + }, + "value": "always", + "raw": "'always'" + } + } + ] + } + } + ], + "typeArguments": null + } + }, + { + "type": "VariableDeclaration", + "span": { + "start": 239, + "end": 312, + "ctxt": 0 + }, + "kind": "const", + "declare": false, + "declarations": [ + { + "type": "VariableDeclarator", + "span": { + "start": 245, + "end": 311, + "ctxt": 0 + }, + "id": { + "type": "ObjectPattern", + "span": { + "start": 245, + "end": 260, + "ctxt": 0 + }, + "properties": [ + { + "type": "AssignmentPatternProperty", + "span": { + "start": 247, + "end": 258, + "ctxt": 0 + }, + "key": { + "type": "Identifier", + "span": { + "start": 247, + "end": 258, + "ctxt": 0 + }, + "value": "useGrouping", + "optional": false, + "typeAnnotation": null + }, + "value": null + } + ], + "optional": false, + "typeAnnotation": null + }, + "init": { + "type": "CallExpression", + "span": { + "start": 263, + "end": 311, + "ctxt": 0 + }, + "callee": { + "type": "MemberExpression", + "span": { + "start": 263, + "end": 309, + "ctxt": 0 + }, + "object": { + "type": "NewExpression", + "span": { + "start": 263, + "end": 293, + "ctxt": 0 + }, + "callee": { + "type": "MemberExpression", + "span": { + "start": 267, + "end": 284, + "ctxt": 0 + }, + "object": { + "type": "Identifier", + "span": { + "start": 267, + "end": 271, + "ctxt": 0 + }, + "value": "Intl", + "optional": false + }, + "property": { + "type": "Identifier", + "span": { + "start": 272, + "end": 284, + "ctxt": 0 + }, + "value": "NumberFormat", + "optional": false + } + }, + "arguments": [ + { + "spread": null, + "expression": { + "type": "StringLiteral", + "span": { + "start": 285, + "end": 292, + "ctxt": 0 + }, + "value": "en-GB", + "raw": "'en-GB'" + } + } + ], + "typeArguments": null + }, + "property": { + "type": "Identifier", + "span": { + "start": 294, + "end": 309, + "ctxt": 0 + }, + "value": "resolvedOptions", + "optional": false + } + }, + "arguments": [], + "typeArguments": null + }, + "definite": false + } + ] + } + ], + "interpreter": null +} diff --git a/crates/swc_ecma_parser/tests/tsc/intlNumberFormatES5UseGrouping.ts b/crates/swc_ecma_parser/tests/tsc/intlNumberFormatES5UseGrouping.ts new file mode 100644 index 000000000000..64203bcab254 --- /dev/null +++ b/crates/swc_ecma_parser/tests/tsc/intlNumberFormatES5UseGrouping.ts @@ -0,0 +1,8 @@ +// @target: es5 +// @strict: true + +new Intl.NumberFormat('en-GB', { useGrouping: true }); +new Intl.NumberFormat('en-GB', { useGrouping: 'true' }); // expect error +new Intl.NumberFormat('en-GB', { useGrouping: 'always' }); // expect error + +const { useGrouping } = new Intl.NumberFormat('en-GB').resolvedOptions(); diff --git a/crates/swc_ecma_parser/tests/tsc/jsObjectsMarkedAsOpenEnded.json b/crates/swc_ecma_parser/tests/tsc/jsObjectsMarkedAsOpenEnded.json index 4778ee31d125..709cd2afb4db 100644 --- a/crates/swc_ecma_parser/tests/tsc/jsObjectsMarkedAsOpenEnded.json +++ b/crates/swc_ecma_parser/tests/tsc/jsObjectsMarkedAsOpenEnded.json @@ -1,16 +1,16 @@ { "type": "Script", "span": { - "start": 58, - "end": 467, + "start": 62, + "end": 471, "ctxt": 0 }, "body": [ { "type": "VariableDeclaration", "span": { - "start": 58, - "end": 76, + "start": 62, + "end": 80, "ctxt": 0 }, "kind": "var", @@ -19,15 +19,15 @@ { "type": "VariableDeclarator", "span": { - "start": 62, - "end": 75, + "start": 66, + "end": 79, "ctxt": 0 }, "id": { "type": "Identifier", "span": { - "start": 62, - "end": 70, + "start": 66, + "end": 74, "ctxt": 0 }, "value": "variable", @@ -37,8 +37,8 @@ "init": { "type": "ObjectExpression", "span": { - "start": 73, - "end": 75, + "start": 77, + "end": 79, "ctxt": 0 }, "properties": [] @@ -50,30 +50,30 @@ { "type": "ExpressionStatement", "span": { - "start": 77, - "end": 92, + "start": 81, + "end": 96, "ctxt": 0 }, "expression": { "type": "AssignmentExpression", "span": { - "start": 77, - "end": 91, + "start": 81, + "end": 95, "ctxt": 0 }, "operator": "=", "left": { "type": "MemberExpression", "span": { - "start": 77, - "end": 87, + "start": 81, + "end": 91, "ctxt": 0 }, "object": { "type": "Identifier", "span": { - "start": 77, - "end": 85, + "start": 81, + "end": 89, "ctxt": 0 }, "value": "variable", @@ -82,8 +82,8 @@ "property": { "type": "Identifier", "span": { - "start": 86, - "end": 87, + "start": 90, + "end": 91, "ctxt": 0 }, "value": "a", @@ -93,8 +93,8 @@ "right": { "type": "NumericLiteral", "span": { - "start": 90, - "end": 91, + "start": 94, + "end": 95, "ctxt": 0 }, "value": 0.0, @@ -107,8 +107,8 @@ "identifier": { "type": "Identifier", "span": { - "start": 100, - "end": 101, + "start": 104, + "end": 105, "ctxt": 0 }, "value": "C", @@ -116,8 +116,8 @@ }, "declare": false, "span": { - "start": 94, - "end": 212, + "start": 98, + "end": 216, "ctxt": 0 }, "decorators": [], @@ -125,15 +125,15 @@ { "type": "ClassProperty", "span": { - "start": 108, - "end": 131, + "start": 112, + "end": 135, "ctxt": 0 }, "key": { "type": "Identifier", "span": { - "start": 108, - "end": 125, + "start": 112, + "end": 129, "ctxt": 0 }, "value": "initializedMember", @@ -142,8 +142,8 @@ "value": { "type": "ObjectExpression", "span": { - "start": 128, - "end": 130, + "start": 132, + "end": 134, "ctxt": 0 }, "properties": [] @@ -162,15 +162,15 @@ { "type": "Constructor", "span": { - "start": 136, - "end": 210, + "start": 140, + "end": 214, "ctxt": 0 }, "key": { "type": "Identifier", "span": { - "start": 136, - "end": 147, + "start": 140, + "end": 151, "ctxt": 0 }, "value": "constructor", @@ -180,46 +180,46 @@ "body": { "type": "BlockStatement", "span": { - "start": 150, - "end": 210, + "start": 154, + "end": 214, "ctxt": 0 }, "stmts": [ { "type": "ExpressionStatement", "span": { - "start": 160, - "end": 177, + "start": 164, + "end": 181, "ctxt": 0 }, "expression": { "type": "AssignmentExpression", "span": { - "start": 160, - "end": 176, + "start": 164, + "end": 180, "ctxt": 0 }, "operator": "=", "left": { "type": "MemberExpression", "span": { - "start": 160, - "end": 171, + "start": 164, + "end": 175, "ctxt": 0 }, "object": { "type": "ThisExpression", "span": { - "start": 160, - "end": 164, + "start": 164, + "end": 168, "ctxt": 0 } }, "property": { "type": "Identifier", "span": { - "start": 165, - "end": 171, + "start": 169, + "end": 175, "ctxt": 0 }, "value": "member", @@ -229,8 +229,8 @@ "right": { "type": "ObjectExpression", "span": { - "start": 174, - "end": 176, + "start": 178, + "end": 180, "ctxt": 0 }, "properties": [] @@ -240,45 +240,45 @@ { "type": "ExpressionStatement", "span": { - "start": 186, - "end": 204, + "start": 190, + "end": 208, "ctxt": 0 }, "expression": { "type": "AssignmentExpression", "span": { - "start": 186, - "end": 203, + "start": 190, + "end": 207, "ctxt": 0 }, "operator": "=", "left": { "type": "MemberExpression", "span": { - "start": 186, - "end": 199, + "start": 190, + "end": 203, "ctxt": 0 }, "object": { "type": "MemberExpression", "span": { - "start": 186, - "end": 197, + "start": 190, + "end": 201, "ctxt": 0 }, "object": { "type": "ThisExpression", "span": { - "start": 186, - "end": 190, + "start": 190, + "end": 194, "ctxt": 0 } }, "property": { "type": "Identifier", "span": { - "start": 191, - "end": 197, + "start": 195, + "end": 201, "ctxt": 0 }, "value": "member", @@ -288,8 +288,8 @@ "property": { "type": "Identifier", "span": { - "start": 198, - "end": 199, + "start": 202, + "end": 203, "ctxt": 0 }, "value": "a", @@ -299,8 +299,8 @@ "right": { "type": "NumericLiteral", "span": { - "start": 202, - "end": 203, + "start": 206, + "end": 207, "ctxt": 0 }, "value": 0.0, @@ -323,8 +323,8 @@ { "type": "VariableDeclaration", "span": { - "start": 214, - "end": 245, + "start": 218, + "end": 249, "ctxt": 0 }, "kind": "var", @@ -333,15 +333,15 @@ { "type": "VariableDeclarator", "span": { - "start": 218, - "end": 244, + "start": 222, + "end": 248, "ctxt": 0 }, "id": { "type": "Identifier", "span": { - "start": 218, - "end": 221, + "start": 222, + "end": 225, "ctxt": 0 }, "value": "obj", @@ -351,8 +351,8 @@ "init": { "type": "ObjectExpression", "span": { - "start": 224, - "end": 244, + "start": 228, + "end": 248, "ctxt": 0 }, "properties": [ @@ -361,8 +361,8 @@ "key": { "type": "Identifier", "span": { - "start": 230, - "end": 238, + "start": 234, + "end": 242, "ctxt": 0 }, "value": "property", @@ -371,8 +371,8 @@ "value": { "type": "ObjectExpression", "span": { - "start": 240, - "end": 242, + "start": 244, + "end": 246, "ctxt": 0 }, "properties": [] @@ -387,37 +387,37 @@ { "type": "ExpressionStatement", "span": { - "start": 247, - "end": 266, + "start": 251, + "end": 270, "ctxt": 0 }, "expression": { "type": "AssignmentExpression", "span": { - "start": 247, - "end": 265, + "start": 251, + "end": 269, "ctxt": 0 }, "operator": "=", "left": { "type": "MemberExpression", "span": { - "start": 247, - "end": 261, + "start": 251, + "end": 265, "ctxt": 0 }, "object": { "type": "MemberExpression", "span": { - "start": 247, - "end": 259, + "start": 251, + "end": 263, "ctxt": 0 }, "object": { "type": "Identifier", "span": { - "start": 247, - "end": 250, + "start": 251, + "end": 254, "ctxt": 0 }, "value": "obj", @@ -426,8 +426,8 @@ "property": { "type": "Identifier", "span": { - "start": 251, - "end": 259, + "start": 255, + "end": 263, "ctxt": 0 }, "value": "property", @@ -437,8 +437,8 @@ "property": { "type": "Identifier", "span": { - "start": 260, - "end": 261, + "start": 264, + "end": 265, "ctxt": 0 }, "value": "a", @@ -448,8 +448,8 @@ "right": { "type": "NumericLiteral", "span": { - "start": 264, - "end": 265, + "start": 268, + "end": 269, "ctxt": 0 }, "value": 0.0, @@ -460,8 +460,8 @@ { "type": "VariableDeclaration", "span": { - "start": 268, - "end": 283, + "start": 272, + "end": 287, "ctxt": 0 }, "kind": "var", @@ -470,15 +470,15 @@ { "type": "VariableDeclarator", "span": { - "start": 272, - "end": 282, + "start": 276, + "end": 286, "ctxt": 0 }, "id": { "type": "Identifier", "span": { - "start": 272, - "end": 275, + "start": 276, + "end": 279, "ctxt": 0 }, "value": "arr", @@ -488,8 +488,8 @@ "init": { "type": "ArrayExpression", "span": { - "start": 278, - "end": 282, + "start": 282, + "end": 286, "ctxt": 0 }, "elements": [ @@ -498,8 +498,8 @@ "expression": { "type": "ObjectExpression", "span": { - "start": 279, - "end": 281, + "start": 283, + "end": 285, "ctxt": 0 }, "properties": [] @@ -516,8 +516,8 @@ "identifier": { "type": "Identifier", "span": { - "start": 294, - "end": 300, + "start": 298, + "end": 304, "ctxt": 0 }, "value": "getObj", @@ -527,30 +527,30 @@ "params": [], "decorators": [], "span": { - "start": 285, - "end": 321, + "start": 289, + "end": 325, "ctxt": 0 }, "body": { "type": "BlockStatement", "span": { - "start": 303, - "end": 321, + "start": 307, + "end": 325, "ctxt": 0 }, "stmts": [ { "type": "ReturnStatement", "span": { - "start": 309, - "end": 319, + "start": 313, + "end": 323, "ctxt": 0 }, "argument": { "type": "ObjectExpression", "span": { - "start": 316, - "end": 318, + "start": 320, + "end": 322, "ctxt": 0 }, "properties": [] @@ -566,30 +566,30 @@ { "type": "ExpressionStatement", "span": { - "start": 343, - "end": 358, + "start": 347, + "end": 362, "ctxt": 0 }, "expression": { "type": "AssignmentExpression", "span": { - "start": 343, - "end": 357, + "start": 347, + "end": 361, "ctxt": 0 }, "operator": "=", "left": { "type": "MemberExpression", "span": { - "start": 343, - "end": 353, + "start": 347, + "end": 357, "ctxt": 0 }, "object": { "type": "Identifier", "span": { - "start": 343, - "end": 351, + "start": 347, + "end": 355, "ctxt": 0 }, "value": "variable", @@ -598,8 +598,8 @@ "property": { "type": "Identifier", "span": { - "start": 352, - "end": 353, + "start": 356, + "end": 357, "ctxt": 0 }, "value": "a", @@ -609,8 +609,8 @@ "right": { "type": "NumericLiteral", "span": { - "start": 356, - "end": 357, + "start": 360, + "end": 361, "ctxt": 0 }, "value": 1.0, @@ -621,51 +621,51 @@ { "type": "ExpressionStatement", "span": { - "start": 359, - "end": 382, + "start": 363, + "end": 386, "ctxt": 0 }, "expression": { "type": "AssignmentExpression", "span": { - "start": 359, - "end": 381, + "start": 363, + "end": 385, "ctxt": 0 }, "operator": "=", "left": { "type": "MemberExpression", "span": { - "start": 359, - "end": 377, + "start": 363, + "end": 381, "ctxt": 0 }, "object": { "type": "MemberExpression", "span": { - "start": 359, - "end": 375, + "start": 363, + "end": 379, "ctxt": 0 }, "object": { "type": "ParenthesisExpression", "span": { - "start": 359, - "end": 368, + "start": 363, + "end": 372, "ctxt": 0 }, "expression": { "type": "NewExpression", "span": { - "start": 360, - "end": 367, + "start": 364, + "end": 371, "ctxt": 0 }, "callee": { "type": "Identifier", "span": { - "start": 364, - "end": 365, + "start": 368, + "end": 369, "ctxt": 0 }, "value": "C", @@ -678,8 +678,8 @@ "property": { "type": "Identifier", "span": { - "start": 369, - "end": 375, + "start": 373, + "end": 379, "ctxt": 0 }, "value": "member", @@ -689,8 +689,8 @@ "property": { "type": "Identifier", "span": { - "start": 376, - "end": 377, + "start": 380, + "end": 381, "ctxt": 0 }, "value": "a", @@ -700,8 +700,8 @@ "right": { "type": "NumericLiteral", "span": { - "start": 380, - "end": 381, + "start": 384, + "end": 385, "ctxt": 0 }, "value": 1.0, @@ -712,51 +712,51 @@ { "type": "ExpressionStatement", "span": { - "start": 383, - "end": 417, + "start": 387, + "end": 421, "ctxt": 0 }, "expression": { "type": "AssignmentExpression", "span": { - "start": 383, - "end": 416, + "start": 387, + "end": 420, "ctxt": 0 }, "operator": "=", "left": { "type": "MemberExpression", "span": { - "start": 383, - "end": 412, + "start": 387, + "end": 416, "ctxt": 0 }, "object": { "type": "MemberExpression", "span": { - "start": 383, - "end": 410, + "start": 387, + "end": 414, "ctxt": 0 }, "object": { "type": "ParenthesisExpression", "span": { - "start": 383, - "end": 392, + "start": 387, + "end": 396, "ctxt": 0 }, "expression": { "type": "NewExpression", "span": { - "start": 384, - "end": 391, + "start": 388, + "end": 395, "ctxt": 0 }, "callee": { "type": "Identifier", "span": { - "start": 388, - "end": 389, + "start": 392, + "end": 393, "ctxt": 0 }, "value": "C", @@ -769,8 +769,8 @@ "property": { "type": "Identifier", "span": { - "start": 393, - "end": 410, + "start": 397, + "end": 414, "ctxt": 0 }, "value": "initializedMember", @@ -780,8 +780,8 @@ "property": { "type": "Identifier", "span": { - "start": 411, - "end": 412, + "start": 415, + "end": 416, "ctxt": 0 }, "value": "a", @@ -791,8 +791,8 @@ "right": { "type": "NumericLiteral", "span": { - "start": 415, - "end": 416, + "start": 419, + "end": 420, "ctxt": 0 }, "value": 1.0, @@ -803,37 +803,37 @@ { "type": "ExpressionStatement", "span": { - "start": 418, - "end": 437, + "start": 422, + "end": 441, "ctxt": 0 }, "expression": { "type": "AssignmentExpression", "span": { - "start": 418, - "end": 436, + "start": 422, + "end": 440, "ctxt": 0 }, "operator": "=", "left": { "type": "MemberExpression", "span": { - "start": 418, - "end": 432, + "start": 422, + "end": 436, "ctxt": 0 }, "object": { "type": "MemberExpression", "span": { - "start": 418, - "end": 430, + "start": 422, + "end": 434, "ctxt": 0 }, "object": { "type": "Identifier", "span": { - "start": 418, - "end": 421, + "start": 422, + "end": 425, "ctxt": 0 }, "value": "obj", @@ -842,8 +842,8 @@ "property": { "type": "Identifier", "span": { - "start": 422, - "end": 430, + "start": 426, + "end": 434, "ctxt": 0 }, "value": "property", @@ -853,8 +853,8 @@ "property": { "type": "Identifier", "span": { - "start": 431, - "end": 432, + "start": 435, + "end": 436, "ctxt": 0 }, "value": "a", @@ -864,8 +864,8 @@ "right": { "type": "NumericLiteral", "span": { - "start": 435, - "end": 436, + "start": 439, + "end": 440, "ctxt": 0 }, "value": 1.0, @@ -876,37 +876,37 @@ { "type": "ExpressionStatement", "span": { - "start": 438, - "end": 451, + "start": 442, + "end": 455, "ctxt": 0 }, "expression": { "type": "AssignmentExpression", "span": { - "start": 438, - "end": 450, + "start": 442, + "end": 454, "ctxt": 0 }, "operator": "=", "left": { "type": "MemberExpression", "span": { - "start": 438, - "end": 446, + "start": 442, + "end": 450, "ctxt": 0 }, "object": { "type": "MemberExpression", "span": { - "start": 438, - "end": 444, + "start": 442, + "end": 448, "ctxt": 0 }, "object": { "type": "Identifier", "span": { - "start": 438, - "end": 441, + "start": 442, + "end": 445, "ctxt": 0 }, "value": "arr", @@ -915,15 +915,15 @@ "property": { "type": "Computed", "span": { - "start": 441, - "end": 444, + "start": 445, + "end": 448, "ctxt": 0 }, "expression": { "type": "NumericLiteral", "span": { - "start": 442, - "end": 443, + "start": 446, + "end": 447, "ctxt": 0 }, "value": 0.0, @@ -934,8 +934,8 @@ "property": { "type": "Identifier", "span": { - "start": 445, - "end": 446, + "start": 449, + "end": 450, "ctxt": 0 }, "value": "a", @@ -945,8 +945,8 @@ "right": { "type": "NumericLiteral", "span": { - "start": 449, - "end": 450, + "start": 453, + "end": 454, "ctxt": 0 }, "value": 1.0, @@ -957,37 +957,37 @@ { "type": "ExpressionStatement", "span": { - "start": 452, - "end": 467, + "start": 456, + "end": 471, "ctxt": 0 }, "expression": { "type": "AssignmentExpression", "span": { - "start": 452, - "end": 466, + "start": 456, + "end": 470, "ctxt": 0 }, "operator": "=", "left": { "type": "MemberExpression", "span": { - "start": 452, - "end": 462, + "start": 456, + "end": 466, "ctxt": 0 }, "object": { "type": "CallExpression", "span": { - "start": 452, - "end": 460, + "start": 456, + "end": 464, "ctxt": 0 }, "callee": { "type": "Identifier", "span": { - "start": 452, - "end": 458, + "start": 456, + "end": 462, "ctxt": 0 }, "value": "getObj", @@ -999,8 +999,8 @@ "property": { "type": "Identifier", "span": { - "start": 461, - "end": 462, + "start": 465, + "end": 466, "ctxt": 0 }, "value": "a", @@ -1010,8 +1010,8 @@ "right": { "type": "NumericLiteral", "span": { - "start": 465, - "end": 466, + "start": 469, + "end": 470, "ctxt": 0 }, "value": 1.0, diff --git a/crates/swc_ecma_parser/tests/tsc/jsObjectsMarkedAsOpenEnded.ts b/crates/swc_ecma_parser/tests/tsc/jsObjectsMarkedAsOpenEnded.ts index 52b27641f0d8..4991d674d5e7 100644 --- a/crates/swc_ecma_parser/tests/tsc/jsObjectsMarkedAsOpenEnded.ts +++ b/crates/swc_ecma_parser/tests/tsc/jsObjectsMarkedAsOpenEnded.ts @@ -1,4 +1,4 @@ -// @out: output.js +// @outFile: output.js // @allowJs: true // @filename: a.js diff --git a/crates/swc_ecma_parser/tests/tsc/jsdocAccessibilityTagsDeclarations.json b/crates/swc_ecma_parser/tests/tsc/jsdocAccessibilityTagsDeclarations.json index 8008703a8fde..aebcc40fc838 100644 --- a/crates/swc_ecma_parser/tests/tsc/jsdocAccessibilityTagsDeclarations.json +++ b/crates/swc_ecma_parser/tests/tsc/jsdocAccessibilityTagsDeclarations.json @@ -1,8 +1,8 @@ { "type": "Script", "span": { - "start": 145, - "end": 852, + "start": 149, + "end": 856, "ctxt": 0 }, "body": [ @@ -11,8 +11,8 @@ "identifier": { "type": "Identifier", "span": { - "start": 151, - "end": 160, + "start": 155, + "end": 164, "ctxt": 0 }, "value": "Protected", @@ -20,8 +20,8 @@ }, "declare": false, "span": { - "start": 145, - "end": 428, + "start": 149, + "end": 432, "ctxt": 0 }, "decorators": [], @@ -29,15 +29,15 @@ { "type": "Constructor", "span": { - "start": 189, - "end": 256, + "start": 193, + "end": 260, "ctxt": 0 }, "key": { "type": "Identifier", "span": { - "start": 189, - "end": 200, + "start": 193, + "end": 204, "ctxt": 0 }, "value": "constructor", @@ -47,16 +47,16 @@ { "type": "Parameter", "span": { - "start": 201, - "end": 202, + "start": 205, + "end": 206, "ctxt": 0 }, "decorators": [], "pat": { "type": "Identifier", "span": { - "start": 201, - "end": 202, + "start": 205, + "end": 206, "ctxt": 0 }, "value": "c", @@ -68,46 +68,46 @@ "body": { "type": "BlockStatement", "span": { - "start": 204, - "end": 256, + "start": 208, + "end": 260, "ctxt": 0 }, "stmts": [ { "type": "ExpressionStatement", "span": { - "start": 240, - "end": 250, + "start": 244, + "end": 254, "ctxt": 0 }, "expression": { "type": "AssignmentExpression", "span": { - "start": 240, - "end": 250, + "start": 244, + "end": 254, "ctxt": 0 }, "operator": "=", "left": { "type": "MemberExpression", "span": { - "start": 240, - "end": 246, + "start": 244, + "end": 250, "ctxt": 0 }, "object": { "type": "ThisExpression", "span": { - "start": 240, - "end": 244, + "start": 244, + "end": 248, "ctxt": 0 } }, "property": { "type": "Identifier", "span": { - "start": 245, - "end": 246, + "start": 249, + "end": 250, "ctxt": 0 }, "value": "c", @@ -117,8 +117,8 @@ "right": { "type": "Identifier", "span": { - "start": 249, - "end": 250, + "start": 253, + "end": 254, "ctxt": 0 }, "value": "c", @@ -134,15 +134,15 @@ { "type": "ClassMethod", "span": { - "start": 283, - "end": 316, + "start": 287, + "end": 320, "ctxt": 0 }, "key": { "type": "Identifier", "span": { - "start": 283, - "end": 284, + "start": 287, + "end": 288, "ctxt": 0 }, "value": "m", @@ -152,45 +152,45 @@ "params": [], "decorators": [], "span": { - "start": 283, - "end": 316, + "start": 287, + "end": 320, "ctxt": 0 }, "body": { "type": "BlockStatement", "span": { - "start": 287, - "end": 316, + "start": 291, + "end": 320, "ctxt": 0 }, "stmts": [ { "type": "ReturnStatement", "span": { - "start": 297, - "end": 310, + "start": 301, + "end": 314, "ctxt": 0 }, "argument": { "type": "MemberExpression", "span": { - "start": 304, - "end": 310, + "start": 308, + "end": 314, "ctxt": 0 }, "object": { "type": "ThisExpression", "span": { - "start": 304, - "end": 308, + "start": 308, + "end": 312, "ctxt": 0 } }, "property": { "type": "Identifier", "span": { - "start": 309, - "end": 310, + "start": 313, + "end": 314, "ctxt": 0 }, "value": "c", @@ -215,15 +215,15 @@ { "type": "ClassMethod", "span": { - "start": 343, - "end": 368, + "start": 347, + "end": 372, "ctxt": 0 }, "key": { "type": "Identifier", "span": { - "start": 347, - "end": 348, + "start": 351, + "end": 352, "ctxt": 0 }, "value": "p", @@ -233,45 +233,45 @@ "params": [], "decorators": [], "span": { - "start": 343, - "end": 368, + "start": 347, + "end": 372, "ctxt": 0 }, "body": { "type": "BlockStatement", "span": { - "start": 351, - "end": 368, + "start": 355, + "end": 372, "ctxt": 0 }, "stmts": [ { "type": "ReturnStatement", "span": { - "start": 353, - "end": 366, + "start": 357, + "end": 370, "ctxt": 0 }, "argument": { "type": "MemberExpression", "span": { - "start": 360, - "end": 366, + "start": 364, + "end": 370, "ctxt": 0 }, "object": { "type": "ThisExpression", "span": { - "start": 360, - "end": 364, + "start": 364, + "end": 368, "ctxt": 0 } }, "property": { "type": "Identifier", "span": { - "start": 365, - "end": 366, + "start": 369, + "end": 370, "ctxt": 0 }, "value": "c", @@ -296,15 +296,15 @@ { "type": "ClassMethod", "span": { - "start": 395, - "end": 426, + "start": 399, + "end": 430, "ctxt": 0 }, "key": { "type": "Identifier", "span": { - "start": 399, - "end": 400, + "start": 403, + "end": 404, "ctxt": 0 }, "value": "p", @@ -315,16 +315,16 @@ { "type": "Parameter", "span": { - "start": 401, - "end": 406, + "start": 405, + "end": 410, "ctxt": 0 }, "decorators": [], "pat": { "type": "Identifier", "span": { - "start": 401, - "end": 406, + "start": 405, + "end": 410, "ctxt": 0 }, "value": "value", @@ -335,53 +335,53 @@ ], "decorators": [], "span": { - "start": 395, - "end": 426, + "start": 399, + "end": 430, "ctxt": 0 }, "body": { "type": "BlockStatement", "span": { - "start": 408, - "end": 426, + "start": 412, + "end": 430, "ctxt": 0 }, "stmts": [ { "type": "ExpressionStatement", "span": { - "start": 410, - "end": 424, + "start": 414, + "end": 428, "ctxt": 0 }, "expression": { "type": "AssignmentExpression", "span": { - "start": 410, - "end": 424, + "start": 414, + "end": 428, "ctxt": 0 }, "operator": "=", "left": { "type": "MemberExpression", "span": { - "start": 410, - "end": 416, + "start": 414, + "end": 420, "ctxt": 0 }, "object": { "type": "ThisExpression", "span": { - "start": 410, - "end": 414, + "start": 414, + "end": 418, "ctxt": 0 } }, "property": { "type": "Identifier", "span": { - "start": 415, - "end": 416, + "start": 419, + "end": 420, "ctxt": 0 }, "value": "c", @@ -391,8 +391,8 @@ "right": { "type": "Identifier", "span": { - "start": 419, - "end": 424, + "start": 423, + "end": 428, "ctxt": 0 }, "value": "value", @@ -426,8 +426,8 @@ "identifier": { "type": "Identifier", "span": { - "start": 436, - "end": 443, + "start": 440, + "end": 447, "ctxt": 0 }, "value": "Private", @@ -435,8 +435,8 @@ }, "declare": false, "span": { - "start": 430, - "end": 701, + "start": 434, + "end": 705, "ctxt": 0 }, "decorators": [], @@ -444,15 +444,15 @@ { "type": "Constructor", "span": { - "start": 470, - "end": 535, + "start": 474, + "end": 539, "ctxt": 0 }, "key": { "type": "Identifier", "span": { - "start": 470, - "end": 481, + "start": 474, + "end": 485, "ctxt": 0 }, "value": "constructor", @@ -462,16 +462,16 @@ { "type": "Parameter", "span": { - "start": 482, - "end": 483, + "start": 486, + "end": 487, "ctxt": 0 }, "decorators": [], "pat": { "type": "Identifier", "span": { - "start": 482, - "end": 483, + "start": 486, + "end": 487, "ctxt": 0 }, "value": "c", @@ -483,46 +483,46 @@ "body": { "type": "BlockStatement", "span": { - "start": 485, - "end": 535, + "start": 489, + "end": 539, "ctxt": 0 }, "stmts": [ { "type": "ExpressionStatement", "span": { - "start": 519, - "end": 529, + "start": 523, + "end": 533, "ctxt": 0 }, "expression": { "type": "AssignmentExpression", "span": { - "start": 519, - "end": 529, + "start": 523, + "end": 533, "ctxt": 0 }, "operator": "=", "left": { "type": "MemberExpression", "span": { - "start": 519, - "end": 525, + "start": 523, + "end": 529, "ctxt": 0 }, "object": { "type": "ThisExpression", "span": { - "start": 519, - "end": 523, + "start": 523, + "end": 527, "ctxt": 0 } }, "property": { "type": "Identifier", "span": { - "start": 524, - "end": 525, + "start": 528, + "end": 529, "ctxt": 0 }, "value": "c", @@ -532,8 +532,8 @@ "right": { "type": "Identifier", "span": { - "start": 528, - "end": 529, + "start": 532, + "end": 533, "ctxt": 0 }, "value": "c", @@ -549,15 +549,15 @@ { "type": "ClassMethod", "span": { - "start": 560, - "end": 593, + "start": 564, + "end": 597, "ctxt": 0 }, "key": { "type": "Identifier", "span": { - "start": 560, - "end": 561, + "start": 564, + "end": 565, "ctxt": 0 }, "value": "m", @@ -567,45 +567,45 @@ "params": [], "decorators": [], "span": { - "start": 560, - "end": 593, + "start": 564, + "end": 597, "ctxt": 0 }, "body": { "type": "BlockStatement", "span": { - "start": 564, - "end": 593, + "start": 568, + "end": 597, "ctxt": 0 }, "stmts": [ { "type": "ReturnStatement", "span": { - "start": 574, - "end": 587, + "start": 578, + "end": 591, "ctxt": 0 }, "argument": { "type": "MemberExpression", "span": { - "start": 581, - "end": 587, + "start": 585, + "end": 591, "ctxt": 0 }, "object": { "type": "ThisExpression", "span": { - "start": 581, - "end": 585, + "start": 585, + "end": 589, "ctxt": 0 } }, "property": { "type": "Identifier", "span": { - "start": 586, - "end": 587, + "start": 590, + "end": 591, "ctxt": 0 }, "value": "c", @@ -630,15 +630,15 @@ { "type": "ClassMethod", "span": { - "start": 618, - "end": 643, + "start": 622, + "end": 647, "ctxt": 0 }, "key": { "type": "Identifier", "span": { - "start": 622, - "end": 623, + "start": 626, + "end": 627, "ctxt": 0 }, "value": "p", @@ -648,45 +648,45 @@ "params": [], "decorators": [], "span": { - "start": 618, - "end": 643, + "start": 622, + "end": 647, "ctxt": 0 }, "body": { "type": "BlockStatement", "span": { - "start": 626, - "end": 643, + "start": 630, + "end": 647, "ctxt": 0 }, "stmts": [ { "type": "ReturnStatement", "span": { - "start": 628, - "end": 641, + "start": 632, + "end": 645, "ctxt": 0 }, "argument": { "type": "MemberExpression", "span": { - "start": 635, - "end": 641, + "start": 639, + "end": 645, "ctxt": 0 }, "object": { "type": "ThisExpression", "span": { - "start": 635, - "end": 639, + "start": 639, + "end": 643, "ctxt": 0 } }, "property": { "type": "Identifier", "span": { - "start": 640, - "end": 641, + "start": 644, + "end": 645, "ctxt": 0 }, "value": "c", @@ -711,15 +711,15 @@ { "type": "ClassMethod", "span": { - "start": 668, - "end": 699, + "start": 672, + "end": 703, "ctxt": 0 }, "key": { "type": "Identifier", "span": { - "start": 672, - "end": 673, + "start": 676, + "end": 677, "ctxt": 0 }, "value": "p", @@ -730,16 +730,16 @@ { "type": "Parameter", "span": { - "start": 674, - "end": 679, + "start": 678, + "end": 683, "ctxt": 0 }, "decorators": [], "pat": { "type": "Identifier", "span": { - "start": 674, - "end": 679, + "start": 678, + "end": 683, "ctxt": 0 }, "value": "value", @@ -750,53 +750,53 @@ ], "decorators": [], "span": { - "start": 668, - "end": 699, + "start": 672, + "end": 703, "ctxt": 0 }, "body": { "type": "BlockStatement", "span": { - "start": 681, - "end": 699, + "start": 685, + "end": 703, "ctxt": 0 }, "stmts": [ { "type": "ExpressionStatement", "span": { - "start": 683, - "end": 697, + "start": 687, + "end": 701, "ctxt": 0 }, "expression": { "type": "AssignmentExpression", "span": { - "start": 683, - "end": 697, + "start": 687, + "end": 701, "ctxt": 0 }, "operator": "=", "left": { "type": "MemberExpression", "span": { - "start": 683, - "end": 689, + "start": 687, + "end": 693, "ctxt": 0 }, "object": { "type": "ThisExpression", "span": { - "start": 683, - "end": 687, + "start": 687, + "end": 691, "ctxt": 0 } }, "property": { "type": "Identifier", "span": { - "start": 688, - "end": 689, + "start": 692, + "end": 693, "ctxt": 0 }, "value": "c", @@ -806,8 +806,8 @@ "right": { "type": "Identifier", "span": { - "start": 692, - "end": 697, + "start": 696, + "end": 701, "ctxt": 0 }, "value": "value", @@ -841,8 +841,8 @@ "identifier": { "type": "Identifier", "span": { - "start": 765, - "end": 766, + "start": 769, + "end": 770, "ctxt": 0 }, "value": "C", @@ -850,8 +850,8 @@ }, "declare": false, "span": { - "start": 759, - "end": 852, + "start": 763, + "end": 856, "ctxt": 0 }, "decorators": [], @@ -859,15 +859,15 @@ { "type": "Constructor", "span": { - "start": 773, - "end": 850, + "start": 777, + "end": 854, "ctxt": 0 }, "key": { "type": "Identifier", "span": { - "start": 773, - "end": 784, + "start": 777, + "end": 788, "ctxt": 0 }, "value": "constructor", @@ -877,16 +877,16 @@ { "type": "Parameter", "span": { - "start": 800, - "end": 801, + "start": 804, + "end": 805, "ctxt": 0 }, "decorators": [], "pat": { "type": "Identifier", "span": { - "start": 800, - "end": 801, + "start": 804, + "end": 805, "ctxt": 0 }, "value": "x", @@ -897,16 +897,16 @@ { "type": "Parameter", "span": { - "start": 821, - "end": 822, + "start": 825, + "end": 826, "ctxt": 0 }, "decorators": [], "pat": { "type": "Identifier", "span": { - "start": 821, - "end": 822, + "start": 825, + "end": 826, "ctxt": 0 }, "value": "y", @@ -917,16 +917,16 @@ { "type": "Parameter", "span": { - "start": 840, - "end": 841, + "start": 844, + "end": 845, "ctxt": 0 }, "decorators": [], "pat": { "type": "Identifier", "span": { - "start": 840, - "end": 841, + "start": 844, + "end": 845, "ctxt": 0 }, "value": "z", @@ -938,8 +938,8 @@ "body": { "type": "BlockStatement", "span": { - "start": 843, - "end": 850, + "start": 847, + "end": 854, "ctxt": 0 }, "stmts": [] diff --git a/crates/swc_ecma_parser/tests/tsc/jsdocAccessibilityTagsDeclarations.ts b/crates/swc_ecma_parser/tests/tsc/jsdocAccessibilityTagsDeclarations.ts index 8890dbf92475..b49f732c1bb1 100644 --- a/crates/swc_ecma_parser/tests/tsc/jsdocAccessibilityTagsDeclarations.ts +++ b/crates/swc_ecma_parser/tests/tsc/jsdocAccessibilityTagsDeclarations.ts @@ -1,7 +1,7 @@ // @allowJs: true // @checkJs: true // @target: esnext -// @out: foo.js +// @outFile: foo.js // @declaration: true // @Filename: jsdocAccessibilityTagDeclarations.js class Protected { @@ -40,4 +40,4 @@ class Private { class C { constructor(/** @public */ x, /** @protected */ y, /** @private */ z) { } -} \ No newline at end of file +} diff --git a/crates/swc_ecma_parser/tests/tsc/jsdocLinkTag8.json b/crates/swc_ecma_parser/tests/tsc/jsdocLinkTag8.json new file mode 100644 index 000000000000..d3ddbce990f9 --- /dev/null +++ b/crates/swc_ecma_parser/tests/tsc/jsdocLinkTag8.json @@ -0,0 +1,88 @@ +{ + "type": "Script", + "span": { + "start": 120, + "end": 151, + "ctxt": 0 + }, + "body": [ + { + "type": "VariableDeclaration", + "span": { + "start": 120, + "end": 151, + "ctxt": 0 + }, + "kind": "const", + "declare": false, + "declarations": [ + { + "type": "VariableDeclarator", + "span": { + "start": 126, + "end": 151, + "ctxt": 0 + }, + "id": { + "type": "Identifier", + "span": { + "start": 126, + "end": 132, + "ctxt": 0 + }, + "value": "remove", + "optional": false, + "typeAnnotation": null + }, + "init": { + "type": "ArrowFunctionExpression", + "span": { + "start": 135, + "end": 151, + "ctxt": 0 + }, + "params": [ + { + "type": "Identifier", + "span": { + "start": 136, + "end": 139, + "ctxt": 0 + }, + "value": "map", + "optional": false, + "typeAnnotation": null + }, + { + "type": "Identifier", + "span": { + "start": 141, + "end": 144, + "ctxt": 0 + }, + "value": "key", + "optional": false, + "typeAnnotation": null + } + ], + "body": { + "type": "BlockStatement", + "span": { + "start": 149, + "end": 151, + "ctxt": 0 + }, + "stmts": [] + }, + "async": false, + "generator": false, + "typeParameters": null, + "returnType": null + }, + "definite": false + } + ] + } + ], + "interpreter": null +} diff --git a/crates/swc_ecma_parser/tests/tsc/jsdocLinkTag8.ts b/crates/swc_ecma_parser/tests/tsc/jsdocLinkTag8.ts new file mode 100644 index 000000000000..ac817f70f117 --- /dev/null +++ b/crates/swc_ecma_parser/tests/tsc/jsdocLinkTag8.ts @@ -0,0 +1,8 @@ +// @checkJs: true +// @allowJs: true +// @target: esnext +// @noEmit: true +// @filename: /a.js + +/** {@link Map.delete} */ +const remove = (map, key) => {} diff --git a/crates/swc_ecma_parser/tests/tsc/jsdocLiteral.json b/crates/swc_ecma_parser/tests/tsc/jsdocLiteral.json index 2fb2980a7f4e..627b3a87edb1 100644 --- a/crates/swc_ecma_parser/tests/tsc/jsdocLiteral.json +++ b/crates/swc_ecma_parser/tests/tsc/jsdocLiteral.json @@ -1,8 +1,8 @@ { "type": "Script", "span": { - "start": 215, - "end": 290, + "start": 219, + "end": 294, "ctxt": 0 }, "body": [ @@ -11,8 +11,8 @@ "identifier": { "type": "Identifier", "span": { - "start": 224, - "end": 225, + "start": 228, + "end": 229, "ctxt": 0 }, "value": "f", @@ -23,16 +23,16 @@ { "type": "Parameter", "span": { - "start": 226, - "end": 228, + "start": 230, + "end": 232, "ctxt": 0 }, "decorators": [], "pat": { "type": "Identifier", "span": { - "start": 226, - "end": 228, + "start": 230, + "end": 232, "ctxt": 0 }, "value": "p1", @@ -43,16 +43,16 @@ { "type": "Parameter", "span": { - "start": 230, - "end": 232, + "start": 234, + "end": 236, "ctxt": 0 }, "decorators": [], "pat": { "type": "Identifier", "span": { - "start": 230, - "end": 232, + "start": 234, + "end": 236, "ctxt": 0 }, "value": "p2", @@ -63,16 +63,16 @@ { "type": "Parameter", "span": { - "start": 234, - "end": 236, + "start": 238, + "end": 240, "ctxt": 0 }, "decorators": [], "pat": { "type": "Identifier", "span": { - "start": 234, - "end": 236, + "start": 238, + "end": 240, "ctxt": 0 }, "value": "p3", @@ -83,16 +83,16 @@ { "type": "Parameter", "span": { - "start": 238, - "end": 240, + "start": 242, + "end": 244, "ctxt": 0 }, "decorators": [], "pat": { "type": "Identifier", "span": { - "start": 238, - "end": 240, + "start": 242, + "end": 244, "ctxt": 0 }, "value": "p4", @@ -103,16 +103,16 @@ { "type": "Parameter", "span": { - "start": 242, - "end": 244, + "start": 246, + "end": 248, "ctxt": 0 }, "decorators": [], "pat": { "type": "Identifier", "span": { - "start": 242, - "end": 244, + "start": 246, + "end": 248, "ctxt": 0 }, "value": "p5", @@ -123,70 +123,70 @@ ], "decorators": [], "span": { - "start": 215, - "end": 290, + "start": 219, + "end": 294, "ctxt": 0 }, "body": { "type": "BlockStatement", "span": { - "start": 246, - "end": 290, + "start": 250, + "end": 294, "ctxt": 0 }, "stmts": [ { "type": "ReturnStatement", "span": { - "start": 252, - "end": 288, + "start": 256, + "end": 292, "ctxt": 0 }, "argument": { "type": "BinaryExpression", "span": { - "start": 259, - "end": 287, + "start": 263, + "end": 291, "ctxt": 0 }, "operator": "+", "left": { "type": "BinaryExpression", "span": { - "start": 259, - "end": 281, + "start": 263, + "end": 285, "ctxt": 0 }, "operator": "+", "left": { "type": "BinaryExpression", "span": { - "start": 259, - "end": 276, + "start": 263, + "end": 280, "ctxt": 0 }, "operator": "+", "left": { "type": "BinaryExpression", "span": { - "start": 259, - "end": 271, + "start": 263, + "end": 275, "ctxt": 0 }, "operator": "+", "left": { "type": "BinaryExpression", "span": { - "start": 259, - "end": 266, + "start": 263, + "end": 270, "ctxt": 0 }, "operator": "+", "left": { "type": "Identifier", "span": { - "start": 259, - "end": 261, + "start": 263, + "end": 265, "ctxt": 0 }, "value": "p1", @@ -195,8 +195,8 @@ "right": { "type": "Identifier", "span": { - "start": 264, - "end": 266, + "start": 268, + "end": 270, "ctxt": 0 }, "value": "p2", @@ -206,8 +206,8 @@ "right": { "type": "Identifier", "span": { - "start": 269, - "end": 271, + "start": 273, + "end": 275, "ctxt": 0 }, "value": "p3", @@ -217,8 +217,8 @@ "right": { "type": "Identifier", "span": { - "start": 274, - "end": 276, + "start": 278, + "end": 280, "ctxt": 0 }, "value": "p4", @@ -228,8 +228,8 @@ "right": { "type": "Identifier", "span": { - "start": 279, - "end": 281, + "start": 283, + "end": 285, "ctxt": 0 }, "value": "p5", @@ -239,8 +239,8 @@ "right": { "type": "StringLiteral", "span": { - "start": 284, - "end": 287, + "start": 288, + "end": 291, "ctxt": 0 }, "value": ".", diff --git a/crates/swc_ecma_parser/tests/tsc/jsdocLiteral.ts b/crates/swc_ecma_parser/tests/tsc/jsdocLiteral.ts index bd0d2d562f9a..ff7b1e24b3e3 100644 --- a/crates/swc_ecma_parser/tests/tsc/jsdocLiteral.ts +++ b/crates/swc_ecma_parser/tests/tsc/jsdocLiteral.ts @@ -1,6 +1,6 @@ // @allowJs: true // @filename: in.js -// @out: out.js +// @outFile: out.js /** * @param {'literal'} p1 * @param {"literal"} p2 diff --git a/crates/swc_ecma_parser/tests/tsc/jsdocNeverUndefinedNull.json b/crates/swc_ecma_parser/tests/tsc/jsdocNeverUndefinedNull.json index 7fc9440a00fa..1a20724e7e2d 100644 --- a/crates/swc_ecma_parser/tests/tsc/jsdocNeverUndefinedNull.json +++ b/crates/swc_ecma_parser/tests/tsc/jsdocNeverUndefinedNull.json @@ -1,8 +1,8 @@ { "type": "Script", "span": { - "start": 156, - "end": 182, + "start": 160, + "end": 186, "ctxt": 0 }, "body": [ @@ -11,8 +11,8 @@ "identifier": { "type": "Identifier", "span": { - "start": 165, - "end": 166, + "start": 169, + "end": 170, "ctxt": 0 }, "value": "f", @@ -23,16 +23,16 @@ { "type": "Parameter", "span": { - "start": 167, - "end": 169, + "start": 171, + "end": 173, "ctxt": 0 }, "decorators": [], "pat": { "type": "Identifier", "span": { - "start": 167, - "end": 169, + "start": 171, + "end": 173, "ctxt": 0 }, "value": "p1", @@ -43,16 +43,16 @@ { "type": "Parameter", "span": { - "start": 171, - "end": 173, + "start": 175, + "end": 177, "ctxt": 0 }, "decorators": [], "pat": { "type": "Identifier", "span": { - "start": 171, - "end": 173, + "start": 175, + "end": 177, "ctxt": 0 }, "value": "p2", @@ -63,16 +63,16 @@ { "type": "Parameter", "span": { - "start": 175, - "end": 177, + "start": 179, + "end": 181, "ctxt": 0 }, "decorators": [], "pat": { "type": "Identifier", "span": { - "start": 175, - "end": 177, + "start": 179, + "end": 181, "ctxt": 0 }, "value": "p3", @@ -83,15 +83,15 @@ ], "decorators": [], "span": { - "start": 156, - "end": 182, + "start": 160, + "end": 186, "ctxt": 0 }, "body": { "type": "BlockStatement", "span": { - "start": 179, - "end": 182, + "start": 183, + "end": 186, "ctxt": 0 }, "stmts": [] diff --git a/crates/swc_ecma_parser/tests/tsc/jsdocNeverUndefinedNull.ts b/crates/swc_ecma_parser/tests/tsc/jsdocNeverUndefinedNull.ts index c095bc1c920d..40ccd5e7f699 100644 --- a/crates/swc_ecma_parser/tests/tsc/jsdocNeverUndefinedNull.ts +++ b/crates/swc_ecma_parser/tests/tsc/jsdocNeverUndefinedNull.ts @@ -1,6 +1,6 @@ // @allowJs: true // @filename: in.js -// @out: out.js +// @outFile: out.js /** * @param {never} p1 * @param {undefined} p2 diff --git a/crates/swc_ecma_parser/tests/tsc/jsdocReadonlyDeclarations.json b/crates/swc_ecma_parser/tests/tsc/jsdocReadonlyDeclarations.json index 0996f132fd16..5c2163fbad03 100644 --- a/crates/swc_ecma_parser/tests/tsc/jsdocReadonlyDeclarations.json +++ b/crates/swc_ecma_parser/tests/tsc/jsdocReadonlyDeclarations.json @@ -1,8 +1,8 @@ { "type": "Script", "span": { - "start": 172, - "end": 543, + "start": 176, + "end": 547, "ctxt": 0 }, "body": [ @@ -11,8 +11,8 @@ "identifier": { "type": "Identifier", "span": { - "start": 178, - "end": 179, + "start": 182, + "end": 183, "ctxt": 0 }, "value": "C", @@ -20,8 +20,8 @@ }, "declare": false, "span": { - "start": 172, - "end": 371, + "start": 176, + "end": 375, "ctxt": 0 }, "decorators": [], @@ -29,15 +29,15 @@ { "type": "ClassProperty", "span": { - "start": 207, - "end": 212, + "start": 211, + "end": 216, "ctxt": 0 }, "key": { "type": "Identifier", "span": { - "start": 207, - "end": 208, + "start": 211, + "end": 212, "ctxt": 0 }, "value": "x", @@ -46,8 +46,8 @@ "value": { "type": "NumericLiteral", "span": { - "start": 211, - "end": 212, + "start": 215, + "end": 216, "ctxt": 0 }, "value": 6.0, @@ -67,15 +67,15 @@ { "type": "Constructor", "span": { - "start": 238, - "end": 369, + "start": 242, + "end": 373, "ctxt": 0 }, "key": { "type": "Identifier", "span": { - "start": 238, - "end": 249, + "start": 242, + "end": 253, "ctxt": 0 }, "value": "constructor", @@ -85,16 +85,16 @@ { "type": "Parameter", "span": { - "start": 250, - "end": 251, + "start": 254, + "end": 255, "ctxt": 0 }, "decorators": [], "pat": { "type": "Identifier", "span": { - "start": 250, - "end": 251, + "start": 254, + "end": 255, "ctxt": 0 }, "value": "n", @@ -106,46 +106,46 @@ "body": { "type": "BlockStatement", "span": { - "start": 253, - "end": 369, + "start": 257, + "end": 373, "ctxt": 0 }, "stmts": [ { "type": "ExpressionStatement", "span": { - "start": 263, - "end": 273, + "start": 267, + "end": 277, "ctxt": 0 }, "expression": { "type": "AssignmentExpression", "span": { - "start": 263, - "end": 273, + "start": 267, + "end": 277, "ctxt": 0 }, "operator": "=", "left": { "type": "MemberExpression", "span": { - "start": 263, - "end": 269, + "start": 267, + "end": 273, "ctxt": 0 }, "object": { "type": "ThisExpression", "span": { - "start": 263, - "end": 267, + "start": 267, + "end": 271, "ctxt": 0 } }, "property": { "type": "Identifier", "span": { - "start": 268, - "end": 269, + "start": 272, + "end": 273, "ctxt": 0 }, "value": "x", @@ -155,8 +155,8 @@ "right": { "type": "Identifier", "span": { - "start": 272, - "end": 273, + "start": 276, + "end": 277, "ctxt": 0 }, "value": "n", @@ -167,38 +167,38 @@ { "type": "ExpressionStatement", "span": { - "start": 353, - "end": 363, + "start": 357, + "end": 367, "ctxt": 0 }, "expression": { "type": "AssignmentExpression", "span": { - "start": 353, - "end": 363, + "start": 357, + "end": 367, "ctxt": 0 }, "operator": "=", "left": { "type": "MemberExpression", "span": { - "start": 353, - "end": 359, + "start": 357, + "end": 363, "ctxt": 0 }, "object": { "type": "ThisExpression", "span": { - "start": 353, - "end": 357, + "start": 357, + "end": 361, "ctxt": 0 } }, "property": { "type": "Identifier", "span": { - "start": 358, - "end": 359, + "start": 362, + "end": 363, "ctxt": 0 }, "value": "y", @@ -208,8 +208,8 @@ "right": { "type": "Identifier", "span": { - "start": 362, - "end": 363, + "start": 366, + "end": 367, "ctxt": 0 }, "value": "n", @@ -232,29 +232,29 @@ { "type": "ExpressionStatement", "span": { - "start": 372, - "end": 381, + "start": 376, + "end": 385, "ctxt": 0 }, "expression": { "type": "MemberExpression", "span": { - "start": 372, - "end": 381, + "start": 376, + "end": 385, "ctxt": 0 }, "object": { "type": "NewExpression", "span": { - "start": 372, - "end": 379, + "start": 376, + "end": 383, "ctxt": 0 }, "callee": { "type": "Identifier", "span": { - "start": 376, - "end": 377, + "start": 380, + "end": 381, "ctxt": 0 }, "value": "C", @@ -266,8 +266,8 @@ "property": { "type": "Identifier", "span": { - "start": 380, - "end": 381, + "start": 384, + "end": 385, "ctxt": 0 }, "value": "x", @@ -280,8 +280,8 @@ "identifier": { "type": "Identifier", "span": { - "start": 392, - "end": 393, + "start": 396, + "end": 397, "ctxt": 0 }, "value": "F", @@ -291,53 +291,53 @@ "params": [], "decorators": [], "span": { - "start": 383, - "end": 435, + "start": 387, + "end": 439, "ctxt": 0 }, "body": { "type": "BlockStatement", "span": { - "start": 396, - "end": 435, + "start": 400, + "end": 439, "ctxt": 0 }, "stmts": [ { "type": "ExpressionStatement", "span": { - "start": 423, - "end": 433, + "start": 427, + "end": 437, "ctxt": 0 }, "expression": { "type": "AssignmentExpression", "span": { - "start": 423, - "end": 433, + "start": 427, + "end": 437, "ctxt": 0 }, "operator": "=", "left": { "type": "MemberExpression", "span": { - "start": 423, - "end": 429, + "start": 427, + "end": 433, "ctxt": 0 }, "object": { "type": "ThisExpression", "span": { - "start": 423, - "end": 427, + "start": 427, + "end": 431, "ctxt": 0 } }, "property": { "type": "Identifier", "span": { - "start": 428, - "end": 429, + "start": 432, + "end": 433, "ctxt": 0 }, "value": "z", @@ -347,8 +347,8 @@ "right": { "type": "NumericLiteral", "span": { - "start": 432, - "end": 433, + "start": 436, + "end": 437, "ctxt": 0 }, "value": 1.0, @@ -368,8 +368,8 @@ "identifier": { "type": "Identifier", "span": { - "start": 499, - "end": 500, + "start": 503, + "end": 504, "ctxt": 0 }, "value": "D", @@ -377,8 +377,8 @@ }, "declare": false, "span": { - "start": 493, - "end": 543, + "start": 497, + "end": 547, "ctxt": 0 }, "decorators": [], @@ -386,15 +386,15 @@ { "type": "Constructor", "span": { - "start": 507, - "end": 541, + "start": 511, + "end": 545, "ctxt": 0 }, "key": { "type": "Identifier", "span": { - "start": 507, - "end": 518, + "start": 511, + "end": 522, "ctxt": 0 }, "value": "constructor", @@ -404,16 +404,16 @@ { "type": "Parameter", "span": { - "start": 536, - "end": 537, + "start": 540, + "end": 541, "ctxt": 0 }, "decorators": [], "pat": { "type": "Identifier", "span": { - "start": 536, - "end": 537, + "start": 540, + "end": 541, "ctxt": 0 }, "value": "x", @@ -425,8 +425,8 @@ "body": { "type": "BlockStatement", "span": { - "start": 539, - "end": 541, + "start": 543, + "end": 545, "ctxt": 0 }, "stmts": [] diff --git a/crates/swc_ecma_parser/tests/tsc/jsdocReadonlyDeclarations.ts b/crates/swc_ecma_parser/tests/tsc/jsdocReadonlyDeclarations.ts index b70e0d75b994..1036c2eb7a85 100644 --- a/crates/swc_ecma_parser/tests/tsc/jsdocReadonlyDeclarations.ts +++ b/crates/swc_ecma_parser/tests/tsc/jsdocReadonlyDeclarations.ts @@ -1,7 +1,7 @@ // @allowJs: true // @checkJs: true // @target: esnext -// @out: foo.js +// @outFile: foo.js // @declaration: true // @Filename: jsdocReadonlyDeclarations.js // @useDefineForClassFields: false @@ -28,4 +28,4 @@ function F() { // https://github.com/microsoft/TypeScript/issues/38401 class D { constructor(/** @readonly */ x) {} -} \ No newline at end of file +} diff --git a/crates/swc_ecma_parser/tests/tsc/jsdocReturnTag1.json b/crates/swc_ecma_parser/tests/tsc/jsdocReturnTag1.json index fbcf01bded0e..d4a24890378b 100644 --- a/crates/swc_ecma_parser/tests/tsc/jsdocReturnTag1.json +++ b/crates/swc_ecma_parser/tests/tsc/jsdocReturnTag1.json @@ -1,8 +1,8 @@ { "type": "Script", "span": { - "start": 129, - "end": 378, + "start": 133, + "end": 382, "ctxt": 0 }, "body": [ @@ -11,8 +11,8 @@ "identifier": { "type": "Identifier", "span": { - "start": 138, - "end": 139, + "start": 142, + "end": 143, "ctxt": 0 }, "value": "f", @@ -22,30 +22,30 @@ "params": [], "decorators": [], "span": { - "start": 129, - "end": 159, + "start": 133, + "end": 163, "ctxt": 0 }, "body": { "type": "BlockStatement", "span": { - "start": 142, - "end": 159, + "start": 146, + "end": 163, "ctxt": 0 }, "stmts": [ { "type": "ReturnStatement", "span": { - "start": 148, - "end": 157, + "start": 152, + "end": 161, "ctxt": 0 }, "argument": { "type": "NumericLiteral", "span": { - "start": 155, - "end": 156, + "start": 159, + "end": 160, "ctxt": 0 }, "value": 5.0, @@ -64,8 +64,8 @@ "identifier": { "type": "Identifier", "span": { - "start": 238, - "end": 240, + "start": 242, + "end": 244, "ctxt": 0 }, "value": "f1", @@ -75,30 +75,30 @@ "params": [], "decorators": [], "span": { - "start": 229, - "end": 260, + "start": 233, + "end": 264, "ctxt": 0 }, "body": { "type": "BlockStatement", "span": { - "start": 243, - "end": 260, + "start": 247, + "end": 264, "ctxt": 0 }, "stmts": [ { "type": "ReturnStatement", "span": { - "start": 249, - "end": 258, + "start": 253, + "end": 262, "ctxt": 0 }, "argument": { "type": "NumericLiteral", "span": { - "start": 256, - "end": 257, + "start": 260, + "end": 261, "ctxt": 0 }, "value": 5.0, @@ -117,8 +117,8 @@ "identifier": { "type": "Identifier", "span": { - "start": 345, - "end": 347, + "start": 349, + "end": 351, "ctxt": 0 }, "value": "f2", @@ -128,38 +128,38 @@ "params": [], "decorators": [], "span": { - "start": 336, - "end": 378, + "start": 340, + "end": 382, "ctxt": 0 }, "body": { "type": "BlockStatement", "span": { - "start": 350, - "end": 378, + "start": 354, + "end": 382, "ctxt": 0 }, "stmts": [ { "type": "ReturnStatement", "span": { - "start": 356, - "end": 376, + "start": 360, + "end": 380, "ctxt": 0 }, "argument": { "type": "BinaryExpression", "span": { - "start": 363, - "end": 375, + "start": 367, + "end": 379, "ctxt": 0 }, "operator": "||", "left": { "type": "NumericLiteral", "span": { - "start": 363, - "end": 364, + "start": 367, + "end": 368, "ctxt": 0 }, "value": 5.0, @@ -168,8 +168,8 @@ "right": { "type": "StringLiteral", "span": { - "start": 368, - "end": 375, + "start": 372, + "end": 379, "ctxt": 0 }, "value": "hello", diff --git a/crates/swc_ecma_parser/tests/tsc/jsdocReturnTag1.ts b/crates/swc_ecma_parser/tests/tsc/jsdocReturnTag1.ts index 046c1d84b62f..fe4be551c4c7 100644 --- a/crates/swc_ecma_parser/tests/tsc/jsdocReturnTag1.ts +++ b/crates/swc_ecma_parser/tests/tsc/jsdocReturnTag1.ts @@ -1,6 +1,6 @@ // @allowJs: true // @filename: returns.js -// @out: dummy.js +// @outFile: dummy.js /** * @returns {string} This comment is not currently exposed */ @@ -20,4 +20,4 @@ function f1() { */ function f2() { return 5 || "hello"; -} \ No newline at end of file +} diff --git a/crates/swc_ecma_parser/tests/tsc/libReferenceDeclarationEmit.json b/crates/swc_ecma_parser/tests/tsc/libReferenceDeclarationEmit.json index 71257cde2d4e..24e91ac6b436 100644 --- a/crates/swc_ecma_parser/tests/tsc/libReferenceDeclarationEmit.json +++ b/crates/swc_ecma_parser/tests/tsc/libReferenceDeclarationEmit.json @@ -1,23 +1,23 @@ { "type": "Module", "span": { - "start": 130, - "end": 264, + "start": 146, + "end": 296, "ctxt": 0 }, "body": [ { "type": "ExportDeclaration", "span": { - "start": 130, - "end": 169, + "start": 146, + "end": 185, "ctxt": 0 }, "declaration": { "type": "VariableDeclaration", "span": { - "start": 137, - "end": 169, + "start": 153, + "end": 185, "ctxt": 0 }, "kind": "const", @@ -26,15 +26,15 @@ { "type": "VariableDeclarator", "span": { - "start": 151, - "end": 168, + "start": 167, + "end": 184, "ctxt": 0 }, "id": { "type": "Identifier", "span": { - "start": 151, - "end": 155, + "start": 167, + "end": 171, "ctxt": 0 }, "value": "elem", @@ -42,22 +42,22 @@ "typeAnnotation": { "type": "TsTypeAnnotation", "span": { - "start": 155, - "end": 168, + "start": 171, + "end": 184, "ctxt": 0 }, "typeAnnotation": { "type": "TsTypeReference", "span": { - "start": 157, - "end": 168, + "start": 173, + "end": 184, "ctxt": 0 }, "typeName": { "type": "Identifier", "span": { - "start": 157, - "end": 168, + "start": 173, + "end": 184, "ctxt": 0 }, "value": "HTMLElement", @@ -76,8 +76,8 @@ { "type": "ExportNamedDeclaration", "span": { - "start": 222, - "end": 231, + "start": 254, + "end": 263, "ctxt": 0 }, "specifiers": [], @@ -88,8 +88,8 @@ { "type": "VariableDeclaration", "span": { - "start": 232, - "end": 264, + "start": 264, + "end": 296, "ctxt": 0 }, "kind": "const", @@ -98,15 +98,15 @@ { "type": "VariableDeclarator", "span": { - "start": 246, - "end": 263, + "start": 278, + "end": 295, "ctxt": 0 }, "id": { "type": "Identifier", "span": { - "start": 246, - "end": 250, + "start": 278, + "end": 282, "ctxt": 0 }, "value": "elem", @@ -114,22 +114,22 @@ "typeAnnotation": { "type": "TsTypeAnnotation", "span": { - "start": 250, - "end": 263, + "start": 282, + "end": 295, "ctxt": 0 }, "typeAnnotation": { "type": "TsTypeReference", "span": { - "start": 252, - "end": 263, + "start": 284, + "end": 295, "ctxt": 0 }, "typeName": { "type": "Identifier", "span": { - "start": 252, - "end": 263, + "start": 284, + "end": 295, "ctxt": 0 }, "value": "HTMLElement", diff --git a/crates/swc_ecma_parser/tests/tsc/libReferenceDeclarationEmit.ts b/crates/swc_ecma_parser/tests/tsc/libReferenceDeclarationEmit.ts index 02e4cd895ae1..6c2d061d31d1 100644 --- a/crates/swc_ecma_parser/tests/tsc/libReferenceDeclarationEmit.ts +++ b/crates/swc_ecma_parser/tests/tsc/libReferenceDeclarationEmit.ts @@ -3,10 +3,10 @@ // @lib: esnext // @declaration: true // @filename: file1.ts -/// +/// export declare const elem: HTMLElement; // @filename: file2.ts -/// +/// export {} declare const elem: HTMLElement; \ No newline at end of file diff --git a/crates/swc_ecma_parser/tests/tsc/libReferenceDeclarationEmitBundle.json b/crates/swc_ecma_parser/tests/tsc/libReferenceDeclarationEmitBundle.json index 530508e646a6..9cccdcabc8ee 100644 --- a/crates/swc_ecma_parser/tests/tsc/libReferenceDeclarationEmitBundle.json +++ b/crates/swc_ecma_parser/tests/tsc/libReferenceDeclarationEmitBundle.json @@ -1,23 +1,23 @@ { "type": "Module", "span": { - "start": 148, - "end": 282, + "start": 164, + "end": 314, "ctxt": 0 }, "body": [ { "type": "ExportDeclaration", "span": { - "start": 148, - "end": 187, + "start": 164, + "end": 203, "ctxt": 0 }, "declaration": { "type": "VariableDeclaration", "span": { - "start": 155, - "end": 187, + "start": 171, + "end": 203, "ctxt": 0 }, "kind": "const", @@ -26,15 +26,15 @@ { "type": "VariableDeclarator", "span": { - "start": 169, - "end": 186, + "start": 185, + "end": 202, "ctxt": 0 }, "id": { "type": "Identifier", "span": { - "start": 169, - "end": 173, + "start": 185, + "end": 189, "ctxt": 0 }, "value": "elem", @@ -42,22 +42,22 @@ "typeAnnotation": { "type": "TsTypeAnnotation", "span": { - "start": 173, - "end": 186, + "start": 189, + "end": 202, "ctxt": 0 }, "typeAnnotation": { "type": "TsTypeReference", "span": { - "start": 175, - "end": 186, + "start": 191, + "end": 202, "ctxt": 0 }, "typeName": { "type": "Identifier", "span": { - "start": 175, - "end": 186, + "start": 191, + "end": 202, "ctxt": 0 }, "value": "HTMLElement", @@ -76,8 +76,8 @@ { "type": "ExportNamedDeclaration", "span": { - "start": 240, - "end": 249, + "start": 272, + "end": 281, "ctxt": 0 }, "specifiers": [], @@ -88,8 +88,8 @@ { "type": "VariableDeclaration", "span": { - "start": 250, - "end": 282, + "start": 282, + "end": 314, "ctxt": 0 }, "kind": "const", @@ -98,15 +98,15 @@ { "type": "VariableDeclarator", "span": { - "start": 264, - "end": 281, + "start": 296, + "end": 313, "ctxt": 0 }, "id": { "type": "Identifier", "span": { - "start": 264, - "end": 268, + "start": 296, + "end": 300, "ctxt": 0 }, "value": "elem", @@ -114,22 +114,22 @@ "typeAnnotation": { "type": "TsTypeAnnotation", "span": { - "start": 268, - "end": 281, + "start": 300, + "end": 313, "ctxt": 0 }, "typeAnnotation": { "type": "TsTypeReference", "span": { - "start": 270, - "end": 281, + "start": 302, + "end": 313, "ctxt": 0 }, "typeName": { "type": "Identifier", "span": { - "start": 270, - "end": 281, + "start": 302, + "end": 313, "ctxt": 0 }, "value": "HTMLElement", diff --git a/crates/swc_ecma_parser/tests/tsc/libReferenceDeclarationEmitBundle.ts b/crates/swc_ecma_parser/tests/tsc/libReferenceDeclarationEmitBundle.ts index aa4c09477e0f..b5180a980207 100644 --- a/crates/swc_ecma_parser/tests/tsc/libReferenceDeclarationEmitBundle.ts +++ b/crates/swc_ecma_parser/tests/tsc/libReferenceDeclarationEmitBundle.ts @@ -4,10 +4,10 @@ // @declaration: true // @outFile: bundle.js // @filename: file1.ts -/// +/// export declare const elem: HTMLElement; // @filename: file2.ts -/// +/// export {} declare const elem: HTMLElement; \ No newline at end of file diff --git a/crates/swc_ecma_parser/tests/tsc/mappedTypesGenericTuples2.json b/crates/swc_ecma_parser/tests/tsc/mappedTypesGenericTuples2.json new file mode 100644 index 000000000000..801694baaaa8 --- /dev/null +++ b/crates/swc_ecma_parser/tests/tsc/mappedTypesGenericTuples2.json @@ -0,0 +1,503 @@ +{ + "type": "Script", + "span": { + "start": 109, + "end": 319, + "ctxt": 0 + }, + "body": [ + { + "type": "FunctionDeclaration", + "identifier": { + "type": "Identifier", + "span": { + "start": 126, + "end": 130, + "ctxt": 0 + }, + "value": "getT", + "optional": false + }, + "declare": true, + "params": [], + "decorators": [], + "span": { + "start": 109, + "end": 139, + "ctxt": 0 + }, + "body": null, + "generator": false, + "async": false, + "typeParameters": { + "type": "TsTypeParameterDeclaration", + "span": { + "start": 130, + "end": 133, + "ctxt": 0 + }, + "parameters": [ + { + "type": "TsTypeParameter", + "span": { + "start": 131, + "end": 132, + "ctxt": 0 + }, + "name": { + "type": "Identifier", + "span": { + "start": 131, + "end": 132, + "ctxt": 0 + }, + "value": "T", + "optional": false + }, + "in": false, + "out": false, + "const": false, + "constraint": null, + "default": null + } + ] + }, + "returnType": { + "type": "TsTypeAnnotation", + "span": { + "start": 135, + "end": 138, + "ctxt": 0 + }, + "typeAnnotation": { + "type": "TsTypeReference", + "span": { + "start": 137, + "end": 138, + "ctxt": 0 + }, + "typeName": { + "type": "Identifier", + "span": { + "start": 137, + "end": 138, + "ctxt": 0 + }, + "value": "T", + "optional": false + }, + "typeParams": null + } + } + }, + { + "type": "ExpressionStatement", + "span": { + "start": 141, + "end": 319, + "ctxt": 0 + }, + "expression": { + "type": "CallExpression", + "span": { + "start": 141, + "end": 318, + "ctxt": 0 + }, + "callee": { + "type": "MemberExpression", + "span": { + "start": 141, + "end": 191, + "ctxt": 0 + }, + "object": { + "type": "CallExpression", + "span": { + "start": 141, + "end": 186, + "ctxt": 0 + }, + "callee": { + "type": "MemberExpression", + "span": { + "start": 141, + "end": 152, + "ctxt": 0 + }, + "object": { + "type": "Identifier", + "span": { + "start": 141, + "end": 148, + "ctxt": 0 + }, + "value": "Promise", + "optional": false + }, + "property": { + "type": "Identifier", + "span": { + "start": 149, + "end": 152, + "ctxt": 0 + }, + "value": "all", + "optional": false + } + }, + "arguments": [ + { + "spread": null, + "expression": { + "type": "ArrayExpression", + "span": { + "start": 153, + "end": 185, + "ctxt": 0 + }, + "elements": [ + { + "spread": null, + "expression": { + "type": "CallExpression", + "span": { + "start": 154, + "end": 168, + "ctxt": 0 + }, + "callee": { + "type": "Identifier", + "span": { + "start": 154, + "end": 158, + "ctxt": 0 + }, + "value": "getT", + "optional": false + }, + "arguments": [], + "typeArguments": { + "type": "TsTypeParameterInstantiation", + "span": { + "start": 158, + "end": 166, + "ctxt": 0 + }, + "params": [ + { + "type": "TsKeywordType", + "span": { + "start": 159, + "end": 165, + "ctxt": 0 + }, + "kind": "string" + } + ] + } + } + }, + { + "spread": { + "start": 170, + "end": 173, + "ctxt": 0 + }, + "expression": { + "type": "CallExpression", + "span": { + "start": 173, + "end": 184, + "ctxt": 0 + }, + "callee": { + "type": "Identifier", + "span": { + "start": 173, + "end": 177, + "ctxt": 0 + }, + "value": "getT", + "optional": false + }, + "arguments": [], + "typeArguments": { + "type": "TsTypeParameterInstantiation", + "span": { + "start": 177, + "end": 182, + "ctxt": 0 + }, + "params": [ + { + "type": "TsKeywordType", + "span": { + "start": 178, + "end": 181, + "ctxt": 0 + }, + "kind": "any" + } + ] + } + } + } + ] + } + } + ], + "typeArguments": null + }, + "property": { + "type": "Identifier", + "span": { + "start": 187, + "end": 191, + "ctxt": 0 + }, + "value": "then", + "optional": false + } + }, + "arguments": [ + { + "spread": null, + "expression": { + "type": "ArrowFunctionExpression", + "span": { + "start": 192, + "end": 317, + "ctxt": 0 + }, + "params": [ + { + "type": "Identifier", + "span": { + "start": 193, + "end": 199, + "ctxt": 0 + }, + "value": "result", + "optional": false, + "typeAnnotation": null + } + ], + "body": { + "type": "BlockStatement", + "span": { + "start": 204, + "end": 317, + "ctxt": 0 + }, + "stmts": [ + { + "type": "VariableDeclaration", + "span": { + "start": 208, + "end": 231, + "ctxt": 0 + }, + "kind": "const", + "declare": false, + "declarations": [ + { + "type": "VariableDeclarator", + "span": { + "start": 214, + "end": 230, + "ctxt": 0 + }, + "id": { + "type": "Identifier", + "span": { + "start": 214, + "end": 218, + "ctxt": 0 + }, + "value": "head", + "optional": false, + "typeAnnotation": null + }, + "init": { + "type": "MemberExpression", + "span": { + "start": 221, + "end": 230, + "ctxt": 0 + }, + "object": { + "type": "Identifier", + "span": { + "start": 221, + "end": 227, + "ctxt": 0 + }, + "value": "result", + "optional": false + }, + "property": { + "type": "Computed", + "span": { + "start": 227, + "end": 230, + "ctxt": 0 + }, + "expression": { + "type": "NumericLiteral", + "span": { + "start": 228, + "end": 229, + "ctxt": 0 + }, + "value": 0.0, + "raw": "0" + } + } + }, + "definite": false + } + ] + }, + { + "type": "VariableDeclaration", + "span": { + "start": 244, + "end": 273, + "ctxt": 0 + }, + "kind": "const", + "declare": false, + "declarations": [ + { + "type": "VariableDeclarator", + "span": { + "start": 250, + "end": 272, + "ctxt": 0 + }, + "id": { + "type": "Identifier", + "span": { + "start": 250, + "end": 254, + "ctxt": 0 + }, + "value": "tail", + "optional": false, + "typeAnnotation": null + }, + "init": { + "type": "CallExpression", + "span": { + "start": 257, + "end": 272, + "ctxt": 0 + }, + "callee": { + "type": "MemberExpression", + "span": { + "start": 257, + "end": 269, + "ctxt": 0 + }, + "object": { + "type": "Identifier", + "span": { + "start": 257, + "end": 263, + "ctxt": 0 + }, + "value": "result", + "optional": false + }, + "property": { + "type": "Identifier", + "span": { + "start": 264, + "end": 269, + "ctxt": 0 + }, + "value": "slice", + "optional": false + } + }, + "arguments": [ + { + "spread": null, + "expression": { + "type": "NumericLiteral", + "span": { + "start": 270, + "end": 271, + "ctxt": 0 + }, + "value": 1.0, + "raw": "1" + } + } + ], + "typeArguments": null + }, + "definite": false + } + ] + }, + { + "type": "ExpressionStatement", + "span": { + "start": 285, + "end": 309, + "ctxt": 0 + }, + "expression": { + "type": "TsSatisfiesExpression", + "span": { + "start": 285, + "end": 308, + "ctxt": 0 + }, + "expression": { + "type": "Identifier", + "span": { + "start": 285, + "end": 289, + "ctxt": 0 + }, + "value": "tail", + "optional": false + }, + "typeAnnotation": { + "type": "TsArrayType", + "span": { + "start": 300, + "end": 308, + "ctxt": 0 + }, + "elemType": { + "type": "TsKeywordType", + "span": { + "start": 300, + "end": 306, + "ctxt": 0 + }, + "kind": "string" + } + } + } + } + ] + }, + "async": false, + "generator": false, + "typeParameters": null, + "returnType": null + } + } + ], + "typeArguments": null + } + } + ], + "interpreter": null +} diff --git a/crates/swc_ecma_parser/tests/tsc/mappedTypesGenericTuples2.ts b/crates/swc_ecma_parser/tests/tsc/mappedTypesGenericTuples2.ts new file mode 100644 index 000000000000..6d411634bc4b --- /dev/null +++ b/crates/swc_ecma_parser/tests/tsc/mappedTypesGenericTuples2.ts @@ -0,0 +1,13 @@ +// @strict: true +// @lib: esnext +// @noEmit: true + +// https://github.com/microsoft/TypeScript/issues/57389 + +declare function getT(): T; + +Promise.all([getT(), ...getT()]).then((result) => { + const head = result[0]; // string + const tail = result.slice(1); // any[] + tail satisfies string[]; // ok +}); diff --git a/crates/swc_ecma_parser/tests/tsc/methodsReturningThis.json b/crates/swc_ecma_parser/tests/tsc/methodsReturningThis.json index 945de32ab850..e569c1569c95 100644 --- a/crates/swc_ecma_parser/tests/tsc/methodsReturningThis.json +++ b/crates/swc_ecma_parser/tests/tsc/methodsReturningThis.json @@ -1,8 +1,8 @@ { "type": "Script", "span": { - "start": 61, - "end": 842, + "start": 65, + "end": 846, "ctxt": 0 }, "body": [ @@ -11,8 +11,8 @@ "identifier": { "type": "Identifier", "span": { - "start": 70, - "end": 75, + "start": 74, + "end": 79, "ctxt": 0 }, "value": "Class", @@ -22,15 +22,15 @@ "params": [], "decorators": [], "span": { - "start": 61, - "end": 81, + "start": 65, + "end": 85, "ctxt": 0 }, "body": { "type": "BlockStatement", "span": { - "start": 78, - "end": 81, + "start": 82, + "end": 85, "ctxt": 0 }, "stmts": [] @@ -43,37 +43,37 @@ { "type": "ExpressionStatement", "span": { - "start": 136, - "end": 208, + "start": 140, + "end": 212, "ctxt": 0 }, "expression": { "type": "AssignmentExpression", "span": { - "start": 136, - "end": 207, + "start": 140, + "end": 211, "ctxt": 0 }, "operator": "=", "left": { "type": "MemberExpression", "span": { - "start": 136, - "end": 165, + "start": 140, + "end": 169, "ctxt": 0 }, "object": { "type": "MemberExpression", "span": { - "start": 136, - "end": 151, + "start": 140, + "end": 155, "ctxt": 0 }, "object": { "type": "Identifier", "span": { - "start": 136, - "end": 141, + "start": 140, + "end": 145, "ctxt": 0 }, "value": "Class", @@ -82,8 +82,8 @@ "property": { "type": "Identifier", "span": { - "start": 142, - "end": 151, + "start": 146, + "end": 155, "ctxt": 0 }, "value": "prototype", @@ -93,8 +93,8 @@ "property": { "type": "Identifier", "span": { - "start": 152, - "end": 165, + "start": 156, + "end": 169, "ctxt": 0 }, "value": "containsError", @@ -107,45 +107,45 @@ "params": [], "decorators": [], "span": { - "start": 168, - "end": 207, + "start": 172, + "end": 211, "ctxt": 0 }, "body": { "type": "BlockStatement", "span": { - "start": 180, - "end": 207, + "start": 184, + "end": 211, "ctxt": 0 }, "stmts": [ { "type": "ReturnStatement", "span": { - "start": 182, - "end": 205, + "start": 186, + "end": 209, "ctxt": 0 }, "argument": { "type": "MemberExpression", "span": { - "start": 189, - "end": 204, + "start": 193, + "end": 208, "ctxt": 0 }, "object": { "type": "ThisExpression", "span": { - "start": 189, - "end": 193, + "start": 193, + "end": 197, "ctxt": 0 } }, "property": { "type": "Identifier", "span": { - "start": 194, - "end": 204, + "start": 198, + "end": 208, "ctxt": 0 }, "value": "notPresent", @@ -165,37 +165,37 @@ { "type": "ExpressionStatement", "span": { - "start": 283, - "end": 351, + "start": 287, + "end": 355, "ctxt": 0 }, "expression": { "type": "AssignmentExpression", "span": { - "start": 283, - "end": 350, + "start": 287, + "end": 354, "ctxt": 0 }, "operator": "=", "left": { "type": "MemberExpression", "span": { - "start": 283, - "end": 301, + "start": 287, + "end": 305, "ctxt": 0 }, "object": { "type": "MemberExpression", "span": { - "start": 283, - "end": 298, + "start": 287, + "end": 302, "ctxt": 0 }, "object": { "type": "Identifier", "span": { - "start": 283, - "end": 288, + "start": 287, + "end": 292, "ctxt": 0 }, "value": "Class", @@ -204,8 +204,8 @@ "property": { "type": "Identifier", "span": { - "start": 289, - "end": 298, + "start": 293, + "end": 302, "ctxt": 0 }, "value": "prototype", @@ -215,8 +215,8 @@ "property": { "type": "Identifier", "span": { - "start": 299, - "end": 301, + "start": 303, + "end": 305, "ctxt": 0 }, "value": "m1", @@ -230,16 +230,16 @@ { "type": "Parameter", "span": { - "start": 314, - "end": 315, + "start": 318, + "end": 319, "ctxt": 0 }, "decorators": [], "pat": { "type": "Identifier", "span": { - "start": 314, - "end": 315, + "start": 318, + "end": 319, "ctxt": 0 }, "value": "a", @@ -250,16 +250,16 @@ { "type": "Parameter", "span": { - "start": 317, - "end": 318, + "start": 321, + "end": 322, "ctxt": 0 }, "decorators": [], "pat": { "type": "Identifier", "span": { - "start": 317, - "end": 318, + "start": 321, + "end": 322, "ctxt": 0 }, "value": "b", @@ -270,16 +270,16 @@ { "type": "Parameter", "span": { - "start": 320, - "end": 321, + "start": 324, + "end": 325, "ctxt": 0 }, "decorators": [], "pat": { "type": "Identifier", "span": { - "start": 320, - "end": 321, + "start": 324, + "end": 325, "ctxt": 0 }, "value": "c", @@ -290,16 +290,16 @@ { "type": "Parameter", "span": { - "start": 323, - "end": 324, + "start": 327, + "end": 328, "ctxt": 0 }, "decorators": [], "pat": { "type": "Identifier", "span": { - "start": 323, - "end": 324, + "start": 327, + "end": 328, "ctxt": 0 }, "value": "d", @@ -310,16 +310,16 @@ { "type": "Parameter", "span": { - "start": 326, - "end": 328, + "start": 330, + "end": 332, "ctxt": 0 }, "decorators": [], "pat": { "type": "Identifier", "span": { - "start": 326, - "end": 328, + "start": 330, + "end": 332, "ctxt": 0 }, "value": "tx", @@ -330,16 +330,16 @@ { "type": "Parameter", "span": { - "start": 330, - "end": 332, + "start": 334, + "end": 336, "ctxt": 0 }, "decorators": [], "pat": { "type": "Identifier", "span": { - "start": 330, - "end": 332, + "start": 334, + "end": 336, "ctxt": 0 }, "value": "ty", @@ -350,30 +350,30 @@ ], "decorators": [], "span": { - "start": 304, - "end": 350, + "start": 308, + "end": 354, "ctxt": 0 }, "body": { "type": "BlockStatement", "span": { - "start": 334, - "end": 350, + "start": 338, + "end": 354, "ctxt": 0 }, "stmts": [ { "type": "ReturnStatement", "span": { - "start": 336, - "end": 348, + "start": 340, + "end": 352, "ctxt": 0 }, "argument": { "type": "ThisExpression", "span": { - "start": 343, - "end": 347, + "start": 347, + "end": 351, "ctxt": 0 } } @@ -390,37 +390,37 @@ { "type": "ExpressionStatement", "span": { - "start": 352, - "end": 406, + "start": 356, + "end": 410, "ctxt": 0 }, "expression": { "type": "AssignmentExpression", "span": { - "start": 352, - "end": 405, + "start": 356, + "end": 409, "ctxt": 0 }, "operator": "=", "left": { "type": "MemberExpression", "span": { - "start": 352, - "end": 370, + "start": 356, + "end": 374, "ctxt": 0 }, "object": { "type": "MemberExpression", "span": { - "start": 352, - "end": 367, + "start": 356, + "end": 371, "ctxt": 0 }, "object": { "type": "Identifier", "span": { - "start": 352, - "end": 357, + "start": 356, + "end": 361, "ctxt": 0 }, "value": "Class", @@ -429,8 +429,8 @@ "property": { "type": "Identifier", "span": { - "start": 358, - "end": 367, + "start": 362, + "end": 371, "ctxt": 0 }, "value": "prototype", @@ -440,8 +440,8 @@ "property": { "type": "Identifier", "span": { - "start": 368, - "end": 370, + "start": 372, + "end": 374, "ctxt": 0 }, "value": "m2", @@ -455,16 +455,16 @@ { "type": "Parameter", "span": { - "start": 383, - "end": 384, + "start": 387, + "end": 388, "ctxt": 0 }, "decorators": [], "pat": { "type": "Identifier", "span": { - "start": 383, - "end": 384, + "start": 387, + "end": 388, "ctxt": 0 }, "value": "x", @@ -475,16 +475,16 @@ { "type": "Parameter", "span": { - "start": 386, - "end": 387, + "start": 390, + "end": 391, "ctxt": 0 }, "decorators": [], "pat": { "type": "Identifier", "span": { - "start": 386, - "end": 387, + "start": 390, + "end": 391, "ctxt": 0 }, "value": "y", @@ -495,30 +495,30 @@ ], "decorators": [], "span": { - "start": 373, - "end": 405, + "start": 377, + "end": 409, "ctxt": 0 }, "body": { "type": "BlockStatement", "span": { - "start": 389, - "end": 405, + "start": 393, + "end": 409, "ctxt": 0 }, "stmts": [ { "type": "ReturnStatement", "span": { - "start": 391, - "end": 403, + "start": 395, + "end": 407, "ctxt": 0 }, "argument": { "type": "ThisExpression", "span": { - "start": 398, - "end": 402, + "start": 402, + "end": 406, "ctxt": 0 } } @@ -535,37 +535,37 @@ { "type": "ExpressionStatement", "span": { - "start": 407, - "end": 461, + "start": 411, + "end": 465, "ctxt": 0 }, "expression": { "type": "AssignmentExpression", "span": { - "start": 407, - "end": 460, + "start": 411, + "end": 464, "ctxt": 0 }, "operator": "=", "left": { "type": "MemberExpression", "span": { - "start": 407, - "end": 425, + "start": 411, + "end": 429, "ctxt": 0 }, "object": { "type": "MemberExpression", "span": { - "start": 407, - "end": 422, + "start": 411, + "end": 426, "ctxt": 0 }, "object": { "type": "Identifier", "span": { - "start": 407, - "end": 412, + "start": 411, + "end": 416, "ctxt": 0 }, "value": "Class", @@ -574,8 +574,8 @@ "property": { "type": "Identifier", "span": { - "start": 413, - "end": 422, + "start": 417, + "end": 426, "ctxt": 0 }, "value": "prototype", @@ -585,8 +585,8 @@ "property": { "type": "Identifier", "span": { - "start": 423, - "end": 425, + "start": 427, + "end": 429, "ctxt": 0 }, "value": "m3", @@ -600,16 +600,16 @@ { "type": "Parameter", "span": { - "start": 438, - "end": 439, + "start": 442, + "end": 443, "ctxt": 0 }, "decorators": [], "pat": { "type": "Identifier", "span": { - "start": 438, - "end": 439, + "start": 442, + "end": 443, "ctxt": 0 }, "value": "x", @@ -620,16 +620,16 @@ { "type": "Parameter", "span": { - "start": 441, - "end": 442, + "start": 445, + "end": 446, "ctxt": 0 }, "decorators": [], "pat": { "type": "Identifier", "span": { - "start": 441, - "end": 442, + "start": 445, + "end": 446, "ctxt": 0 }, "value": "y", @@ -640,30 +640,30 @@ ], "decorators": [], "span": { - "start": 428, - "end": 460, + "start": 432, + "end": 464, "ctxt": 0 }, "body": { "type": "BlockStatement", "span": { - "start": 444, - "end": 460, + "start": 448, + "end": 464, "ctxt": 0 }, "stmts": [ { "type": "ReturnStatement", "span": { - "start": 446, - "end": 458, + "start": 450, + "end": 462, "ctxt": 0 }, "argument": { "type": "ThisExpression", "span": { - "start": 453, - "end": 457, + "start": 457, + "end": 461, "ctxt": 0 } } @@ -680,37 +680,37 @@ { "type": "ExpressionStatement", "span": { - "start": 462, - "end": 517, + "start": 466, + "end": 521, "ctxt": 0 }, "expression": { "type": "AssignmentExpression", "span": { - "start": 462, - "end": 516, + "start": 466, + "end": 520, "ctxt": 0 }, "operator": "=", "left": { "type": "MemberExpression", "span": { - "start": 462, - "end": 480, + "start": 466, + "end": 484, "ctxt": 0 }, "object": { "type": "MemberExpression", "span": { - "start": 462, - "end": 477, + "start": 466, + "end": 481, "ctxt": 0 }, "object": { "type": "Identifier", "span": { - "start": 462, - "end": 467, + "start": 466, + "end": 471, "ctxt": 0 }, "value": "Class", @@ -719,8 +719,8 @@ "property": { "type": "Identifier", "span": { - "start": 468, - "end": 477, + "start": 472, + "end": 481, "ctxt": 0 }, "value": "prototype", @@ -730,8 +730,8 @@ "property": { "type": "Identifier", "span": { - "start": 478, - "end": 480, + "start": 482, + "end": 484, "ctxt": 0 }, "value": "m4", @@ -745,16 +745,16 @@ { "type": "Parameter", "span": { - "start": 493, - "end": 498, + "start": 497, + "end": 502, "ctxt": 0 }, "decorators": [], "pat": { "type": "Identifier", "span": { - "start": 493, - "end": 498, + "start": 497, + "end": 502, "ctxt": 0 }, "value": "angle", @@ -765,30 +765,30 @@ ], "decorators": [], "span": { - "start": 483, - "end": 516, + "start": 487, + "end": 520, "ctxt": 0 }, "body": { "type": "BlockStatement", "span": { - "start": 500, - "end": 516, + "start": 504, + "end": 520, "ctxt": 0 }, "stmts": [ { "type": "ReturnStatement", "span": { - "start": 502, - "end": 514, + "start": 506, + "end": 518, "ctxt": 0 }, "argument": { "type": "ThisExpression", "span": { - "start": 509, - "end": 513, + "start": 513, + "end": 517, "ctxt": 0 } } @@ -805,37 +805,37 @@ { "type": "ExpressionStatement", "span": { - "start": 518, - "end": 574, + "start": 522, + "end": 578, "ctxt": 0 }, "expression": { "type": "AssignmentExpression", "span": { - "start": 518, - "end": 573, + "start": 522, + "end": 577, "ctxt": 0 }, "operator": "=", "left": { "type": "MemberExpression", "span": { - "start": 518, - "end": 536, + "start": 522, + "end": 540, "ctxt": 0 }, "object": { "type": "MemberExpression", "span": { - "start": 518, - "end": 533, + "start": 522, + "end": 537, "ctxt": 0 }, "object": { "type": "Identifier", "span": { - "start": 518, - "end": 523, + "start": 522, + "end": 527, "ctxt": 0 }, "value": "Class", @@ -844,8 +844,8 @@ "property": { "type": "Identifier", "span": { - "start": 524, - "end": 533, + "start": 528, + "end": 537, "ctxt": 0 }, "value": "prototype", @@ -855,8 +855,8 @@ "property": { "type": "Identifier", "span": { - "start": 534, - "end": 536, + "start": 538, + "end": 540, "ctxt": 0 }, "value": "m5", @@ -870,16 +870,16 @@ { "type": "Parameter", "span": { - "start": 549, - "end": 555, + "start": 553, + "end": 559, "ctxt": 0 }, "decorators": [], "pat": { "type": "Identifier", "span": { - "start": 549, - "end": 555, + "start": 553, + "end": 559, "ctxt": 0 }, "value": "matrix", @@ -890,30 +890,30 @@ ], "decorators": [], "span": { - "start": 539, - "end": 573, + "start": 543, + "end": 577, "ctxt": 0 }, "body": { "type": "BlockStatement", "span": { - "start": 557, - "end": 573, + "start": 561, + "end": 577, "ctxt": 0 }, "stmts": [ { "type": "ReturnStatement", "span": { - "start": 559, - "end": 571, + "start": 563, + "end": 575, "ctxt": 0 }, "argument": { "type": "ThisExpression", "span": { - "start": 566, - "end": 570, + "start": 570, + "end": 574, "ctxt": 0 } } @@ -930,37 +930,37 @@ { "type": "ExpressionStatement", "span": { - "start": 575, - "end": 685, + "start": 579, + "end": 689, "ctxt": 0 }, "expression": { "type": "AssignmentExpression", "span": { - "start": 575, - "end": 684, + "start": 579, + "end": 688, "ctxt": 0 }, "operator": "=", "left": { "type": "MemberExpression", "span": { - "start": 575, - "end": 593, + "start": 579, + "end": 597, "ctxt": 0 }, "object": { "type": "MemberExpression", "span": { - "start": 575, - "end": 590, + "start": 579, + "end": 594, "ctxt": 0 }, "object": { "type": "Identifier", "span": { - "start": 575, - "end": 580, + "start": 579, + "end": 584, "ctxt": 0 }, "value": "Class", @@ -969,8 +969,8 @@ "property": { "type": "Identifier", "span": { - "start": 581, - "end": 590, + "start": 585, + "end": 594, "ctxt": 0 }, "value": "prototype", @@ -980,8 +980,8 @@ "property": { "type": "Identifier", "span": { - "start": 591, - "end": 593, + "start": 595, + "end": 597, "ctxt": 0 }, "value": "m6", @@ -995,16 +995,16 @@ { "type": "Parameter", "span": { - "start": 606, - "end": 607, + "start": 610, + "end": 611, "ctxt": 0 }, "decorators": [], "pat": { "type": "Identifier", "span": { - "start": 606, - "end": 607, + "start": 610, + "end": 611, "ctxt": 0 }, "value": "x", @@ -1015,16 +1015,16 @@ { "type": "Parameter", "span": { - "start": 609, - "end": 610, + "start": 613, + "end": 614, "ctxt": 0 }, "decorators": [], "pat": { "type": "Identifier", "span": { - "start": 609, - "end": 610, + "start": 613, + "end": 614, "ctxt": 0 }, "value": "y", @@ -1035,16 +1035,16 @@ { "type": "Parameter", "span": { - "start": 612, - "end": 618, + "start": 616, + "end": 622, "ctxt": 0 }, "decorators": [], "pat": { "type": "Identifier", "span": { - "start": 612, - "end": 618, + "start": 616, + "end": 622, "ctxt": 0 }, "value": "pivotX", @@ -1055,16 +1055,16 @@ { "type": "Parameter", "span": { - "start": 620, - "end": 626, + "start": 624, + "end": 630, "ctxt": 0 }, "decorators": [], "pat": { "type": "Identifier", "span": { - "start": 620, - "end": 626, + "start": 624, + "end": 630, "ctxt": 0 }, "value": "pivotY", @@ -1075,16 +1075,16 @@ { "type": "Parameter", "span": { - "start": 628, - "end": 634, + "start": 632, + "end": 638, "ctxt": 0 }, "decorators": [], "pat": { "type": "Identifier", "span": { - "start": 628, - "end": 634, + "start": 632, + "end": 638, "ctxt": 0 }, "value": "scaleX", @@ -1095,16 +1095,16 @@ { "type": "Parameter", "span": { - "start": 636, - "end": 642, + "start": 640, + "end": 646, "ctxt": 0 }, "decorators": [], "pat": { "type": "Identifier", "span": { - "start": 636, - "end": 642, + "start": 640, + "end": 646, "ctxt": 0 }, "value": "scaleY", @@ -1115,16 +1115,16 @@ { "type": "Parameter", "span": { - "start": 644, - "end": 652, + "start": 648, + "end": 656, "ctxt": 0 }, "decorators": [], "pat": { "type": "Identifier", "span": { - "start": 644, - "end": 652, + "start": 648, + "end": 656, "ctxt": 0 }, "value": "rotation", @@ -1135,16 +1135,16 @@ { "type": "Parameter", "span": { - "start": 654, - "end": 659, + "start": 658, + "end": 663, "ctxt": 0 }, "decorators": [], "pat": { "type": "Identifier", "span": { - "start": 654, - "end": 659, + "start": 658, + "end": 663, "ctxt": 0 }, "value": "skewX", @@ -1155,16 +1155,16 @@ { "type": "Parameter", "span": { - "start": 661, - "end": 666, + "start": 665, + "end": 670, "ctxt": 0 }, "decorators": [], "pat": { "type": "Identifier", "span": { - "start": 661, - "end": 666, + "start": 665, + "end": 670, "ctxt": 0 }, "value": "skewY", @@ -1175,30 +1175,30 @@ ], "decorators": [], "span": { - "start": 596, - "end": 684, + "start": 600, + "end": 688, "ctxt": 0 }, "body": { "type": "BlockStatement", "span": { - "start": 668, - "end": 684, + "start": 672, + "end": 688, "ctxt": 0 }, "stmts": [ { "type": "ReturnStatement", "span": { - "start": 670, - "end": 682, + "start": 674, + "end": 686, "ctxt": 0 }, "argument": { "type": "ThisExpression", "span": { - "start": 677, - "end": 681, + "start": 681, + "end": 685, "ctxt": 0 } } @@ -1215,37 +1215,37 @@ { "type": "ExpressionStatement", "span": { - "start": 686, - "end": 741, + "start": 690, + "end": 745, "ctxt": 0 }, "expression": { "type": "AssignmentExpression", "span": { - "start": 686, - "end": 740, + "start": 690, + "end": 744, "ctxt": 0 }, "operator": "=", "left": { "type": "MemberExpression", "span": { - "start": 686, - "end": 704, + "start": 690, + "end": 708, "ctxt": 0 }, "object": { "type": "MemberExpression", "span": { - "start": 686, - "end": 701, + "start": 690, + "end": 705, "ctxt": 0 }, "object": { "type": "Identifier", "span": { - "start": 686, - "end": 691, + "start": 690, + "end": 695, "ctxt": 0 }, "value": "Class", @@ -1254,8 +1254,8 @@ "property": { "type": "Identifier", "span": { - "start": 692, - "end": 701, + "start": 696, + "end": 705, "ctxt": 0 }, "value": "prototype", @@ -1265,8 +1265,8 @@ "property": { "type": "Identifier", "span": { - "start": 702, - "end": 704, + "start": 706, + "end": 708, "ctxt": 0 }, "value": "m7", @@ -1280,16 +1280,16 @@ { "type": "Parameter", "span": { - "start": 716, - "end": 722, + "start": 720, + "end": 726, "ctxt": 0 }, "decorators": [], "pat": { "type": "Identifier", "span": { - "start": 716, - "end": 722, + "start": 720, + "end": 726, "ctxt": 0 }, "value": "matrix", @@ -1300,30 +1300,30 @@ ], "decorators": [], "span": { - "start": 707, - "end": 740, + "start": 711, + "end": 744, "ctxt": 0 }, "body": { "type": "BlockStatement", "span": { - "start": 724, - "end": 740, + "start": 728, + "end": 744, "ctxt": 0 }, "stmts": [ { "type": "ReturnStatement", "span": { - "start": 726, - "end": 738, + "start": 730, + "end": 742, "ctxt": 0 }, "argument": { "type": "ThisExpression", "span": { - "start": 733, - "end": 737, + "start": 737, + "end": 741, "ctxt": 0 } } @@ -1340,37 +1340,37 @@ { "type": "ExpressionStatement", "span": { - "start": 742, - "end": 791, + "start": 746, + "end": 795, "ctxt": 0 }, "expression": { "type": "AssignmentExpression", "span": { - "start": 742, - "end": 790, + "start": 746, + "end": 794, "ctxt": 0 }, "operator": "=", "left": { "type": "MemberExpression", "span": { - "start": 742, - "end": 760, + "start": 746, + "end": 764, "ctxt": 0 }, "object": { "type": "MemberExpression", "span": { - "start": 742, - "end": 757, + "start": 746, + "end": 761, "ctxt": 0 }, "object": { "type": "Identifier", "span": { - "start": 742, - "end": 747, + "start": 746, + "end": 751, "ctxt": 0 }, "value": "Class", @@ -1379,8 +1379,8 @@ "property": { "type": "Identifier", "span": { - "start": 748, - "end": 757, + "start": 752, + "end": 761, "ctxt": 0 }, "value": "prototype", @@ -1390,8 +1390,8 @@ "property": { "type": "Identifier", "span": { - "start": 758, - "end": 760, + "start": 762, + "end": 764, "ctxt": 0 }, "value": "m8", @@ -1404,30 +1404,30 @@ "params": [], "decorators": [], "span": { - "start": 763, - "end": 790, + "start": 767, + "end": 794, "ctxt": 0 }, "body": { "type": "BlockStatement", "span": { - "start": 774, - "end": 790, + "start": 778, + "end": 794, "ctxt": 0 }, "stmts": [ { "type": "ReturnStatement", "span": { - "start": 776, - "end": 788, + "start": 780, + "end": 792, "ctxt": 0 }, "argument": { "type": "ThisExpression", "span": { - "start": 783, - "end": 787, + "start": 787, + "end": 791, "ctxt": 0 } } @@ -1444,37 +1444,37 @@ { "type": "ExpressionStatement", "span": { - "start": 792, - "end": 842, + "start": 796, + "end": 846, "ctxt": 0 }, "expression": { "type": "AssignmentExpression", "span": { - "start": 792, - "end": 841, + "start": 796, + "end": 845, "ctxt": 0 }, "operator": "=", "left": { "type": "MemberExpression", "span": { - "start": 792, - "end": 810, + "start": 796, + "end": 814, "ctxt": 0 }, "object": { "type": "MemberExpression", "span": { - "start": 792, - "end": 807, + "start": 796, + "end": 811, "ctxt": 0 }, "object": { "type": "Identifier", "span": { - "start": 792, - "end": 797, + "start": 796, + "end": 801, "ctxt": 0 }, "value": "Class", @@ -1483,8 +1483,8 @@ "property": { "type": "Identifier", "span": { - "start": 798, - "end": 807, + "start": 802, + "end": 811, "ctxt": 0 }, "value": "prototype", @@ -1494,8 +1494,8 @@ "property": { "type": "Identifier", "span": { - "start": 808, - "end": 810, + "start": 812, + "end": 814, "ctxt": 0 }, "value": "m9", @@ -1508,30 +1508,30 @@ "params": [], "decorators": [], "span": { - "start": 813, - "end": 841, + "start": 817, + "end": 845, "ctxt": 0 }, "body": { "type": "BlockStatement", "span": { - "start": 825, - "end": 841, + "start": 829, + "end": 845, "ctxt": 0 }, "stmts": [ { "type": "ReturnStatement", "span": { - "start": 827, - "end": 839, + "start": 831, + "end": 843, "ctxt": 0 }, "argument": { "type": "ThisExpression", "span": { - "start": 834, - "end": 838, + "start": 838, + "end": 842, "ctxt": 0 } } diff --git a/crates/swc_ecma_parser/tests/tsc/methodsReturningThis.ts b/crates/swc_ecma_parser/tests/tsc/methodsReturningThis.ts index 4c9f0d5cd0b1..521613d9e986 100644 --- a/crates/swc_ecma_parser/tests/tsc/methodsReturningThis.ts +++ b/crates/swc_ecma_parser/tests/tsc/methodsReturningThis.ts @@ -1,5 +1,5 @@ // @filename: input.js -// @out: output.js +// @outFile: output.js // @allowJs: true function Class() { diff --git a/crates/swc_ecma_parser/tests/tsc/multipleDeclarations.json b/crates/swc_ecma_parser/tests/tsc/multipleDeclarations.json index 65bb7c8d7f4d..7c232fed071c 100644 --- a/crates/swc_ecma_parser/tests/tsc/multipleDeclarations.json +++ b/crates/swc_ecma_parser/tests/tsc/multipleDeclarations.json @@ -1,8 +1,8 @@ { "type": "Script", "span": { - "start": 61, - "end": 598, + "start": 65, + "end": 602, "ctxt": 0 }, "body": [ @@ -11,8 +11,8 @@ "identifier": { "type": "Identifier", "span": { - "start": 70, - "end": 71, + "start": 74, + "end": 75, "ctxt": 0 }, "value": "C", @@ -22,53 +22,53 @@ "params": [], "decorators": [], "span": { - "start": 61, - "end": 96, + "start": 65, + "end": 100, "ctxt": 0 }, "body": { "type": "BlockStatement", "span": { - "start": 74, - "end": 96, + "start": 78, + "end": 100, "ctxt": 0 }, "stmts": [ { "type": "ExpressionStatement", "span": { - "start": 80, - "end": 94, + "start": 84, + "end": 98, "ctxt": 0 }, "expression": { "type": "AssignmentExpression", "span": { - "start": 80, - "end": 93, + "start": 84, + "end": 97, "ctxt": 0 }, "operator": "=", "left": { "type": "MemberExpression", "span": { - "start": 80, - "end": 86, + "start": 84, + "end": 90, "ctxt": 0 }, "object": { "type": "ThisExpression", "span": { - "start": 80, - "end": 84, + "start": 84, + "end": 88, "ctxt": 0 } }, "property": { "type": "Identifier", "span": { - "start": 85, - "end": 86, + "start": 89, + "end": 90, "ctxt": 0 }, "value": "m", @@ -78,8 +78,8 @@ "right": { "type": "NullLiteral", "span": { - "start": 89, - "end": 93, + "start": 93, + "end": 97, "ctxt": 0 } } @@ -95,37 +95,37 @@ { "type": "ExpressionStatement", "span": { - "start": 97, - "end": 147, + "start": 101, + "end": 151, "ctxt": 0 }, "expression": { "type": "AssignmentExpression", "span": { - "start": 97, - "end": 147, + "start": 101, + "end": 151, "ctxt": 0 }, "operator": "=", "left": { "type": "MemberExpression", "span": { - "start": 97, - "end": 110, + "start": 101, + "end": 114, "ctxt": 0 }, "object": { "type": "MemberExpression", "span": { - "start": 97, - "end": 108, + "start": 101, + "end": 112, "ctxt": 0 }, "object": { "type": "Identifier", "span": { - "start": 97, - "end": 98, + "start": 101, + "end": 102, "ctxt": 0 }, "value": "C", @@ -134,8 +134,8 @@ "property": { "type": "Identifier", "span": { - "start": 99, - "end": 108, + "start": 103, + "end": 112, "ctxt": 0 }, "value": "prototype", @@ -145,8 +145,8 @@ "property": { "type": "Identifier", "span": { - "start": 109, - "end": 110, + "start": 113, + "end": 114, "ctxt": 0 }, "value": "m", @@ -159,52 +159,52 @@ "params": [], "decorators": [], "span": { - "start": 113, - "end": 147, + "start": 117, + "end": 151, "ctxt": 0 }, "body": { "type": "BlockStatement", "span": { - "start": 124, - "end": 147, + "start": 128, + "end": 151, "ctxt": 0 }, "stmts": [ { "type": "ExpressionStatement", "span": { - "start": 130, - "end": 145, + "start": 134, + "end": 149, "ctxt": 0 }, "expression": { "type": "CallExpression", "span": { - "start": 130, - "end": 144, + "start": 134, + "end": 148, "ctxt": 0 }, "callee": { "type": "MemberExpression", "span": { - "start": 130, - "end": 142, + "start": 134, + "end": 146, "ctxt": 0 }, "object": { "type": "ThisExpression", "span": { - "start": 130, - "end": 134, + "start": 134, + "end": 138, "ctxt": 0 } }, "property": { "type": "Identifier", "span": { - "start": 135, - "end": 142, + "start": 139, + "end": 146, "ctxt": 0 }, "value": "nothing", @@ -229,8 +229,8 @@ "identifier": { "type": "Identifier", "span": { - "start": 154, - "end": 155, + "start": 158, + "end": 159, "ctxt": 0 }, "value": "X", @@ -238,8 +238,8 @@ }, "declare": false, "span": { - "start": 148, - "end": 312, + "start": 152, + "end": 316, "ctxt": 0 }, "decorators": [], @@ -247,15 +247,15 @@ { "type": "Constructor", "span": { - "start": 162, - "end": 272, + "start": 166, + "end": 276, "ctxt": 0 }, "key": { "type": "Identifier", "span": { - "start": 162, - "end": 173, + "start": 166, + "end": 177, "ctxt": 0 }, "value": "constructor", @@ -265,46 +265,46 @@ "body": { "type": "BlockStatement", "span": { - "start": 176, - "end": 272, + "start": 180, + "end": 276, "ctxt": 0 }, "stmts": [ { "type": "ExpressionStatement", "span": { - "start": 186, - "end": 213, + "start": 190, + "end": 217, "ctxt": 0 }, "expression": { "type": "AssignmentExpression", "span": { - "start": 186, - "end": 212, + "start": 190, + "end": 216, "ctxt": 0 }, "operator": "=", "left": { "type": "MemberExpression", "span": { - "start": 186, - "end": 192, + "start": 190, + "end": 196, "ctxt": 0 }, "object": { "type": "ThisExpression", "span": { - "start": 186, - "end": 190, + "start": 190, + "end": 194, "ctxt": 0 } }, "property": { "type": "Identifier", "span": { - "start": 191, - "end": 192, + "start": 195, + "end": 196, "ctxt": 0 }, "value": "m", @@ -314,37 +314,37 @@ "right": { "type": "CallExpression", "span": { - "start": 195, - "end": 212, + "start": 199, + "end": 216, "ctxt": 0 }, "callee": { "type": "MemberExpression", "span": { - "start": 195, - "end": 206, + "start": 199, + "end": 210, "ctxt": 0 }, "object": { "type": "MemberExpression", "span": { - "start": 195, - "end": 201, + "start": 199, + "end": 205, "ctxt": 0 }, "object": { "type": "ThisExpression", "span": { - "start": 195, - "end": 199, + "start": 199, + "end": 203, "ctxt": 0 } }, "property": { "type": "Identifier", "span": { - "start": 200, - "end": 201, + "start": 204, + "end": 205, "ctxt": 0 }, "value": "m", @@ -354,8 +354,8 @@ "property": { "type": "Identifier", "span": { - "start": 202, - "end": 206, + "start": 206, + "end": 210, "ctxt": 0 }, "value": "bind", @@ -368,8 +368,8 @@ "expression": { "type": "ThisExpression", "span": { - "start": 207, - "end": 211, + "start": 211, + "end": 215, "ctxt": 0 } } @@ -382,38 +382,38 @@ { "type": "ExpressionStatement", "span": { - "start": 222, - "end": 266, + "start": 226, + "end": 270, "ctxt": 0 }, "expression": { "type": "AssignmentExpression", "span": { - "start": 222, - "end": 265, + "start": 226, + "end": 269, "ctxt": 0 }, "operator": "=", "left": { "type": "MemberExpression", "span": { - "start": 222, - "end": 234, + "start": 226, + "end": 238, "ctxt": 0 }, "object": { "type": "ThisExpression", "span": { - "start": 222, - "end": 226, + "start": 226, + "end": 230, "ctxt": 0 } }, "property": { "type": "Identifier", "span": { - "start": 227, - "end": 234, + "start": 231, + "end": 238, "ctxt": 0 }, "value": "mistake", @@ -423,8 +423,8 @@ "right": { "type": "StringLiteral", "span": { - "start": 237, - "end": 265, + "start": 241, + "end": 269, "ctxt": 0 }, "value": "frankly, complete nonsense", @@ -440,15 +440,15 @@ { "type": "ClassMethod", "span": { - "start": 277, - "end": 288, + "start": 281, + "end": 292, "ctxt": 0 }, "key": { "type": "Identifier", "span": { - "start": 277, - "end": 278, + "start": 281, + "end": 282, "ctxt": 0 }, "value": "m", @@ -458,15 +458,15 @@ "params": [], "decorators": [], "span": { - "start": 277, - "end": 288, + "start": 281, + "end": 292, "ctxt": 0 }, "body": { "type": "BlockStatement", "span": { - "start": 281, - "end": 288, + "start": 285, + "end": 292, "ctxt": 0 }, "stmts": [] @@ -486,15 +486,15 @@ { "type": "ClassMethod", "span": { - "start": 293, - "end": 310, + "start": 297, + "end": 314, "ctxt": 0 }, "key": { "type": "Identifier", "span": { - "start": 293, - "end": 300, + "start": 297, + "end": 304, "ctxt": 0 }, "value": "mistake", @@ -504,15 +504,15 @@ "params": [], "decorators": [], "span": { - "start": 293, - "end": 310, + "start": 297, + "end": 314, "ctxt": 0 }, "body": { "type": "BlockStatement", "span": { - "start": 303, - "end": 310, + "start": 307, + "end": 314, "ctxt": 0 }, "stmts": [] @@ -539,8 +539,8 @@ { "type": "VariableDeclaration", "span": { - "start": 313, - "end": 329, + "start": 317, + "end": 333, "ctxt": 0 }, "kind": "let", @@ -549,15 +549,15 @@ { "type": "VariableDeclarator", "span": { - "start": 317, - "end": 328, + "start": 321, + "end": 332, "ctxt": 0 }, "id": { "type": "Identifier", "span": { - "start": 317, - "end": 318, + "start": 321, + "end": 322, "ctxt": 0 }, "value": "x", @@ -567,15 +567,15 @@ "init": { "type": "NewExpression", "span": { - "start": 321, - "end": 328, + "start": 325, + "end": 332, "ctxt": 0 }, "callee": { "type": "Identifier", "span": { - "start": 325, - "end": 326, + "start": 329, + "end": 330, "ctxt": 0 }, "value": "X", @@ -591,37 +591,37 @@ { "type": "ExpressionStatement", "span": { - "start": 330, - "end": 358, + "start": 334, + "end": 362, "ctxt": 0 }, "expression": { "type": "AssignmentExpression", "span": { - "start": 330, - "end": 357, + "start": 334, + "end": 361, "ctxt": 0 }, "operator": "=", "left": { "type": "MemberExpression", "span": { - "start": 330, - "end": 349, + "start": 334, + "end": 353, "ctxt": 0 }, "object": { "type": "MemberExpression", "span": { - "start": 330, - "end": 341, + "start": 334, + "end": 345, "ctxt": 0 }, "object": { "type": "Identifier", "span": { - "start": 330, - "end": 331, + "start": 334, + "end": 335, "ctxt": 0 }, "value": "X", @@ -630,8 +630,8 @@ "property": { "type": "Identifier", "span": { - "start": 332, - "end": 341, + "start": 336, + "end": 345, "ctxt": 0 }, "value": "prototype", @@ -641,8 +641,8 @@ "property": { "type": "Identifier", "span": { - "start": 342, - "end": 349, + "start": 346, + "end": 353, "ctxt": 0 }, "value": "mistake", @@ -652,8 +652,8 @@ "right": { "type": "BooleanLiteral", "span": { - "start": 352, - "end": 357, + "start": 356, + "end": 361, "ctxt": 0 }, "value": false @@ -663,29 +663,29 @@ { "type": "ExpressionStatement", "span": { - "start": 359, - "end": 365, + "start": 363, + "end": 369, "ctxt": 0 }, "expression": { "type": "CallExpression", "span": { - "start": 359, - "end": 364, + "start": 363, + "end": 368, "ctxt": 0 }, "callee": { "type": "MemberExpression", "span": { - "start": 359, - "end": 362, + "start": 363, + "end": 366, "ctxt": 0 }, "object": { "type": "Identifier", "span": { - "start": 359, - "end": 360, + "start": 363, + "end": 364, "ctxt": 0 }, "value": "x", @@ -694,8 +694,8 @@ "property": { "type": "Identifier", "span": { - "start": 361, - "end": 362, + "start": 365, + "end": 366, "ctxt": 0 }, "value": "m", @@ -709,22 +709,22 @@ { "type": "ExpressionStatement", "span": { - "start": 366, - "end": 376, + "start": 370, + "end": 380, "ctxt": 0 }, "expression": { "type": "MemberExpression", "span": { - "start": 366, - "end": 375, + "start": 370, + "end": 379, "ctxt": 0 }, "object": { "type": "Identifier", "span": { - "start": 366, - "end": 367, + "start": 370, + "end": 371, "ctxt": 0 }, "value": "x", @@ -733,8 +733,8 @@ "property": { "type": "Identifier", "span": { - "start": 368, - "end": 375, + "start": 372, + "end": 379, "ctxt": 0 }, "value": "mistake", @@ -747,8 +747,8 @@ "identifier": { "type": "Identifier", "span": { - "start": 383, - "end": 384, + "start": 387, + "end": 388, "ctxt": 0 }, "value": "Y", @@ -756,8 +756,8 @@ }, "declare": false, "span": { - "start": 377, - "end": 533, + "start": 381, + "end": 537, "ctxt": 0 }, "decorators": [], @@ -765,15 +765,15 @@ { "type": "ClassMethod", "span": { - "start": 391, - "end": 408, + "start": 395, + "end": 412, "ctxt": 0 }, "key": { "type": "Identifier", "span": { - "start": 391, - "end": 398, + "start": 395, + "end": 402, "ctxt": 0 }, "value": "mistake", @@ -783,15 +783,15 @@ "params": [], "decorators": [], "span": { - "start": 391, - "end": 408, + "start": 395, + "end": 412, "ctxt": 0 }, "body": { "type": "BlockStatement", "span": { - "start": 401, - "end": 408, + "start": 405, + "end": 412, "ctxt": 0 }, "stmts": [] @@ -811,15 +811,15 @@ { "type": "ClassMethod", "span": { - "start": 413, - "end": 424, + "start": 417, + "end": 428, "ctxt": 0 }, "key": { "type": "Identifier", "span": { - "start": 413, - "end": 414, + "start": 417, + "end": 418, "ctxt": 0 }, "value": "m", @@ -829,15 +829,15 @@ "params": [], "decorators": [], "span": { - "start": 413, - "end": 424, + "start": 417, + "end": 428, "ctxt": 0 }, "body": { "type": "BlockStatement", "span": { - "start": 417, - "end": 424, + "start": 421, + "end": 428, "ctxt": 0 }, "stmts": [] @@ -857,15 +857,15 @@ { "type": "Constructor", "span": { - "start": 429, - "end": 531, + "start": 433, + "end": 535, "ctxt": 0 }, "key": { "type": "Identifier", "span": { - "start": 429, - "end": 440, + "start": 433, + "end": 444, "ctxt": 0 }, "value": "constructor", @@ -875,46 +875,46 @@ "body": { "type": "BlockStatement", "span": { - "start": 443, - "end": 531, + "start": 447, + "end": 535, "ctxt": 0 }, "stmts": [ { "type": "ExpressionStatement", "span": { - "start": 453, - "end": 480, + "start": 457, + "end": 484, "ctxt": 0 }, "expression": { "type": "AssignmentExpression", "span": { - "start": 453, - "end": 479, + "start": 457, + "end": 483, "ctxt": 0 }, "operator": "=", "left": { "type": "MemberExpression", "span": { - "start": 453, - "end": 459, + "start": 457, + "end": 463, "ctxt": 0 }, "object": { "type": "ThisExpression", "span": { - "start": 453, - "end": 457, + "start": 457, + "end": 461, "ctxt": 0 } }, "property": { "type": "Identifier", "span": { - "start": 458, - "end": 459, + "start": 462, + "end": 463, "ctxt": 0 }, "value": "m", @@ -924,37 +924,37 @@ "right": { "type": "CallExpression", "span": { - "start": 462, - "end": 479, + "start": 466, + "end": 483, "ctxt": 0 }, "callee": { "type": "MemberExpression", "span": { - "start": 462, - "end": 473, + "start": 466, + "end": 477, "ctxt": 0 }, "object": { "type": "MemberExpression", "span": { - "start": 462, - "end": 468, + "start": 466, + "end": 472, "ctxt": 0 }, "object": { "type": "ThisExpression", "span": { - "start": 462, - "end": 466, + "start": 466, + "end": 470, "ctxt": 0 } }, "property": { "type": "Identifier", "span": { - "start": 467, - "end": 468, + "start": 471, + "end": 472, "ctxt": 0 }, "value": "m", @@ -964,8 +964,8 @@ "property": { "type": "Identifier", "span": { - "start": 469, - "end": 473, + "start": 473, + "end": 477, "ctxt": 0 }, "value": "bind", @@ -978,8 +978,8 @@ "expression": { "type": "ThisExpression", "span": { - "start": 474, - "end": 478, + "start": 478, + "end": 482, "ctxt": 0 } } @@ -992,38 +992,38 @@ { "type": "ExpressionStatement", "span": { - "start": 489, - "end": 525, + "start": 493, + "end": 529, "ctxt": 0 }, "expression": { "type": "AssignmentExpression", "span": { - "start": 489, - "end": 524, + "start": 493, + "end": 528, "ctxt": 0 }, "operator": "=", "left": { "type": "MemberExpression", "span": { - "start": 489, - "end": 501, + "start": 493, + "end": 505, "ctxt": 0 }, "object": { "type": "ThisExpression", "span": { - "start": 489, - "end": 493, + "start": 493, + "end": 497, "ctxt": 0 } }, "property": { "type": "Identifier", "span": { - "start": 494, - "end": 501, + "start": 498, + "end": 505, "ctxt": 0 }, "value": "mistake", @@ -1033,8 +1033,8 @@ "right": { "type": "StringLiteral", "span": { - "start": 504, - "end": 524, + "start": 508, + "end": 528, "ctxt": 0 }, "value": "even more nonsense", @@ -1057,37 +1057,37 @@ { "type": "ExpressionStatement", "span": { - "start": 534, - "end": 561, + "start": 538, + "end": 565, "ctxt": 0 }, "expression": { "type": "AssignmentExpression", "span": { - "start": 534, - "end": 560, + "start": 538, + "end": 564, "ctxt": 0 }, "operator": "=", "left": { "type": "MemberExpression", "span": { - "start": 534, - "end": 553, + "start": 538, + "end": 557, "ctxt": 0 }, "object": { "type": "MemberExpression", "span": { - "start": 534, - "end": 545, + "start": 538, + "end": 549, "ctxt": 0 }, "object": { "type": "Identifier", "span": { - "start": 534, - "end": 535, + "start": 538, + "end": 539, "ctxt": 0 }, "value": "Y", @@ -1096,8 +1096,8 @@ "property": { "type": "Identifier", "span": { - "start": 536, - "end": 545, + "start": 540, + "end": 549, "ctxt": 0 }, "value": "prototype", @@ -1107,8 +1107,8 @@ "property": { "type": "Identifier", "span": { - "start": 546, - "end": 553, + "start": 550, + "end": 557, "ctxt": 0 }, "value": "mistake", @@ -1118,8 +1118,8 @@ "right": { "type": "BooleanLiteral", "span": { - "start": 556, - "end": 560, + "start": 560, + "end": 564, "ctxt": 0 }, "value": true @@ -1129,8 +1129,8 @@ { "type": "VariableDeclaration", "span": { - "start": 562, - "end": 578, + "start": 566, + "end": 582, "ctxt": 0 }, "kind": "let", @@ -1139,15 +1139,15 @@ { "type": "VariableDeclarator", "span": { - "start": 566, - "end": 577, + "start": 570, + "end": 581, "ctxt": 0 }, "id": { "type": "Identifier", "span": { - "start": 566, - "end": 567, + "start": 570, + "end": 571, "ctxt": 0 }, "value": "y", @@ -1157,15 +1157,15 @@ "init": { "type": "NewExpression", "span": { - "start": 570, - "end": 577, + "start": 574, + "end": 581, "ctxt": 0 }, "callee": { "type": "Identifier", "span": { - "start": 574, - "end": 575, + "start": 578, + "end": 579, "ctxt": 0 }, "value": "Y", @@ -1181,29 +1181,29 @@ { "type": "ExpressionStatement", "span": { - "start": 579, - "end": 585, + "start": 583, + "end": 589, "ctxt": 0 }, "expression": { "type": "CallExpression", "span": { - "start": 579, - "end": 584, + "start": 583, + "end": 588, "ctxt": 0 }, "callee": { "type": "MemberExpression", "span": { - "start": 579, - "end": 582, + "start": 583, + "end": 586, "ctxt": 0 }, "object": { "type": "Identifier", "span": { - "start": 579, - "end": 580, + "start": 583, + "end": 584, "ctxt": 0 }, "value": "y", @@ -1212,8 +1212,8 @@ "property": { "type": "Identifier", "span": { - "start": 581, - "end": 582, + "start": 585, + "end": 586, "ctxt": 0 }, "value": "m", @@ -1227,29 +1227,29 @@ { "type": "ExpressionStatement", "span": { - "start": 586, - "end": 598, + "start": 590, + "end": 602, "ctxt": 0 }, "expression": { "type": "CallExpression", "span": { - "start": 586, - "end": 597, + "start": 590, + "end": 601, "ctxt": 0 }, "callee": { "type": "MemberExpression", "span": { - "start": 586, - "end": 595, + "start": 590, + "end": 599, "ctxt": 0 }, "object": { "type": "Identifier", "span": { - "start": 586, - "end": 587, + "start": 590, + "end": 591, "ctxt": 0 }, "value": "y", @@ -1258,8 +1258,8 @@ "property": { "type": "Identifier", "span": { - "start": 588, - "end": 595, + "start": 592, + "end": 599, "ctxt": 0 }, "value": "mistake", diff --git a/crates/swc_ecma_parser/tests/tsc/multipleDeclarations.ts b/crates/swc_ecma_parser/tests/tsc/multipleDeclarations.ts index ba2e14e11e93..89f1308eaddc 100644 --- a/crates/swc_ecma_parser/tests/tsc/multipleDeclarations.ts +++ b/crates/swc_ecma_parser/tests/tsc/multipleDeclarations.ts @@ -1,5 +1,5 @@ // @filename: input.js -// @out: output.js +// @outFile: output.js // @allowJs: true function C() { this.m = null; diff --git a/crates/swc_ecma_parser/tests/tsc/numberFormatCurrencySign.json b/crates/swc_ecma_parser/tests/tsc/numberFormatCurrencySign.json deleted file mode 100644 index efab4ff2c7d2..000000000000 --- a/crates/swc_ecma_parser/tests/tsc/numberFormatCurrencySign.json +++ /dev/null @@ -1,219 +0,0 @@ -{ - "type": "Script", - "span": { - "start": 53, - "end": 179, - "ctxt": 0 - }, - "body": [ - { - "type": "VariableDeclaration", - "span": { - "start": 53, - "end": 179, - "ctxt": 0 - }, - "kind": "const", - "declare": false, - "declarations": [ - { - "type": "VariableDeclarator", - "span": { - "start": 59, - "end": 178, - "ctxt": 0 - }, - "id": { - "type": "Identifier", - "span": { - "start": 59, - "end": 62, - "ctxt": 0 - }, - "value": "str", - "optional": false, - "typeAnnotation": null - }, - "init": { - "type": "CallExpression", - "span": { - "start": 65, - "end": 178, - "ctxt": 0 - }, - "callee": { - "type": "MemberExpression", - "span": { - "start": 65, - "end": 170, - "ctxt": 0 - }, - "object": { - "type": "NewExpression", - "span": { - "start": 65, - "end": 163, - "ctxt": 0 - }, - "callee": { - "type": "MemberExpression", - "span": { - "start": 69, - "end": 86, - "ctxt": 0 - }, - "object": { - "type": "Identifier", - "span": { - "start": 69, - "end": 73, - "ctxt": 0 - }, - "value": "Intl", - "optional": false - }, - "property": { - "type": "Identifier", - "span": { - "start": 74, - "end": 86, - "ctxt": 0 - }, - "value": "NumberFormat", - "optional": false - } - }, - "arguments": [ - { - "spread": null, - "expression": { - "type": "StringLiteral", - "span": { - "start": 87, - "end": 94, - "ctxt": 0 - }, - "value": "en-NZ", - "raw": "'en-NZ'" - } - }, - { - "spread": null, - "expression": { - "type": "ObjectExpression", - "span": { - "start": 96, - "end": 162, - "ctxt": 0 - }, - "properties": [ - { - "type": "KeyValueProperty", - "key": { - "type": "Identifier", - "span": { - "start": 98, - "end": 103, - "ctxt": 0 - }, - "value": "style", - "optional": false - }, - "value": { - "type": "StringLiteral", - "span": { - "start": 105, - "end": 115, - "ctxt": 0 - }, - "value": "currency", - "raw": "'currency'" - } - }, - { - "type": "KeyValueProperty", - "key": { - "type": "Identifier", - "span": { - "start": 117, - "end": 125, - "ctxt": 0 - }, - "value": "currency", - "optional": false - }, - "value": { - "type": "StringLiteral", - "span": { - "start": 127, - "end": 132, - "ctxt": 0 - }, - "value": "NZD", - "raw": "'NZD'" - } - }, - { - "type": "KeyValueProperty", - "key": { - "type": "Identifier", - "span": { - "start": 134, - "end": 146, - "ctxt": 0 - }, - "value": "currencySign", - "optional": false - }, - "value": { - "type": "StringLiteral", - "span": { - "start": 148, - "end": 160, - "ctxt": 0 - }, - "value": "accounting", - "raw": "'accounting'" - } - } - ] - } - } - ], - "typeArguments": null - }, - "property": { - "type": "Identifier", - "span": { - "start": 164, - "end": 170, - "ctxt": 0 - }, - "value": "format", - "optional": false - } - }, - "arguments": [ - { - "spread": null, - "expression": { - "type": "NumericLiteral", - "span": { - "start": 171, - "end": 177, - "ctxt": 0 - }, - "value": 999999.0, - "raw": "999999" - } - } - ], - "typeArguments": null - }, - "definite": false - } - ] - } - ], - "interpreter": null -} diff --git a/crates/swc_ecma_parser/tests/tsc/numberFormatCurrencySign.ts b/crates/swc_ecma_parser/tests/tsc/numberFormatCurrencySign.ts deleted file mode 100644 index b7b451150d09..000000000000 --- a/crates/swc_ecma_parser/tests/tsc/numberFormatCurrencySign.ts +++ /dev/null @@ -1,4 +0,0 @@ -// @target: esnext -// @lib: esnext -// @strict: true -const str = new Intl.NumberFormat('en-NZ', { style: 'currency', currency: 'NZD', currencySign: 'accounting' }).format(999999); diff --git a/crates/swc_ecma_parser/tests/tsc/numberFormatCurrencySignResolved.json b/crates/swc_ecma_parser/tests/tsc/numberFormatCurrencySignResolved.json deleted file mode 100644 index 845b1dfce5d3..000000000000 --- a/crates/swc_ecma_parser/tests/tsc/numberFormatCurrencySignResolved.json +++ /dev/null @@ -1,265 +0,0 @@ -{ - "type": "Script", - "span": { - "start": 53, - "end": 229, - "ctxt": 0 - }, - "body": [ - { - "type": "VariableDeclaration", - "span": { - "start": 53, - "end": 186, - "ctxt": 0 - }, - "kind": "const", - "declare": false, - "declarations": [ - { - "type": "VariableDeclarator", - "span": { - "start": 59, - "end": 185, - "ctxt": 0 - }, - "id": { - "type": "Identifier", - "span": { - "start": 59, - "end": 66, - "ctxt": 0 - }, - "value": "options", - "optional": false, - "typeAnnotation": null - }, - "init": { - "type": "CallExpression", - "span": { - "start": 69, - "end": 185, - "ctxt": 0 - }, - "callee": { - "type": "MemberExpression", - "span": { - "start": 69, - "end": 183, - "ctxt": 0 - }, - "object": { - "type": "NewExpression", - "span": { - "start": 69, - "end": 167, - "ctxt": 0 - }, - "callee": { - "type": "MemberExpression", - "span": { - "start": 73, - "end": 90, - "ctxt": 0 - }, - "object": { - "type": "Identifier", - "span": { - "start": 73, - "end": 77, - "ctxt": 0 - }, - "value": "Intl", - "optional": false - }, - "property": { - "type": "Identifier", - "span": { - "start": 78, - "end": 90, - "ctxt": 0 - }, - "value": "NumberFormat", - "optional": false - } - }, - "arguments": [ - { - "spread": null, - "expression": { - "type": "StringLiteral", - "span": { - "start": 91, - "end": 98, - "ctxt": 0 - }, - "value": "en-NZ", - "raw": "'en-NZ'" - } - }, - { - "spread": null, - "expression": { - "type": "ObjectExpression", - "span": { - "start": 100, - "end": 166, - "ctxt": 0 - }, - "properties": [ - { - "type": "KeyValueProperty", - "key": { - "type": "Identifier", - "span": { - "start": 102, - "end": 107, - "ctxt": 0 - }, - "value": "style", - "optional": false - }, - "value": { - "type": "StringLiteral", - "span": { - "start": 109, - "end": 119, - "ctxt": 0 - }, - "value": "currency", - "raw": "'currency'" - } - }, - { - "type": "KeyValueProperty", - "key": { - "type": "Identifier", - "span": { - "start": 121, - "end": 129, - "ctxt": 0 - }, - "value": "currency", - "optional": false - }, - "value": { - "type": "StringLiteral", - "span": { - "start": 131, - "end": 136, - "ctxt": 0 - }, - "value": "NZD", - "raw": "'NZD'" - } - }, - { - "type": "KeyValueProperty", - "key": { - "type": "Identifier", - "span": { - "start": 138, - "end": 150, - "ctxt": 0 - }, - "value": "currencySign", - "optional": false - }, - "value": { - "type": "StringLiteral", - "span": { - "start": 152, - "end": 164, - "ctxt": 0 - }, - "value": "accounting", - "raw": "'accounting'" - } - } - ] - } - } - ], - "typeArguments": null - }, - "property": { - "type": "Identifier", - "span": { - "start": 168, - "end": 183, - "ctxt": 0 - }, - "value": "resolvedOptions", - "optional": false - } - }, - "arguments": [], - "typeArguments": null - }, - "definite": false - } - ] - }, - { - "type": "VariableDeclaration", - "span": { - "start": 187, - "end": 229, - "ctxt": 0 - }, - "kind": "const", - "declare": false, - "declarations": [ - { - "type": "VariableDeclarator", - "span": { - "start": 193, - "end": 228, - "ctxt": 0 - }, - "id": { - "type": "Identifier", - "span": { - "start": 193, - "end": 205, - "ctxt": 0 - }, - "value": "currencySign", - "optional": false, - "typeAnnotation": null - }, - "init": { - "type": "MemberExpression", - "span": { - "start": 208, - "end": 228, - "ctxt": 0 - }, - "object": { - "type": "Identifier", - "span": { - "start": 208, - "end": 215, - "ctxt": 0 - }, - "value": "options", - "optional": false - }, - "property": { - "type": "Identifier", - "span": { - "start": 216, - "end": 228, - "ctxt": 0 - }, - "value": "currencySign", - "optional": false - } - }, - "definite": false - } - ] - } - ], - "interpreter": null -} diff --git a/crates/swc_ecma_parser/tests/tsc/numberFormatCurrencySignResolved.ts b/crates/swc_ecma_parser/tests/tsc/numberFormatCurrencySignResolved.ts deleted file mode 100644 index ce6c36fb19fe..000000000000 --- a/crates/swc_ecma_parser/tests/tsc/numberFormatCurrencySignResolved.ts +++ /dev/null @@ -1,5 +0,0 @@ -// @target: esnext -// @lib: esnext -// @strict: true -const options = new Intl.NumberFormat('en-NZ', { style: 'currency', currency: 'NZD', currencySign: 'accounting' }).resolvedOptions(); -const currencySign = options.currencySign; diff --git a/crates/swc_ecma_parser/tests/tsc/objectLiteralErrorsES3.json b/crates/swc_ecma_parser/tests/tsc/objectLiteralErrorsES3.json deleted file mode 100644 index 4eaedf004dc3..000000000000 --- a/crates/swc_ecma_parser/tests/tsc/objectLiteralErrorsES3.json +++ /dev/null @@ -1,309 +0,0 @@ -{ - "type": "Script", - "span": { - "start": 17, - "end": 130, - "ctxt": 0 - }, - "body": [ - { - "type": "VariableDeclaration", - "span": { - "start": 17, - "end": 52, - "ctxt": 0 - }, - "kind": "var", - "declare": false, - "declarations": [ - { - "type": "VariableDeclarator", - "span": { - "start": 21, - "end": 51, - "ctxt": 0 - }, - "id": { - "type": "Identifier", - "span": { - "start": 21, - "end": 23, - "ctxt": 0 - }, - "value": "e1", - "optional": false, - "typeAnnotation": null - }, - "init": { - "type": "ObjectExpression", - "span": { - "start": 26, - "end": 51, - "ctxt": 0 - }, - "properties": [ - { - "type": "GetterProperty", - "span": { - "start": 28, - "end": 49, - "ctxt": 0 - }, - "key": { - "type": "Identifier", - "span": { - "start": 32, - "end": 33, - "ctxt": 0 - }, - "value": "a", - "optional": false - }, - "typeAnnotation": null, - "body": { - "type": "BlockStatement", - "span": { - "start": 36, - "end": 49, - "ctxt": 0 - }, - "stmts": [ - { - "type": "ReturnStatement", - "span": { - "start": 38, - "end": 47, - "ctxt": 0 - }, - "argument": { - "type": "NumericLiteral", - "span": { - "start": 45, - "end": 46, - "ctxt": 0 - }, - "value": 4.0, - "raw": "4" - } - } - ] - } - } - ] - }, - "definite": false - } - ] - }, - { - "type": "VariableDeclaration", - "span": { - "start": 53, - "end": 79, - "ctxt": 0 - }, - "kind": "var", - "declare": false, - "declarations": [ - { - "type": "VariableDeclarator", - "span": { - "start": 57, - "end": 78, - "ctxt": 0 - }, - "id": { - "type": "Identifier", - "span": { - "start": 57, - "end": 59, - "ctxt": 0 - }, - "value": "e2", - "optional": false, - "typeAnnotation": null - }, - "init": { - "type": "ObjectExpression", - "span": { - "start": 62, - "end": 78, - "ctxt": 0 - }, - "properties": [ - { - "type": "SetterProperty", - "span": { - "start": 64, - "end": 76, - "ctxt": 0 - }, - "key": { - "type": "Identifier", - "span": { - "start": 68, - "end": 69, - "ctxt": 0 - }, - "value": "a", - "optional": false - }, - "thisParam": null, - "param": { - "type": "Identifier", - "span": { - "start": 70, - "end": 71, - "ctxt": 0 - }, - "value": "n", - "optional": false, - "typeAnnotation": null - }, - "body": { - "type": "BlockStatement", - "span": { - "start": 73, - "end": 76, - "ctxt": 0 - }, - "stmts": [] - } - } - ] - }, - "definite": false - } - ] - }, - { - "type": "VariableDeclaration", - "span": { - "start": 80, - "end": 130, - "ctxt": 0 - }, - "kind": "var", - "declare": false, - "declarations": [ - { - "type": "VariableDeclarator", - "span": { - "start": 84, - "end": 129, - "ctxt": 0 - }, - "id": { - "type": "Identifier", - "span": { - "start": 84, - "end": 86, - "ctxt": 0 - }, - "value": "e3", - "optional": false, - "typeAnnotation": null - }, - "init": { - "type": "ObjectExpression", - "span": { - "start": 89, - "end": 129, - "ctxt": 0 - }, - "properties": [ - { - "type": "GetterProperty", - "span": { - "start": 91, - "end": 113, - "ctxt": 0 - }, - "key": { - "type": "Identifier", - "span": { - "start": 95, - "end": 96, - "ctxt": 0 - }, - "value": "a", - "optional": false - }, - "typeAnnotation": null, - "body": { - "type": "BlockStatement", - "span": { - "start": 99, - "end": 113, - "ctxt": 0 - }, - "stmts": [ - { - "type": "ReturnStatement", - "span": { - "start": 101, - "end": 111, - "ctxt": 0 - }, - "argument": { - "type": "StringLiteral", - "span": { - "start": 108, - "end": 110, - "ctxt": 0 - }, - "value": "", - "raw": "''" - } - } - ] - } - }, - { - "type": "SetterProperty", - "span": { - "start": 115, - "end": 127, - "ctxt": 0 - }, - "key": { - "type": "Identifier", - "span": { - "start": 119, - "end": 120, - "ctxt": 0 - }, - "value": "a", - "optional": false - }, - "thisParam": null, - "param": { - "type": "Identifier", - "span": { - "start": 121, - "end": 122, - "ctxt": 0 - }, - "value": "n", - "optional": false, - "typeAnnotation": null - }, - "body": { - "type": "BlockStatement", - "span": { - "start": 124, - "end": 127, - "ctxt": 0 - }, - "stmts": [] - } - } - ] - }, - "definite": false - } - ] - } - ], - "interpreter": null -} diff --git a/crates/swc_ecma_parser/tests/tsc/objectLiteralErrorsES3.ts b/crates/swc_ecma_parser/tests/tsc/objectLiteralErrorsES3.ts deleted file mode 100644 index 7477e8b4827d..000000000000 --- a/crates/swc_ecma_parser/tests/tsc/objectLiteralErrorsES3.ts +++ /dev/null @@ -1,6 +0,0 @@ -//@Target: ES3 - -var e1 = { get a() { return 4; } }; -var e2 = { set a(n) { } }; -var e3 = { get a() { return ''; }, set a(n) { } }; - diff --git a/crates/swc_ecma_parser/tests/tsc/parser.numericSeparators.decimal.ts b/crates/swc_ecma_parser/tests/tsc/parser.numericSeparators.decimal.ts index a882fa9ccbd3..b48ec382fa0b 100644 --- a/crates/swc_ecma_parser/tests/tsc/parser.numericSeparators.decimal.ts +++ b/crates/swc_ecma_parser/tests/tsc/parser.numericSeparators.decimal.ts @@ -1,3 +1,4 @@ +// @target: es5, es2020, es2021 1_000_000_000 1.1_00_01 1e1_0 diff --git a/crates/swc_ecma_parser/tests/tsc/parserArrowFunctionExpression10.json b/crates/swc_ecma_parser/tests/tsc/parserArrowFunctionExpression10.json index 488b3d1fa0e1..d3c5352fa32c 100644 --- a/crates/swc_ecma_parser/tests/tsc/parserArrowFunctionExpression10.json +++ b/crates/swc_ecma_parser/tests/tsc/parserArrowFunctionExpression10.json @@ -1,30 +1,30 @@ { "type": "Script", "span": { - "start": 98, - "end": 232, + "start": 94, + "end": 228, "ctxt": 0 }, "body": [ { "type": "ExpressionStatement", "span": { - "start": 98, - "end": 125, + "start": 94, + "end": 121, "ctxt": 0 }, "expression": { "type": "ConditionalExpression", "span": { - "start": 98, - "end": 125, + "start": 94, + "end": 121, "ctxt": 0 }, "test": { "type": "Identifier", "span": { - "start": 98, - "end": 99, + "start": 94, + "end": 95, "ctxt": 0 }, "value": "a", @@ -33,16 +33,16 @@ "consequent": { "type": "ArrowFunctionExpression", "span": { - "start": 102, - "end": 116, + "start": 98, + "end": 112, "ctxt": 0 }, "params": [ { "type": "Identifier", "span": { - "start": 103, - "end": 104, + "start": 99, + "end": 100, "ctxt": 0 }, "value": "b", @@ -53,15 +53,15 @@ "body": { "type": "ParenthesisExpression", "span": { - "start": 113, - "end": 116, + "start": 109, + "end": 112, "ctxt": 0 }, "expression": { "type": "Identifier", "span": { - "start": 114, - "end": 115, + "start": 110, + "end": 111, "ctxt": 0 }, "value": "d", @@ -74,22 +74,22 @@ "returnType": { "type": "TsTypeAnnotation", "span": { - "start": 106, - "end": 109, + "start": 102, + "end": 105, "ctxt": 0 }, "typeAnnotation": { "type": "TsTypeReference", "span": { - "start": 108, - "end": 109, + "start": 104, + "end": 105, "ctxt": 0 }, "typeName": { "type": "Identifier", "span": { - "start": 108, - "end": 109, + "start": 104, + "end": 105, "ctxt": 0 }, "value": "c", @@ -102,16 +102,16 @@ "alternate": { "type": "ArrowFunctionExpression", "span": { - "start": 119, - "end": 125, + "start": 115, + "end": 121, "ctxt": 0 }, "params": [ { "type": "Identifier", "span": { - "start": 119, - "end": 120, + "start": 115, + "end": 116, "ctxt": 0 }, "value": "e", @@ -122,8 +122,8 @@ "body": { "type": "Identifier", "span": { - "start": 124, - "end": 125, + "start": 120, + "end": 121, "ctxt": 0 }, "value": "f", @@ -139,22 +139,22 @@ { "type": "ExpressionStatement", "span": { - "start": 205, - "end": 232, + "start": 201, + "end": 228, "ctxt": 0 }, "expression": { "type": "ConditionalExpression", "span": { - "start": 205, - "end": 232, + "start": 201, + "end": 228, "ctxt": 0 }, "test": { "type": "Identifier", "span": { - "start": 205, - "end": 206, + "start": 201, + "end": 202, "ctxt": 0 }, "value": "a", @@ -163,16 +163,16 @@ "consequent": { "type": "ArrowFunctionExpression", "span": { - "start": 209, - "end": 223, + "start": 205, + "end": 219, "ctxt": 0 }, "params": [ { "type": "Identifier", "span": { - "start": 210, - "end": 211, + "start": 206, + "end": 207, "ctxt": 0 }, "value": "b", @@ -183,15 +183,15 @@ "body": { "type": "ParenthesisExpression", "span": { - "start": 220, - "end": 223, + "start": 216, + "end": 219, "ctxt": 0 }, "expression": { "type": "Identifier", "span": { - "start": 221, - "end": 222, + "start": 217, + "end": 218, "ctxt": 0 }, "value": "d", @@ -204,22 +204,22 @@ "returnType": { "type": "TsTypeAnnotation", "span": { - "start": 213, - "end": 216, + "start": 209, + "end": 212, "ctxt": 0 }, "typeAnnotation": { "type": "TsTypeReference", "span": { - "start": 215, - "end": 216, + "start": 211, + "end": 212, "ctxt": 0 }, "typeName": { "type": "Identifier", "span": { - "start": 215, - "end": 216, + "start": 211, + "end": 212, "ctxt": 0 }, "value": "c", @@ -232,16 +232,16 @@ "alternate": { "type": "ArrowFunctionExpression", "span": { - "start": 226, - "end": 232, + "start": 222, + "end": 228, "ctxt": 0 }, "params": [ { "type": "Identifier", "span": { - "start": 226, - "end": 227, + "start": 222, + "end": 223, "ctxt": 0 }, "value": "e", @@ -252,8 +252,8 @@ "body": { "type": "Identifier", "span": { - "start": 231, - "end": 232, + "start": 227, + "end": 228, "ctxt": 0 }, "value": "f", diff --git a/crates/swc_ecma_parser/tests/tsc/parserArrowFunctionExpression10.ts b/crates/swc_ecma_parser/tests/tsc/parserArrowFunctionExpression10.ts index 306e32d7a238..35ed556d9500 100644 --- a/crates/swc_ecma_parser/tests/tsc/parserArrowFunctionExpression10.ts +++ b/crates/swc_ecma_parser/tests/tsc/parserArrowFunctionExpression10.ts @@ -1,7 +1,7 @@ // @allowjs: true // @checkjs: true // @outdir: out -// @target: es3,es6 +// @target: es6 // @filename: fileJs.js a ? (b) : c => (d) : e => f // Not legal JS; "Unexpected token ':'" at last colon diff --git a/crates/swc_ecma_parser/tests/tsc/parserArrowFunctionExpression11.ts b/crates/swc_ecma_parser/tests/tsc/parserArrowFunctionExpression11.ts index ef0a245ff5db..be1dbd5fda86 100644 --- a/crates/swc_ecma_parser/tests/tsc/parserArrowFunctionExpression11.ts +++ b/crates/swc_ecma_parser/tests/tsc/parserArrowFunctionExpression11.ts @@ -1,7 +1,7 @@ // @allowjs: true // @checkjs: true // @outdir: out -// @target: es3,es6 +// @target: es6 // @filename: fileJs.js a ? b ? c : (d) : e => f // Legal JS diff --git a/crates/swc_ecma_parser/tests/tsc/parserArrowFunctionExpression12.json b/crates/swc_ecma_parser/tests/tsc/parserArrowFunctionExpression12.json index 3185f8c5a4f7..528b1c927759 100644 --- a/crates/swc_ecma_parser/tests/tsc/parserArrowFunctionExpression12.json +++ b/crates/swc_ecma_parser/tests/tsc/parserArrowFunctionExpression12.json @@ -1,30 +1,30 @@ { "type": "Script", "span": { - "start": 98, - "end": 180, + "start": 94, + "end": 176, "ctxt": 0 }, "body": [ { "type": "ExpressionStatement", "span": { - "start": 98, - "end": 120, + "start": 94, + "end": 116, "ctxt": 0 }, "expression": { "type": "ConditionalExpression", "span": { - "start": 98, - "end": 120, + "start": 94, + "end": 116, "ctxt": 0 }, "test": { "type": "Identifier", "span": { - "start": 98, - "end": 99, + "start": 94, + "end": 95, "ctxt": 0 }, "value": "a", @@ -33,16 +33,16 @@ "consequent": { "type": "ArrowFunctionExpression", "span": { - "start": 102, - "end": 112, + "start": 98, + "end": 108, "ctxt": 0 }, "params": [ { "type": "Identifier", "span": { - "start": 103, - "end": 104, + "start": 99, + "end": 100, "ctxt": 0 }, "value": "b", @@ -53,15 +53,15 @@ "body": { "type": "ParenthesisExpression", "span": { - "start": 109, - "end": 112, + "start": 105, + "end": 108, "ctxt": 0 }, "expression": { "type": "Identifier", "span": { - "start": 110, - "end": 111, + "start": 106, + "end": 107, "ctxt": 0 }, "value": "c", @@ -76,16 +76,16 @@ "alternate": { "type": "ArrowFunctionExpression", "span": { - "start": 114, - "end": 120, + "start": 110, + "end": 116, "ctxt": 0 }, "params": [ { "type": "Identifier", "span": { - "start": 114, - "end": 115, + "start": 110, + "end": 111, "ctxt": 0 }, "value": "d", @@ -96,8 +96,8 @@ "body": { "type": "Identifier", "span": { - "start": 119, - "end": 120, + "start": 115, + "end": 116, "ctxt": 0 }, "value": "e", @@ -113,22 +113,22 @@ { "type": "ExpressionStatement", "span": { - "start": 158, - "end": 180, + "start": 154, + "end": 176, "ctxt": 0 }, "expression": { "type": "ConditionalExpression", "span": { - "start": 158, - "end": 180, + "start": 154, + "end": 176, "ctxt": 0 }, "test": { "type": "Identifier", "span": { - "start": 158, - "end": 159, + "start": 154, + "end": 155, "ctxt": 0 }, "value": "a", @@ -137,16 +137,16 @@ "consequent": { "type": "ArrowFunctionExpression", "span": { - "start": 162, - "end": 172, + "start": 158, + "end": 168, "ctxt": 0 }, "params": [ { "type": "Identifier", "span": { - "start": 163, - "end": 164, + "start": 159, + "end": 160, "ctxt": 0 }, "value": "b", @@ -157,15 +157,15 @@ "body": { "type": "ParenthesisExpression", "span": { - "start": 169, - "end": 172, + "start": 165, + "end": 168, "ctxt": 0 }, "expression": { "type": "Identifier", "span": { - "start": 170, - "end": 171, + "start": 166, + "end": 167, "ctxt": 0 }, "value": "c", @@ -180,16 +180,16 @@ "alternate": { "type": "ArrowFunctionExpression", "span": { - "start": 174, - "end": 180, + "start": 170, + "end": 176, "ctxt": 0 }, "params": [ { "type": "Identifier", "span": { - "start": 174, - "end": 175, + "start": 170, + "end": 171, "ctxt": 0 }, "value": "d", @@ -200,8 +200,8 @@ "body": { "type": "Identifier", "span": { - "start": 179, - "end": 180, + "start": 175, + "end": 176, "ctxt": 0 }, "value": "e", diff --git a/crates/swc_ecma_parser/tests/tsc/parserArrowFunctionExpression12.ts b/crates/swc_ecma_parser/tests/tsc/parserArrowFunctionExpression12.ts index 9d75874c0555..d76b73f550ef 100644 --- a/crates/swc_ecma_parser/tests/tsc/parserArrowFunctionExpression12.ts +++ b/crates/swc_ecma_parser/tests/tsc/parserArrowFunctionExpression12.ts @@ -1,7 +1,7 @@ // @allowjs: true // @checkjs: true // @outdir: out -// @target: es3,es6 +// @target: es6 // @filename: fileJs.js a ? (b) => (c): d => e // Legal JS diff --git a/crates/swc_ecma_parser/tests/tsc/parserArrowFunctionExpression13.json b/crates/swc_ecma_parser/tests/tsc/parserArrowFunctionExpression13.json index 8d302acddecb..841b7b1131ed 100644 --- a/crates/swc_ecma_parser/tests/tsc/parserArrowFunctionExpression13.json +++ b/crates/swc_ecma_parser/tests/tsc/parserArrowFunctionExpression13.json @@ -1,30 +1,30 @@ { "type": "Script", "span": { - "start": 98, - "end": 242, + "start": 94, + "end": 238, "ctxt": 0 }, "body": [ { "type": "ExpressionStatement", "span": { - "start": 98, - "end": 130, + "start": 94, + "end": 126, "ctxt": 0 }, "expression": { "type": "ConditionalExpression", "span": { - "start": 98, - "end": 129, + "start": 94, + "end": 125, "ctxt": 0 }, "test": { "type": "Identifier", "span": { - "start": 98, - "end": 99, + "start": 94, + "end": 95, "ctxt": 0 }, "value": "a", @@ -33,23 +33,23 @@ "consequent": { "type": "ArrowFunctionExpression", "span": { - "start": 102, - "end": 111, + "start": 98, + "end": 107, "ctxt": 0 }, "params": [], "body": { "type": "CallExpression", "span": { - "start": 108, - "end": 111, + "start": 104, + "end": 107, "ctxt": 0 }, "callee": { "type": "Identifier", "span": { - "start": 108, - "end": 109, + "start": 104, + "end": 105, "ctxt": 0 }, "value": "a", @@ -66,16 +66,16 @@ "alternate": { "type": "ArrowFunctionExpression", "span": { - "start": 114, - "end": 129, + "start": 110, + "end": 125, "ctxt": 0 }, "params": [], "body": { "type": "NullLiteral", "span": { - "start": 125, - "end": 129, + "start": 121, + "end": 125, "ctxt": 0 } }, @@ -85,15 +85,15 @@ "returnType": { "type": "TsTypeAnnotation", "span": { - "start": 116, - "end": 121, + "start": 112, + "end": 117, "ctxt": 0 }, "typeAnnotation": { "type": "TsKeywordType", "span": { - "start": 118, - "end": 121, + "start": 114, + "end": 117, "ctxt": 0 }, "kind": "any" @@ -105,22 +105,22 @@ { "type": "ExpressionStatement", "span": { - "start": 210, - "end": 242, + "start": 206, + "end": 238, "ctxt": 0 }, "expression": { "type": "ConditionalExpression", "span": { - "start": 210, - "end": 241, + "start": 206, + "end": 237, "ctxt": 0 }, "test": { "type": "Identifier", "span": { - "start": 210, - "end": 211, + "start": 206, + "end": 207, "ctxt": 0 }, "value": "a", @@ -129,23 +129,23 @@ "consequent": { "type": "ArrowFunctionExpression", "span": { - "start": 214, - "end": 223, + "start": 210, + "end": 219, "ctxt": 0 }, "params": [], "body": { "type": "CallExpression", "span": { - "start": 220, - "end": 223, + "start": 216, + "end": 219, "ctxt": 0 }, "callee": { "type": "Identifier", "span": { - "start": 220, - "end": 221, + "start": 216, + "end": 217, "ctxt": 0 }, "value": "a", @@ -162,16 +162,16 @@ "alternate": { "type": "ArrowFunctionExpression", "span": { - "start": 226, - "end": 241, + "start": 222, + "end": 237, "ctxt": 0 }, "params": [], "body": { "type": "NullLiteral", "span": { - "start": 237, - "end": 241, + "start": 233, + "end": 237, "ctxt": 0 } }, @@ -181,15 +181,15 @@ "returnType": { "type": "TsTypeAnnotation", "span": { - "start": 228, - "end": 233, + "start": 224, + "end": 229, "ctxt": 0 }, "typeAnnotation": { "type": "TsKeywordType", "span": { - "start": 230, - "end": 233, + "start": 226, + "end": 229, "ctxt": 0 }, "kind": "any" diff --git a/crates/swc_ecma_parser/tests/tsc/parserArrowFunctionExpression13.ts b/crates/swc_ecma_parser/tests/tsc/parserArrowFunctionExpression13.ts index eb988e3ea803..bfd9c623f710 100644 --- a/crates/swc_ecma_parser/tests/tsc/parserArrowFunctionExpression13.ts +++ b/crates/swc_ecma_parser/tests/tsc/parserArrowFunctionExpression13.ts @@ -1,7 +1,7 @@ // @allowjs: true // @checkjs: true // @outdir: out -// @target: es3,es6 +// @target: es6 // @filename: fileJs.js a ? () => a() : (): any => null; // Not legal JS; "Unexpected token ')'" at last paren diff --git a/crates/swc_ecma_parser/tests/tsc/parserArrowFunctionExpression14.json b/crates/swc_ecma_parser/tests/tsc/parserArrowFunctionExpression14.json index 335579af5059..5d500bd9f669 100644 --- a/crates/swc_ecma_parser/tests/tsc/parserArrowFunctionExpression14.json +++ b/crates/swc_ecma_parser/tests/tsc/parserArrowFunctionExpression14.json @@ -1,37 +1,37 @@ { "type": "Script", "span": { - "start": 98, - "end": 273, + "start": 94, + "end": 269, "ctxt": 0 }, "body": [ { "type": "ExpressionStatement", "span": { - "start": 98, - "end": 145, + "start": 94, + "end": 141, "ctxt": 0 }, "expression": { "type": "ConditionalExpression", "span": { - "start": 98, - "end": 144, + "start": 94, + "end": 140, "ctxt": 0 }, "test": { "type": "CallExpression", "span": { - "start": 98, - "end": 101, + "start": 94, + "end": 97, "ctxt": 0 }, "callee": { "type": "Identifier", "span": { - "start": 98, - "end": 99, + "start": 94, + "end": 95, "ctxt": 0 }, "value": "a", @@ -43,16 +43,16 @@ "consequent": { "type": "ArrowFunctionExpression", "span": { - "start": 104, - "end": 140, + "start": 100, + "end": 136, "ctxt": 0 }, "params": [ { "type": "Identifier", "span": { - "start": 105, - "end": 114, + "start": 101, + "end": 110, "ctxt": 0 }, "value": "b", @@ -60,15 +60,15 @@ "typeAnnotation": { "type": "TsTypeAnnotation", "span": { - "start": 106, - "end": 114, + "start": 102, + "end": 110, "ctxt": 0 }, "typeAnnotation": { "type": "TsKeywordType", "span": { - "start": 108, - "end": 114, + "start": 104, + "end": 110, "ctxt": 0 }, "kind": "number" @@ -78,8 +78,8 @@ { "type": "Identifier", "span": { - "start": 116, - "end": 126, + "start": 112, + "end": 122, "ctxt": 0 }, "value": "c", @@ -87,15 +87,15 @@ "typeAnnotation": { "type": "TsTypeAnnotation", "span": { - "start": 118, - "end": 126, + "start": 114, + "end": 122, "ctxt": 0 }, "typeAnnotation": { "type": "TsKeywordType", "span": { - "start": 120, - "end": 126, + "start": 116, + "end": 122, "ctxt": 0 }, "kind": "string" @@ -106,15 +106,15 @@ "body": { "type": "CallExpression", "span": { - "start": 137, - "end": 140, + "start": 133, + "end": 136, "ctxt": 0 }, "callee": { "type": "Identifier", "span": { - "start": 137, - "end": 138, + "start": 133, + "end": 134, "ctxt": 0 }, "value": "d", @@ -129,15 +129,15 @@ "returnType": { "type": "TsTypeAnnotation", "span": { - "start": 127, - "end": 133, + "start": 123, + "end": 129, "ctxt": 0 }, "typeAnnotation": { "type": "TsKeywordType", "span": { - "start": 129, - "end": 133, + "start": 125, + "end": 129, "ctxt": 0 }, "kind": "void" @@ -147,8 +147,8 @@ "alternate": { "type": "Identifier", "span": { - "start": 143, - "end": 144, + "start": 139, + "end": 140, "ctxt": 0 }, "value": "e", @@ -159,29 +159,29 @@ { "type": "ExpressionStatement", "span": { - "start": 226, - "end": 273, + "start": 222, + "end": 269, "ctxt": 0 }, "expression": { "type": "ConditionalExpression", "span": { - "start": 226, - "end": 272, + "start": 222, + "end": 268, "ctxt": 0 }, "test": { "type": "CallExpression", "span": { - "start": 226, - "end": 229, + "start": 222, + "end": 225, "ctxt": 0 }, "callee": { "type": "Identifier", "span": { - "start": 226, - "end": 227, + "start": 222, + "end": 223, "ctxt": 0 }, "value": "a", @@ -193,16 +193,16 @@ "consequent": { "type": "ArrowFunctionExpression", "span": { - "start": 232, - "end": 268, + "start": 228, + "end": 264, "ctxt": 0 }, "params": [ { "type": "Identifier", "span": { - "start": 233, - "end": 242, + "start": 229, + "end": 238, "ctxt": 0 }, "value": "b", @@ -210,15 +210,15 @@ "typeAnnotation": { "type": "TsTypeAnnotation", "span": { - "start": 234, - "end": 242, + "start": 230, + "end": 238, "ctxt": 0 }, "typeAnnotation": { "type": "TsKeywordType", "span": { - "start": 236, - "end": 242, + "start": 232, + "end": 238, "ctxt": 0 }, "kind": "number" @@ -228,8 +228,8 @@ { "type": "Identifier", "span": { - "start": 244, - "end": 254, + "start": 240, + "end": 250, "ctxt": 0 }, "value": "c", @@ -237,15 +237,15 @@ "typeAnnotation": { "type": "TsTypeAnnotation", "span": { - "start": 246, - "end": 254, + "start": 242, + "end": 250, "ctxt": 0 }, "typeAnnotation": { "type": "TsKeywordType", "span": { - "start": 248, - "end": 254, + "start": 244, + "end": 250, "ctxt": 0 }, "kind": "string" @@ -256,15 +256,15 @@ "body": { "type": "CallExpression", "span": { - "start": 265, - "end": 268, + "start": 261, + "end": 264, "ctxt": 0 }, "callee": { "type": "Identifier", "span": { - "start": 265, - "end": 266, + "start": 261, + "end": 262, "ctxt": 0 }, "value": "d", @@ -279,15 +279,15 @@ "returnType": { "type": "TsTypeAnnotation", "span": { - "start": 255, - "end": 261, + "start": 251, + "end": 257, "ctxt": 0 }, "typeAnnotation": { "type": "TsKeywordType", "span": { - "start": 257, - "end": 261, + "start": 253, + "end": 257, "ctxt": 0 }, "kind": "void" @@ -297,8 +297,8 @@ "alternate": { "type": "Identifier", "span": { - "start": 271, - "end": 272, + "start": 267, + "end": 268, "ctxt": 0 }, "value": "e", diff --git a/crates/swc_ecma_parser/tests/tsc/parserArrowFunctionExpression14.ts b/crates/swc_ecma_parser/tests/tsc/parserArrowFunctionExpression14.ts index 7462eaf6558d..e2cf539290ff 100644 --- a/crates/swc_ecma_parser/tests/tsc/parserArrowFunctionExpression14.ts +++ b/crates/swc_ecma_parser/tests/tsc/parserArrowFunctionExpression14.ts @@ -1,7 +1,7 @@ // @allowjs: true // @checkjs: true // @outdir: out -// @target: es3,es6 +// @target: es6 // @filename: fileJs.js a() ? (b: number, c?: string): void => d() : e; // Not legal JS; "Unexpected token ':'" at first colon diff --git a/crates/swc_ecma_parser/tests/tsc/parserArrowFunctionExpression15.json b/crates/swc_ecma_parser/tests/tsc/parserArrowFunctionExpression15.json index afd49a392a60..8ed6d17abb16 100644 --- a/crates/swc_ecma_parser/tests/tsc/parserArrowFunctionExpression15.json +++ b/crates/swc_ecma_parser/tests/tsc/parserArrowFunctionExpression15.json @@ -1,30 +1,30 @@ { "type": "Script", "span": { - "start": 98, - "end": 256, + "start": 94, + "end": 252, "ctxt": 0 }, "body": [ { "type": "ExpressionStatement", "span": { - "start": 98, - "end": 137, + "start": 94, + "end": 133, "ctxt": 0 }, "expression": { "type": "ConditionalExpression", "span": { - "start": 98, - "end": 137, + "start": 94, + "end": 133, "ctxt": 0 }, "test": { "type": "BooleanLiteral", "span": { - "start": 98, - "end": 103, + "start": 94, + "end": 99, "ctxt": 0 }, "value": false @@ -32,16 +32,16 @@ "consequent": { "type": "ArrowFunctionExpression", "span": { - "start": 106, - "end": 130, + "start": 102, + "end": 126, "ctxt": 0 }, "params": [ { "type": "Identifier", "span": { - "start": 107, - "end": 112, + "start": 103, + "end": 108, "ctxt": 0 }, "value": "param", @@ -52,8 +52,8 @@ "body": { "type": "Identifier", "span": { - "start": 125, - "end": 130, + "start": 121, + "end": 126, "ctxt": 0 }, "value": "param", @@ -65,15 +65,15 @@ "returnType": { "type": "TsTypeAnnotation", "span": { - "start": 113, - "end": 121, + "start": 109, + "end": 117, "ctxt": 0 }, "typeAnnotation": { "type": "TsKeywordType", "span": { - "start": 115, - "end": 121, + "start": 111, + "end": 117, "ctxt": 0 }, "kind": "string" @@ -83,8 +83,8 @@ "alternate": { "type": "NullLiteral", "span": { - "start": 133, - "end": 137, + "start": 129, + "end": 133, "ctxt": 0 } } @@ -93,22 +93,22 @@ { "type": "ExpressionStatement", "span": { - "start": 217, - "end": 256, + "start": 213, + "end": 252, "ctxt": 0 }, "expression": { "type": "ConditionalExpression", "span": { - "start": 217, - "end": 256, + "start": 213, + "end": 252, "ctxt": 0 }, "test": { "type": "BooleanLiteral", "span": { - "start": 217, - "end": 222, + "start": 213, + "end": 218, "ctxt": 0 }, "value": false @@ -116,16 +116,16 @@ "consequent": { "type": "ArrowFunctionExpression", "span": { - "start": 225, - "end": 249, + "start": 221, + "end": 245, "ctxt": 0 }, "params": [ { "type": "Identifier", "span": { - "start": 226, - "end": 231, + "start": 222, + "end": 227, "ctxt": 0 }, "value": "param", @@ -136,8 +136,8 @@ "body": { "type": "Identifier", "span": { - "start": 244, - "end": 249, + "start": 240, + "end": 245, "ctxt": 0 }, "value": "param", @@ -149,15 +149,15 @@ "returnType": { "type": "TsTypeAnnotation", "span": { - "start": 232, - "end": 240, + "start": 228, + "end": 236, "ctxt": 0 }, "typeAnnotation": { "type": "TsKeywordType", "span": { - "start": 234, - "end": 240, + "start": 230, + "end": 236, "ctxt": 0 }, "kind": "string" @@ -167,8 +167,8 @@ "alternate": { "type": "NullLiteral", "span": { - "start": 252, - "end": 256, + "start": 248, + "end": 252, "ctxt": 0 } } diff --git a/crates/swc_ecma_parser/tests/tsc/parserArrowFunctionExpression15.ts b/crates/swc_ecma_parser/tests/tsc/parserArrowFunctionExpression15.ts index b68e10ea31dd..00bf1782bb5a 100644 --- a/crates/swc_ecma_parser/tests/tsc/parserArrowFunctionExpression15.ts +++ b/crates/swc_ecma_parser/tests/tsc/parserArrowFunctionExpression15.ts @@ -1,7 +1,7 @@ // @allowjs: true // @checkjs: true // @outdir: out -// @target: es3,es6 +// @target: es6 // @filename: fileJs.js false ? (param): string => param : null // Not legal JS; "Unexpected token ':'" at last colon diff --git a/crates/swc_ecma_parser/tests/tsc/parserArrowFunctionExpression16.json b/crates/swc_ecma_parser/tests/tsc/parserArrowFunctionExpression16.json index 6c256979ed8e..23e5faaa543f 100644 --- a/crates/swc_ecma_parser/tests/tsc/parserArrowFunctionExpression16.json +++ b/crates/swc_ecma_parser/tests/tsc/parserArrowFunctionExpression16.json @@ -1,30 +1,30 @@ { "type": "Script", "span": { - "start": 98, - "end": 284, + "start": 94, + "end": 280, "ctxt": 0 }, "body": [ { "type": "ExpressionStatement", "span": { - "start": 98, - "end": 151, + "start": 94, + "end": 147, "ctxt": 0 }, "expression": { "type": "ConditionalExpression", "span": { - "start": 98, - "end": 151, + "start": 94, + "end": 147, "ctxt": 0 }, "test": { "type": "BooleanLiteral", "span": { - "start": 98, - "end": 102, + "start": 94, + "end": 98, "ctxt": 0 }, "value": true @@ -32,15 +32,15 @@ "consequent": { "type": "ConditionalExpression", "span": { - "start": 105, - "end": 144, + "start": 101, + "end": 140, "ctxt": 0 }, "test": { "type": "BooleanLiteral", "span": { - "start": 105, - "end": 110, + "start": 101, + "end": 106, "ctxt": 0 }, "value": false @@ -48,16 +48,16 @@ "consequent": { "type": "ArrowFunctionExpression", "span": { - "start": 113, - "end": 137, + "start": 109, + "end": 133, "ctxt": 0 }, "params": [ { "type": "Identifier", "span": { - "start": 114, - "end": 119, + "start": 110, + "end": 115, "ctxt": 0 }, "value": "param", @@ -68,8 +68,8 @@ "body": { "type": "Identifier", "span": { - "start": 132, - "end": 137, + "start": 128, + "end": 133, "ctxt": 0 }, "value": "param", @@ -81,15 +81,15 @@ "returnType": { "type": "TsTypeAnnotation", "span": { - "start": 120, - "end": 128, + "start": 116, + "end": 124, "ctxt": 0 }, "typeAnnotation": { "type": "TsKeywordType", "span": { - "start": 122, - "end": 128, + "start": 118, + "end": 124, "ctxt": 0 }, "kind": "string" @@ -99,8 +99,8 @@ "alternate": { "type": "NullLiteral", "span": { - "start": 140, - "end": 144, + "start": 136, + "end": 140, "ctxt": 0 } } @@ -108,8 +108,8 @@ "alternate": { "type": "NullLiteral", "span": { - "start": 147, - "end": 151, + "start": 143, + "end": 147, "ctxt": 0 } } @@ -118,22 +118,22 @@ { "type": "ExpressionStatement", "span": { - "start": 231, - "end": 284, + "start": 227, + "end": 280, "ctxt": 0 }, "expression": { "type": "ConditionalExpression", "span": { - "start": 231, - "end": 284, + "start": 227, + "end": 280, "ctxt": 0 }, "test": { "type": "BooleanLiteral", "span": { - "start": 231, - "end": 235, + "start": 227, + "end": 231, "ctxt": 0 }, "value": true @@ -141,15 +141,15 @@ "consequent": { "type": "ConditionalExpression", "span": { - "start": 238, - "end": 277, + "start": 234, + "end": 273, "ctxt": 0 }, "test": { "type": "BooleanLiteral", "span": { - "start": 238, - "end": 243, + "start": 234, + "end": 239, "ctxt": 0 }, "value": false @@ -157,16 +157,16 @@ "consequent": { "type": "ArrowFunctionExpression", "span": { - "start": 246, - "end": 270, + "start": 242, + "end": 266, "ctxt": 0 }, "params": [ { "type": "Identifier", "span": { - "start": 247, - "end": 252, + "start": 243, + "end": 248, "ctxt": 0 }, "value": "param", @@ -177,8 +177,8 @@ "body": { "type": "Identifier", "span": { - "start": 265, - "end": 270, + "start": 261, + "end": 266, "ctxt": 0 }, "value": "param", @@ -190,15 +190,15 @@ "returnType": { "type": "TsTypeAnnotation", "span": { - "start": 253, - "end": 261, + "start": 249, + "end": 257, "ctxt": 0 }, "typeAnnotation": { "type": "TsKeywordType", "span": { - "start": 255, - "end": 261, + "start": 251, + "end": 257, "ctxt": 0 }, "kind": "string" @@ -208,8 +208,8 @@ "alternate": { "type": "NullLiteral", "span": { - "start": 273, - "end": 277, + "start": 269, + "end": 273, "ctxt": 0 } } @@ -217,8 +217,8 @@ "alternate": { "type": "NullLiteral", "span": { - "start": 280, - "end": 284, + "start": 276, + "end": 280, "ctxt": 0 } } diff --git a/crates/swc_ecma_parser/tests/tsc/parserArrowFunctionExpression16.ts b/crates/swc_ecma_parser/tests/tsc/parserArrowFunctionExpression16.ts index c9a1c9b47226..dab1ea06c3b7 100644 --- a/crates/swc_ecma_parser/tests/tsc/parserArrowFunctionExpression16.ts +++ b/crates/swc_ecma_parser/tests/tsc/parserArrowFunctionExpression16.ts @@ -1,7 +1,7 @@ // @allowjs: true // @checkjs: true // @outdir: out -// @target: es3,es6 +// @target: es6 // @filename: fileJs.js true ? false ? (param): string => param : null : null // Not legal JS; "Unexpected token ':'" at last colon diff --git a/crates/swc_ecma_parser/tests/tsc/parserArrowFunctionExpression17.json b/crates/swc_ecma_parser/tests/tsc/parserArrowFunctionExpression17.json index 2cb9c1e3ca78..cfc1cf5b9edb 100644 --- a/crates/swc_ecma_parser/tests/tsc/parserArrowFunctionExpression17.json +++ b/crates/swc_ecma_parser/tests/tsc/parserArrowFunctionExpression17.json @@ -1,30 +1,30 @@ { "type": "Script", "span": { - "start": 98, - "end": 218, + "start": 94, + "end": 214, "ctxt": 0 }, "body": [ { "type": "ExpressionStatement", "span": { - "start": 98, - "end": 118, + "start": 94, + "end": 114, "ctxt": 0 }, "expression": { "type": "ConditionalExpression", "span": { - "start": 98, - "end": 118, + "start": 94, + "end": 114, "ctxt": 0 }, "test": { "type": "Identifier", "span": { - "start": 98, - "end": 99, + "start": 94, + "end": 95, "ctxt": 0 }, "value": "a", @@ -33,8 +33,8 @@ "consequent": { "type": "Identifier", "span": { - "start": 102, - "end": 103, + "start": 98, + "end": 99, "ctxt": 0 }, "value": "b", @@ -43,16 +43,16 @@ "alternate": { "type": "ArrowFunctionExpression", "span": { - "start": 106, - "end": 118, + "start": 102, + "end": 114, "ctxt": 0 }, "params": [ { "type": "Identifier", "span": { - "start": 107, - "end": 108, + "start": 103, + "end": 104, "ctxt": 0 }, "value": "c", @@ -63,8 +63,8 @@ "body": { "type": "Identifier", "span": { - "start": 117, - "end": 118, + "start": 113, + "end": 114, "ctxt": 0 }, "value": "e", @@ -76,22 +76,22 @@ "returnType": { "type": "TsTypeAnnotation", "span": { - "start": 110, - "end": 113, + "start": 106, + "end": 109, "ctxt": 0 }, "typeAnnotation": { "type": "TsTypeReference", "span": { - "start": 112, - "end": 113, + "start": 108, + "end": 109, "ctxt": 0 }, "typeName": { "type": "Identifier", "span": { - "start": 112, - "end": 113, + "start": 108, + "end": 109, "ctxt": 0 }, "value": "d", @@ -106,22 +106,22 @@ { "type": "ExpressionStatement", "span": { - "start": 198, - "end": 218, + "start": 194, + "end": 214, "ctxt": 0 }, "expression": { "type": "ConditionalExpression", "span": { - "start": 198, - "end": 218, + "start": 194, + "end": 214, "ctxt": 0 }, "test": { "type": "Identifier", "span": { - "start": 198, - "end": 199, + "start": 194, + "end": 195, "ctxt": 0 }, "value": "a", @@ -130,8 +130,8 @@ "consequent": { "type": "Identifier", "span": { - "start": 202, - "end": 203, + "start": 198, + "end": 199, "ctxt": 0 }, "value": "b", @@ -140,16 +140,16 @@ "alternate": { "type": "ArrowFunctionExpression", "span": { - "start": 206, - "end": 218, + "start": 202, + "end": 214, "ctxt": 0 }, "params": [ { "type": "Identifier", "span": { - "start": 207, - "end": 208, + "start": 203, + "end": 204, "ctxt": 0 }, "value": "c", @@ -160,8 +160,8 @@ "body": { "type": "Identifier", "span": { - "start": 217, - "end": 218, + "start": 213, + "end": 214, "ctxt": 0 }, "value": "e", @@ -173,22 +173,22 @@ "returnType": { "type": "TsTypeAnnotation", "span": { - "start": 210, - "end": 213, + "start": 206, + "end": 209, "ctxt": 0 }, "typeAnnotation": { "type": "TsTypeReference", "span": { - "start": 212, - "end": 213, + "start": 208, + "end": 209, "ctxt": 0 }, "typeName": { "type": "Identifier", "span": { - "start": 212, - "end": 213, + "start": 208, + "end": 209, "ctxt": 0 }, "value": "d", diff --git a/crates/swc_ecma_parser/tests/tsc/parserArrowFunctionExpression17.ts b/crates/swc_ecma_parser/tests/tsc/parserArrowFunctionExpression17.ts index bd0f531b717c..b6675b878a32 100644 --- a/crates/swc_ecma_parser/tests/tsc/parserArrowFunctionExpression17.ts +++ b/crates/swc_ecma_parser/tests/tsc/parserArrowFunctionExpression17.ts @@ -1,7 +1,7 @@ // @allowjs: true // @checkjs: true // @outdir: out -// @target: es3,es6 +// @target: es6 // @filename: fileJs.js a ? b : (c) : d => e // Not legal JS; "Unexpected token ':'" at last colon diff --git a/crates/swc_ecma_parser/tests/tsc/parserArrowFunctionExpression8.json b/crates/swc_ecma_parser/tests/tsc/parserArrowFunctionExpression8.json index 32597b17d6fd..8f48887ae296 100644 --- a/crates/swc_ecma_parser/tests/tsc/parserArrowFunctionExpression8.json +++ b/crates/swc_ecma_parser/tests/tsc/parserArrowFunctionExpression8.json @@ -1,30 +1,30 @@ { "type": "Script", "span": { - "start": 98, - "end": 198, + "start": 94, + "end": 194, "ctxt": 0 }, "body": [ { "type": "ExpressionStatement", "span": { - "start": 98, - "end": 129, + "start": 94, + "end": 125, "ctxt": 0 }, "expression": { "type": "ConditionalExpression", "span": { - "start": 98, - "end": 129, + "start": 94, + "end": 125, "ctxt": 0 }, "test": { "type": "Identifier", "span": { - "start": 98, - "end": 99, + "start": 94, + "end": 95, "ctxt": 0 }, "value": "x", @@ -33,16 +33,16 @@ "consequent": { "type": "ArrowFunctionExpression", "span": { - "start": 102, - "end": 114, + "start": 98, + "end": 110, "ctxt": 0 }, "params": [ { "type": "Identifier", "span": { - "start": 102, - "end": 103, + "start": 98, + "end": 99, "ctxt": 0 }, "value": "y", @@ -53,23 +53,23 @@ "body": { "type": "ParenthesisExpression", "span": { - "start": 107, - "end": 114, + "start": 103, + "end": 110, "ctxt": 0 }, "expression": { "type": "ObjectExpression", "span": { - "start": 108, - "end": 113, + "start": 104, + "end": 109, "ctxt": 0 }, "properties": [ { "type": "Identifier", "span": { - "start": 110, - "end": 111, + "start": 106, + "end": 107, "ctxt": 0 }, "value": "y", @@ -86,16 +86,16 @@ "alternate": { "type": "ArrowFunctionExpression", "span": { - "start": 117, - "end": 129, + "start": 113, + "end": 125, "ctxt": 0 }, "params": [ { "type": "Identifier", "span": { - "start": 117, - "end": 118, + "start": 113, + "end": 114, "ctxt": 0 }, "value": "z", @@ -106,23 +106,23 @@ "body": { "type": "ParenthesisExpression", "span": { - "start": 122, - "end": 129, + "start": 118, + "end": 125, "ctxt": 0 }, "expression": { "type": "ObjectExpression", "span": { - "start": 123, - "end": 128, + "start": 119, + "end": 124, "ctxt": 0 }, "properties": [ { "type": "Identifier", "span": { - "start": 125, - "end": 126, + "start": 121, + "end": 122, "ctxt": 0 }, "value": "z", @@ -141,22 +141,22 @@ { "type": "ExpressionStatement", "span": { - "start": 167, - "end": 198, + "start": 163, + "end": 194, "ctxt": 0 }, "expression": { "type": "ConditionalExpression", "span": { - "start": 167, - "end": 198, + "start": 163, + "end": 194, "ctxt": 0 }, "test": { "type": "Identifier", "span": { - "start": 167, - "end": 168, + "start": 163, + "end": 164, "ctxt": 0 }, "value": "x", @@ -165,16 +165,16 @@ "consequent": { "type": "ArrowFunctionExpression", "span": { - "start": 171, - "end": 183, + "start": 167, + "end": 179, "ctxt": 0 }, "params": [ { "type": "Identifier", "span": { - "start": 171, - "end": 172, + "start": 167, + "end": 168, "ctxt": 0 }, "value": "y", @@ -185,23 +185,23 @@ "body": { "type": "ParenthesisExpression", "span": { - "start": 176, - "end": 183, + "start": 172, + "end": 179, "ctxt": 0 }, "expression": { "type": "ObjectExpression", "span": { - "start": 177, - "end": 182, + "start": 173, + "end": 178, "ctxt": 0 }, "properties": [ { "type": "Identifier", "span": { - "start": 179, - "end": 180, + "start": 175, + "end": 176, "ctxt": 0 }, "value": "y", @@ -218,16 +218,16 @@ "alternate": { "type": "ArrowFunctionExpression", "span": { - "start": 186, - "end": 198, + "start": 182, + "end": 194, "ctxt": 0 }, "params": [ { "type": "Identifier", "span": { - "start": 186, - "end": 187, + "start": 182, + "end": 183, "ctxt": 0 }, "value": "z", @@ -238,23 +238,23 @@ "body": { "type": "ParenthesisExpression", "span": { - "start": 191, - "end": 198, + "start": 187, + "end": 194, "ctxt": 0 }, "expression": { "type": "ObjectExpression", "span": { - "start": 192, - "end": 197, + "start": 188, + "end": 193, "ctxt": 0 }, "properties": [ { "type": "Identifier", "span": { - "start": 194, - "end": 195, + "start": 190, + "end": 191, "ctxt": 0 }, "value": "z", diff --git a/crates/swc_ecma_parser/tests/tsc/parserArrowFunctionExpression8.ts b/crates/swc_ecma_parser/tests/tsc/parserArrowFunctionExpression8.ts index 4a908beffa74..641cb5ac45d5 100644 --- a/crates/swc_ecma_parser/tests/tsc/parserArrowFunctionExpression8.ts +++ b/crates/swc_ecma_parser/tests/tsc/parserArrowFunctionExpression8.ts @@ -1,7 +1,7 @@ // @allowjs: true // @checkjs: true // @outdir: out -// @target: es3,es6 +// @target: es6 // @filename: fileJs.js x ? y => ({ y }) : z => ({ z }) // Legal JS diff --git a/crates/swc_ecma_parser/tests/tsc/parserArrowFunctionExpression9.json b/crates/swc_ecma_parser/tests/tsc/parserArrowFunctionExpression9.json index fa35eb686736..3a4b4e88dfd8 100644 --- a/crates/swc_ecma_parser/tests/tsc/parserArrowFunctionExpression9.json +++ b/crates/swc_ecma_parser/tests/tsc/parserArrowFunctionExpression9.json @@ -1,30 +1,30 @@ { "type": "Script", "span": { - "start": 98, - "end": 168, + "start": 94, + "end": 164, "ctxt": 0 }, "body": [ { "type": "ExpressionStatement", "span": { - "start": 98, - "end": 114, + "start": 94, + "end": 110, "ctxt": 0 }, "expression": { "type": "ConditionalExpression", "span": { - "start": 98, - "end": 114, + "start": 94, + "end": 110, "ctxt": 0 }, "test": { "type": "Identifier", "span": { - "start": 98, - "end": 99, + "start": 94, + "end": 95, "ctxt": 0 }, "value": "b", @@ -33,15 +33,15 @@ "consequent": { "type": "ParenthesisExpression", "span": { - "start": 102, - "end": 105, + "start": 98, + "end": 101, "ctxt": 0 }, "expression": { "type": "Identifier", "span": { - "start": 103, - "end": 104, + "start": 99, + "end": 100, "ctxt": 0 }, "value": "c", @@ -51,16 +51,16 @@ "alternate": { "type": "ArrowFunctionExpression", "span": { - "start": 108, - "end": 114, + "start": 104, + "end": 110, "ctxt": 0 }, "params": [ { "type": "Identifier", "span": { - "start": 108, - "end": 109, + "start": 104, + "end": 105, "ctxt": 0 }, "value": "d", @@ -71,8 +71,8 @@ "body": { "type": "Identifier", "span": { - "start": 113, - "end": 114, + "start": 109, + "end": 110, "ctxt": 0 }, "value": "e", @@ -88,22 +88,22 @@ { "type": "ExpressionStatement", "span": { - "start": 152, - "end": 168, + "start": 148, + "end": 164, "ctxt": 0 }, "expression": { "type": "ConditionalExpression", "span": { - "start": 152, - "end": 168, + "start": 148, + "end": 164, "ctxt": 0 }, "test": { "type": "Identifier", "span": { - "start": 152, - "end": 153, + "start": 148, + "end": 149, "ctxt": 0 }, "value": "b", @@ -112,15 +112,15 @@ "consequent": { "type": "ParenthesisExpression", "span": { - "start": 156, - "end": 159, + "start": 152, + "end": 155, "ctxt": 0 }, "expression": { "type": "Identifier", "span": { - "start": 157, - "end": 158, + "start": 153, + "end": 154, "ctxt": 0 }, "value": "c", @@ -130,16 +130,16 @@ "alternate": { "type": "ArrowFunctionExpression", "span": { - "start": 162, - "end": 168, + "start": 158, + "end": 164, "ctxt": 0 }, "params": [ { "type": "Identifier", "span": { - "start": 162, - "end": 163, + "start": 158, + "end": 159, "ctxt": 0 }, "value": "d", @@ -150,8 +150,8 @@ "body": { "type": "Identifier", "span": { - "start": 167, - "end": 168, + "start": 163, + "end": 164, "ctxt": 0 }, "value": "e", diff --git a/crates/swc_ecma_parser/tests/tsc/parserArrowFunctionExpression9.ts b/crates/swc_ecma_parser/tests/tsc/parserArrowFunctionExpression9.ts index 93ebbc25408e..d2dd9733a18f 100644 --- a/crates/swc_ecma_parser/tests/tsc/parserArrowFunctionExpression9.ts +++ b/crates/swc_ecma_parser/tests/tsc/parserArrowFunctionExpression9.ts @@ -1,7 +1,7 @@ // @allowjs: true // @checkjs: true // @outdir: out -// @target: es3,es6 +// @target: es6 // @filename: fileJs.js b ? (c) : d => e // Legal JS diff --git a/crates/swc_ecma_parser/tests/tsc/privateNameES5Ban.json b/crates/swc_ecma_parser/tests/tsc/privateNameES5Ban.json index c4617fd22e0a..1bb50f37e118 100644 --- a/crates/swc_ecma_parser/tests/tsc/privateNameES5Ban.json +++ b/crates/swc_ecma_parser/tests/tsc/privateNameES5Ban.json @@ -1,8 +1,8 @@ { "type": "Script", "span": { - "start": 23, - "end": 280, + "start": 18, + "end": 275, "ctxt": 0 }, "body": [ @@ -11,8 +11,8 @@ "identifier": { "type": "Identifier", "span": { - "start": 29, - "end": 30, + "start": 24, + "end": 25, "ctxt": 0 }, "value": "A", @@ -20,8 +20,8 @@ }, "declare": false, "span": { - "start": 23, - "end": 280, + "start": 18, + "end": 275, "ctxt": 0 }, "decorators": [], @@ -29,15 +29,15 @@ { "type": "Constructor", "span": { - "start": 37, - "end": 53, + "start": 32, + "end": 48, "ctxt": 0 }, "key": { "type": "Identifier", "span": { - "start": 37, - "end": 48, + "start": 32, + "end": 43, "ctxt": 0 }, "value": "constructor", @@ -47,8 +47,8 @@ "body": { "type": "BlockStatement", "span": { - "start": 51, - "end": 53, + "start": 46, + "end": 48, "ctxt": 0 }, "stmts": [] @@ -59,22 +59,22 @@ { "type": "PrivateProperty", "span": { - "start": 58, - "end": 71, + "start": 53, + "end": 66, "ctxt": 0 }, "key": { "type": "PrivateName", "span": { - "start": 58, - "end": 64, + "start": 53, + "end": 59, "ctxt": 0 }, "id": { "type": "Identifier", "span": { - "start": 59, - "end": 64, + "start": 54, + "end": 59, "ctxt": 0 }, "value": "field", @@ -84,8 +84,8 @@ "value": { "type": "NumericLiteral", "span": { - "start": 67, - "end": 70, + "start": 62, + "end": 65, "ctxt": 0 }, "value": 123.0, @@ -103,22 +103,22 @@ { "type": "PrivateMethod", "span": { - "start": 76, - "end": 88, + "start": 71, + "end": 83, "ctxt": 0 }, "key": { "type": "PrivateName", "span": { - "start": 76, - "end": 83, + "start": 71, + "end": 78, "ctxt": 0 }, "id": { "type": "Identifier", "span": { - "start": 77, - "end": 83, + "start": 72, + "end": 78, "ctxt": 0 }, "value": "method", @@ -129,15 +129,15 @@ "params": [], "decorators": [], "span": { - "start": 76, - "end": 88, + "start": 71, + "end": 83, "ctxt": 0 }, "body": { "type": "BlockStatement", "span": { - "start": 86, - "end": 88, + "start": 81, + "end": 83, "ctxt": 0 }, "stmts": [] @@ -157,22 +157,22 @@ { "type": "PrivateProperty", "span": { - "start": 93, - "end": 124, + "start": 88, + "end": 119, "ctxt": 0 }, "key": { "type": "PrivateName", "span": { - "start": 100, - "end": 107, + "start": 95, + "end": 102, "ctxt": 0 }, "id": { "type": "Identifier", "span": { - "start": 101, - "end": 107, + "start": 96, + "end": 102, "ctxt": 0 }, "value": "sField", @@ -182,8 +182,8 @@ "value": { "type": "StringLiteral", "span": { - "start": 110, - "end": 123, + "start": 105, + "end": 118, "ctxt": 0 }, "value": "hello world", @@ -201,22 +201,22 @@ { "type": "PrivateMethod", "span": { - "start": 129, - "end": 149, + "start": 124, + "end": 144, "ctxt": 0 }, "key": { "type": "PrivateName", "span": { - "start": 136, - "end": 144, + "start": 131, + "end": 139, "ctxt": 0 }, "id": { "type": "Identifier", "span": { - "start": 137, - "end": 144, + "start": 132, + "end": 139, "ctxt": 0 }, "value": "sMethod", @@ -227,15 +227,15 @@ "params": [], "decorators": [], "span": { - "start": 129, - "end": 149, + "start": 124, + "end": 144, "ctxt": 0 }, "body": { "type": "BlockStatement", "span": { - "start": 147, - "end": 149, + "start": 142, + "end": 144, "ctxt": 0 }, "stmts": [] @@ -255,22 +255,22 @@ { "type": "PrivateMethod", "span": { - "start": 154, - "end": 179, + "start": 149, + "end": 174, "ctxt": 0 }, "key": { "type": "PrivateName", "span": { - "start": 158, - "end": 162, + "start": 153, + "end": 157, "ctxt": 0 }, "id": { "type": "Identifier", "span": { - "start": 159, - "end": 162, + "start": 154, + "end": 157, "ctxt": 0 }, "value": "acc", @@ -281,30 +281,30 @@ "params": [], "decorators": [], "span": { - "start": 154, - "end": 179, + "start": 149, + "end": 174, "ctxt": 0 }, "body": { "type": "BlockStatement", "span": { - "start": 165, - "end": 179, + "start": 160, + "end": 174, "ctxt": 0 }, "stmts": [ { "type": "ReturnStatement", "span": { - "start": 167, - "end": 177, + "start": 162, + "end": 172, "ctxt": 0 }, "argument": { "type": "StringLiteral", "span": { - "start": 174, - "end": 176, + "start": 169, + "end": 171, "ctxt": 0 }, "value": "", @@ -328,22 +328,22 @@ { "type": "PrivateMethod", "span": { - "start": 184, - "end": 206, + "start": 179, + "end": 201, "ctxt": 0 }, "key": { "type": "PrivateName", "span": { - "start": 188, - "end": 192, + "start": 183, + "end": 187, "ctxt": 0 }, "id": { "type": "Identifier", "span": { - "start": 189, - "end": 192, + "start": 184, + "end": 187, "ctxt": 0 }, "value": "acc", @@ -355,16 +355,16 @@ { "type": "Parameter", "span": { - "start": 193, - "end": 202, + "start": 188, + "end": 197, "ctxt": 0 }, "decorators": [], "pat": { "type": "Identifier", "span": { - "start": 193, - "end": 202, + "start": 188, + "end": 197, "ctxt": 0 }, "value": "x", @@ -372,15 +372,15 @@ "typeAnnotation": { "type": "TsTypeAnnotation", "span": { - "start": 194, - "end": 202, + "start": 189, + "end": 197, "ctxt": 0 }, "typeAnnotation": { "type": "TsKeywordType", "span": { - "start": 196, - "end": 202, + "start": 191, + "end": 197, "ctxt": 0 }, "kind": "string" @@ -391,15 +391,15 @@ ], "decorators": [], "span": { - "start": 184, - "end": 206, + "start": 179, + "end": 201, "ctxt": 0 }, "body": { "type": "BlockStatement", "span": { - "start": 204, - "end": 206, + "start": 199, + "end": 201, "ctxt": 0 }, "stmts": [] @@ -419,22 +419,22 @@ { "type": "PrivateMethod", "span": { - "start": 211, - "end": 243, + "start": 206, + "end": 238, "ctxt": 0 }, "key": { "type": "PrivateName", "span": { - "start": 222, - "end": 227, + "start": 217, + "end": 222, "ctxt": 0 }, "id": { "type": "Identifier", "span": { - "start": 223, - "end": 227, + "start": 218, + "end": 222, "ctxt": 0 }, "value": "sAcc", @@ -445,30 +445,30 @@ "params": [], "decorators": [], "span": { - "start": 211, - "end": 243, + "start": 206, + "end": 238, "ctxt": 0 }, "body": { "type": "BlockStatement", "span": { - "start": 230, - "end": 243, + "start": 225, + "end": 238, "ctxt": 0 }, "stmts": [ { "type": "ReturnStatement", "span": { - "start": 232, - "end": 241, + "start": 227, + "end": 236, "ctxt": 0 }, "argument": { "type": "NumericLiteral", "span": { - "start": 239, - "end": 240, + "start": 234, + "end": 235, "ctxt": 0 }, "value": 0.0, @@ -492,22 +492,22 @@ { "type": "PrivateMethod", "span": { - "start": 248, - "end": 278, + "start": 243, + "end": 273, "ctxt": 0 }, "key": { "type": "PrivateName", "span": { - "start": 259, - "end": 264, + "start": 254, + "end": 259, "ctxt": 0 }, "id": { "type": "Identifier", "span": { - "start": 260, - "end": 264, + "start": 255, + "end": 259, "ctxt": 0 }, "value": "sAcc", @@ -519,16 +519,16 @@ { "type": "Parameter", "span": { - "start": 265, - "end": 274, + "start": 260, + "end": 269, "ctxt": 0 }, "decorators": [], "pat": { "type": "Identifier", "span": { - "start": 265, - "end": 274, + "start": 260, + "end": 269, "ctxt": 0 }, "value": "x", @@ -536,15 +536,15 @@ "typeAnnotation": { "type": "TsTypeAnnotation", "span": { - "start": 266, - "end": 274, + "start": 261, + "end": 269, "ctxt": 0 }, "typeAnnotation": { "type": "TsKeywordType", "span": { - "start": 268, - "end": 274, + "start": 263, + "end": 269, "ctxt": 0 }, "kind": "number" @@ -555,15 +555,15 @@ ], "decorators": [], "span": { - "start": 248, - "end": 278, + "start": 243, + "end": 273, "ctxt": 0 }, "body": { "type": "BlockStatement", "span": { - "start": 276, - "end": 278, + "start": 271, + "end": 273, "ctxt": 0 }, "stmts": [] diff --git a/crates/swc_ecma_parser/tests/tsc/privateNameES5Ban.ts b/crates/swc_ecma_parser/tests/tsc/privateNameES5Ban.ts index 169351c9822a..0d5ec7a66499 100644 --- a/crates/swc_ecma_parser/tests/tsc/privateNameES5Ban.ts +++ b/crates/swc_ecma_parser/tests/tsc/privateNameES5Ban.ts @@ -1,4 +1,4 @@ -// @target: es5, es3 +// @target: es5 class A { constructor() {} diff --git a/crates/swc_ecma_parser/tests/tsc/spreadNonObject1.json b/crates/swc_ecma_parser/tests/tsc/spreadNonObject1.json new file mode 100644 index 000000000000..c83051576ddd --- /dev/null +++ b/crates/swc_ecma_parser/tests/tsc/spreadNonObject1.json @@ -0,0 +1,364 @@ +{ + "type": "Script", + "span": { + "start": 93, + "end": 204, + "ctxt": 0 + }, + "body": [ + { + "type": "TsTypeAliasDeclaration", + "span": { + "start": 93, + "end": 114, + "ctxt": 0 + }, + "declare": false, + "id": { + "type": "Identifier", + "span": { + "start": 98, + "end": 99, + "ctxt": 0 + }, + "value": "S", + "optional": false + }, + "typeParams": null, + "typeAnnotation": { + "type": "TsLiteralType", + "span": { + "start": 102, + "end": 113, + "ctxt": 0 + }, + "literal": { + "type": "TemplateLiteral", + "span": { + "start": 102, + "end": 113, + "ctxt": 0 + }, + "types": [ + { + "type": "TsKeywordType", + "span": { + "start": 105, + "end": 111, + "ctxt": 0 + }, + "kind": "number" + } + ], + "quasis": [ + { + "type": "TemplateElement", + "span": { + "start": 103, + "end": 103, + "ctxt": 0 + }, + "tail": false, + "cooked": "", + "raw": "" + }, + { + "type": "TemplateElement", + "span": { + "start": 112, + "end": 112, + "ctxt": 0 + }, + "tail": true, + "cooked": "", + "raw": "" + } + ] + } + } + }, + { + "type": "VariableDeclaration", + "span": { + "start": 115, + "end": 204, + "ctxt": 0 + }, + "kind": "const", + "declare": false, + "declarations": [ + { + "type": "VariableDeclarator", + "span": { + "start": 121, + "end": 203, + "ctxt": 0 + }, + "id": { + "type": "Identifier", + "span": { + "start": 121, + "end": 122, + "ctxt": 0 + }, + "value": "b", + "optional": false, + "typeAnnotation": null + }, + "init": { + "type": "ObjectExpression", + "span": { + "start": 125, + "end": 203, + "ctxt": 0 + }, + "properties": [ + { + "type": "KeyValueProperty", + "key": { + "type": "Identifier", + "span": { + "start": 129, + "end": 130, + "ctxt": 0 + }, + "value": "c", + "optional": false + }, + "value": { + "type": "CallExpression", + "span": { + "start": 132, + "end": 200, + "ctxt": 0 + }, + "callee": { + "type": "MemberExpression", + "span": { + "start": 132, + "end": 150, + "ctxt": 0 + }, + "object": { + "type": "ParenthesisExpression", + "span": { + "start": 132, + "end": 146, + "ctxt": 0 + }, + "expression": { + "type": "TsAsExpression", + "span": { + "start": 133, + "end": 145, + "ctxt": 0 + }, + "expression": { + "type": "ArrayExpression", + "span": { + "start": 133, + "end": 138, + "ctxt": 0 + }, + "elements": [ + { + "spread": null, + "expression": { + "type": "StringLiteral", + "span": { + "start": 134, + "end": 137, + "ctxt": 0 + }, + "value": "4", + "raw": "\"4\"" + } + } + ] + }, + "typeAnnotation": { + "type": "TsArrayType", + "span": { + "start": 142, + "end": 145, + "ctxt": 0 + }, + "elemType": { + "type": "TsTypeReference", + "span": { + "start": 142, + "end": 143, + "ctxt": 0 + }, + "typeName": { + "type": "Identifier", + "span": { + "start": 142, + "end": 143, + "ctxt": 0 + }, + "value": "S", + "optional": false + }, + "typeParams": null + } + } + } + }, + "property": { + "type": "Identifier", + "span": { + "start": 147, + "end": 150, + "ctxt": 0 + }, + "value": "map", + "optional": false + } + }, + "arguments": [ + { + "spread": null, + "expression": { + "type": "FunctionExpression", + "identifier": null, + "params": [ + { + "type": "Parameter", + "span": { + "start": 161, + "end": 162, + "ctxt": 0 + }, + "decorators": [], + "pat": { + "type": "Identifier", + "span": { + "start": 161, + "end": 162, + "ctxt": 0 + }, + "value": "s", + "optional": false, + "typeAnnotation": null + } + } + ], + "decorators": [], + "span": { + "start": 151, + "end": 199, + "ctxt": 0 + }, + "body": { + "type": "BlockStatement", + "span": { + "start": 164, + "end": 199, + "ctxt": 0 + }, + "stmts": [ + { + "type": "VariableDeclaration", + "span": { + "start": 170, + "end": 195, + "ctxt": 0 + }, + "kind": "const", + "declare": false, + "declarations": [ + { + "type": "VariableDeclarator", + "span": { + "start": 176, + "end": 194, + "ctxt": 0 + }, + "id": { + "type": "Identifier", + "span": { + "start": 176, + "end": 177, + "ctxt": 0 + }, + "value": "a", + "optional": false, + "typeAnnotation": null + }, + "init": { + "type": "ObjectExpression", + "span": { + "start": 180, + "end": 194, + "ctxt": 0 + }, + "properties": [ + { + "type": "SpreadElement", + "spread": { + "start": 182, + "end": 185, + "ctxt": 0 + }, + "arguments": { + "type": "Identifier", + "span": { + "start": 185, + "end": 186, + "ctxt": 0 + }, + "value": "s", + "optional": false + } + }, + { + "type": "KeyValueProperty", + "key": { + "type": "Identifier", + "span": { + "start": 188, + "end": 189, + "ctxt": 0 + }, + "value": "y", + "optional": false + }, + "value": { + "type": "NumericLiteral", + "span": { + "start": 191, + "end": 192, + "ctxt": 0 + }, + "value": 6.0, + "raw": "6" + } + } + ] + }, + "definite": false + } + ] + } + ] + }, + "generator": false, + "async": false, + "typeParameters": null, + "returnType": null + } + } + ], + "typeArguments": null + } + } + ] + }, + "definite": false + } + ] + } + ], + "interpreter": null +} diff --git a/crates/swc_ecma_parser/tests/tsc/spreadNonObject1.ts b/crates/swc_ecma_parser/tests/tsc/spreadNonObject1.ts new file mode 100644 index 000000000000..17eb5fd2e521 --- /dev/null +++ b/crates/swc_ecma_parser/tests/tsc/spreadNonObject1.ts @@ -0,0 +1,11 @@ +// @strict: true +// @noEmit: true + +// https://github.com/microsoft/TypeScript/issues/45493 + +type S = `${number}`; +const b = { + c: (["4"] as S[]).map(function (s) { + const a = { ...s, y: 6 }; + }), +}; diff --git a/crates/swc_ecma_parser/tests/tsc/templateLiteralTypes5.json b/crates/swc_ecma_parser/tests/tsc/templateLiteralTypes5.json new file mode 100644 index 000000000000..a6606fe6a20d --- /dev/null +++ b/crates/swc_ecma_parser/tests/tsc/templateLiteralTypes5.json @@ -0,0 +1,1472 @@ +{ + "type": "Script", + "span": { + "start": 111, + "end": 502, + "ctxt": 0 + }, + "body": [ + { + "type": "TsInterfaceDeclaration", + "span": { + "start": 111, + "end": 152, + "ctxt": 0 + }, + "id": { + "type": "Identifier", + "span": { + "start": 121, + "end": 128, + "ctxt": 0 + }, + "value": "TypeMap", + "optional": false + }, + "declare": false, + "typeParams": null, + "extends": [], + "body": { + "type": "TsInterfaceBody", + "span": { + "start": 129, + "end": 152, + "ctxt": 0 + }, + "body": [ + { + "type": "TsPropertySignature", + "span": { + "start": 133, + "end": 140, + "ctxt": 0 + }, + "readonly": false, + "key": { + "type": "Identifier", + "span": { + "start": 133, + "end": 134, + "ctxt": 0 + }, + "value": "a", + "optional": false + }, + "computed": false, + "optional": false, + "init": null, + "params": [], + "typeAnnotation": { + "type": "TsTypeAnnotation", + "span": { + "start": 134, + "end": 139, + "ctxt": 0 + }, + "typeAnnotation": { + "type": "TsLiteralType", + "span": { + "start": 136, + "end": 139, + "ctxt": 0 + }, + "literal": { + "type": "StringLiteral", + "span": { + "start": 136, + "end": 139, + "ctxt": 0 + }, + "value": "A", + "raw": "\"A\"" + } + } + }, + "typeParams": null + }, + { + "type": "TsPropertySignature", + "span": { + "start": 143, + "end": 150, + "ctxt": 0 + }, + "readonly": false, + "key": { + "type": "Identifier", + "span": { + "start": 143, + "end": 144, + "ctxt": 0 + }, + "value": "b", + "optional": false + }, + "computed": false, + "optional": false, + "init": null, + "params": [], + "typeAnnotation": { + "type": "TsTypeAnnotation", + "span": { + "start": 144, + "end": 149, + "ctxt": 0 + }, + "typeAnnotation": { + "type": "TsLiteralType", + "span": { + "start": 146, + "end": 149, + "ctxt": 0 + }, + "literal": { + "type": "StringLiteral", + "span": { + "start": 146, + "end": 149, + "ctxt": 0 + }, + "value": "B", + "raw": "\"B\"" + } + } + }, + "typeParams": null + } + ] + } + }, + { + "type": "VariableDeclaration", + "span": { + "start": 153, + "end": 220, + "ctxt": 0 + }, + "kind": "const", + "declare": true, + "declarations": [ + { + "type": "VariableDeclarator", + "span": { + "start": 167, + "end": 219, + "ctxt": 0 + }, + "id": { + "type": "Identifier", + "span": { + "start": 167, + "end": 168, + "ctxt": 0 + }, + "value": "f", + "optional": false, + "typeAnnotation": { + "type": "TsTypeAnnotation", + "span": { + "start": 168, + "end": 219, + "ctxt": 0 + }, + "typeAnnotation": { + "type": "TsFunctionType", + "span": { + "start": 170, + "end": 219, + "ctxt": 0 + }, + "params": [ + { + "type": "Identifier", + "span": { + "start": 193, + "end": 203, + "ctxt": 0 + }, + "value": "x", + "optional": false, + "typeAnnotation": { + "type": "TsTypeAnnotation", + "span": { + "start": 194, + "end": 203, + "ctxt": 0 + }, + "typeAnnotation": { + "type": "TsLiteralType", + "span": { + "start": 196, + "end": 203, + "ctxt": 0 + }, + "literal": { + "type": "TemplateLiteral", + "span": { + "start": 196, + "end": 203, + "ctxt": 0 + }, + "types": [ + { + "type": "TsTypeReference", + "span": { + "start": 199, + "end": 201, + "ctxt": 0 + }, + "typeName": { + "type": "Identifier", + "span": { + "start": 199, + "end": 201, + "ctxt": 0 + }, + "value": "T0", + "optional": false + }, + "typeParams": null + } + ], + "quasis": [ + { + "type": "TemplateElement", + "span": { + "start": 197, + "end": 197, + "ctxt": 0 + }, + "tail": false, + "cooked": "", + "raw": "" + }, + { + "type": "TemplateElement", + "span": { + "start": 202, + "end": 202, + "ctxt": 0 + }, + "tail": true, + "cooked": "", + "raw": "" + } + ] + } + } + } + } + ], + "typeParams": { + "type": "TsTypeParameterDeclaration", + "span": { + "start": 170, + "end": 192, + "ctxt": 0 + }, + "parameters": [ + { + "type": "TsTypeParameter", + "span": { + "start": 171, + "end": 191, + "ctxt": 0 + }, + "name": { + "type": "Identifier", + "span": { + "start": 171, + "end": 173, + "ctxt": 0 + }, + "value": "T0", + "optional": false + }, + "in": false, + "out": false, + "const": false, + "constraint": { + "type": "TsUnionType", + "span": { + "start": 182, + "end": 191, + "ctxt": 0 + }, + "types": [ + { + "type": "TsLiteralType", + "span": { + "start": 182, + "end": 185, + "ctxt": 0 + }, + "literal": { + "type": "StringLiteral", + "span": { + "start": 182, + "end": 185, + "ctxt": 0 + }, + "value": "a", + "raw": "\"a\"" + } + }, + { + "type": "TsLiteralType", + "span": { + "start": 188, + "end": 191, + "ctxt": 0 + }, + "literal": { + "type": "StringLiteral", + "span": { + "start": 188, + "end": 191, + "ctxt": 0 + }, + "value": "b", + "raw": "\"b\"" + } + } + ] + }, + "default": null + } + ] + }, + "typeAnnotation": { + "type": "TsTypeAnnotation", + "span": { + "start": 205, + "end": 219, + "ctxt": 0 + }, + "typeAnnotation": { + "type": "TsIndexedAccessType", + "span": { + "start": 208, + "end": 219, + "ctxt": 0 + }, + "readonly": false, + "objectType": { + "type": "TsTypeReference", + "span": { + "start": 208, + "end": 215, + "ctxt": 0 + }, + "typeName": { + "type": "Identifier", + "span": { + "start": 208, + "end": 215, + "ctxt": 0 + }, + "value": "TypeMap", + "optional": false + }, + "typeParams": null + }, + "indexType": { + "type": "TsTypeReference", + "span": { + "start": 216, + "end": 218, + "ctxt": 0 + }, + "typeName": { + "type": "Identifier", + "span": { + "start": 216, + "end": 218, + "ctxt": 0 + }, + "value": "T0", + "optional": false + }, + "typeParams": null + } + } + } + } + } + }, + "init": null, + "definite": false + } + ] + }, + { + "type": "TsTypeAliasDeclaration", + "span": { + "start": 221, + "end": 281, + "ctxt": 0 + }, + "declare": false, + "id": { + "type": "Identifier", + "span": { + "start": 226, + "end": 228, + "ctxt": 0 + }, + "value": "F1", + "optional": false + }, + "typeParams": null, + "typeAnnotation": { + "type": "TsFunctionType", + "span": { + "start": 231, + "end": 280, + "ctxt": 0 + }, + "params": [ + { + "type": "Identifier", + "span": { + "start": 254, + "end": 264, + "ctxt": 0 + }, + "value": "x", + "optional": false, + "typeAnnotation": { + "type": "TsTypeAnnotation", + "span": { + "start": 255, + "end": 264, + "ctxt": 0 + }, + "typeAnnotation": { + "type": "TsLiteralType", + "span": { + "start": 257, + "end": 264, + "ctxt": 0 + }, + "literal": { + "type": "TemplateLiteral", + "span": { + "start": 257, + "end": 264, + "ctxt": 0 + }, + "types": [ + { + "type": "TsTypeReference", + "span": { + "start": 260, + "end": 262, + "ctxt": 0 + }, + "typeName": { + "type": "Identifier", + "span": { + "start": 260, + "end": 262, + "ctxt": 0 + }, + "value": "T1", + "optional": false + }, + "typeParams": null + } + ], + "quasis": [ + { + "type": "TemplateElement", + "span": { + "start": 258, + "end": 258, + "ctxt": 0 + }, + "tail": false, + "cooked": "", + "raw": "" + }, + { + "type": "TemplateElement", + "span": { + "start": 263, + "end": 263, + "ctxt": 0 + }, + "tail": true, + "cooked": "", + "raw": "" + } + ] + } + } + } + } + ], + "typeParams": { + "type": "TsTypeParameterDeclaration", + "span": { + "start": 231, + "end": 253, + "ctxt": 0 + }, + "parameters": [ + { + "type": "TsTypeParameter", + "span": { + "start": 232, + "end": 252, + "ctxt": 0 + }, + "name": { + "type": "Identifier", + "span": { + "start": 232, + "end": 234, + "ctxt": 0 + }, + "value": "T1", + "optional": false + }, + "in": false, + "out": false, + "const": false, + "constraint": { + "type": "TsUnionType", + "span": { + "start": 243, + "end": 252, + "ctxt": 0 + }, + "types": [ + { + "type": "TsLiteralType", + "span": { + "start": 243, + "end": 246, + "ctxt": 0 + }, + "literal": { + "type": "StringLiteral", + "span": { + "start": 243, + "end": 246, + "ctxt": 0 + }, + "value": "a", + "raw": "\"a\"" + } + }, + { + "type": "TsLiteralType", + "span": { + "start": 249, + "end": 252, + "ctxt": 0 + }, + "literal": { + "type": "StringLiteral", + "span": { + "start": 249, + "end": 252, + "ctxt": 0 + }, + "value": "b", + "raw": "\"b\"" + } + } + ] + }, + "default": null + } + ] + }, + "typeAnnotation": { + "type": "TsTypeAnnotation", + "span": { + "start": 266, + "end": 280, + "ctxt": 0 + }, + "typeAnnotation": { + "type": "TsIndexedAccessType", + "span": { + "start": 269, + "end": 280, + "ctxt": 0 + }, + "readonly": false, + "objectType": { + "type": "TsTypeReference", + "span": { + "start": 269, + "end": 276, + "ctxt": 0 + }, + "typeName": { + "type": "Identifier", + "span": { + "start": 269, + "end": 276, + "ctxt": 0 + }, + "value": "TypeMap", + "optional": false + }, + "typeParams": null + }, + "indexType": { + "type": "TsTypeReference", + "span": { + "start": 277, + "end": 279, + "ctxt": 0 + }, + "typeName": { + "type": "Identifier", + "span": { + "start": 277, + "end": 279, + "ctxt": 0 + }, + "value": "T1", + "optional": false + }, + "typeParams": null + } + } + } + } + }, + { + "type": "VariableDeclaration", + "span": { + "start": 282, + "end": 299, + "ctxt": 0 + }, + "kind": "const", + "declare": false, + "declarations": [ + { + "type": "VariableDeclarator", + "span": { + "start": 288, + "end": 298, + "ctxt": 0 + }, + "id": { + "type": "Identifier", + "span": { + "start": 288, + "end": 290, + "ctxt": 0 + }, + "value": "f1", + "optional": false, + "typeAnnotation": { + "type": "TsTypeAnnotation", + "span": { + "start": 290, + "end": 294, + "ctxt": 0 + }, + "typeAnnotation": { + "type": "TsTypeReference", + "span": { + "start": 292, + "end": 294, + "ctxt": 0 + }, + "typeName": { + "type": "Identifier", + "span": { + "start": 292, + "end": 294, + "ctxt": 0 + }, + "value": "F1", + "optional": false + }, + "typeParams": null + } + } + }, + "init": { + "type": "Identifier", + "span": { + "start": 297, + "end": 298, + "ctxt": 0 + }, + "value": "f", + "optional": false + }, + "definite": false + } + ] + }, + { + "type": "TsTypeAliasDeclaration", + "span": { + "start": 301, + "end": 365, + "ctxt": 0 + }, + "declare": false, + "id": { + "type": "Identifier", + "span": { + "start": 306, + "end": 308, + "ctxt": 0 + }, + "value": "F2", + "optional": false + }, + "typeParams": null, + "typeAnnotation": { + "type": "TsFunctionType", + "span": { + "start": 311, + "end": 365, + "ctxt": 0 + }, + "params": [ + { + "type": "Identifier", + "span": { + "start": 334, + "end": 344, + "ctxt": 0 + }, + "value": "x", + "optional": false, + "typeAnnotation": { + "type": "TsTypeAnnotation", + "span": { + "start": 335, + "end": 344, + "ctxt": 0 + }, + "typeAnnotation": { + "type": "TsLiteralType", + "span": { + "start": 337, + "end": 344, + "ctxt": 0 + }, + "literal": { + "type": "TemplateLiteral", + "span": { + "start": 337, + "end": 344, + "ctxt": 0 + }, + "types": [ + { + "type": "TsTypeReference", + "span": { + "start": 340, + "end": 342, + "ctxt": 0 + }, + "typeName": { + "type": "Identifier", + "span": { + "start": 340, + "end": 342, + "ctxt": 0 + }, + "value": "T2", + "optional": false + }, + "typeParams": null + } + ], + "quasis": [ + { + "type": "TemplateElement", + "span": { + "start": 338, + "end": 338, + "ctxt": 0 + }, + "tail": false, + "cooked": "", + "raw": "" + }, + { + "type": "TemplateElement", + "span": { + "start": 343, + "end": 343, + "ctxt": 0 + }, + "tail": true, + "cooked": "", + "raw": "" + } + ] + } + } + } + } + ], + "typeParams": { + "type": "TsTypeParameterDeclaration", + "span": { + "start": 311, + "end": 333, + "ctxt": 0 + }, + "parameters": [ + { + "type": "TsTypeParameter", + "span": { + "start": 312, + "end": 332, + "ctxt": 0 + }, + "name": { + "type": "Identifier", + "span": { + "start": 312, + "end": 314, + "ctxt": 0 + }, + "value": "T2", + "optional": false + }, + "in": false, + "out": false, + "const": false, + "constraint": { + "type": "TsUnionType", + "span": { + "start": 323, + "end": 332, + "ctxt": 0 + }, + "types": [ + { + "type": "TsLiteralType", + "span": { + "start": 323, + "end": 326, + "ctxt": 0 + }, + "literal": { + "type": "StringLiteral", + "span": { + "start": 323, + "end": 326, + "ctxt": 0 + }, + "value": "a", + "raw": "'a'" + } + }, + { + "type": "TsLiteralType", + "span": { + "start": 329, + "end": 332, + "ctxt": 0 + }, + "literal": { + "type": "StringLiteral", + "span": { + "start": 329, + "end": 332, + "ctxt": 0 + }, + "value": "b", + "raw": "'b'" + } + } + ] + }, + "default": null + } + ] + }, + "typeAnnotation": { + "type": "TsTypeAnnotation", + "span": { + "start": 346, + "end": 365, + "ctxt": 0 + }, + "typeAnnotation": { + "type": "TsIndexedAccessType", + "span": { + "start": 349, + "end": 365, + "ctxt": 0 + }, + "readonly": false, + "objectType": { + "type": "TsTypeReference", + "span": { + "start": 349, + "end": 356, + "ctxt": 0 + }, + "typeName": { + "type": "Identifier", + "span": { + "start": 349, + "end": 356, + "ctxt": 0 + }, + "value": "TypeMap", + "optional": false + }, + "typeParams": null + }, + "indexType": { + "type": "TsLiteralType", + "span": { + "start": 357, + "end": 364, + "ctxt": 0 + }, + "literal": { + "type": "TemplateLiteral", + "span": { + "start": 357, + "end": 364, + "ctxt": 0 + }, + "types": [ + { + "type": "TsTypeReference", + "span": { + "start": 360, + "end": 362, + "ctxt": 0 + }, + "typeName": { + "type": "Identifier", + "span": { + "start": 360, + "end": 362, + "ctxt": 0 + }, + "value": "T2", + "optional": false + }, + "typeParams": null + } + ], + "quasis": [ + { + "type": "TemplateElement", + "span": { + "start": 358, + "end": 358, + "ctxt": 0 + }, + "tail": false, + "cooked": "", + "raw": "" + }, + { + "type": "TemplateElement", + "span": { + "start": 363, + "end": 363, + "ctxt": 0 + }, + "tail": true, + "cooked": "", + "raw": "" + } + ] + } + } + } + } + } + }, + { + "type": "VariableDeclaration", + "span": { + "start": 366, + "end": 382, + "ctxt": 0 + }, + "kind": "const", + "declare": false, + "declarations": [ + { + "type": "VariableDeclarator", + "span": { + "start": 372, + "end": 382, + "ctxt": 0 + }, + "id": { + "type": "Identifier", + "span": { + "start": 372, + "end": 374, + "ctxt": 0 + }, + "value": "f2", + "optional": false, + "typeAnnotation": { + "type": "TsTypeAnnotation", + "span": { + "start": 374, + "end": 378, + "ctxt": 0 + }, + "typeAnnotation": { + "type": "TsTypeReference", + "span": { + "start": 376, + "end": 378, + "ctxt": 0 + }, + "typeName": { + "type": "Identifier", + "span": { + "start": 376, + "end": 378, + "ctxt": 0 + }, + "value": "F2", + "optional": false + }, + "typeParams": null + } + } + }, + "init": { + "type": "Identifier", + "span": { + "start": 381, + "end": 382, + "ctxt": 0 + }, + "value": "f", + "optional": false + }, + "definite": false + } + ] + }, + { + "type": "FunctionDeclaration", + "identifier": { + "type": "Identifier", + "span": { + "start": 393, + "end": 395, + "ctxt": 0 + }, + "value": "f3", + "optional": false + }, + "declare": false, + "params": [ + { + "type": "Parameter", + "span": { + "start": 418, + "end": 423, + "ctxt": 0 + }, + "decorators": [], + "pat": { + "type": "Identifier", + "span": { + "start": 418, + "end": 423, + "ctxt": 0 + }, + "value": "x", + "optional": false, + "typeAnnotation": { + "type": "TsTypeAnnotation", + "span": { + "start": 419, + "end": 423, + "ctxt": 0 + }, + "typeAnnotation": { + "type": "TsTypeReference", + "span": { + "start": 421, + "end": 423, + "ctxt": 0 + }, + "typeName": { + "type": "Identifier", + "span": { + "start": 421, + "end": 423, + "ctxt": 0 + }, + "value": "T3", + "optional": false + }, + "typeParams": null + } + } + } + } + ], + "decorators": [], + "span": { + "start": 384, + "end": 502, + "ctxt": 0 + }, + "body": { + "type": "BlockStatement", + "span": { + "start": 425, + "end": 502, + "ctxt": 0 + }, + "stmts": [ + { + "type": "VariableDeclaration", + "span": { + "start": 431, + "end": 455, + "ctxt": 0 + }, + "kind": "const", + "declare": false, + "declarations": [ + { + "type": "VariableDeclarator", + "span": { + "start": 437, + "end": 455, + "ctxt": 0 + }, + "id": { + "type": "Identifier", + "span": { + "start": 437, + "end": 442, + "ctxt": 0 + }, + "value": "test1", + "optional": false, + "typeAnnotation": { + "type": "TsTypeAnnotation", + "span": { + "start": 442, + "end": 451, + "ctxt": 0 + }, + "typeAnnotation": { + "type": "TsLiteralType", + "span": { + "start": 444, + "end": 451, + "ctxt": 0 + }, + "literal": { + "type": "TemplateLiteral", + "span": { + "start": 444, + "end": 451, + "ctxt": 0 + }, + "types": [ + { + "type": "TsTypeReference", + "span": { + "start": 447, + "end": 449, + "ctxt": 0 + }, + "typeName": { + "type": "Identifier", + "span": { + "start": 447, + "end": 449, + "ctxt": 0 + }, + "value": "T3", + "optional": false + }, + "typeParams": null + } + ], + "quasis": [ + { + "type": "TemplateElement", + "span": { + "start": 445, + "end": 445, + "ctxt": 0 + }, + "tail": false, + "cooked": "", + "raw": "" + }, + { + "type": "TemplateElement", + "span": { + "start": 450, + "end": 450, + "ctxt": 0 + }, + "tail": true, + "cooked": "", + "raw": "" + } + ] + } + } + } + }, + "init": { + "type": "Identifier", + "span": { + "start": 454, + "end": 455, + "ctxt": 0 + }, + "value": "x", + "optional": false + }, + "definite": false + } + ] + }, + { + "type": "VariableDeclaration", + "span": { + "start": 464, + "end": 496, + "ctxt": 0 + }, + "kind": "const", + "declare": false, + "declarations": [ + { + "type": "VariableDeclarator", + "span": { + "start": 470, + "end": 495, + "ctxt": 0 + }, + "id": { + "type": "Identifier", + "span": { + "start": 470, + "end": 475, + "ctxt": 0 + }, + "value": "test2", + "optional": false, + "typeAnnotation": { + "type": "TsTypeAnnotation", + "span": { + "start": 475, + "end": 479, + "ctxt": 0 + }, + "typeAnnotation": { + "type": "TsTypeReference", + "span": { + "start": 477, + "end": 479, + "ctxt": 0 + }, + "typeName": { + "type": "Identifier", + "span": { + "start": 477, + "end": 479, + "ctxt": 0 + }, + "value": "T3", + "optional": false + }, + "typeParams": null + } + } + }, + "init": { + "type": "TsAsExpression", + "span": { + "start": 482, + "end": 495, + "ctxt": 0 + }, + "expression": { + "type": "StringLiteral", + "span": { + "start": 482, + "end": 484, + "ctxt": 0 + }, + "value": "", + "raw": "\"\"" + }, + "typeAnnotation": { + "type": "TsLiteralType", + "span": { + "start": 488, + "end": 495, + "ctxt": 0 + }, + "literal": { + "type": "TemplateLiteral", + "span": { + "start": 488, + "end": 495, + "ctxt": 0 + }, + "types": [ + { + "type": "TsTypeReference", + "span": { + "start": 491, + "end": 493, + "ctxt": 0 + }, + "typeName": { + "type": "Identifier", + "span": { + "start": 491, + "end": 493, + "ctxt": 0 + }, + "value": "T3", + "optional": false + }, + "typeParams": null + } + ], + "quasis": [ + { + "type": "TemplateElement", + "span": { + "start": 489, + "end": 489, + "ctxt": 0 + }, + "tail": false, + "cooked": "", + "raw": "" + }, + { + "type": "TemplateElement", + "span": { + "start": 494, + "end": 494, + "ctxt": 0 + }, + "tail": true, + "cooked": "", + "raw": "" + } + ] + } + } + }, + "definite": false + } + ] + } + ] + }, + "generator": false, + "async": false, + "typeParameters": { + "type": "TsTypeParameterDeclaration", + "span": { + "start": 395, + "end": 417, + "ctxt": 0 + }, + "parameters": [ + { + "type": "TsTypeParameter", + "span": { + "start": 396, + "end": 416, + "ctxt": 0 + }, + "name": { + "type": "Identifier", + "span": { + "start": 396, + "end": 398, + "ctxt": 0 + }, + "value": "T3", + "optional": false + }, + "in": false, + "out": false, + "const": false, + "constraint": { + "type": "TsUnionType", + "span": { + "start": 407, + "end": 416, + "ctxt": 0 + }, + "types": [ + { + "type": "TsLiteralType", + "span": { + "start": 407, + "end": 410, + "ctxt": 0 + }, + "literal": { + "type": "StringLiteral", + "span": { + "start": 407, + "end": 410, + "ctxt": 0 + }, + "value": "a", + "raw": "\"a\"" + } + }, + { + "type": "TsLiteralType", + "span": { + "start": 413, + "end": 416, + "ctxt": 0 + }, + "literal": { + "type": "StringLiteral", + "span": { + "start": 413, + "end": 416, + "ctxt": 0 + }, + "value": "b", + "raw": "\"b\"" + } + } + ] + }, + "default": null + } + ] + }, + "returnType": null + } + ], + "interpreter": null +} diff --git a/crates/swc_ecma_parser/tests/tsc/templateLiteralTypes5.ts b/crates/swc_ecma_parser/tests/tsc/templateLiteralTypes5.ts new file mode 100644 index 000000000000..ae1c32078f9b --- /dev/null +++ b/crates/swc_ecma_parser/tests/tsc/templateLiteralTypes5.ts @@ -0,0 +1,19 @@ +// @strict: true +// @target: esnext +// @noEmit: true + +// https://github.com/microsoft/TypeScript/issues/55364 +interface TypeMap { + a: "A"; + b: "B"; +} +declare const f: (x: `${T0}`) => TypeMap[T0]; +type F1 = (x: `${T1}`) => TypeMap[T1]; +const f1: F1 = f; +type F2 = (x: `${T2}`) => TypeMap[`${T2}`] +const f2: F2 = f + +function f3(x: T3) { + const test1: `${T3}` = x + const test2: T3 = "" as `${T3}`; +} diff --git a/crates/swc_ecma_parser/tests/tsc/templateLiteralTypes6.json b/crates/swc_ecma_parser/tests/tsc/templateLiteralTypes6.json new file mode 100644 index 000000000000..a8f9300cfca9 --- /dev/null +++ b/crates/swc_ecma_parser/tests/tsc/templateLiteralTypes6.json @@ -0,0 +1,1042 @@ +{ + "type": "Script", + "span": { + "start": 112, + "end": 485, + "ctxt": 0 + }, + "body": [ + { + "type": "TsTypeAliasDeclaration", + "span": { + "start": 112, + "end": 166, + "ctxt": 0 + }, + "declare": false, + "id": { + "type": "Identifier", + "span": { + "start": 117, + "end": 125, + "ctxt": 0 + }, + "value": "Registry", + "optional": false + }, + "typeParams": null, + "typeAnnotation": { + "type": "TsTypeLiteral", + "span": { + "start": 128, + "end": 165, + "ctxt": 0 + }, + "members": [ + { + "type": "TsPropertySignature", + "span": { + "start": 132, + "end": 146, + "ctxt": 0 + }, + "readonly": false, + "key": { + "type": "Identifier", + "span": { + "start": 132, + "end": 133, + "ctxt": 0 + }, + "value": "a", + "optional": false + }, + "computed": false, + "optional": false, + "init": null, + "params": [], + "typeAnnotation": { + "type": "TsTypeAnnotation", + "span": { + "start": 133, + "end": 145, + "ctxt": 0 + }, + "typeAnnotation": { + "type": "TsTypeLiteral", + "span": { + "start": 135, + "end": 145, + "ctxt": 0 + }, + "members": [ + { + "type": "TsPropertySignature", + "span": { + "start": 137, + "end": 143, + "ctxt": 0 + }, + "readonly": false, + "key": { + "type": "Identifier", + "span": { + "start": 137, + "end": 139, + "ctxt": 0 + }, + "value": "a1", + "optional": false + }, + "computed": false, + "optional": false, + "init": null, + "params": [], + "typeAnnotation": { + "type": "TsTypeAnnotation", + "span": { + "start": 139, + "end": 143, + "ctxt": 0 + }, + "typeAnnotation": { + "type": "TsTypeLiteral", + "span": { + "start": 141, + "end": 143, + "ctxt": 0 + }, + "members": [] + } + }, + "typeParams": null + } + ] + } + }, + "typeParams": null + }, + { + "type": "TsPropertySignature", + "span": { + "start": 149, + "end": 163, + "ctxt": 0 + }, + "readonly": false, + "key": { + "type": "Identifier", + "span": { + "start": 149, + "end": 150, + "ctxt": 0 + }, + "value": "b", + "optional": false + }, + "computed": false, + "optional": false, + "init": null, + "params": [], + "typeAnnotation": { + "type": "TsTypeAnnotation", + "span": { + "start": 150, + "end": 162, + "ctxt": 0 + }, + "typeAnnotation": { + "type": "TsTypeLiteral", + "span": { + "start": 152, + "end": 162, + "ctxt": 0 + }, + "members": [ + { + "type": "TsPropertySignature", + "span": { + "start": 154, + "end": 160, + "ctxt": 0 + }, + "readonly": false, + "key": { + "type": "Identifier", + "span": { + "start": 154, + "end": 156, + "ctxt": 0 + }, + "value": "b1", + "optional": false + }, + "computed": false, + "optional": false, + "init": null, + "params": [], + "typeAnnotation": { + "type": "TsTypeAnnotation", + "span": { + "start": 156, + "end": 160, + "ctxt": 0 + }, + "typeAnnotation": { + "type": "TsTypeLiteral", + "span": { + "start": 158, + "end": 160, + "ctxt": 0 + }, + "members": [] + } + }, + "typeParams": null + } + ] + } + }, + "typeParams": null + } + ] + } + }, + { + "type": "TsTypeAliasDeclaration", + "span": { + "start": 168, + "end": 201, + "ctxt": 0 + }, + "declare": false, + "id": { + "type": "Identifier", + "span": { + "start": 173, + "end": 178, + "ctxt": 0 + }, + "value": "Keyof", + "optional": false + }, + "typeParams": { + "type": "TsTypeParameterDeclaration", + "span": { + "start": 178, + "end": 181, + "ctxt": 0 + }, + "parameters": [ + { + "type": "TsTypeParameter", + "span": { + "start": 179, + "end": 180, + "ctxt": 0 + }, + "name": { + "type": "Identifier", + "span": { + "start": 179, + "end": 180, + "ctxt": 0 + }, + "value": "T", + "optional": false + }, + "in": false, + "out": false, + "const": false, + "constraint": null, + "default": null + } + ] + }, + "typeAnnotation": { + "type": "TsIntersectionType", + "span": { + "start": 184, + "end": 200, + "ctxt": 0 + }, + "types": [ + { + "type": "TsTypeOperator", + "span": { + "start": 184, + "end": 191, + "ctxt": 0 + }, + "op": "keyof", + "typeAnnotation": { + "type": "TsTypeReference", + "span": { + "start": 190, + "end": 191, + "ctxt": 0 + }, + "typeName": { + "type": "Identifier", + "span": { + "start": 190, + "end": 191, + "ctxt": 0 + }, + "value": "T", + "optional": false + }, + "typeParams": null + } + }, + { + "type": "TsKeywordType", + "span": { + "start": 194, + "end": 200, + "ctxt": 0 + }, + "kind": "string" + } + ] + } + }, + { + "type": "FunctionDeclaration", + "identifier": { + "type": "Identifier", + "span": { + "start": 220, + "end": 222, + "ctxt": 0 + }, + "value": "f1", + "optional": false + }, + "declare": true, + "params": [ + { + "type": "Parameter", + "span": { + "start": 299, + "end": 329, + "ctxt": 0 + }, + "decorators": [], + "pat": { + "type": "Identifier", + "span": { + "start": 299, + "end": 329, + "ctxt": 0 + }, + "value": "eventPath", + "optional": false, + "typeAnnotation": { + "type": "TsTypeAnnotation", + "span": { + "start": 308, + "end": 329, + "ctxt": 0 + }, + "typeAnnotation": { + "type": "TsLiteralType", + "span": { + "start": 310, + "end": 329, + "ctxt": 0 + }, + "literal": { + "type": "TemplateLiteral", + "span": { + "start": 310, + "end": 329, + "ctxt": 0 + }, + "types": [ + { + "type": "TsTypeReference", + "span": { + "start": 313, + "end": 318, + "ctxt": 0 + }, + "typeName": { + "type": "Identifier", + "span": { + "start": 313, + "end": 318, + "ctxt": 0 + }, + "value": "Scope", + "optional": false + }, + "typeParams": null + }, + { + "type": "TsTypeReference", + "span": { + "start": 322, + "end": 327, + "ctxt": 0 + }, + "typeName": { + "type": "Identifier", + "span": { + "start": 322, + "end": 327, + "ctxt": 0 + }, + "value": "Event", + "optional": false + }, + "typeParams": null + } + ], + "quasis": [ + { + "type": "TemplateElement", + "span": { + "start": 311, + "end": 311, + "ctxt": 0 + }, + "tail": false, + "cooked": "", + "raw": "" + }, + { + "type": "TemplateElement", + "span": { + "start": 319, + "end": 320, + "ctxt": 0 + }, + "tail": false, + "cooked": ":", + "raw": ":" + }, + { + "type": "TemplateElement", + "span": { + "start": 328, + "end": 328, + "ctxt": 0 + }, + "tail": true, + "cooked": "", + "raw": "" + } + ] + } + } + } + } + } + ], + "decorators": [], + "span": { + "start": 203, + "end": 337, + "ctxt": 0 + }, + "body": null, + "generator": false, + "async": false, + "typeParameters": { + "type": "TsTypeParameterDeclaration", + "span": { + "start": 222, + "end": 298, + "ctxt": 0 + }, + "parameters": [ + { + "type": "TsTypeParameter", + "span": { + "start": 226, + "end": 255, + "ctxt": 0 + }, + "name": { + "type": "Identifier", + "span": { + "start": 226, + "end": 231, + "ctxt": 0 + }, + "value": "Scope", + "optional": false + }, + "in": false, + "out": false, + "const": false, + "constraint": { + "type": "TsTypeReference", + "span": { + "start": 240, + "end": 255, + "ctxt": 0 + }, + "typeName": { + "type": "Identifier", + "span": { + "start": 240, + "end": 245, + "ctxt": 0 + }, + "value": "Keyof", + "optional": false + }, + "typeParams": { + "type": "TsTypeParameterInstantiation", + "span": { + "start": 245, + "end": 255, + "ctxt": 0 + }, + "params": [ + { + "type": "TsTypeReference", + "span": { + "start": 246, + "end": 254, + "ctxt": 0 + }, + "typeName": { + "type": "Identifier", + "span": { + "start": 246, + "end": 254, + "ctxt": 0 + }, + "value": "Registry", + "optional": false + }, + "typeParams": null + } + ] + } + }, + "default": null + }, + { + "type": "TsTypeParameter", + "span": { + "start": 259, + "end": 295, + "ctxt": 0 + }, + "name": { + "type": "Identifier", + "span": { + "start": 259, + "end": 264, + "ctxt": 0 + }, + "value": "Event", + "optional": false + }, + "in": false, + "out": false, + "const": false, + "constraint": { + "type": "TsTypeReference", + "span": { + "start": 273, + "end": 295, + "ctxt": 0 + }, + "typeName": { + "type": "Identifier", + "span": { + "start": 273, + "end": 278, + "ctxt": 0 + }, + "value": "Keyof", + "optional": false + }, + "typeParams": { + "type": "TsTypeParameterInstantiation", + "span": { + "start": 278, + "end": 295, + "ctxt": 0 + }, + "params": [ + { + "type": "TsIndexedAccessType", + "span": { + "start": 279, + "end": 294, + "ctxt": 0 + }, + "readonly": false, + "objectType": { + "type": "TsTypeReference", + "span": { + "start": 279, + "end": 287, + "ctxt": 0 + }, + "typeName": { + "type": "Identifier", + "span": { + "start": 279, + "end": 287, + "ctxt": 0 + }, + "value": "Registry", + "optional": false + }, + "typeParams": null + }, + "indexType": { + "type": "TsTypeReference", + "span": { + "start": 288, + "end": 293, + "ctxt": 0 + }, + "typeName": { + "type": "Identifier", + "span": { + "start": 288, + "end": 293, + "ctxt": 0 + }, + "value": "Scope", + "optional": false + }, + "typeParams": null + } + } + ] + } + }, + "default": null + } + ] + }, + "returnType": { + "type": "TsTypeAnnotation", + "span": { + "start": 330, + "end": 336, + "ctxt": 0 + }, + "typeAnnotation": { + "type": "TsKeywordType", + "span": { + "start": 332, + "end": 336, + "ctxt": 0 + }, + "kind": "void" + } + } + }, + { + "type": "FunctionDeclaration", + "identifier": { + "type": "Identifier", + "span": { + "start": 348, + "end": 350, + "ctxt": 0 + }, + "value": "f2", + "optional": false + }, + "declare": false, + "params": [ + { + "type": "Parameter", + "span": { + "start": 427, + "end": 439, + "ctxt": 0 + }, + "decorators": [], + "pat": { + "type": "Identifier", + "span": { + "start": 427, + "end": 439, + "ctxt": 0 + }, + "value": "scope", + "optional": false, + "typeAnnotation": { + "type": "TsTypeAnnotation", + "span": { + "start": 432, + "end": 439, + "ctxt": 0 + }, + "typeAnnotation": { + "type": "TsTypeReference", + "span": { + "start": 434, + "end": 439, + "ctxt": 0 + }, + "typeName": { + "type": "Identifier", + "span": { + "start": 434, + "end": 439, + "ctxt": 0 + }, + "value": "Scope", + "optional": false + }, + "typeParams": null + } + } + } + }, + { + "type": "Parameter", + "span": { + "start": 441, + "end": 453, + "ctxt": 0 + }, + "decorators": [], + "pat": { + "type": "Identifier", + "span": { + "start": 441, + "end": 453, + "ctxt": 0 + }, + "value": "event", + "optional": false, + "typeAnnotation": { + "type": "TsTypeAnnotation", + "span": { + "start": 446, + "end": 453, + "ctxt": 0 + }, + "typeAnnotation": { + "type": "TsTypeReference", + "span": { + "start": 448, + "end": 453, + "ctxt": 0 + }, + "typeName": { + "type": "Identifier", + "span": { + "start": 448, + "end": 453, + "ctxt": 0 + }, + "value": "Event", + "optional": false + }, + "typeParams": null + } + } + } + } + ], + "decorators": [], + "span": { + "start": 339, + "end": 485, + "ctxt": 0 + }, + "body": { + "type": "BlockStatement", + "span": { + "start": 455, + "end": 485, + "ctxt": 0 + }, + "stmts": [ + { + "type": "ExpressionStatement", + "span": { + "start": 459, + "end": 483, + "ctxt": 0 + }, + "expression": { + "type": "CallExpression", + "span": { + "start": 459, + "end": 482, + "ctxt": 0 + }, + "callee": { + "type": "Identifier", + "span": { + "start": 459, + "end": 461, + "ctxt": 0 + }, + "value": "f1", + "optional": false + }, + "arguments": [ + { + "spread": null, + "expression": { + "type": "TemplateLiteral", + "span": { + "start": 462, + "end": 481, + "ctxt": 0 + }, + "expressions": [ + { + "type": "Identifier", + "span": { + "start": 465, + "end": 470, + "ctxt": 0 + }, + "value": "scope", + "optional": false + }, + { + "type": "Identifier", + "span": { + "start": 474, + "end": 479, + "ctxt": 0 + }, + "value": "event", + "optional": false + } + ], + "quasis": [ + { + "type": "TemplateElement", + "span": { + "start": 463, + "end": 463, + "ctxt": 0 + }, + "tail": false, + "cooked": "", + "raw": "" + }, + { + "type": "TemplateElement", + "span": { + "start": 471, + "end": 472, + "ctxt": 0 + }, + "tail": false, + "cooked": ":", + "raw": ":" + }, + { + "type": "TemplateElement", + "span": { + "start": 480, + "end": 480, + "ctxt": 0 + }, + "tail": true, + "cooked": "", + "raw": "" + } + ] + } + } + ], + "typeArguments": null + } + } + ] + }, + "generator": false, + "async": false, + "typeParameters": { + "type": "TsTypeParameterDeclaration", + "span": { + "start": 350, + "end": 426, + "ctxt": 0 + }, + "parameters": [ + { + "type": "TsTypeParameter", + "span": { + "start": 354, + "end": 383, + "ctxt": 0 + }, + "name": { + "type": "Identifier", + "span": { + "start": 354, + "end": 359, + "ctxt": 0 + }, + "value": "Scope", + "optional": false + }, + "in": false, + "out": false, + "const": false, + "constraint": { + "type": "TsTypeReference", + "span": { + "start": 368, + "end": 383, + "ctxt": 0 + }, + "typeName": { + "type": "Identifier", + "span": { + "start": 368, + "end": 373, + "ctxt": 0 + }, + "value": "Keyof", + "optional": false + }, + "typeParams": { + "type": "TsTypeParameterInstantiation", + "span": { + "start": 373, + "end": 383, + "ctxt": 0 + }, + "params": [ + { + "type": "TsTypeReference", + "span": { + "start": 374, + "end": 382, + "ctxt": 0 + }, + "typeName": { + "type": "Identifier", + "span": { + "start": 374, + "end": 382, + "ctxt": 0 + }, + "value": "Registry", + "optional": false + }, + "typeParams": null + } + ] + } + }, + "default": null + }, + { + "type": "TsTypeParameter", + "span": { + "start": 387, + "end": 423, + "ctxt": 0 + }, + "name": { + "type": "Identifier", + "span": { + "start": 387, + "end": 392, + "ctxt": 0 + }, + "value": "Event", + "optional": false + }, + "in": false, + "out": false, + "const": false, + "constraint": { + "type": "TsTypeReference", + "span": { + "start": 401, + "end": 423, + "ctxt": 0 + }, + "typeName": { + "type": "Identifier", + "span": { + "start": 401, + "end": 406, + "ctxt": 0 + }, + "value": "Keyof", + "optional": false + }, + "typeParams": { + "type": "TsTypeParameterInstantiation", + "span": { + "start": 406, + "end": 423, + "ctxt": 0 + }, + "params": [ + { + "type": "TsIndexedAccessType", + "span": { + "start": 407, + "end": 422, + "ctxt": 0 + }, + "readonly": false, + "objectType": { + "type": "TsTypeReference", + "span": { + "start": 407, + "end": 415, + "ctxt": 0 + }, + "typeName": { + "type": "Identifier", + "span": { + "start": 407, + "end": 415, + "ctxt": 0 + }, + "value": "Registry", + "optional": false + }, + "typeParams": null + }, + "indexType": { + "type": "TsTypeReference", + "span": { + "start": 416, + "end": 421, + "ctxt": 0 + }, + "typeName": { + "type": "Identifier", + "span": { + "start": 416, + "end": 421, + "ctxt": 0 + }, + "value": "Scope", + "optional": false + }, + "typeParams": null + } + } + ] + } + }, + "default": null + } + ] + }, + "returnType": null + } + ], + "interpreter": null +} diff --git a/crates/swc_ecma_parser/tests/tsc/templateLiteralTypes6.ts b/crates/swc_ecma_parser/tests/tsc/templateLiteralTypes6.ts new file mode 100644 index 000000000000..0123c9a22c4b --- /dev/null +++ b/crates/swc_ecma_parser/tests/tsc/templateLiteralTypes6.ts @@ -0,0 +1,24 @@ +// @strict: true +// @target: esnext +// @noEmit: true + +// https://github.com/microsoft/TypeScript/issues/56659 + +type Registry = { + a: { a1: {} }; + b: { b1: {} }; +}; + +type Keyof = keyof T & string; + +declare function f1< + Scope extends Keyof, + Event extends Keyof, +>(eventPath: `${Scope}:${Event}`): void; + +function f2< + Scope extends Keyof, + Event extends Keyof, +>(scope: Scope, event: Event) { + f1(`${scope}:${event}`); +} diff --git a/crates/swc_ecma_parser/tests/tsc/templateLiteralTypes7.json b/crates/swc_ecma_parser/tests/tsc/templateLiteralTypes7.json new file mode 100644 index 000000000000..b13ed167a458 --- /dev/null +++ b/crates/swc_ecma_parser/tests/tsc/templateLiteralTypes7.json @@ -0,0 +1,1506 @@ +{ + "type": "Script", + "span": { + "start": 112, + "end": 462, + "ctxt": 0 + }, + "body": [ + { + "type": "TsInterfaceDeclaration", + "span": { + "start": 112, + "end": 166, + "ctxt": 0 + }, + "id": { + "type": "Identifier", + "span": { + "start": 122, + "end": 126, + "ctxt": 0 + }, + "value": "NMap", + "optional": false + }, + "declare": false, + "typeParams": null, + "extends": [], + "body": { + "type": "TsInterfaceBody", + "span": { + "start": 127, + "end": 166, + "ctxt": 0 + }, + "body": [ + { + "type": "TsPropertySignature", + "span": { + "start": 131, + "end": 137, + "ctxt": 0 + }, + "readonly": false, + "key": { + "type": "NumericLiteral", + "span": { + "start": 131, + "end": 132, + "ctxt": 0 + }, + "value": 1.0, + "raw": "1" + }, + "computed": false, + "optional": false, + "init": null, + "params": [], + "typeAnnotation": { + "type": "TsTypeAnnotation", + "span": { + "start": 132, + "end": 137, + "ctxt": 0 + }, + "typeAnnotation": { + "type": "TsLiteralType", + "span": { + "start": 134, + "end": 137, + "ctxt": 0 + }, + "literal": { + "type": "StringLiteral", + "span": { + "start": 134, + "end": 137, + "ctxt": 0 + }, + "value": "A", + "raw": "'A'" + } + } + }, + "typeParams": null + }, + { + "type": "TsPropertySignature", + "span": { + "start": 140, + "end": 146, + "ctxt": 0 + }, + "readonly": false, + "key": { + "type": "NumericLiteral", + "span": { + "start": 140, + "end": 141, + "ctxt": 0 + }, + "value": 2.0, + "raw": "2" + }, + "computed": false, + "optional": false, + "init": null, + "params": [], + "typeAnnotation": { + "type": "TsTypeAnnotation", + "span": { + "start": 141, + "end": 146, + "ctxt": 0 + }, + "typeAnnotation": { + "type": "TsLiteralType", + "span": { + "start": 143, + "end": 146, + "ctxt": 0 + }, + "literal": { + "type": "StringLiteral", + "span": { + "start": 143, + "end": 146, + "ctxt": 0 + }, + "value": "B", + "raw": "'B'" + } + } + }, + "typeParams": null + }, + { + "type": "TsPropertySignature", + "span": { + "start": 149, + "end": 155, + "ctxt": 0 + }, + "readonly": false, + "key": { + "type": "NumericLiteral", + "span": { + "start": 149, + "end": 150, + "ctxt": 0 + }, + "value": 3.0, + "raw": "3" + }, + "computed": false, + "optional": false, + "init": null, + "params": [], + "typeAnnotation": { + "type": "TsTypeAnnotation", + "span": { + "start": 150, + "end": 155, + "ctxt": 0 + }, + "typeAnnotation": { + "type": "TsLiteralType", + "span": { + "start": 152, + "end": 155, + "ctxt": 0 + }, + "literal": { + "type": "StringLiteral", + "span": { + "start": 152, + "end": 155, + "ctxt": 0 + }, + "value": "C", + "raw": "'C'" + } + } + }, + "typeParams": null + }, + { + "type": "TsPropertySignature", + "span": { + "start": 158, + "end": 164, + "ctxt": 0 + }, + "readonly": false, + "key": { + "type": "NumericLiteral", + "span": { + "start": 158, + "end": 159, + "ctxt": 0 + }, + "value": 4.0, + "raw": "4" + }, + "computed": false, + "optional": false, + "init": null, + "params": [], + "typeAnnotation": { + "type": "TsTypeAnnotation", + "span": { + "start": 159, + "end": 164, + "ctxt": 0 + }, + "typeAnnotation": { + "type": "TsLiteralType", + "span": { + "start": 161, + "end": 164, + "ctxt": 0 + }, + "literal": { + "type": "StringLiteral", + "span": { + "start": 161, + "end": 164, + "ctxt": 0 + }, + "value": "D", + "raw": "'D'" + } + } + }, + "typeParams": null + } + ] + } + }, + { + "type": "VariableDeclaration", + "span": { + "start": 168, + "end": 228, + "ctxt": 0 + }, + "kind": "const", + "declare": true, + "declarations": [ + { + "type": "VariableDeclarator", + "span": { + "start": 182, + "end": 228, + "ctxt": 0 + }, + "id": { + "type": "Identifier", + "span": { + "start": 182, + "end": 183, + "ctxt": 0 + }, + "value": "g", + "optional": false, + "typeAnnotation": { + "type": "TsTypeAnnotation", + "span": { + "start": 183, + "end": 228, + "ctxt": 0 + }, + "typeAnnotation": { + "type": "TsFunctionType", + "span": { + "start": 185, + "end": 228, + "ctxt": 0 + }, + "params": [ + { + "type": "Identifier", + "span": { + "start": 207, + "end": 216, + "ctxt": 0 + }, + "value": "x", + "optional": false, + "typeAnnotation": { + "type": "TsTypeAnnotation", + "span": { + "start": 208, + "end": 216, + "ctxt": 0 + }, + "typeAnnotation": { + "type": "TsLiteralType", + "span": { + "start": 210, + "end": 216, + "ctxt": 0 + }, + "literal": { + "type": "TemplateLiteral", + "span": { + "start": 210, + "end": 216, + "ctxt": 0 + }, + "types": [ + { + "type": "TsTypeReference", + "span": { + "start": 213, + "end": 214, + "ctxt": 0 + }, + "typeName": { + "type": "Identifier", + "span": { + "start": 213, + "end": 214, + "ctxt": 0 + }, + "value": "T", + "optional": false + }, + "typeParams": null + } + ], + "quasis": [ + { + "type": "TemplateElement", + "span": { + "start": 211, + "end": 211, + "ctxt": 0 + }, + "tail": false, + "cooked": "", + "raw": "" + }, + { + "type": "TemplateElement", + "span": { + "start": 215, + "end": 215, + "ctxt": 0 + }, + "tail": true, + "cooked": "", + "raw": "" + } + ] + } + } + } + } + ], + "typeParams": { + "type": "TsTypeParameterDeclaration", + "span": { + "start": 185, + "end": 206, + "ctxt": 0 + }, + "parameters": [ + { + "type": "TsTypeParameter", + "span": { + "start": 186, + "end": 205, + "ctxt": 0 + }, + "name": { + "type": "Identifier", + "span": { + "start": 186, + "end": 187, + "ctxt": 0 + }, + "value": "T", + "optional": false + }, + "in": false, + "out": false, + "const": false, + "constraint": { + "type": "TsUnionType", + "span": { + "start": 196, + "end": 205, + "ctxt": 0 + }, + "types": [ + { + "type": "TsLiteralType", + "span": { + "start": 196, + "end": 197, + "ctxt": 0 + }, + "literal": { + "type": "NumericLiteral", + "span": { + "start": 196, + "end": 197, + "ctxt": 0 + }, + "value": 1.0, + "raw": "1" + } + }, + { + "type": "TsLiteralType", + "span": { + "start": 200, + "end": 201, + "ctxt": 0 + }, + "literal": { + "type": "NumericLiteral", + "span": { + "start": 200, + "end": 201, + "ctxt": 0 + }, + "value": 2.0, + "raw": "2" + } + }, + { + "type": "TsLiteralType", + "span": { + "start": 204, + "end": 205, + "ctxt": 0 + }, + "literal": { + "type": "NumericLiteral", + "span": { + "start": 204, + "end": 205, + "ctxt": 0 + }, + "value": 3.0, + "raw": "3" + } + } + ] + }, + "default": null + } + ] + }, + "typeAnnotation": { + "type": "TsTypeAnnotation", + "span": { + "start": 218, + "end": 228, + "ctxt": 0 + }, + "typeAnnotation": { + "type": "TsIndexedAccessType", + "span": { + "start": 221, + "end": 228, + "ctxt": 0 + }, + "readonly": false, + "objectType": { + "type": "TsTypeReference", + "span": { + "start": 221, + "end": 225, + "ctxt": 0 + }, + "typeName": { + "type": "Identifier", + "span": { + "start": 221, + "end": 225, + "ctxt": 0 + }, + "value": "NMap", + "optional": false + }, + "typeParams": null + }, + "indexType": { + "type": "TsTypeReference", + "span": { + "start": 226, + "end": 227, + "ctxt": 0 + }, + "typeName": { + "type": "Identifier", + "span": { + "start": 226, + "end": 227, + "ctxt": 0 + }, + "value": "T", + "optional": false + }, + "typeParams": null + } + } + } + } + } + }, + "init": null, + "definite": false + } + ] + }, + { + "type": "TsTypeAliasDeclaration", + "span": { + "start": 230, + "end": 283, + "ctxt": 0 + }, + "declare": false, + "id": { + "type": "Identifier", + "span": { + "start": 235, + "end": 237, + "ctxt": 0 + }, + "value": "G1", + "optional": false + }, + "typeParams": null, + "typeAnnotation": { + "type": "TsFunctionType", + "span": { + "start": 240, + "end": 283, + "ctxt": 0 + }, + "params": [ + { + "type": "Identifier", + "span": { + "start": 262, + "end": 271, + "ctxt": 0 + }, + "value": "x", + "optional": false, + "typeAnnotation": { + "type": "TsTypeAnnotation", + "span": { + "start": 263, + "end": 271, + "ctxt": 0 + }, + "typeAnnotation": { + "type": "TsLiteralType", + "span": { + "start": 265, + "end": 271, + "ctxt": 0 + }, + "literal": { + "type": "TemplateLiteral", + "span": { + "start": 265, + "end": 271, + "ctxt": 0 + }, + "types": [ + { + "type": "TsTypeReference", + "span": { + "start": 268, + "end": 269, + "ctxt": 0 + }, + "typeName": { + "type": "Identifier", + "span": { + "start": 268, + "end": 269, + "ctxt": 0 + }, + "value": "T", + "optional": false + }, + "typeParams": null + } + ], + "quasis": [ + { + "type": "TemplateElement", + "span": { + "start": 266, + "end": 266, + "ctxt": 0 + }, + "tail": false, + "cooked": "", + "raw": "" + }, + { + "type": "TemplateElement", + "span": { + "start": 270, + "end": 270, + "ctxt": 0 + }, + "tail": true, + "cooked": "", + "raw": "" + } + ] + } + } + } + } + ], + "typeParams": { + "type": "TsTypeParameterDeclaration", + "span": { + "start": 240, + "end": 261, + "ctxt": 0 + }, + "parameters": [ + { + "type": "TsTypeParameter", + "span": { + "start": 241, + "end": 260, + "ctxt": 0 + }, + "name": { + "type": "Identifier", + "span": { + "start": 241, + "end": 242, + "ctxt": 0 + }, + "value": "T", + "optional": false + }, + "in": false, + "out": false, + "const": false, + "constraint": { + "type": "TsUnionType", + "span": { + "start": 251, + "end": 260, + "ctxt": 0 + }, + "types": [ + { + "type": "TsLiteralType", + "span": { + "start": 251, + "end": 252, + "ctxt": 0 + }, + "literal": { + "type": "NumericLiteral", + "span": { + "start": 251, + "end": 252, + "ctxt": 0 + }, + "value": 1.0, + "raw": "1" + } + }, + { + "type": "TsLiteralType", + "span": { + "start": 255, + "end": 256, + "ctxt": 0 + }, + "literal": { + "type": "NumericLiteral", + "span": { + "start": 255, + "end": 256, + "ctxt": 0 + }, + "value": 2.0, + "raw": "2" + } + }, + { + "type": "TsLiteralType", + "span": { + "start": 259, + "end": 260, + "ctxt": 0 + }, + "literal": { + "type": "NumericLiteral", + "span": { + "start": 259, + "end": 260, + "ctxt": 0 + }, + "value": 3.0, + "raw": "3" + } + } + ] + }, + "default": null + } + ] + }, + "typeAnnotation": { + "type": "TsTypeAnnotation", + "span": { + "start": 273, + "end": 283, + "ctxt": 0 + }, + "typeAnnotation": { + "type": "TsIndexedAccessType", + "span": { + "start": 276, + "end": 283, + "ctxt": 0 + }, + "readonly": false, + "objectType": { + "type": "TsTypeReference", + "span": { + "start": 276, + "end": 280, + "ctxt": 0 + }, + "typeName": { + "type": "Identifier", + "span": { + "start": 276, + "end": 280, + "ctxt": 0 + }, + "value": "NMap", + "optional": false + }, + "typeParams": null + }, + "indexType": { + "type": "TsTypeReference", + "span": { + "start": 281, + "end": 282, + "ctxt": 0 + }, + "typeName": { + "type": "Identifier", + "span": { + "start": 281, + "end": 282, + "ctxt": 0 + }, + "value": "T", + "optional": false + }, + "typeParams": null + } + } + } + } + }, + { + "type": "VariableDeclaration", + "span": { + "start": 284, + "end": 301, + "ctxt": 0 + }, + "kind": "const", + "declare": false, + "declarations": [ + { + "type": "VariableDeclarator", + "span": { + "start": 290, + "end": 300, + "ctxt": 0 + }, + "id": { + "type": "Identifier", + "span": { + "start": 290, + "end": 292, + "ctxt": 0 + }, + "value": "g1", + "optional": false, + "typeAnnotation": { + "type": "TsTypeAnnotation", + "span": { + "start": 292, + "end": 296, + "ctxt": 0 + }, + "typeAnnotation": { + "type": "TsTypeReference", + "span": { + "start": 294, + "end": 296, + "ctxt": 0 + }, + "typeName": { + "type": "Identifier", + "span": { + "start": 294, + "end": 296, + "ctxt": 0 + }, + "value": "G1", + "optional": false + }, + "typeParams": null + } + } + }, + "init": { + "type": "Identifier", + "span": { + "start": 299, + "end": 300, + "ctxt": 0 + }, + "value": "g", + "optional": false + }, + "definite": false + } + ] + }, + { + "type": "TsTypeAliasDeclaration", + "span": { + "start": 309, + "end": 366, + "ctxt": 0 + }, + "declare": false, + "id": { + "type": "Identifier", + "span": { + "start": 314, + "end": 316, + "ctxt": 0 + }, + "value": "G2", + "optional": false + }, + "typeParams": null, + "typeAnnotation": { + "type": "TsFunctionType", + "span": { + "start": 319, + "end": 366, + "ctxt": 0 + }, + "params": [ + { + "type": "Identifier", + "span": { + "start": 345, + "end": 354, + "ctxt": 0 + }, + "value": "x", + "optional": false, + "typeAnnotation": { + "type": "TsTypeAnnotation", + "span": { + "start": 346, + "end": 354, + "ctxt": 0 + }, + "typeAnnotation": { + "type": "TsLiteralType", + "span": { + "start": 348, + "end": 354, + "ctxt": 0 + }, + "literal": { + "type": "TemplateLiteral", + "span": { + "start": 348, + "end": 354, + "ctxt": 0 + }, + "types": [ + { + "type": "TsTypeReference", + "span": { + "start": 351, + "end": 352, + "ctxt": 0 + }, + "typeName": { + "type": "Identifier", + "span": { + "start": 351, + "end": 352, + "ctxt": 0 + }, + "value": "T", + "optional": false + }, + "typeParams": null + } + ], + "quasis": [ + { + "type": "TemplateElement", + "span": { + "start": 349, + "end": 349, + "ctxt": 0 + }, + "tail": false, + "cooked": "", + "raw": "" + }, + { + "type": "TemplateElement", + "span": { + "start": 353, + "end": 353, + "ctxt": 0 + }, + "tail": true, + "cooked": "", + "raw": "" + } + ] + } + } + } + } + ], + "typeParams": { + "type": "TsTypeParameterDeclaration", + "span": { + "start": 319, + "end": 344, + "ctxt": 0 + }, + "parameters": [ + { + "type": "TsTypeParameter", + "span": { + "start": 320, + "end": 343, + "ctxt": 0 + }, + "name": { + "type": "Identifier", + "span": { + "start": 320, + "end": 321, + "ctxt": 0 + }, + "value": "T", + "optional": false + }, + "in": false, + "out": false, + "const": false, + "constraint": { + "type": "TsUnionType", + "span": { + "start": 330, + "end": 343, + "ctxt": 0 + }, + "types": [ + { + "type": "TsLiteralType", + "span": { + "start": 330, + "end": 331, + "ctxt": 0 + }, + "literal": { + "type": "NumericLiteral", + "span": { + "start": 330, + "end": 331, + "ctxt": 0 + }, + "value": 1.0, + "raw": "1" + } + }, + { + "type": "TsLiteralType", + "span": { + "start": 334, + "end": 335, + "ctxt": 0 + }, + "literal": { + "type": "NumericLiteral", + "span": { + "start": 334, + "end": 335, + "ctxt": 0 + }, + "value": 2.0, + "raw": "2" + } + }, + { + "type": "TsLiteralType", + "span": { + "start": 338, + "end": 339, + "ctxt": 0 + }, + "literal": { + "type": "NumericLiteral", + "span": { + "start": 338, + "end": 339, + "ctxt": 0 + }, + "value": 3.0, + "raw": "3" + } + }, + { + "type": "TsLiteralType", + "span": { + "start": 342, + "end": 343, + "ctxt": 0 + }, + "literal": { + "type": "NumericLiteral", + "span": { + "start": 342, + "end": 343, + "ctxt": 0 + }, + "value": 4.0, + "raw": "4" + } + } + ] + }, + "default": null + } + ] + }, + "typeAnnotation": { + "type": "TsTypeAnnotation", + "span": { + "start": 356, + "end": 366, + "ctxt": 0 + }, + "typeAnnotation": { + "type": "TsIndexedAccessType", + "span": { + "start": 359, + "end": 366, + "ctxt": 0 + }, + "readonly": false, + "objectType": { + "type": "TsTypeReference", + "span": { + "start": 359, + "end": 363, + "ctxt": 0 + }, + "typeName": { + "type": "Identifier", + "span": { + "start": 359, + "end": 363, + "ctxt": 0 + }, + "value": "NMap", + "optional": false + }, + "typeParams": null + }, + "indexType": { + "type": "TsTypeReference", + "span": { + "start": 364, + "end": 365, + "ctxt": 0 + }, + "typeName": { + "type": "Identifier", + "span": { + "start": 364, + "end": 365, + "ctxt": 0 + }, + "value": "T", + "optional": false + }, + "typeParams": null + } + } + } + } + }, + { + "type": "VariableDeclaration", + "span": { + "start": 367, + "end": 384, + "ctxt": 0 + }, + "kind": "const", + "declare": false, + "declarations": [ + { + "type": "VariableDeclarator", + "span": { + "start": 373, + "end": 383, + "ctxt": 0 + }, + "id": { + "type": "Identifier", + "span": { + "start": 373, + "end": 375, + "ctxt": 0 + }, + "value": "g2", + "optional": false, + "typeAnnotation": { + "type": "TsTypeAnnotation", + "span": { + "start": 375, + "end": 379, + "ctxt": 0 + }, + "typeAnnotation": { + "type": "TsTypeReference", + "span": { + "start": 377, + "end": 379, + "ctxt": 0 + }, + "typeName": { + "type": "Identifier", + "span": { + "start": 377, + "end": 379, + "ctxt": 0 + }, + "value": "G2", + "optional": false + }, + "typeParams": null + } + } + }, + "init": { + "type": "Identifier", + "span": { + "start": 382, + "end": 383, + "ctxt": 0 + }, + "value": "g", + "optional": false + }, + "definite": false + } + ] + }, + { + "type": "TsTypeAliasDeclaration", + "span": { + "start": 395, + "end": 444, + "ctxt": 0 + }, + "declare": false, + "id": { + "type": "Identifier", + "span": { + "start": 400, + "end": 402, + "ctxt": 0 + }, + "value": "G3", + "optional": false + }, + "typeParams": null, + "typeAnnotation": { + "type": "TsFunctionType", + "span": { + "start": 405, + "end": 444, + "ctxt": 0 + }, + "params": [ + { + "type": "Identifier", + "span": { + "start": 423, + "end": 432, + "ctxt": 0 + }, + "value": "x", + "optional": false, + "typeAnnotation": { + "type": "TsTypeAnnotation", + "span": { + "start": 424, + "end": 432, + "ctxt": 0 + }, + "typeAnnotation": { + "type": "TsLiteralType", + "span": { + "start": 426, + "end": 432, + "ctxt": 0 + }, + "literal": { + "type": "TemplateLiteral", + "span": { + "start": 426, + "end": 432, + "ctxt": 0 + }, + "types": [ + { + "type": "TsTypeReference", + "span": { + "start": 429, + "end": 430, + "ctxt": 0 + }, + "typeName": { + "type": "Identifier", + "span": { + "start": 429, + "end": 430, + "ctxt": 0 + }, + "value": "T", + "optional": false + }, + "typeParams": null + } + ], + "quasis": [ + { + "type": "TemplateElement", + "span": { + "start": 427, + "end": 427, + "ctxt": 0 + }, + "tail": false, + "cooked": "", + "raw": "" + }, + { + "type": "TemplateElement", + "span": { + "start": 431, + "end": 431, + "ctxt": 0 + }, + "tail": true, + "cooked": "", + "raw": "" + } + ] + } + } + } + } + ], + "typeParams": { + "type": "TsTypeParameterDeclaration", + "span": { + "start": 405, + "end": 422, + "ctxt": 0 + }, + "parameters": [ + { + "type": "TsTypeParameter", + "span": { + "start": 406, + "end": 421, + "ctxt": 0 + }, + "name": { + "type": "Identifier", + "span": { + "start": 406, + "end": 407, + "ctxt": 0 + }, + "value": "T", + "optional": false + }, + "in": false, + "out": false, + "const": false, + "constraint": { + "type": "TsUnionType", + "span": { + "start": 416, + "end": 421, + "ctxt": 0 + }, + "types": [ + { + "type": "TsLiteralType", + "span": { + "start": 416, + "end": 417, + "ctxt": 0 + }, + "literal": { + "type": "NumericLiteral", + "span": { + "start": 416, + "end": 417, + "ctxt": 0 + }, + "value": 1.0, + "raw": "1" + } + }, + { + "type": "TsLiteralType", + "span": { + "start": 420, + "end": 421, + "ctxt": 0 + }, + "literal": { + "type": "NumericLiteral", + "span": { + "start": 420, + "end": 421, + "ctxt": 0 + }, + "value": 2.0, + "raw": "2" + } + } + ] + }, + "default": null + } + ] + }, + "typeAnnotation": { + "type": "TsTypeAnnotation", + "span": { + "start": 434, + "end": 444, + "ctxt": 0 + }, + "typeAnnotation": { + "type": "TsIndexedAccessType", + "span": { + "start": 437, + "end": 444, + "ctxt": 0 + }, + "readonly": false, + "objectType": { + "type": "TsTypeReference", + "span": { + "start": 437, + "end": 441, + "ctxt": 0 + }, + "typeName": { + "type": "Identifier", + "span": { + "start": 437, + "end": 441, + "ctxt": 0 + }, + "value": "NMap", + "optional": false + }, + "typeParams": null + }, + "indexType": { + "type": "TsTypeReference", + "span": { + "start": 442, + "end": 443, + "ctxt": 0 + }, + "typeName": { + "type": "Identifier", + "span": { + "start": 442, + "end": 443, + "ctxt": 0 + }, + "value": "T", + "optional": false + }, + "typeParams": null + } + } + } + } + }, + { + "type": "VariableDeclaration", + "span": { + "start": 445, + "end": 462, + "ctxt": 0 + }, + "kind": "const", + "declare": false, + "declarations": [ + { + "type": "VariableDeclarator", + "span": { + "start": 451, + "end": 461, + "ctxt": 0 + }, + "id": { + "type": "Identifier", + "span": { + "start": 451, + "end": 453, + "ctxt": 0 + }, + "value": "g3", + "optional": false, + "typeAnnotation": { + "type": "TsTypeAnnotation", + "span": { + "start": 453, + "end": 457, + "ctxt": 0 + }, + "typeAnnotation": { + "type": "TsTypeReference", + "span": { + "start": 455, + "end": 457, + "ctxt": 0 + }, + "typeName": { + "type": "Identifier", + "span": { + "start": 455, + "end": 457, + "ctxt": 0 + }, + "value": "G3", + "optional": false + }, + "typeParams": null + } + } + }, + "init": { + "type": "Identifier", + "span": { + "start": 460, + "end": 461, + "ctxt": 0 + }, + "value": "g", + "optional": false + }, + "definite": false + } + ] + } + ], + "interpreter": null +} diff --git a/crates/swc_ecma_parser/tests/tsc/templateLiteralTypes7.ts b/crates/swc_ecma_parser/tests/tsc/templateLiteralTypes7.ts new file mode 100644 index 000000000000..2f06f286d2aa --- /dev/null +++ b/crates/swc_ecma_parser/tests/tsc/templateLiteralTypes7.ts @@ -0,0 +1,23 @@ +// @strict: true +// @target: esnext +// @noEmit: true + +// https://github.com/microsoft/TypeScript/issues/57807 + +interface NMap { + 1: 'A' + 2: 'B' + 3: 'C' + 4: 'D' +} + +declare const g: (x: `${T}`) => NMap[T] + +type G1 = (x: `${T}`) => NMap[T] +const g1: G1 = g; // ok + +type G2 = (x: `${T}`) => NMap[T] +const g2: G2 = g; // error + +type G3 = (x: `${T}`) => NMap[T] +const g3: G3 = g; // ok diff --git a/crates/swc_ecma_parser/tests/tsc/templateStringMultiline3.json b/crates/swc_ecma_parser/tests/tsc/templateStringMultiline3.json index f467151e7d07..e6ebc6ba5b0c 100644 --- a/crates/swc_ecma_parser/tests/tsc/templateStringMultiline3.json +++ b/crates/swc_ecma_parser/tests/tsc/templateStringMultiline3.json @@ -1,41 +1,10 @@ { "type": "Script", "span": { - "start": 24, - "end": 29, + "start": 1, + "end": 1, "ctxt": 0 }, - "body": [ - { - "type": "ExpressionStatement", - "span": { - "start": 24, - "end": 29, - "ctxt": 0 - }, - "expression": { - "type": "TemplateLiteral", - "span": { - "start": 24, - "end": 29, - "ctxt": 0 - }, - "expressions": [], - "quasis": [ - { - "type": "TemplateElement", - "span": { - "start": 25, - "end": 28, - "ctxt": 0 - }, - "tail": true, - "cooked": "\n", - "raw": "\n\\\r" - } - ] - } - } - ], + "body": [], "interpreter": null } diff --git a/crates/swc_ecma_parser/tests/tsc/templateStringMultiline3.ts b/crates/swc_ecma_parser/tests/tsc/templateStringMultiline3.ts index fbde56ac230b..045d5995ccdb 100644 --- a/crates/swc_ecma_parser/tests/tsc/templateStringMultiline3.ts +++ b/crates/swc_ecma_parser/tests/tsc/templateStringMultiline3.ts @@ -1 +1 @@ - // newlines are ` \ ` \ No newline at end of file +// newlines are `\` \ No newline at end of file diff --git a/crates/swc_ecma_parser/tests/tsc/templateStringMultiline3_ES6.json b/crates/swc_ecma_parser/tests/tsc/templateStringMultiline3_ES6.json index a6887797b9c1..e6ebc6ba5b0c 100644 --- a/crates/swc_ecma_parser/tests/tsc/templateStringMultiline3_ES6.json +++ b/crates/swc_ecma_parser/tests/tsc/templateStringMultiline3_ES6.json @@ -1,41 +1,10 @@ { "type": "Script", "span": { - "start": 38, - "end": 43, + "start": 1, + "end": 1, "ctxt": 0 }, - "body": [ - { - "type": "ExpressionStatement", - "span": { - "start": 38, - "end": 43, - "ctxt": 0 - }, - "expression": { - "type": "TemplateLiteral", - "span": { - "start": 38, - "end": 43, - "ctxt": 0 - }, - "expressions": [], - "quasis": [ - { - "type": "TemplateElement", - "span": { - "start": 39, - "end": 42, - "ctxt": 0 - }, - "tail": true, - "cooked": "\n", - "raw": "\n\\\r" - } - ] - } - } - ], + "body": [], "interpreter": null } diff --git a/crates/swc_ecma_parser/tests/tsc/templateStringMultiline3_ES6.ts b/crates/swc_ecma_parser/tests/tsc/templateStringMultiline3_ES6.ts index 4d2613f9f9fe..739dafbf098d 100644 --- a/crates/swc_ecma_parser/tests/tsc/templateStringMultiline3_ES6.ts +++ b/crates/swc_ecma_parser/tests/tsc/templateStringMultiline3_ES6.ts @@ -1 +1 @@ -//@target: es6 // newlines are ` \ ` \ No newline at end of file +//@target: es6// newlines are `\` \ No newline at end of file diff --git a/crates/swc_ecma_parser/tests/tsc/topLevelThisAssignment.json b/crates/swc_ecma_parser/tests/tsc/topLevelThisAssignment.json index 3ac3f4561b07..44a02675bd96 100644 --- a/crates/swc_ecma_parser/tests/tsc/topLevelThisAssignment.json +++ b/crates/swc_ecma_parser/tests/tsc/topLevelThisAssignment.json @@ -1,46 +1,46 @@ { "type": "Script", "span": { - "start": 75, - "end": 129, + "start": 79, + "end": 133, "ctxt": 0 }, "body": [ { "type": "ExpressionStatement", "span": { - "start": 75, - "end": 87, + "start": 79, + "end": 91, "ctxt": 0 }, "expression": { "type": "AssignmentExpression", "span": { - "start": 75, - "end": 86, + "start": 79, + "end": 90, "ctxt": 0 }, "operator": "=", "left": { "type": "MemberExpression", "span": { - "start": 75, - "end": 81, + "start": 79, + "end": 85, "ctxt": 0 }, "object": { "type": "ThisExpression", "span": { - "start": 75, - "end": 79, + "start": 79, + "end": 83, "ctxt": 0 } }, "property": { "type": "Identifier", "span": { - "start": 80, - "end": 81, + "start": 84, + "end": 85, "ctxt": 0 }, "value": "a", @@ -50,8 +50,8 @@ "right": { "type": "NumericLiteral", "span": { - "start": 84, - "end": 86, + "start": 88, + "end": 90, "ctxt": 0 }, "value": 10.0, @@ -62,30 +62,30 @@ { "type": "ExpressionStatement", "span": { - "start": 88, - "end": 95, + "start": 92, + "end": 99, "ctxt": 0 }, "expression": { "type": "MemberExpression", "span": { - "start": 88, - "end": 94, + "start": 92, + "end": 98, "ctxt": 0 }, "object": { "type": "ThisExpression", "span": { - "start": 88, - "end": 92, + "start": 92, + "end": 96, "ctxt": 0 } }, "property": { "type": "Identifier", "span": { - "start": 93, - "end": 94, + "start": 97, + "end": 98, "ctxt": 0 }, "value": "a", @@ -96,15 +96,15 @@ { "type": "ExpressionStatement", "span": { - "start": 96, - "end": 98, + "start": 100, + "end": 102, "ctxt": 0 }, "expression": { "type": "Identifier", "span": { - "start": 96, - "end": 97, + "start": 100, + "end": 101, "ctxt": 0 }, "value": "a", @@ -114,30 +114,30 @@ { "type": "ExpressionStatement", "span": { - "start": 119, - "end": 126, + "start": 123, + "end": 130, "ctxt": 0 }, "expression": { "type": "MemberExpression", "span": { - "start": 119, - "end": 125, + "start": 123, + "end": 129, "ctxt": 0 }, "object": { "type": "ThisExpression", "span": { - "start": 119, - "end": 123, + "start": 123, + "end": 127, "ctxt": 0 } }, "property": { "type": "Identifier", "span": { - "start": 124, - "end": 125, + "start": 128, + "end": 129, "ctxt": 0 }, "value": "a", @@ -148,15 +148,15 @@ { "type": "ExpressionStatement", "span": { - "start": 127, - "end": 129, + "start": 131, + "end": 133, "ctxt": 0 }, "expression": { "type": "Identifier", "span": { - "start": 127, - "end": 128, + "start": 131, + "end": 132, "ctxt": 0 }, "value": "a", diff --git a/crates/swc_ecma_parser/tests/tsc/topLevelThisAssignment.ts b/crates/swc_ecma_parser/tests/tsc/topLevelThisAssignment.ts index aed2f8671080..7cf806450a0e 100644 --- a/crates/swc_ecma_parser/tests/tsc/topLevelThisAssignment.ts +++ b/crates/swc_ecma_parser/tests/tsc/topLevelThisAssignment.ts @@ -1,4 +1,4 @@ -// @out: output.js +// @outFile: output.js // @allowJs: true // @checkJs: true // @Filename: a.js diff --git a/crates/swc_ecma_parser/tests/tsc/topLevelVarHoistingCommonJS.json b/crates/swc_ecma_parser/tests/tsc/topLevelVarHoistingCommonJS.json deleted file mode 100644 index a3506a531b59..000000000000 --- a/crates/swc_ecma_parser/tests/tsc/topLevelVarHoistingCommonJS.json +++ /dev/null @@ -1,1631 +0,0 @@ -{ - "type": "Module", - "span": { - "start": 70, - "end": 709, - "ctxt": 0 - }, - "body": [ - { - "type": "VariableDeclaration", - "span": { - "start": 70, - "end": 89, - "ctxt": 0 - }, - "kind": "var", - "declare": true, - "declarations": [ - { - "type": "VariableDeclarator", - "span": { - "start": 82, - "end": 88, - "ctxt": 0 - }, - "id": { - "type": "Identifier", - "span": { - "start": 82, - "end": 83, - "ctxt": 0 - }, - "value": "_", - "optional": false, - "typeAnnotation": { - "type": "TsTypeAnnotation", - "span": { - "start": 83, - "end": 88, - "ctxt": 0 - }, - "typeAnnotation": { - "type": "TsKeywordType", - "span": { - "start": 85, - "end": 88, - "ctxt": 0 - }, - "kind": "any" - } - } - }, - "init": null, - "definite": false - } - ] - }, - { - "type": "BlockStatement", - "span": { - "start": 91, - "end": 109, - "ctxt": 0 - }, - "stmts": [ - { - "type": "VariableDeclaration", - "span": { - "start": 97, - "end": 107, - "ctxt": 0 - }, - "kind": "var", - "declare": false, - "declarations": [ - { - "type": "VariableDeclarator", - "span": { - "start": 101, - "end": 106, - "ctxt": 0 - }, - "id": { - "type": "Identifier", - "span": { - "start": 101, - "end": 102, - "ctxt": 0 - }, - "value": "a", - "optional": false, - "typeAnnotation": null - }, - "init": { - "type": "Identifier", - "span": { - "start": 105, - "end": 106, - "ctxt": 0 - }, - "value": "_", - "optional": false - }, - "definite": false - } - ] - } - ] - }, - { - "type": "IfStatement", - "span": { - "start": 111, - "end": 160, - "ctxt": 0 - }, - "test": { - "type": "Identifier", - "span": { - "start": 115, - "end": 116, - "ctxt": 0 - }, - "value": "_", - "optional": false - }, - "consequent": { - "type": "BlockStatement", - "span": { - "start": 118, - "end": 136, - "ctxt": 0 - }, - "stmts": [ - { - "type": "VariableDeclaration", - "span": { - "start": 124, - "end": 134, - "ctxt": 0 - }, - "kind": "var", - "declare": false, - "declarations": [ - { - "type": "VariableDeclarator", - "span": { - "start": 128, - "end": 133, - "ctxt": 0 - }, - "id": { - "type": "Identifier", - "span": { - "start": 128, - "end": 129, - "ctxt": 0 - }, - "value": "b", - "optional": false, - "typeAnnotation": null - }, - "init": { - "type": "Identifier", - "span": { - "start": 132, - "end": 133, - "ctxt": 0 - }, - "value": "_", - "optional": false - }, - "definite": false - } - ] - } - ] - }, - "alternate": { - "type": "BlockStatement", - "span": { - "start": 142, - "end": 160, - "ctxt": 0 - }, - "stmts": [ - { - "type": "VariableDeclaration", - "span": { - "start": 148, - "end": 158, - "ctxt": 0 - }, - "kind": "var", - "declare": false, - "declarations": [ - { - "type": "VariableDeclarator", - "span": { - "start": 152, - "end": 157, - "ctxt": 0 - }, - "id": { - "type": "Identifier", - "span": { - "start": 152, - "end": 153, - "ctxt": 0 - }, - "value": "c", - "optional": false, - "typeAnnotation": null - }, - "init": { - "type": "Identifier", - "span": { - "start": 156, - "end": 157, - "ctxt": 0 - }, - "value": "_", - "optional": false - }, - "definite": false - } - ] - } - ] - } - }, - { - "type": "SwitchStatement", - "span": { - "start": 162, - "end": 239, - "ctxt": 0 - }, - "discriminant": { - "type": "Identifier", - "span": { - "start": 170, - "end": 171, - "ctxt": 0 - }, - "value": "_", - "optional": false - }, - "cases": [ - { - "type": "SwitchCase", - "span": { - "start": 179, - "end": 205, - "ctxt": 0 - }, - "test": { - "type": "Identifier", - "span": { - "start": 184, - "end": 185, - "ctxt": 0 - }, - "value": "_", - "optional": false - }, - "consequent": [ - { - "type": "VariableDeclaration", - "span": { - "start": 195, - "end": 205, - "ctxt": 0 - }, - "kind": "var", - "declare": false, - "declarations": [ - { - "type": "VariableDeclarator", - "span": { - "start": 199, - "end": 204, - "ctxt": 0 - }, - "id": { - "type": "Identifier", - "span": { - "start": 199, - "end": 200, - "ctxt": 0 - }, - "value": "d", - "optional": false, - "typeAnnotation": null - }, - "init": { - "type": "Identifier", - "span": { - "start": 203, - "end": 204, - "ctxt": 0 - }, - "value": "_", - "optional": false - }, - "definite": false - } - ] - } - ] - }, - { - "type": "SwitchCase", - "span": { - "start": 210, - "end": 237, - "ctxt": 0 - }, - "test": null, - "consequent": [ - { - "type": "VariableDeclaration", - "span": { - "start": 227, - "end": 237, - "ctxt": 0 - }, - "kind": "var", - "declare": false, - "declarations": [ - { - "type": "VariableDeclarator", - "span": { - "start": 231, - "end": 236, - "ctxt": 0 - }, - "id": { - "type": "Identifier", - "span": { - "start": 231, - "end": 232, - "ctxt": 0 - }, - "value": "e", - "optional": false, - "typeAnnotation": null - }, - "init": { - "type": "Identifier", - "span": { - "start": 235, - "end": 236, - "ctxt": 0 - }, - "value": "_", - "optional": false - }, - "definite": false - } - ] - } - ] - } - ] - }, - { - "type": "WhileStatement", - "span": { - "start": 241, - "end": 269, - "ctxt": 0 - }, - "test": { - "type": "Identifier", - "span": { - "start": 248, - "end": 249, - "ctxt": 0 - }, - "value": "_", - "optional": false - }, - "body": { - "type": "BlockStatement", - "span": { - "start": 251, - "end": 269, - "ctxt": 0 - }, - "stmts": [ - { - "type": "VariableDeclaration", - "span": { - "start": 257, - "end": 267, - "ctxt": 0 - }, - "kind": "var", - "declare": false, - "declarations": [ - { - "type": "VariableDeclarator", - "span": { - "start": 261, - "end": 266, - "ctxt": 0 - }, - "id": { - "type": "Identifier", - "span": { - "start": 261, - "end": 262, - "ctxt": 0 - }, - "value": "f", - "optional": false, - "typeAnnotation": null - }, - "init": { - "type": "Identifier", - "span": { - "start": 265, - "end": 266, - "ctxt": 0 - }, - "value": "_", - "optional": false - }, - "definite": false - } - ] - } - ] - } - }, - { - "type": "DoWhileStatement", - "span": { - "start": 271, - "end": 303, - "ctxt": 0 - }, - "test": { - "type": "Identifier", - "span": { - "start": 300, - "end": 301, - "ctxt": 0 - }, - "value": "_", - "optional": false - }, - "body": { - "type": "BlockStatement", - "span": { - "start": 274, - "end": 292, - "ctxt": 0 - }, - "stmts": [ - { - "type": "VariableDeclaration", - "span": { - "start": 280, - "end": 290, - "ctxt": 0 - }, - "kind": "var", - "declare": false, - "declarations": [ - { - "type": "VariableDeclarator", - "span": { - "start": 284, - "end": 289, - "ctxt": 0 - }, - "id": { - "type": "Identifier", - "span": { - "start": 284, - "end": 285, - "ctxt": 0 - }, - "value": "g", - "optional": false, - "typeAnnotation": null - }, - "init": { - "type": "Identifier", - "span": { - "start": 288, - "end": 289, - "ctxt": 0 - }, - "value": "_", - "optional": false - }, - "definite": false - } - ] - } - ] - } - }, - { - "type": "ForStatement", - "span": { - "start": 305, - "end": 338, - "ctxt": 0 - }, - "init": { - "type": "VariableDeclaration", - "span": { - "start": 310, - "end": 319, - "ctxt": 0 - }, - "kind": "var", - "declare": false, - "declarations": [ - { - "type": "VariableDeclarator", - "span": { - "start": 314, - "end": 319, - "ctxt": 0 - }, - "id": { - "type": "Identifier", - "span": { - "start": 314, - "end": 315, - "ctxt": 0 - }, - "value": "h", - "optional": false, - "typeAnnotation": null - }, - "init": { - "type": "Identifier", - "span": { - "start": 318, - "end": 319, - "ctxt": 0 - }, - "value": "_", - "optional": false - }, - "definite": false - } - ] - }, - "test": null, - "update": null, - "body": { - "type": "BlockStatement", - "span": { - "start": 324, - "end": 338, - "ctxt": 0 - }, - "stmts": [ - { - "type": "BreakStatement", - "span": { - "start": 330, - "end": 336, - "ctxt": 0 - }, - "label": null - } - ] - } - }, - { - "type": "ForStatement", - "span": { - "start": 340, - "end": 379, - "ctxt": 0 - }, - "init": null, - "test": null, - "update": null, - "body": { - "type": "BlockStatement", - "span": { - "start": 350, - "end": 379, - "ctxt": 0 - }, - "stmts": [ - { - "type": "VariableDeclaration", - "span": { - "start": 356, - "end": 366, - "ctxt": 0 - }, - "kind": "var", - "declare": false, - "declarations": [ - { - "type": "VariableDeclarator", - "span": { - "start": 360, - "end": 365, - "ctxt": 0 - }, - "id": { - "type": "Identifier", - "span": { - "start": 360, - "end": 361, - "ctxt": 0 - }, - "value": "m", - "optional": false, - "typeAnnotation": null - }, - "init": { - "type": "Identifier", - "span": { - "start": 364, - "end": 365, - "ctxt": 0 - }, - "value": "_", - "optional": false - }, - "definite": false - } - ] - }, - { - "type": "BreakStatement", - "span": { - "start": 371, - "end": 377, - "ctxt": 0 - }, - "label": null - } - ] - } - }, - { - "type": "ForInStatement", - "span": { - "start": 381, - "end": 404, - "ctxt": 0 - }, - "left": { - "type": "VariableDeclaration", - "span": { - "start": 386, - "end": 391, - "ctxt": 0 - }, - "kind": "var", - "declare": false, - "declarations": [ - { - "type": "VariableDeclarator", - "span": { - "start": 390, - "end": 391, - "ctxt": 0 - }, - "id": { - "type": "Identifier", - "span": { - "start": 390, - "end": 391, - "ctxt": 0 - }, - "value": "n", - "optional": false, - "typeAnnotation": null - }, - "init": null, - "definite": false - } - ] - }, - "right": { - "type": "Identifier", - "span": { - "start": 395, - "end": 396, - "ctxt": 0 - }, - "value": "_", - "optional": false - }, - "body": { - "type": "BreakStatement", - "span": { - "start": 398, - "end": 404, - "ctxt": 0 - }, - "label": null - } - }, - { - "type": "ForInStatement", - "span": { - "start": 406, - "end": 437, - "ctxt": 0 - }, - "left": { - "type": "Identifier", - "span": { - "start": 411, - "end": 412, - "ctxt": 0 - }, - "value": "_", - "optional": false, - "typeAnnotation": null - }, - "right": { - "type": "Identifier", - "span": { - "start": 416, - "end": 417, - "ctxt": 0 - }, - "value": "_", - "optional": false - }, - "body": { - "type": "BlockStatement", - "span": { - "start": 419, - "end": 437, - "ctxt": 0 - }, - "stmts": [ - { - "type": "VariableDeclaration", - "span": { - "start": 425, - "end": 435, - "ctxt": 0 - }, - "kind": "var", - "declare": false, - "declarations": [ - { - "type": "VariableDeclarator", - "span": { - "start": 429, - "end": 434, - "ctxt": 0 - }, - "id": { - "type": "Identifier", - "span": { - "start": 429, - "end": 430, - "ctxt": 0 - }, - "value": "o", - "optional": false, - "typeAnnotation": null - }, - "init": { - "type": "Identifier", - "span": { - "start": 433, - "end": 434, - "ctxt": 0 - }, - "value": "_", - "optional": false - }, - "definite": false - } - ] - } - ] - } - }, - { - "type": "ForOfStatement", - "span": { - "start": 439, - "end": 462, - "ctxt": 0 - }, - "await": false, - "left": { - "type": "VariableDeclaration", - "span": { - "start": 444, - "end": 449, - "ctxt": 0 - }, - "kind": "var", - "declare": false, - "declarations": [ - { - "type": "VariableDeclarator", - "span": { - "start": 448, - "end": 449, - "ctxt": 0 - }, - "id": { - "type": "Identifier", - "span": { - "start": 448, - "end": 449, - "ctxt": 0 - }, - "value": "p", - "optional": false, - "typeAnnotation": null - }, - "init": null, - "definite": false - } - ] - }, - "right": { - "type": "Identifier", - "span": { - "start": 453, - "end": 454, - "ctxt": 0 - }, - "value": "_", - "optional": false - }, - "body": { - "type": "BreakStatement", - "span": { - "start": 456, - "end": 462, - "ctxt": 0 - }, - "label": null - } - }, - { - "type": "ForOfStatement", - "span": { - "start": 464, - "end": 495, - "ctxt": 0 - }, - "await": false, - "left": { - "type": "Identifier", - "span": { - "start": 469, - "end": 470, - "ctxt": 0 - }, - "value": "_", - "optional": false, - "typeAnnotation": null - }, - "right": { - "type": "Identifier", - "span": { - "start": 474, - "end": 475, - "ctxt": 0 - }, - "value": "_", - "optional": false - }, - "body": { - "type": "BlockStatement", - "span": { - "start": 477, - "end": 495, - "ctxt": 0 - }, - "stmts": [ - { - "type": "VariableDeclaration", - "span": { - "start": 483, - "end": 493, - "ctxt": 0 - }, - "kind": "var", - "declare": false, - "declarations": [ - { - "type": "VariableDeclarator", - "span": { - "start": 487, - "end": 492, - "ctxt": 0 - }, - "id": { - "type": "Identifier", - "span": { - "start": 487, - "end": 488, - "ctxt": 0 - }, - "value": "u", - "optional": false, - "typeAnnotation": null - }, - "init": { - "type": "Identifier", - "span": { - "start": 491, - "end": 492, - "ctxt": 0 - }, - "value": "_", - "optional": false - }, - "definite": false - } - ] - } - ] - } - }, - { - "type": "TryStatement", - "span": { - "start": 497, - "end": 544, - "ctxt": 0 - }, - "block": { - "type": "BlockStatement", - "span": { - "start": 501, - "end": 519, - "ctxt": 0 - }, - "stmts": [ - { - "type": "VariableDeclaration", - "span": { - "start": 507, - "end": 517, - "ctxt": 0 - }, - "kind": "var", - "declare": false, - "declarations": [ - { - "type": "VariableDeclarator", - "span": { - "start": 511, - "end": 516, - "ctxt": 0 - }, - "id": { - "type": "Identifier", - "span": { - "start": 511, - "end": 512, - "ctxt": 0 - }, - "value": "v", - "optional": false, - "typeAnnotation": null - }, - "init": { - "type": "Identifier", - "span": { - "start": 515, - "end": 516, - "ctxt": 0 - }, - "value": "_", - "optional": false - }, - "definite": false - } - ] - } - ] - }, - "handler": { - "type": "CatchClause", - "span": { - "start": 520, - "end": 544, - "ctxt": 0 - }, - "param": null, - "body": { - "type": "BlockStatement", - "span": { - "start": 526, - "end": 544, - "ctxt": 0 - }, - "stmts": [ - { - "type": "VariableDeclaration", - "span": { - "start": 532, - "end": 542, - "ctxt": 0 - }, - "kind": "var", - "declare": false, - "declarations": [ - { - "type": "VariableDeclarator", - "span": { - "start": 536, - "end": 541, - "ctxt": 0 - }, - "id": { - "type": "Identifier", - "span": { - "start": 536, - "end": 537, - "ctxt": 0 - }, - "value": "w", - "optional": false, - "typeAnnotation": null - }, - "init": { - "type": "Identifier", - "span": { - "start": 540, - "end": 541, - "ctxt": 0 - }, - "value": "_", - "optional": false - }, - "definite": false - } - ] - } - ] - } - }, - "finalizer": null - }, - { - "type": "LabeledStatement", - "span": { - "start": 546, - "end": 588, - "ctxt": 0 - }, - "label": { - "type": "Identifier", - "span": { - "start": 546, - "end": 551, - "ctxt": 0 - }, - "value": "label", - "optional": false - }, - "body": { - "type": "BlockStatement", - "span": { - "start": 553, - "end": 588, - "ctxt": 0 - }, - "stmts": [ - { - "type": "VariableDeclaration", - "span": { - "start": 559, - "end": 569, - "ctxt": 0 - }, - "kind": "var", - "declare": false, - "declarations": [ - { - "type": "VariableDeclarator", - "span": { - "start": 563, - "end": 568, - "ctxt": 0 - }, - "id": { - "type": "Identifier", - "span": { - "start": 563, - "end": 564, - "ctxt": 0 - }, - "value": "x", - "optional": false, - "typeAnnotation": null - }, - "init": { - "type": "Identifier", - "span": { - "start": 567, - "end": 568, - "ctxt": 0 - }, - "value": "_", - "optional": false - }, - "definite": false - } - ] - }, - { - "type": "BreakStatement", - "span": { - "start": 574, - "end": 586, - "ctxt": 0 - }, - "label": { - "type": "Identifier", - "span": { - "start": 580, - "end": 585, - "ctxt": 0 - }, - "value": "label", - "optional": false - } - } - ] - } - }, - { - "type": "WithStatement", - "span": { - "start": 604, - "end": 631, - "ctxt": 0 - }, - "object": { - "type": "Identifier", - "span": { - "start": 610, - "end": 611, - "ctxt": 0 - }, - "value": "_", - "optional": false - }, - "body": { - "type": "BlockStatement", - "span": { - "start": 613, - "end": 631, - "ctxt": 0 - }, - "stmts": [ - { - "type": "VariableDeclaration", - "span": { - "start": 619, - "end": 629, - "ctxt": 0 - }, - "kind": "var", - "declare": false, - "declarations": [ - { - "type": "VariableDeclarator", - "span": { - "start": 623, - "end": 628, - "ctxt": 0 - }, - "id": { - "type": "Identifier", - "span": { - "start": 623, - "end": 624, - "ctxt": 0 - }, - "value": "y", - "optional": false, - "typeAnnotation": null - }, - "init": { - "type": "Identifier", - "span": { - "start": 627, - "end": 628, - "ctxt": 0 - }, - "value": "_", - "optional": false - }, - "definite": false - } - ] - } - ] - } - }, - { - "type": "VariableDeclaration", - "span": { - "start": 633, - "end": 643, - "ctxt": 0 - }, - "kind": "var", - "declare": false, - "declarations": [ - { - "type": "VariableDeclarator", - "span": { - "start": 637, - "end": 642, - "ctxt": 0 - }, - "id": { - "type": "Identifier", - "span": { - "start": 637, - "end": 638, - "ctxt": 0 - }, - "value": "z", - "optional": false, - "typeAnnotation": null - }, - "init": { - "type": "Identifier", - "span": { - "start": 641, - "end": 642, - "ctxt": 0 - }, - "value": "_", - "optional": false - }, - "definite": false - } - ] - }, - { - "type": "ExportNamedDeclaration", - "span": { - "start": 645, - "end": 709, - "ctxt": 0 - }, - "specifiers": [ - { - "type": "ExportSpecifier", - "span": { - "start": 654, - "end": 655, - "ctxt": 0 - }, - "orig": { - "type": "Identifier", - "span": { - "start": 654, - "end": 655, - "ctxt": 0 - }, - "value": "a", - "optional": false - }, - "exported": null, - "isTypeOnly": false - }, - { - "type": "ExportSpecifier", - "span": { - "start": 657, - "end": 658, - "ctxt": 0 - }, - "orig": { - "type": "Identifier", - "span": { - "start": 657, - "end": 658, - "ctxt": 0 - }, - "value": "b", - "optional": false - }, - "exported": null, - "isTypeOnly": false - }, - { - "type": "ExportSpecifier", - "span": { - "start": 660, - "end": 661, - "ctxt": 0 - }, - "orig": { - "type": "Identifier", - "span": { - "start": 660, - "end": 661, - "ctxt": 0 - }, - "value": "c", - "optional": false - }, - "exported": null, - "isTypeOnly": false - }, - { - "type": "ExportSpecifier", - "span": { - "start": 663, - "end": 664, - "ctxt": 0 - }, - "orig": { - "type": "Identifier", - "span": { - "start": 663, - "end": 664, - "ctxt": 0 - }, - "value": "d", - "optional": false - }, - "exported": null, - "isTypeOnly": false - }, - { - "type": "ExportSpecifier", - "span": { - "start": 666, - "end": 667, - "ctxt": 0 - }, - "orig": { - "type": "Identifier", - "span": { - "start": 666, - "end": 667, - "ctxt": 0 - }, - "value": "e", - "optional": false - }, - "exported": null, - "isTypeOnly": false - }, - { - "type": "ExportSpecifier", - "span": { - "start": 669, - "end": 670, - "ctxt": 0 - }, - "orig": { - "type": "Identifier", - "span": { - "start": 669, - "end": 670, - "ctxt": 0 - }, - "value": "f", - "optional": false - }, - "exported": null, - "isTypeOnly": false - }, - { - "type": "ExportSpecifier", - "span": { - "start": 672, - "end": 673, - "ctxt": 0 - }, - "orig": { - "type": "Identifier", - "span": { - "start": 672, - "end": 673, - "ctxt": 0 - }, - "value": "g", - "optional": false - }, - "exported": null, - "isTypeOnly": false - }, - { - "type": "ExportSpecifier", - "span": { - "start": 675, - "end": 676, - "ctxt": 0 - }, - "orig": { - "type": "Identifier", - "span": { - "start": 675, - "end": 676, - "ctxt": 0 - }, - "value": "h", - "optional": false - }, - "exported": null, - "isTypeOnly": false - }, - { - "type": "ExportSpecifier", - "span": { - "start": 678, - "end": 679, - "ctxt": 0 - }, - "orig": { - "type": "Identifier", - "span": { - "start": 678, - "end": 679, - "ctxt": 0 - }, - "value": "m", - "optional": false - }, - "exported": null, - "isTypeOnly": false - }, - { - "type": "ExportSpecifier", - "span": { - "start": 681, - "end": 682, - "ctxt": 0 - }, - "orig": { - "type": "Identifier", - "span": { - "start": 681, - "end": 682, - "ctxt": 0 - }, - "value": "n", - "optional": false - }, - "exported": null, - "isTypeOnly": false - }, - { - "type": "ExportSpecifier", - "span": { - "start": 684, - "end": 685, - "ctxt": 0 - }, - "orig": { - "type": "Identifier", - "span": { - "start": 684, - "end": 685, - "ctxt": 0 - }, - "value": "o", - "optional": false - }, - "exported": null, - "isTypeOnly": false - }, - { - "type": "ExportSpecifier", - "span": { - "start": 687, - "end": 688, - "ctxt": 0 - }, - "orig": { - "type": "Identifier", - "span": { - "start": 687, - "end": 688, - "ctxt": 0 - }, - "value": "p", - "optional": false - }, - "exported": null, - "isTypeOnly": false - }, - { - "type": "ExportSpecifier", - "span": { - "start": 690, - "end": 691, - "ctxt": 0 - }, - "orig": { - "type": "Identifier", - "span": { - "start": 690, - "end": 691, - "ctxt": 0 - }, - "value": "u", - "optional": false - }, - "exported": null, - "isTypeOnly": false - }, - { - "type": "ExportSpecifier", - "span": { - "start": 693, - "end": 694, - "ctxt": 0 - }, - "orig": { - "type": "Identifier", - "span": { - "start": 693, - "end": 694, - "ctxt": 0 - }, - "value": "v", - "optional": false - }, - "exported": null, - "isTypeOnly": false - }, - { - "type": "ExportSpecifier", - "span": { - "start": 696, - "end": 697, - "ctxt": 0 - }, - "orig": { - "type": "Identifier", - "span": { - "start": 696, - "end": 697, - "ctxt": 0 - }, - "value": "w", - "optional": false - }, - "exported": null, - "isTypeOnly": false - }, - { - "type": "ExportSpecifier", - "span": { - "start": 699, - "end": 700, - "ctxt": 0 - }, - "orig": { - "type": "Identifier", - "span": { - "start": 699, - "end": 700, - "ctxt": 0 - }, - "value": "x", - "optional": false - }, - "exported": null, - "isTypeOnly": false - }, - { - "type": "ExportSpecifier", - "span": { - "start": 702, - "end": 703, - "ctxt": 0 - }, - "orig": { - "type": "Identifier", - "span": { - "start": 702, - "end": 703, - "ctxt": 0 - }, - "value": "y", - "optional": false - }, - "exported": null, - "isTypeOnly": false - }, - { - "type": "ExportSpecifier", - "span": { - "start": 705, - "end": 706, - "ctxt": 0 - }, - "orig": { - "type": "Identifier", - "span": { - "start": 705, - "end": 706, - "ctxt": 0 - }, - "value": "z", - "optional": false - }, - "exported": null, - "isTypeOnly": false - } - ], - "source": null, - "typeOnly": false, - "with": null - } - ], - "interpreter": null -} diff --git a/crates/swc_ecma_parser/tests/tsc/typeFromPropertyAssignmentOutOfOrder.ts b/crates/swc_ecma_parser/tests/tsc/typeFromPropertyAssignmentOutOfOrder.ts index cbb4f90b4400..7014abb5f31a 100644 --- a/crates/swc_ecma_parser/tests/tsc/typeFromPropertyAssignmentOutOfOrder.ts +++ b/crates/swc_ecma_parser/tests/tsc/typeFromPropertyAssignmentOutOfOrder.ts @@ -1,7 +1,7 @@ // @noEmit: true // @allowJs: true // @checkJs: true -// @target: es3 +// @target: es5 // @filename: index.js First.Item = class I {} Common.Object = class extends First.Item {} diff --git a/crates/swc_ecma_parser/tests/tsc/typeSatisfaction_js.json b/crates/swc_ecma_parser/tests/tsc/typeSatisfaction_js.json index 036aed577333..488206b1cfa2 100644 --- a/crates/swc_ecma_parser/tests/tsc/typeSatisfaction_js.json +++ b/crates/swc_ecma_parser/tests/tsc/typeSatisfaction_js.json @@ -1,16 +1,16 @@ { "type": "Script", "span": { - "start": 63, - "end": 93, + "start": 67, + "end": 97, "ctxt": 0 }, "body": [ { "type": "VariableDeclaration", "span": { - "start": 63, - "end": 93, + "start": 67, + "end": 97, "ctxt": 0 }, "kind": "var", @@ -19,15 +19,15 @@ { "type": "VariableDeclarator", "span": { - "start": 67, - "end": 92, + "start": 71, + "end": 96, "ctxt": 0 }, "id": { "type": "Identifier", "span": { - "start": 67, - "end": 68, + "start": 71, + "end": 72, "ctxt": 0 }, "value": "v", @@ -37,15 +37,15 @@ "init": { "type": "TsSatisfiesExpression", "span": { - "start": 71, - "end": 92, + "start": 75, + "end": 96, "ctxt": 0 }, "expression": { "type": "Identifier", "span": { - "start": 71, - "end": 80, + "start": 75, + "end": 84, "ctxt": 0 }, "value": "undefined", @@ -54,15 +54,15 @@ "typeAnnotation": { "type": "TsLiteralType", "span": { - "start": 91, - "end": 92, + "start": 95, + "end": 96, "ctxt": 0 }, "literal": { "type": "NumericLiteral", "span": { - "start": 91, - "end": 92, + "start": 95, + "end": 96, "ctxt": 0 }, "value": 1.0, diff --git a/crates/swc_ecma_parser/tests/tsc/typeSatisfaction_js.ts b/crates/swc_ecma_parser/tests/tsc/typeSatisfaction_js.ts index 5826e4a20971..af47eeff3c33 100644 --- a/crates/swc_ecma_parser/tests/tsc/typeSatisfaction_js.ts +++ b/crates/swc_ecma_parser/tests/tsc/typeSatisfaction_js.ts @@ -1,5 +1,5 @@ // @allowJs: true // @filename: /src/a.js -// @out: /lib/a.js +// @outFile: /lib/a.js var v = undefined satisfies 1; diff --git a/crates/swc_ecma_parser/tests/tsc/uniqueSymbolsDeclarationsInJs.json b/crates/swc_ecma_parser/tests/tsc/uniqueSymbolsDeclarationsInJs.json index 2c7e53de0c87..132bb11890ea 100644 --- a/crates/swc_ecma_parser/tests/tsc/uniqueSymbolsDeclarationsInJs.json +++ b/crates/swc_ecma_parser/tests/tsc/uniqueSymbolsDeclarationsInJs.json @@ -1,8 +1,8 @@ { "type": "Script", "span": { - "start": 234, - "end": 710, + "start": 238, + "end": 714, "ctxt": 0 }, "body": [ @@ -11,8 +11,8 @@ "identifier": { "type": "Identifier", "span": { - "start": 240, - "end": 241, + "start": 244, + "end": 245, "ctxt": 0 }, "value": "C", @@ -20,8 +20,8 @@ }, "declare": false, "span": { - "start": 234, - "end": 660, + "start": 238, + "end": 664, "ctxt": 0 }, "decorators": [], @@ -29,15 +29,15 @@ { "type": "ClassProperty", "span": { - "start": 281, - "end": 318, + "start": 285, + "end": 322, "ctxt": 0 }, "key": { "type": "Identifier", "span": { - "start": 288, - "end": 306, + "start": 292, + "end": 310, "ctxt": 0 }, "value": "readonlyStaticCall", @@ -46,15 +46,15 @@ "value": { "type": "CallExpression", "span": { - "start": 309, - "end": 317, + "start": 313, + "end": 321, "ctxt": 0 }, "callee": { "type": "Identifier", "span": { - "start": 309, - "end": 315, + "start": 313, + "end": 319, "ctxt": 0 }, "value": "Symbol", @@ -77,15 +77,15 @@ { "type": "ClassProperty", "span": { - "start": 385, - "end": 411, + "start": 389, + "end": 415, "ctxt": 0 }, "key": { "type": "Identifier", "span": { - "start": 392, - "end": 410, + "start": 396, + "end": 414, "ctxt": 0 }, "value": "readonlyStaticType", @@ -106,15 +106,15 @@ { "type": "ClassProperty", "span": { - "start": 478, - "end": 522, + "start": 482, + "end": 526, "ctxt": 0 }, "key": { "type": "Identifier", "span": { - "start": 485, - "end": 510, + "start": 489, + "end": 514, "ctxt": 0 }, "value": "readonlyStaticTypeAndCall", @@ -123,15 +123,15 @@ "value": { "type": "CallExpression", "span": { - "start": 513, - "end": 521, + "start": 517, + "end": 525, "ctxt": 0 }, "callee": { "type": "Identifier", "span": { - "start": 513, - "end": 519, + "start": 517, + "end": 523, "ctxt": 0 }, "value": "Symbol", @@ -154,15 +154,15 @@ { "type": "ClassProperty", "span": { - "start": 527, - "end": 565, + "start": 531, + "end": 569, "ctxt": 0 }, "key": { "type": "Identifier", "span": { - "start": 534, - "end": 553, + "start": 538, + "end": 557, "ctxt": 0 }, "value": "readwriteStaticCall", @@ -171,15 +171,15 @@ "value": { "type": "CallExpression", "span": { - "start": 556, - "end": 564, + "start": 560, + "end": 568, "ctxt": 0 }, "callee": { "type": "Identifier", "span": { - "start": 556, - "end": 562, + "start": 560, + "end": 566, "ctxt": 0 }, "value": "Symbol", @@ -202,15 +202,15 @@ { "type": "ClassProperty", "span": { - "start": 604, - "end": 628, + "start": 608, + "end": 632, "ctxt": 0 }, "key": { "type": "Identifier", "span": { - "start": 604, - "end": 616, + "start": 608, + "end": 620, "ctxt": 0 }, "value": "readonlyCall", @@ -219,15 +219,15 @@ "value": { "type": "CallExpression", "span": { - "start": 619, - "end": 627, + "start": 623, + "end": 631, "ctxt": 0 }, "callee": { "type": "Identifier", "span": { - "start": 619, - "end": 625, + "start": 623, + "end": 629, "ctxt": 0 }, "value": "Symbol", @@ -250,15 +250,15 @@ { "type": "ClassProperty", "span": { - "start": 633, - "end": 658, + "start": 637, + "end": 662, "ctxt": 0 }, "key": { "type": "Identifier", "span": { - "start": 633, - "end": 646, + "start": 637, + "end": 650, "ctxt": 0 }, "value": "readwriteCall", @@ -267,15 +267,15 @@ "value": { "type": "CallExpression", "span": { - "start": 649, - "end": 657, + "start": 653, + "end": 661, "ctxt": 0 }, "callee": { "type": "Identifier", "span": { - "start": 649, - "end": 655, + "start": 653, + "end": 659, "ctxt": 0 }, "value": "Symbol", @@ -305,8 +305,8 @@ { "type": "VariableDeclaration", "span": { - "start": 691, - "end": 710, + "start": 695, + "end": 714, "ctxt": 0 }, "kind": "const", @@ -315,15 +315,15 @@ { "type": "VariableDeclarator", "span": { - "start": 697, - "end": 709, + "start": 701, + "end": 713, "ctxt": 0 }, "id": { "type": "Identifier", "span": { - "start": 697, - "end": 698, + "start": 701, + "end": 702, "ctxt": 0 }, "value": "a", @@ -333,15 +333,15 @@ "init": { "type": "CallExpression", "span": { - "start": 701, - "end": 709, + "start": 705, + "end": 713, "ctxt": 0 }, "callee": { "type": "Identifier", "span": { - "start": 701, - "end": 707, + "start": 705, + "end": 711, "ctxt": 0 }, "value": "Symbol", diff --git a/crates/swc_ecma_parser/tests/tsc/uniqueSymbolsDeclarationsInJs.ts b/crates/swc_ecma_parser/tests/tsc/uniqueSymbolsDeclarationsInJs.ts index 9ba9147faac4..55f36b812b11 100644 --- a/crates/swc_ecma_parser/tests/tsc/uniqueSymbolsDeclarationsInJs.ts +++ b/crates/swc_ecma_parser/tests/tsc/uniqueSymbolsDeclarationsInJs.ts @@ -4,7 +4,7 @@ // @allowJs: true // @checkJs: true // @filename: uniqueSymbolsDeclarationsInJs.js -// @out: uniqueSymbolsDeclarationsInJs-out.js +// @outFile: uniqueSymbolsDeclarationsInJs-out.js // @useDefineForClassFields: false // classes diff --git a/crates/swc_ecma_parser/tests/tsc/uniqueSymbolsDeclarationsInJsErrors.json b/crates/swc_ecma_parser/tests/tsc/uniqueSymbolsDeclarationsInJsErrors.json index cfff295badff..1cc1413c1007 100644 --- a/crates/swc_ecma_parser/tests/tsc/uniqueSymbolsDeclarationsInJsErrors.json +++ b/crates/swc_ecma_parser/tests/tsc/uniqueSymbolsDeclarationsInJsErrors.json @@ -1,8 +1,8 @@ { "type": "Script", "span": { - "start": 235, - "end": 481, + "start": 239, + "end": 485, "ctxt": 0 }, "body": [ @@ -11,8 +11,8 @@ "identifier": { "type": "Identifier", "span": { - "start": 241, - "end": 242, + "start": 245, + "end": 246, "ctxt": 0 }, "value": "C", @@ -20,8 +20,8 @@ }, "declare": false, "span": { - "start": 235, - "end": 481, + "start": 239, + "end": 485, "ctxt": 0 }, "decorators": [], @@ -29,15 +29,15 @@ { "type": "ClassProperty", "span": { - "start": 294, - "end": 321, + "start": 298, + "end": 325, "ctxt": 0 }, "key": { "type": "Identifier", "span": { - "start": 301, - "end": 320, + "start": 305, + "end": 324, "ctxt": 0 }, "value": "readwriteStaticType", @@ -58,15 +58,15 @@ { "type": "ClassProperty", "span": { - "start": 388, - "end": 408, + "start": 392, + "end": 412, "ctxt": 0 }, "key": { "type": "Identifier", "span": { - "start": 395, - "end": 407, + "start": 399, + "end": 411, "ctxt": 0 }, "value": "readonlyType", @@ -87,15 +87,15 @@ { "type": "ClassProperty", "span": { - "start": 458, - "end": 479, + "start": 462, + "end": 483, "ctxt": 0 }, "key": { "type": "Identifier", "span": { - "start": 465, - "end": 478, + "start": 469, + "end": 482, "ctxt": 0 }, "value": "readwriteType", diff --git a/crates/swc_ecma_parser/tests/tsc/uniqueSymbolsDeclarationsInJsErrors.ts b/crates/swc_ecma_parser/tests/tsc/uniqueSymbolsDeclarationsInJsErrors.ts index 8bf87812bb09..b47e25a690f8 100644 --- a/crates/swc_ecma_parser/tests/tsc/uniqueSymbolsDeclarationsInJsErrors.ts +++ b/crates/swc_ecma_parser/tests/tsc/uniqueSymbolsDeclarationsInJsErrors.ts @@ -4,7 +4,7 @@ // @allowJs: true // @checkJs: true // @filename: uniqueSymbolsDeclarationsInJsErrors.js -// @out: uniqueSymbolsDeclarationsInJsErrors-out.js +// @outFile: uniqueSymbolsDeclarationsInJsErrors-out.js // @useDefineForClassFields: false class C { @@ -21,4 +21,4 @@ class C { * @type {unique symbol} */ static readwriteType; -} \ No newline at end of file +} diff --git a/crates/swc_ecma_parser/tests/tsc/usingDeclarationsWithImportHelpers.ts b/crates/swc_ecma_parser/tests/tsc/usingDeclarationsWithImportHelpers.ts index ef6d86cc7297..39d0d9436fb5 100644 --- a/crates/swc_ecma_parser/tests/tsc/usingDeclarationsWithImportHelpers.ts +++ b/crates/swc_ecma_parser/tests/tsc/usingDeclarationsWithImportHelpers.ts @@ -1,4 +1,4 @@ -// @target: esnext +// @target: es2022 // @module: esnext // @lib: esnext // @importHelpers: true diff --git a/crates/swc_ecma_parser/tests/tsc/variadicTuples1.json b/crates/swc_ecma_parser/tests/tsc/variadicTuples1.json index 4043cf14e2c3..bb71a47bcd17 100644 --- a/crates/swc_ecma_parser/tests/tsc/variadicTuples1.json +++ b/crates/swc_ecma_parser/tests/tsc/variadicTuples1.json @@ -2,7 +2,7 @@ "type": "Script", "span": { "start": 70, - "end": 13612, + "end": 13637, "ctxt": 0 }, "body": [ @@ -30407,6 +30407,62 @@ ] } } + }, + { + "type": "TsTypeAliasDeclaration", + "span": { + "start": 13614, + "end": 13637, + "ctxt": 0 + }, + "declare": false, + "id": { + "type": "Identifier", + "span": { + "start": 13619, + "end": 13625, + "ctxt": 0 + }, + "value": "AnyArr", + "optional": false + }, + "typeParams": null, + "typeAnnotation": { + "type": "TsTupleType", + "span": { + "start": 13628, + "end": 13636, + "ctxt": 0 + }, + "elemTypes": [ + { + "type": "TsTupleElement", + "span": { + "start": 13629, + "end": 13635, + "ctxt": 0 + }, + "label": null, + "ty": { + "type": "TsRestType", + "span": { + "start": 13629, + "end": 13635, + "ctxt": 0 + }, + "typeAnnotation": { + "type": "TsKeywordType", + "span": { + "start": 13632, + "end": 13635, + "ctxt": 0 + }, + "kind": "any" + } + } + } + ] + } } ], "interpreter": null diff --git a/crates/swc_ecma_parser/tests/tsc/variadicTuples1.ts b/crates/swc_ecma_parser/tests/tsc/variadicTuples1.ts index 23eec07a6843..1c8b73e26d6a 100644 --- a/crates/swc_ecma_parser/tests/tsc/variadicTuples1.ts +++ b/crates/swc_ecma_parser/tests/tsc/variadicTuples1.ts @@ -421,3 +421,5 @@ type U3 = [...[string, number], boolean]; type ToStringLength1 = `${T['length']}`; type ToStringLength2 = `${[...T]['length']}`; + +type AnyArr = [...any]; diff --git a/crates/swc_ecma_parser/tests/typescript.rs b/crates/swc_ecma_parser/tests/typescript.rs index a55c6df25817..0495747ee189 100644 --- a/crates/swc_ecma_parser/tests/typescript.rs +++ b/crates/swc_ecma_parser/tests/typescript.rs @@ -78,7 +78,13 @@ fn spec(file: PathBuf) { run_spec(&file, &output); } -#[testing::fixture("tests/tsc/**/*.ts", exclude("parserArrowFunctionExpression11"))] +#[testing::fixture( + "tests/tsc/**/*.ts", + exclude( + "parserArrowFunctionExpression11", + "esDecorators-decoratorExpression.1" + ) +)] fn tsc_spec(file: PathBuf) { let output = file.with_extension("json"); run_spec(&file, &output); diff --git a/crates/swc_ecma_transforms_typescript/tests/strip_correctness.rs b/crates/swc_ecma_transforms_typescript/tests/strip_correctness.rs index 4a6dcfc8e297..8629fb871ad6 100644 --- a/crates/swc_ecma_transforms_typescript/tests/strip_correctness.rs +++ b/crates/swc_ecma_transforms_typescript/tests/strip_correctness.rs @@ -63,6 +63,9 @@ fn identity(entry: PathBuf) { "esDecorators-classDeclaration-classSuper.2.ts", "esDecorators-classExpression-classSuper.2.ts", "contextualTypes.ts", + "decoratorOnClassMethod12.ts", + "decoratorExpression.2.ts", + "preservesThis.ts", ]; // TODO: Unignore const enum test