mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-02-05 16:38:05 -06:00
Add test that infers 'number' from pattern
This commit is contained in:
parent
ae4a983c59
commit
70d8def398
@ -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;
|
||||
});
|
||||
|
||||
@ -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))
|
||||
|
||||
|
||||
@ -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
|
||||
|
||||
|
||||
@ -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);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user