Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Add "exportKind: type" when needed with TS (#11157)
* Add "exportKind: type" to TS type export declratation

Co-authored-by: Henry Zhu <smiley.we@gmail.com>
Co-authored-by: Huáng Jùnliàng <jlhwung@gmail.com>
Co-authored-by: Siddhant N Trivedi <sidntrivedi012@gmail.com>

* Add test to @babel/generator

Co-authored-by: Henry Zhu <hi@henryzoo.com>
Co-authored-by: Huáng Jùnliàng <jlhwung@gmail.com>
Co-authored-by: Siddhant N Trivedi <sidntrivedi012@gmail.com>
  • Loading branch information
4 people committed Mar 2, 2020
commit 4ade5785815124d6e4740fd9117043573298cead
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
export interface A {}
export type B = string;
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
export interface A {}
export type B = string;
8 changes: 8 additions & 0 deletions packages/babel-parser/src/plugins/typescript/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2127,6 +2127,14 @@ export default (superClass: Class<Parser>): Class<Parser> =>
if (!declaration) {
declaration = super.parseExportDeclaration(node);
}
if (
declaration &&
(declaration.type === "TSInterfaceDeclaration" ||
declaration.type === "TSTypeAliasDeclaration" ||
isDeclare)
) {
node.exportKind = "type";
}

if (declaration && isDeclare) {
// Reset location to include `declare` in range
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@
"column": 29
}
},
"exportKind": "value",
"exportKind": "type",
"specifiers": [],
"source": null,
"declaration": {
Expand Down Expand Up @@ -229,7 +229,7 @@
"column": 21
}
},
"exportKind": "value",
"exportKind": "type",
"specifiers": [],
"source": null,
"declaration": {
Expand Down Expand Up @@ -427,7 +427,7 @@
"column": 27
}
},
"exportKind": "value",
"exportKind": "type",
"specifiers": [],
"source": null,
"declaration": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
"column": 30
}
},
"exportKind": "value",
"exportKind": "type",
"specifiers": [],
"source": null,
"declaration": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
"column": 31
}
},
"exportKind": "value",
"exportKind": "type",
"specifiers": [],
"source": null,
"declaration": {
Expand Down Expand Up @@ -143,7 +143,7 @@
"column": 34
}
},
"exportKind": "value",
"exportKind": "type",
"specifiers": [],
"source": null,
"declaration": {
Expand Down Expand Up @@ -227,7 +227,7 @@
"column": 25
}
},
"exportKind": "value",
"exportKind": "type",
"specifiers": [],
"source": null,
"declaration": {
Expand Down Expand Up @@ -295,7 +295,7 @@
"column": 29
}
},
"exportKind": "value",
"exportKind": "type",
"specifiers": [],
"source": null,
"declaration": {
Expand Down Expand Up @@ -362,7 +362,7 @@
"column": 31
}
},
"exportKind": "value",
"exportKind": "type",
"specifiers": [],
"source": null,
"declaration": {
Expand Down Expand Up @@ -428,7 +428,7 @@
"column": 26
}
},
"exportKind": "value",
"exportKind": "type",
"specifiers": [],
"source": null,
"declaration": {
Expand Down Expand Up @@ -495,7 +495,7 @@
"column": 29
}
},
"exportKind": "value",
"exportKind": "type",
"specifiers": [],
"source": null,
"declaration": {
Expand Down Expand Up @@ -562,7 +562,7 @@
"column": 26
}
},
"exportKind": "value",
"exportKind": "type",
"specifiers": [],
"source": null,
"declaration": {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
export type A = 2;
export interface B {}
export declare function a(): string;
export declare var b: string;
Loading