File tree Expand file tree Collapse file tree 1 file changed +6
-2
lines changed Expand file tree Collapse file tree 1 file changed +6
-2
lines changed Original file line number Diff line number Diff line change @@ -92,6 +92,10 @@ module.exports = {
92
92
result . typeParameters = node . init . typeParameters && node . init . typeParameters . params && node . init . typeParameters . params . length ? node . init . typeParameters . params . map ( t => sourceCode . getText ( t ) ) . join ( ", " ) : null ;
93
93
}
94
94
95
+ if ( result . typeAnnotation && ! result . returnType ) {
96
+ result . returnType = `ReturnType<${ result . typeAnnotation } >` ;
97
+ }
98
+
95
99
return result ;
96
100
}
97
101
@@ -106,9 +110,9 @@ module.exports = {
106
110
case "declaration" :
107
111
return `${ data . async ? "async " : "" } function${ data . name ? ` ${ data . name } ` : "" } ${ data . typeParameters ? `<${ data . typeParameters } >` : "" } (${ data . params ? data . params : "" } )${ data . returnType ? `: ${ data . returnType } ` : "" } ` ;
108
112
case "expression" :
109
- return `${ data . kind } ${ data . name } = ${ data . async ? "async " : "" } function${ data . typeParameters ? `<${ data . typeParameters } >` : "" } (${ data . params ? data . params : "" } )${ data . returnType ? `: ${ data . returnType } ` : "" } ` ;
113
+ return `${ data . kind } ${ data . name } ${ data . typeAnnotation ? `: ${ data . typeAnnotation } ` : "" } = ${ data . async ? "async " : "" } function${ data . typeParameters ? `<${ data . typeParameters } >` : "" } (${ data . params ? data . params : "" } )${ data . returnType ? `: ${ data . returnType } ` : "" } ` ;
110
114
case "arrow" :
111
- return `${ data . kind } ${ data . name } = ${ data . async ? "async " : "" } ${ data . typeParameters ? `<${ data . typeParameters } >` : "" } (${ data . params ? data . params : "" } )${ data . returnType ? `: ${ data . returnType } ` : "" } =>` ;
115
+ return `${ data . kind } ${ data . name } ${ data . typeAnnotation ? `: ${ data . typeAnnotation } ` : "" } = ${ data . async ? "async " : "" } ${ data . typeParameters ? `<${ data . typeParameters } >` : "" } (${ data . params ? data . params : "" } )${ data . returnType ? `: ${ data . returnType } ` : "" } =>` ;
112
116
default :
113
117
return null ;
114
118
}
You can’t perform that action at this time.
0 commit comments