Skip to content

Commit 4484583

Browse files
committed
fix(transpiler): support arrow functions with complex body in named arguments
1 parent 9f462c0 commit 4484583

2 files changed

Lines changed: 17 additions & 2 deletions

File tree

tools/transpiler/spec/arrow_functions_spec.js

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import {describe, it, expect} from 'angular2/test_lib';
1+
import {describe, it, expect, iit} from 'angular2/test_lib';
22

33
var inc = x => x + 1;
44

@@ -12,6 +12,10 @@ var max = (a, b) => {
1212
}
1313
};
1414

15+
var namedFn = function({fn}) {
16+
return fn();
17+
}
18+
1519
class LexicalThis {
1620
zero;
1721

@@ -30,6 +34,10 @@ export function main() {
3034
expect(inc(0)).toBe(1);
3135
});
3236

37+
it('should support implicit return in named arguments', function() {
38+
expect(namedFn({fn: () => 1})).toBe(1);
39+
});
40+
3341
it('should support object literal', function() {
3442
var o = objLiteral('val');
3543
expect(o['key']).toBe('val');
@@ -40,9 +48,16 @@ export function main() {
4048
expect(max(1, 0)).toBe(1);
4149
});
4250

51+
it('should support complex body in named arguments', function() {
52+
expect(namedFn({fn: () => {
53+
return 1;
54+
}})).toBe(1);
55+
});
56+
4357
it('should support lexical this', function() {
4458
var lthis = new LexicalThis();
4559
expect(lthis.getZero()).toBe(0);
4660
});
61+
4762
});
4863
}

tools/transpiler/src/codegeneration/DartTransformer.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,8 @@ export class DartTransformer extends MultiTransformer {
2525
});
2626
};
2727

28-
append(NamedParamsTransformer);
2928
append(ArrowFunctionTransformer);
29+
append(NamedParamsTransformer);
3030
append(MultiVarTransformer);
3131
append(InstanceOfTransformer);
3232
append(StrictEqualityTransformer);

0 commit comments

Comments
 (0)