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

Commit 01c34f4

Browse files
authored
Fix: Ensure exports applied to TSModuleDeclaration (#375)
1 parent 38bd1ae commit 01c34f4

File tree

5 files changed

+1468
-1
lines changed

5 files changed

+1468
-1
lines changed

lib/ast-node-types.js

+1
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,7 @@ module.exports = {
113113
TSEnumDeclaration: "TSEnumDeclaration",
114114
TSEnumMember: "TSEnumMember",
115115
TSExportAssignment: "TSExportAssignment",
116+
TSExportKeyword: "TSExportKeyword",
116117
TSIndexSignature: "TSIndexSignature",
117118
TSInterfaceBody: "TSInterfaceBody",
118119
TSInterfaceDeclaration: "TSInterfaceDeclaration",

lib/convert.js

+4-1
Original file line numberDiff line numberDiff line change
@@ -2096,10 +2096,13 @@ module.exports = function convert(config) {
20962096
type: AST_NODE_TYPES.TSModuleDeclaration,
20972097
id: convertChild(node.name)
20982098
});
2099-
applyModifiersToResult(node.modifiers);
21002099
if (node.body) {
21012100
result.body = convertChild(node.body);
21022101
}
2102+
// apply modifiers first...
2103+
applyModifiersToResult(node.modifiers);
2104+
// ...then check for exports
2105+
result = nodeUtils.fixExports(node, result, ast);
21032106
break;
21042107
}
21052108

tests/ast-alignment/spec.js

+1
Original file line numberDiff line numberDiff line change
@@ -461,6 +461,7 @@ const fixturePatternsToTest = [
461461
// "typescript/basics/export-type-function-declaration.src.ts", // babylon parse errors
462462
// "typescript/basics/interface-with-all-property-types.src.ts", // babylon parse errors
463463
// "typescript/basics/interface-with-construct-signature-with-parameter-accessibility.src.ts", // babylon parse errors
464+
// "typescript/namespaces-and-modules/nested-internal-module.src.ts", // babylon parse errors
464465

465466
/**
466467
* typescript-eslint-parser erroring, but babylon not.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
module A {
2+
3+
export var x = 'hello world'
4+
export class Point {
5+
constructor(public x: number, public y: number) { }
6+
}
7+
export module B {
8+
export interface Id {
9+
name: string;
10+
}
11+
}
12+
}

0 commit comments

Comments
 (0)