Closed
Description
Bug Report
It seems some Promise.all
inferencing has changed in 4.5., as I have some patterns in GitLens where I am building an array in the call to Promise.all
where some of the promises might be undefined
. And in TS 4.5. I now get a Expected 1 type arguments, but got 2
error.
🔎 Search Terms
🕗 Version & Regression Information
- This is a crash
- This changed between versions
4.4.4
and4.5-beta
and still present in4.6.0-dev.20211102
. - This is the behavior in every version I tried, and I reviewed the FAQ for entries about _________
- I was unable to test this on prior versions because _______
⏯ Playground Link
Playground link with relevant code
💻 Code
interface GitBranch { type: 'branch' }
interface GitTag { type: 'tag' }
async function getBranches(): Promise<GitBranch[]> {
return undefined!;
}
async function getTags(): Promise<GitTag[]> {
return undefined!;
}
async function getBranchesOrTags(include?: 'all' | 'branches' | 'tags') {
const [branches, tags] = await Promise.all<GitBranch[] | undefined, GitTag[] | undefined>([
include == null || include === 'all' || include === 'branches'
? getBranches()
: undefined,
include == null || include === 'all' || include === 'tags'
? getTags()
: undefined,
]);
branches;
tags;
}
Output
"use strict";
async function getBranches() {
return undefined;
}
async function getTags() {
return undefined;
}
async function getBranchesOrTags(include) {
const [branches, tags] = await Promise.all([
include == null || include === 'all' || include === 'branches'
? getBranches()
: undefined,
include == null || include === 'all' || include === 'tags'
? getTags()
: undefined,
]);
branches;
tags;
}
Compiler Options
{
"compilerOptions": {
"strict": true,
"noImplicitAny": true,
"strictNullChecks": true,
"strictFunctionTypes": true,
"strictPropertyInitialization": true,
"strictBindCallApply": true,
"noImplicitThis": true,
"noImplicitReturns": true,
"alwaysStrict": true,
"esModuleInterop": true,
"declaration": true,
"experimentalDecorators": true,
"emitDecoratorMetadata": true,
"target": "ES2017",
"jsx": "react",
"module": "ESNext",
"moduleResolution": "node"
}
}
🙁 Actual behavior
Got Expected 1 type arguments, but got 2
on the Promise.all
call.
🙂 Expected behavior
No errors like in TS 4.4.4 and prior