Add test that infers 'number' from pattern

This commit is contained in:
Nathan Shively-Sanders 2016-05-17 09:33:55 -07:00
parent ae4a983c59
commit 70d8def398
4 changed files with 21 additions and 0 deletions

View File

@ -4,6 +4,7 @@ trans(({a}) => a);
trans(([b,c]) => 'foo');
trans(({d: [e,f]}) => 'foo');
trans(([{g},{h}]) => 'foo');
trans(({a, b = 10}) => a);
//// [fallbackToBindingPatternForTypeInference.js]
@ -23,3 +24,7 @@ trans(function (_a) {
var g = _a[0].g, h = _a[1].h;
return 'foo';
});
trans(function (_a) {
var a = _a.a, _b = _a.b, b = _b === void 0 ? 10 : _b;
return a;
});

View File

@ -26,3 +26,9 @@ trans(([{g},{h}]) => 'foo');
>g : Symbol(g, Decl(fallbackToBindingPatternForTypeInference.ts, 4, 9))
>h : Symbol(h, Decl(fallbackToBindingPatternForTypeInference.ts, 4, 13))
trans(({a, b = 10}) => a);
>trans : Symbol(trans, Decl(fallbackToBindingPatternForTypeInference.ts, 0, 0))
>a : Symbol(a, Decl(fallbackToBindingPatternForTypeInference.ts, 5, 8))
>b : Symbol(b, Decl(fallbackToBindingPatternForTypeInference.ts, 5, 10))
>a : Symbol(a, Decl(fallbackToBindingPatternForTypeInference.ts, 5, 8))

View File

@ -38,3 +38,12 @@ trans(([{g},{h}]) => 'foo');
>h : any
>'foo' : string
trans(({a, b = 10}) => a);
>trans(({a, b = 10}) => a) : number
>trans : <T>(f: (x: T) => string) => number
>({a, b = 10}) => a : ({a, b}: { a: any; b?: number; }) => any
>a : any
>b : number
>10 : number
>a : any

View File

@ -3,3 +3,4 @@ trans(({a}) => a);
trans(([b,c]) => 'foo');
trans(({d: [e,f]}) => 'foo');
trans(([{g},{h}]) => 'foo');
trans(({a, b = 10}) => a);