File tree 2 files changed +11
-1
lines changed
2 files changed +11
-1
lines changed Original file line number Diff line number Diff line change @@ -223,7 +223,16 @@ class DeclarationTranspiler extends base.TranspilerStep {
223
223
}
224
224
225
225
private visitFunctionLike ( fn : ts . FunctionLikeDeclaration , accessor ?: string ) {
226
- if ( fn . type ) this . visit ( fn . type ) ;
226
+ if ( fn . type ) {
227
+ if ( fn . kind === ts . SyntaxKind . ArrowFunction ) {
228
+ // Type is silently dropped for arrow functions, not supported in Dart.
229
+ this . emit ( '/*' ) ;
230
+ this . visit ( fn . type ) ;
231
+ this . emit ( '*/' ) ;
232
+ } else {
233
+ this . visit ( fn . type ) ;
234
+ }
235
+ }
227
236
if ( accessor ) this . emit ( accessor ) ;
228
237
if ( fn . name ) this . visit ( fn . name ) ;
229
238
// Dart does not even allow the parens of an empty param list on getter
Original file line number Diff line number Diff line change @@ -38,6 +38,7 @@ describe('functions', () => {
38
38
( ) => { expectTranslate ( 'var a = function() {}' ) . to . equal ( ' var a = ( ) { } ;' ) ; } ) ;
39
39
it ( 'translates fat arrow operator' , ( ) => {
40
40
expectTranslate ( 'var a = () => {}' ) . to . equal ( ' var a = ( ) { } ;' ) ;
41
+ expectTranslate ( 'var a = (): string => {}' ) . to . equal ( ' var a = /* String */ ( ) { } ;' ) ;
41
42
expectTranslate ( 'var a = (p) => isBlank(p)' ) . to . equal ( ' var a = ( p ) => isBlank ( p ) ;' ) ;
42
43
expectTranslate ( 'var a = (p = null) => isBlank(p)' )
43
44
. to . equal ( ' var a = ( [ p = null ] ) => isBlank ( p ) ;' ) ;
You can’t perform that action at this time.
0 commit comments