A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://github.com/microsoft/TypeScript/issues/46651 below:

Promise.all -- "Expected 1 type arguments, but got 2" ยท Issue #46651 ยท microsoft/TypeScript ยท GitHub

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 โฏ 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


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4