TypeScript Version: 3.2.1 & 3.3.0-dev.20181201
Search Terms:
type inference, promise, tuple
Code
asyncfunctionf(x: number): Promise<number>{returnx+1;}asyncfunctiong(s: string): Promise<string>{returns+"\n";}asyncfunctionh(): Promise<string>{const[a,b]=awaitPromise.all([f(1),g("x")]).catch(()=>[null,null]);if(a===null||b===null)thrownewError();returnb.trim();}Expected behavior:
no compile error, as in TS3.1
Actual behavior:
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)
Related Issues:
TypeScript Version: 3.2.1 & 3.3.0-dev.20181201
Search Terms:
type inference, promise, tuple
Code
Expected behavior:
no compile error, as in TS3.1
Actual behavior:
In TS3.1:
In TS3.2:
Playground Link:
here
(Enable strictNullChecks to reproduce it)
Related Issues: