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

Commit dcd8e88

Browse files
committed
feat: align TSModuleDeclaration with babel/eslint
1 parent 7599aba commit dcd8e88

File tree

4 files changed

+158
-0
lines changed

4 files changed

+158
-0
lines changed

src/convert.ts

+3
Original file line numberDiff line numberDiff line change
@@ -2527,6 +2527,9 @@ export default function convert(config: ConvertConfig): ESTreeNode | null {
25272527
}
25282528
// apply modifiers first...
25292529
applyModifiersToResult((node as any).modifiers);
2530+
if (node.flags & ts.NodeFlags.GlobalAugmentation) {
2531+
result.global = true;
2532+
}
25302533
// ...then check for exports
25312534
result = nodeUtils.fixExports(node, result as any, ast);
25322535
break;

src/temp-types-based-on-js-source.ts

+1
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ export interface ESTreeNode {
3232
decorators?: any;
3333
const?: boolean;
3434
declare?: boolean;
35+
global?: boolean;
3536
modifiers?: any;
3637
body?: any;
3738
params?: any;
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
declare global {
2+
}

tests/lib/__snapshots__/typescript.ts.snap

+152
Original file line numberDiff line numberDiff line change
@@ -66645,6 +66645,158 @@ Object {
6664566645
}
6664666646
`;
6664766647

66648+
exports[`typescript fixtures/namespaces-and-modules/global-module-declaration.src 1`] = `
66649+
Object {
66650+
"body": Array [
66651+
Object {
66652+
"body": Object {
66653+
"body": Array [],
66654+
"loc": Object {
66655+
"end": Object {
66656+
"column": 1,
66657+
"line": 2,
66658+
},
66659+
"start": Object {
66660+
"column": 15,
66661+
"line": 1,
66662+
},
66663+
},
66664+
"range": Array [
66665+
15,
66666+
18,
66667+
],
66668+
"type": "TSModuleBlock",
66669+
},
66670+
"declare": true,
66671+
"global": true,
66672+
"id": Object {
66673+
"loc": Object {
66674+
"end": Object {
66675+
"column": 14,
66676+
"line": 1,
66677+
},
66678+
"start": Object {
66679+
"column": 8,
66680+
"line": 1,
66681+
},
66682+
},
66683+
"name": "global",
66684+
"range": Array [
66685+
8,
66686+
14,
66687+
],
66688+
"type": "Identifier",
66689+
},
66690+
"loc": Object {
66691+
"end": Object {
66692+
"column": 1,
66693+
"line": 2,
66694+
},
66695+
"start": Object {
66696+
"column": 0,
66697+
"line": 1,
66698+
},
66699+
},
66700+
"range": Array [
66701+
0,
66702+
18,
66703+
],
66704+
"type": "TSModuleDeclaration",
66705+
},
66706+
],
66707+
"loc": Object {
66708+
"end": Object {
66709+
"column": 0,
66710+
"line": 3,
66711+
},
66712+
"start": Object {
66713+
"column": 0,
66714+
"line": 1,
66715+
},
66716+
},
66717+
"range": Array [
66718+
0,
66719+
19,
66720+
],
66721+
"sourceType": "script",
66722+
"tokens": Array [
66723+
Object {
66724+
"loc": Object {
66725+
"end": Object {
66726+
"column": 7,
66727+
"line": 1,
66728+
},
66729+
"start": Object {
66730+
"column": 0,
66731+
"line": 1,
66732+
},
66733+
},
66734+
"range": Array [
66735+
0,
66736+
7,
66737+
],
66738+
"type": "Identifier",
66739+
"value": "declare",
66740+
},
66741+
Object {
66742+
"loc": Object {
66743+
"end": Object {
66744+
"column": 14,
66745+
"line": 1,
66746+
},
66747+
"start": Object {
66748+
"column": 8,
66749+
"line": 1,
66750+
},
66751+
},
66752+
"range": Array [
66753+
8,
66754+
14,
66755+
],
66756+
"type": "Keyword",
66757+
"value": "global",
66758+
},
66759+
Object {
66760+
"loc": Object {
66761+
"end": Object {
66762+
"column": 16,
66763+
"line": 1,
66764+
},
66765+
"start": Object {
66766+
"column": 15,
66767+
"line": 1,
66768+
},
66769+
},
66770+
"range": Array [
66771+
15,
66772+
16,
66773+
],
66774+
"type": "Punctuator",
66775+
"value": "{",
66776+
},
66777+
Object {
66778+
"loc": Object {
66779+
"end": Object {
66780+
"column": 1,
66781+
"line": 2,
66782+
},
66783+
"start": Object {
66784+
"column": 0,
66785+
"line": 2,
66786+
},
66787+
},
66788+
"range": Array [
66789+
17,
66790+
18,
66791+
],
66792+
"type": "Punctuator",
66793+
"value": "}",
66794+
},
66795+
],
66796+
"type": "Program",
66797+
}
66798+
`;
66799+
6664866800
exports[`typescript fixtures/namespaces-and-modules/module-with-default-exports.src 1`] = `
6664966801
Object {
6665066802
"body": Array [

0 commit comments

Comments
 (0)