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

Commit 7827666

Browse files
armano2JamesHenry
authored andcommitted
feat: add support for export equal declaration (#71)
BREAKING CHANGE: This changes the AST
1 parent 9947036 commit 7827666

File tree

7 files changed

+528
-1
lines changed

7 files changed

+528
-1
lines changed

src/ast-node-types.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,7 @@ export const AST_NODE_TYPES: { [key: string]: string } = {
115115
TSEnumMember: 'TSEnumMember',
116116
TSExportAssignment: 'TSExportAssignment',
117117
TSExportKeyword: 'TSExportKeyword',
118+
TSExternalModuleReference: 'TSExternalModuleReference',
118119
TSImportType: 'TSImportType',
119120
TSInferType: 'TSInferType',
120121
TSLiteralType: 'TSLiteralType',
@@ -123,6 +124,7 @@ export const AST_NODE_TYPES: { [key: string]: string } = {
123124
TSInterfaceBody: 'TSInterfaceBody',
124125
TSInterfaceDeclaration: 'TSInterfaceDeclaration',
125126
TSInterfaceHeritage: 'TSInterfaceHeritage',
127+
TSImportEqualsDeclaration: 'TSImportEqualsDeclaration',
126128
TSFunctionType: 'TSFunctionType',
127129
TSMethodSignature: 'TSMethodSignature',
128130
TSModuleBlock: 'TSModuleBlock',

src/convert.ts

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2689,6 +2689,23 @@ export default function convert(config: ConvertConfig): ESTreeNode | null {
26892689
});
26902690
break;
26912691
}
2692+
case SyntaxKind.ImportEqualsDeclaration: {
2693+
Object.assign(result, {
2694+
type: AST_NODE_TYPES.TSImportEqualsDeclaration,
2695+
id: convertChild(node.name),
2696+
moduleReference: convertChild(node.moduleReference),
2697+
isExport: nodeUtils.hasModifier(SyntaxKind.ExportKeyword, node)
2698+
});
2699+
break;
2700+
}
2701+
case SyntaxKind.ExternalModuleReference: {
2702+
Object.assign(result, {
2703+
type: AST_NODE_TYPES.TSExternalModuleReference,
2704+
expression: convertChild(node.expression)
2705+
});
2706+
break;
2707+
}
2708+
26922709
default:
26932710
deeplyCopy();
26942711
}

tests/ast-alignment/fixtures-to-test.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -390,7 +390,9 @@ let fixturePatternConfigsToTest = [
390390
],
391391
ignoreSourceType: [
392392
// https://github.com/babel/babel/issues/9213
393-
'export-assignment'
393+
'export-assignment',
394+
'import-equal-declaration',
395+
'import-export-equal-declaration'
394396
]
395397
}),
396398

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
import foo = require('bar');
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export import foo = require('bar');

tests/lib/__snapshots__/semantic-diagnostics-enabled.ts.snap

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1699,6 +1699,10 @@ exports[`Parse all fixtures with "errorOnTypeScriptSyntaticAndSemanticIssues" en
16991699

17001700
exports[`Parse all fixtures with "errorOnTypeScriptSyntaticAndSemanticIssues" enabled fixtures/typescript/basics/function-with-types-assignation.src.ts.src 1`] = `"TEST OUTPUT: No semantic or syntactic issues found"`;
17011701

1702+
exports[`Parse all fixtures with "errorOnTypeScriptSyntaticAndSemanticIssues" enabled fixtures/typescript/basics/import-equal-declaration.src.ts.src 1`] = `"TEST OUTPUT: No semantic or syntactic issues found"`;
1703+
1704+
exports[`Parse all fixtures with "errorOnTypeScriptSyntaticAndSemanticIssues" enabled fixtures/typescript/basics/import-export-equal-declaration.src.ts.src 1`] = `"TEST OUTPUT: No semantic or syntactic issues found"`;
1705+
17021706
exports[`Parse all fixtures with "errorOnTypeScriptSyntaticAndSemanticIssues" enabled fixtures/typescript/basics/import-type.src.ts.src 1`] = `"TEST OUTPUT: No semantic or syntactic issues found"`;
17031707

17041708
exports[`Parse all fixtures with "errorOnTypeScriptSyntaticAndSemanticIssues" enabled fixtures/typescript/basics/import-type-with-type-parameters-in-type-reference.src.ts.src 1`] = `"TEST OUTPUT: No semantic or syntactic issues found"`;

0 commit comments

Comments
 (0)