Skip to content

Commit

Permalink
add tests
Browse files Browse the repository at this point in the history
  • Loading branch information
CPunisher committed Sep 24, 2024
1 parent d056bcb commit c37558a
Show file tree
Hide file tree
Showing 4 changed files with 250 additions and 0 deletions.
3 changes: 3 additions & 0 deletions crates/swc_ecma_parser/tests/typescript/issue-8627/1/input.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
class Module<T> {}

export default Module<number> as unknown;
122 changes: 122 additions & 0 deletions crates/swc_ecma_parser/tests/typescript/issue-8627/1/input.ts.json
Original file line number Diff line number Diff line change
@@ -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
}
3 changes: 3 additions & 0 deletions crates/swc_ecma_parser/tests/typescript/issue-8627/2/input.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
class Module<T> {}

export default Module<number> satisfies unknown;
122 changes: 122 additions & 0 deletions crates/swc_ecma_parser/tests/typescript/issue-8627/2/input.ts.json
Original file line number Diff line number Diff line change
@@ -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
}

0 comments on commit c37558a

Please sign in to comment.