File tree Expand file tree Collapse file tree 4 files changed +18
-4
lines changed
Expand file tree Collapse file tree 4 files changed +18
-4
lines changed Original file line number Diff line number Diff line change @@ -7,6 +7,7 @@ declare export { module as newModule };
77declare export { GeneratorOptions } from \\ "@babel/generator\\ ";
88declare export { GeneratorOptions as NewGeneratorOptions } from \\ "@babel/generator\\ ";
99declare export * from \\ "typescript\\ "
10+ declare export * as t from \\ "@babel/types\\ ";
1011"
1112` ;
1213
Original file line number Diff line number Diff line change @@ -9,10 +9,10 @@ export { module as newModule }
99export { GeneratorOptions } from "@babel/generator";
1010export { GeneratorOptions as NewGeneratorOptions } from "@babel/generator";
1111export * from 'typescript';
12+ export * as t from "@babel/types";
1213//enable when typescript supports
1314//export traverse, { Visitor, NodePath } from "@babel/traverse";
14- //export template from "@babel/template";
15- //export * as t from "@babel/types";` ;
15+ //export template from "@babel/template";` ;
1616 const result = compiler . compileDefinitionString ( ts , { quiet : true } ) ;
1717 expect ( beautify ( result ) ) . toMatchSnapshot ( ) ;
1818 expect ( result ) . not . toBeValidFlowTypeDeclarations ( ) ; // cannot-resolve-module
Original file line number Diff line number Diff line change 11import type { RawNode } from "./node" ;
22import type { Expression , ExportDeclaration as RawExport } from "typescript" ;
3+ import { isNamespaceExport } from "typescript" ;
34import * as printers from "../printers" ;
45import Node from "./node" ;
56
@@ -17,14 +18,17 @@ export default class ExportDeclaration extends Node<ExportDeclarationType> {
1718 print ( ) : string {
1819 //TODO: move to printers
1920 if ( this . raw . exportClause ) {
20- // @ts -expect-error todo(flow->ts)
21- const elements = this . raw . exportClause . elements ;
2221 const isTypeImport = this . raw . isTypeOnly ;
2322
2423 let specifier = "" ;
2524 if ( this . raw . moduleSpecifier )
2625 specifier = `from '${ this . raw . moduleSpecifier . text } ';` ;
2726
27+ if ( isNamespaceExport ( this . raw . exportClause ) ) {
28+ return `declare export * as ${ this . raw . exportClause . name . escapedText } ${ specifier } \n` ;
29+ }
30+ const elements = this . raw . exportClause . elements ;
31+
2832 const generateOutput = prefix => {
2933 return `${ prefix } {
3034 ${ elements . map ( node => printers . node . printType ( node ) ) }
Original file line number Diff line number Diff line change @@ -37,6 +37,15 @@ export const parseNameFromNode = (node: RawNode): string => {
3737 names . push ( parseNameFromNode ( child ) ) ;
3838 } ) ;
3939 return names . join ( "," ) ;
40+ } else if ( ts . isIdentifier ( node ) ) {
41+ /*
42+ * Parse name for NamespaceExport, please refer to the PR: https://github.com/joarwilk/flowgen/pull/131
43+ * Based on the test, seems it only affects NamespaceExport
44+ * May need someone to update the implementation later if there are any issues
45+ */
46+ if ( node . escapedText && typeof node . escapedText === "string" ) {
47+ return node . escapedText ;
48+ }
4049 }
4150 switch ( node . kind ) {
4251 case ts . SyntaxKind . FunctionDeclaration :
You can’t perform that action at this time.
0 commit comments