From c37558a384cbc16476a8064c875516728bf8ac39 Mon Sep 17 00:00:00 2001 From: CPunisher <1343316114@qq.com> Date: Tue, 24 Sep 2024 14:47:20 +0800 Subject: [PATCH] add tests --- .../tests/typescript/issue-8627/1/input.ts | 3 + .../typescript/issue-8627/1/input.ts.json | 122 ++++++++++++++++++ .../tests/typescript/issue-8627/2/input.ts | 3 + .../typescript/issue-8627/2/input.ts.json | 122 ++++++++++++++++++ 4 files changed, 250 insertions(+) create mode 100644 crates/swc_ecma_parser/tests/typescript/issue-8627/1/input.ts create mode 100644 crates/swc_ecma_parser/tests/typescript/issue-8627/1/input.ts.json create mode 100644 crates/swc_ecma_parser/tests/typescript/issue-8627/2/input.ts create mode 100644 crates/swc_ecma_parser/tests/typescript/issue-8627/2/input.ts.json diff --git a/crates/swc_ecma_parser/tests/typescript/issue-8627/1/input.ts b/crates/swc_ecma_parser/tests/typescript/issue-8627/1/input.ts new file mode 100644 index 000000000000..1d369de63040 --- /dev/null +++ b/crates/swc_ecma_parser/tests/typescript/issue-8627/1/input.ts @@ -0,0 +1,3 @@ +class Module {} + +export default Module as unknown; diff --git a/crates/swc_ecma_parser/tests/typescript/issue-8627/1/input.ts.json b/crates/swc_ecma_parser/tests/typescript/issue-8627/1/input.ts.json new file mode 100644 index 000000000000..90fb2e5cb576 --- /dev/null +++ b/crates/swc_ecma_parser/tests/typescript/issue-8627/1/input.ts.json @@ -0,0 +1,122 @@ +{ + "type": "Module", + "span": { + "start": 1, + "end": 62 + }, + "body": [ + { + "type": "ClassDeclaration", + "identifier": { + "type": "Identifier", + "span": { + "start": 7, + "end": 13 + }, + "ctxt": 0, + "value": "Module", + "optional": false + }, + "declare": false, + "span": { + "start": 1, + "end": 19 + }, + "ctxt": 0, + "decorators": [], + "body": [], + "superClass": null, + "isAbstract": false, + "typeParams": { + "type": "TsTypeParameterDeclaration", + "span": { + "start": 13, + "end": 16 + }, + "parameters": [ + { + "type": "TsTypeParameter", + "span": { + "start": 14, + "end": 15 + }, + "name": { + "type": "Identifier", + "span": { + "start": 14, + "end": 15 + }, + "ctxt": 0, + "value": "T", + "optional": false + }, + "in": false, + "out": false, + "const": false, + "constraint": null, + "default": null + } + ] + }, + "superTypeParams": null, + "implements": [] + }, + { + "type": "ExportDefaultExpression", + "span": { + "start": 21, + "end": 62 + }, + "expression": { + "type": "TsAsExpression", + "span": { + "start": 36, + "end": 61 + }, + "expression": { + "type": "TsInstantiation", + "span": { + "start": 36, + "end": 50 + }, + "expression": { + "type": "Identifier", + "span": { + "start": 36, + "end": 42 + }, + "ctxt": 0, + "value": "Module", + "optional": false + }, + "typeArguments": { + "type": "TsTypeParameterInstantiation", + "span": { + "start": 42, + "end": 50 + }, + "params": [ + { + "type": "TsKeywordType", + "span": { + "start": 43, + "end": 49 + }, + "kind": "number" + } + ] + } + }, + "typeAnnotation": { + "type": "TsKeywordType", + "span": { + "start": 54, + "end": 61 + }, + "kind": "unknown" + } + } + } + ], + "interpreter": null +} diff --git a/crates/swc_ecma_parser/tests/typescript/issue-8627/2/input.ts b/crates/swc_ecma_parser/tests/typescript/issue-8627/2/input.ts new file mode 100644 index 000000000000..6cd3b3e72b2f --- /dev/null +++ b/crates/swc_ecma_parser/tests/typescript/issue-8627/2/input.ts @@ -0,0 +1,3 @@ +class Module {} + +export default Module satisfies unknown; diff --git a/crates/swc_ecma_parser/tests/typescript/issue-8627/2/input.ts.json b/crates/swc_ecma_parser/tests/typescript/issue-8627/2/input.ts.json new file mode 100644 index 000000000000..165f7c36af34 --- /dev/null +++ b/crates/swc_ecma_parser/tests/typescript/issue-8627/2/input.ts.json @@ -0,0 +1,122 @@ +{ + "type": "Module", + "span": { + "start": 1, + "end": 69 + }, + "body": [ + { + "type": "ClassDeclaration", + "identifier": { + "type": "Identifier", + "span": { + "start": 7, + "end": 13 + }, + "ctxt": 0, + "value": "Module", + "optional": false + }, + "declare": false, + "span": { + "start": 1, + "end": 19 + }, + "ctxt": 0, + "decorators": [], + "body": [], + "superClass": null, + "isAbstract": false, + "typeParams": { + "type": "TsTypeParameterDeclaration", + "span": { + "start": 13, + "end": 16 + }, + "parameters": [ + { + "type": "TsTypeParameter", + "span": { + "start": 14, + "end": 15 + }, + "name": { + "type": "Identifier", + "span": { + "start": 14, + "end": 15 + }, + "ctxt": 0, + "value": "T", + "optional": false + }, + "in": false, + "out": false, + "const": false, + "constraint": null, + "default": null + } + ] + }, + "superTypeParams": null, + "implements": [] + }, + { + "type": "ExportDefaultExpression", + "span": { + "start": 21, + "end": 69 + }, + "expression": { + "type": "TsSatisfiesExpression", + "span": { + "start": 36, + "end": 68 + }, + "expression": { + "type": "TsInstantiation", + "span": { + "start": 36, + "end": 50 + }, + "expression": { + "type": "Identifier", + "span": { + "start": 36, + "end": 42 + }, + "ctxt": 0, + "value": "Module", + "optional": false + }, + "typeArguments": { + "type": "TsTypeParameterInstantiation", + "span": { + "start": 42, + "end": 50 + }, + "params": [ + { + "type": "TsKeywordType", + "span": { + "start": 43, + "end": 49 + }, + "kind": "number" + } + ] + } + }, + "typeAnnotation": { + "type": "TsKeywordType", + "span": { + "start": 61, + "end": 68 + }, + "kind": "unknown" + } + } + } + ], + "interpreter": null +}