TypeScript/tests/baselines/reference/contextualTypingOfLambdaReturnExpression.js
2014-07-12 17:30:19 -07:00

16 lines
584 B
JavaScript

//// [contextualTypingOfLambdaReturnExpression.ts]
function callb(lam: (l: number) => void);
function callb(lam: (n: string) => void);
function callb(a) { }
callb((a) => a.length); // Ok, we choose the second overload because the first one gave us an error when trying to resolve the lambda return type
callb((a) => { a.length; }); // Error, we picked the first overload and errored when type checking the lambda body
//// [contextualTypingOfLambdaReturnExpression.js]
function callb(a) {
}
callb(function (a) { return a.length; });
callb(function (a) {
a.length;
});