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

Commit

Permalink
feat: add missing TSNamespaceExportDeclaration node (#87)
Browse files Browse the repository at this point in the history
BREAKING CHANGE: This changes the AST
  • Loading branch information
armano2 authored and JamesHenry committed Jan 4, 2019
1 parent 3ec7fce commit 45d0d31
Show file tree
Hide file tree
Showing 5 changed files with 161 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/ast-node-types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,7 @@ export const AST_NODE_TYPES: { [key: string]: string } = {
TSModuleBlock: 'TSModuleBlock',
TSModuleDeclaration: 'TSModuleDeclaration',
TSNamespaceFunctionDeclaration: 'TSNamespaceFunctionDeclaration',
TSNamespaceExportDeclaration: 'TSNamespaceExportDeclaration',
TSNonNullExpression: 'TSNonNullExpression',
TSNeverKeyword: 'TSNeverKeyword',
TSNullKeyword: 'TSNullKeyword',
Expand Down
7 changes: 7 additions & 0 deletions src/convert.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2711,6 +2711,13 @@ export default function convert(config: ConvertConfig): ESTreeNode | null {
});
break;
}
case SyntaxKind.NamespaceExportDeclaration: {
Object.assign(result, {
type: AST_NODE_TYPES.TSNamespaceExportDeclaration,
id: convertChild(node.name)
});
break;
}

default:
deeplyCopy();
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export as namespace a;
2 changes: 2 additions & 0 deletions tests/lib/__snapshots__/semantic-diagnostics-enabled.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -1760,6 +1760,8 @@ exports[`Parse all fixtures with "errorOnTypeScriptSyntaticAndSemanticIssues" en

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

exports[`Parse all fixtures with "errorOnTypeScriptSyntaticAndSemanticIssues" enabled fixtures/typescript/basics/export-as-namespace.src.ts.src 1`] = `"TEST OUTPUT: No semantic or syntactic issues found"`;

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

exports[`Parse all fixtures with "errorOnTypeScriptSyntaticAndSemanticIssues" enabled fixtures/typescript/basics/export-default-class-with-generic.src.ts.src 1`] = `"TEST OUTPUT: No semantic or syntactic issues found"`;
Expand Down
150 changes: 150 additions & 0 deletions tests/lib/__snapshots__/typescript.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -28708,6 +28708,156 @@ Object {
}
`;

exports[`typescript fixtures/basics/export-as-namespace.src 1`] = `
Object {
"body": Array [
Object {
"id": Object {
"loc": Object {
"end": Object {
"column": 21,
"line": 1,
},
"start": Object {
"column": 20,
"line": 1,
},
},
"name": "a",
"range": Array [
20,
21,
],
"type": "Identifier",
},
"loc": Object {
"end": Object {
"column": 22,
"line": 1,
},
"start": Object {
"column": 0,
"line": 1,
},
},
"range": Array [
0,
22,
],
"type": "TSNamespaceExportDeclaration",
},
],
"loc": Object {
"end": Object {
"column": 0,
"line": 2,
},
"start": Object {
"column": 0,
"line": 1,
},
},
"range": Array [
0,
23,
],
"sourceType": "script",
"tokens": Array [
Object {
"loc": Object {
"end": Object {
"column": 6,
"line": 1,
},
"start": Object {
"column": 0,
"line": 1,
},
},
"range": Array [
0,
6,
],
"type": "Keyword",
"value": "export",
},
Object {
"loc": Object {
"end": Object {
"column": 9,
"line": 1,
},
"start": Object {
"column": 7,
"line": 1,
},
},
"range": Array [
7,
9,
],
"type": "Identifier",
"value": "as",
},
Object {
"loc": Object {
"end": Object {
"column": 19,
"line": 1,
},
"start": Object {
"column": 10,
"line": 1,
},
},
"range": Array [
10,
19,
],
"type": "Identifier",
"value": "namespace",
},
Object {
"loc": Object {
"end": Object {
"column": 21,
"line": 1,
},
"start": Object {
"column": 20,
"line": 1,
},
},
"range": Array [
20,
21,
],
"type": "Identifier",
"value": "a",
},
Object {
"loc": Object {
"end": Object {
"column": 22,
"line": 1,
},
"start": Object {
"column": 21,
"line": 1,
},
},
"range": Array [
21,
22,
],
"type": "Punctuator",
"value": ";",
},
],
"type": "Program",
}
`;

exports[`typescript fixtures/basics/export-assignment.src 1`] = `
Object {
"body": Array [
Expand Down

0 comments on commit 45d0d31

Please sign in to comment.