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.
4.4.4
and 4.5-beta
and still present in 4.6.0-dev.20211102
.Playground link with relevant code
๐ป Codeinterface 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.
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