microsoft / microsoft/TypeScript
Changed behaviour in TS2.1 for Promise<void>
Nobody has claimed this yet.
- Dominant language
- Go
- Stars
- 111k
- Forks
- 14.3k
- Avg merge
- 2d 4h
- Merged PRs (30d)
- 132
Description
In typescript 2.0 any promise could be used a promise of type void, this does not seem to be the case in typescript 2.1.
I couldn't find this listed as a breaking change or any existing tickets so raised this one.
TypeScript Version: 2.1.4
Code
function testVoidPromises(promiseA: Promise<void>, promiseB: Promise<void>): Promise<void> {
return Promise.all([promiseA, promiseB]);
}
Expected behavior:
This compiles without errors in typescript 2.0
Actual behavior:
This fails to compile in typescript 2.1.4 with the following error:
test.ts(2,9): error TS2322: Type 'Promise<[void, void]>' is not assignable to type 'Promise'.
Type '[void, void]' is not assignable to type 'void'.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by compiling the provided test.ts example with TypeScript 2.1.4 and compare it with TypeScript 2.0, focusing on Promise.all's inferred return type. Trace the Promise.all type definitions or checker behavior involved; done means the expected Promise compatibility is restored or the changed behavior is documented with an appropriate regression test.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript
- Domain
- compilers
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100