-
Notifications
You must be signed in to change notification settings - Fork 12.9k
Closed
Labels
BugA bug in TypeScriptA bug in TypeScriptFixedA PR has been merged for this issueA PR has been merged for this issue
Milestone
Description
TypeScript Version: 3.2.1 & 3.3.0-dev.20181201
Search Terms:
type inference, promise, tuple
Code
async function f(x: number): Promise<number>{
return x + 1;
}
async function g(s: string): Promise<string>{
return s + "\n";
}
async function h(): Promise<string> {
const [a, b] = await Promise.all([f(1), g("x")]).catch(() => [null, null]);
if (a === null || b === null) throw new Error();
return b.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:
Metadata
Metadata
Assignees
Labels
BugA bug in TypeScriptA bug in TypeScriptFixedA PR has been merged for this issueA PR has been merged for this issue