You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Regression in type inference for Promise.all() #28792
test.ts:12:12 - error TS2339: Property 'trim' does not exist on type 'string | number'.
Property 'trim' does not exist on type 'number'.
12 return b.trim();
~~~~
In TS3.1:
a: number | null
b: string | null
In TS3.2:
a: string | number | null
b: string | number | null
Playground Link: here
(Enable strictNullChecks to reproduce it)
It looks like the problem of destructuring assignment with an union between tuple and Array types.
simplified code:
functionf(): [number,string]|null[]{// when using [null, null] instead of null[], it works properlyreturnMath.random()<0.5 ? [1,"x"] : [null,null];}const[a,b]=f();// a:string|number|null, b:string|number|null
Activity
Tatamo commentedon Dec 1, 2018
It looks like the problem of destructuring assignment with an union between tuple and Array types.
simplified code:
weswigham commentedon Dec 4, 2018
cc Daniel Rosenwasser (@DanielRosenwasser)