Skip to content
This repository was archived by the owner on Jan 19, 2019. It is now read-only.

Commit 1f20557

Browse files
soda0289JamesHenry
authored andcommitted
Fix: Use TSExportAssignment node type (fixes #304) (#317)
1 parent b26cda1 commit 1f20557

File tree

4 files changed

+71
-4
lines changed

4 files changed

+71
-4
lines changed

lib/ast-node-types.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,7 @@ module.exports = {
108108
TSConstructSignature: "TSConstructSignature",
109109
TSDeclareKeyword: "TSDeclareKeyword",
110110
TSEnumDeclaration: "TSEnumDeclaration",
111+
TSExportAssignment: "TSExportAssigment",
111112
TSIndexSignature: "TSIndexSignature",
112113
TSInterfaceBody: "TSInterfaceBody",
113114
TSInterfaceDeclaration: "TSInterfaceDeclaration",

lib/convert.js

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1330,10 +1330,17 @@ module.exports = function convert(config) {
13301330
break;
13311331

13321332
case SyntaxKind.ExportAssignment:
1333-
Object.assign(result, {
1334-
type: AST_NODE_TYPES.ExportDefaultDeclaration,
1335-
declaration: convertChild(node.expression)
1336-
});
1333+
if (node.isExportEquals) {
1334+
Object.assign(result, {
1335+
type: AST_NODE_TYPES.TSExportAssignment,
1336+
expression: convertChild(node.expression)
1337+
});
1338+
} else {
1339+
Object.assign(result, {
1340+
type: AST_NODE_TYPES.ExportDefaultDeclaration,
1341+
declaration: convertChild(node.expression)
1342+
});
1343+
}
13371344
break;
13381345

13391346
// Unary Operations
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export = foo;

tests/lib/__snapshots__/typescript.js.snap

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8898,6 +8898,64 @@ Object {
88988898
}
88998899
`;
89008900

8901+
exports[`typescript fixtures/basics/export-assignment.src 1`] = `
8902+
Object {
8903+
"body": Array [
8904+
Object {
8905+
"expression": Object {
8906+
"loc": Object {
8907+
"end": Object {
8908+
"column": 12,
8909+
"line": 1,
8910+
},
8911+
"start": Object {
8912+
"column": 9,
8913+
"line": 1,
8914+
},
8915+
},
8916+
"name": "foo",
8917+
"range": Array [
8918+
9,
8919+
12,
8920+
],
8921+
"type": "Identifier",
8922+
},
8923+
"loc": Object {
8924+
"end": Object {
8925+
"column": 13,
8926+
"line": 1,
8927+
},
8928+
"start": Object {
8929+
"column": 0,
8930+
"line": 1,
8931+
},
8932+
},
8933+
"range": Array [
8934+
0,
8935+
13,
8936+
],
8937+
"type": "TSExportAssigment",
8938+
},
8939+
],
8940+
"loc": Object {
8941+
"end": Object {
8942+
"column": 13,
8943+
"line": 1,
8944+
},
8945+
"start": Object {
8946+
"column": 0,
8947+
"line": 1,
8948+
},
8949+
},
8950+
"range": Array [
8951+
0,
8952+
13,
8953+
],
8954+
"sourceType": "module",
8955+
"type": "Program",
8956+
}
8957+
`;
8958+
89018959
exports[`typescript fixtures/basics/export-default-class-with-generic.src 1`] = `
89028960
Object {
89038961
"body": Array [

0 commit comments

Comments
 (0)