Skip to content

Wrong type for Promise.finally in lib.es2018.promise.d.ts #29885

Description

@Elrendio

TypeScript Version: 3.4.0-dev.201xxxxx

Search Terms:

  • "promise"
  • "finally"
  • "promise finally"

Code

// A *self-contained* demonstration of the problem follows...
// Test this by running `tsc` on the command-line, rather than through another build tool such as Gulp, Webpack, etc.
let myCmpt = 1
const myPromise = new Promise((fulfill, _reject) => {
	setTimeout(() => fulfill(true), 1000)
}).finally(() => myCmpt--)

Expected behavior:
Code should compile.
Actual behavior:
I get error:

tsBug.ts:4:17 - error TS2322: Type 'number' is not assignable to type 'void'.

4 }).finally(() => myCmpt--)
                  ~~~~~~~~

  ../../../../../usr/local/lib/node_modules/typescript/lib/lib.es2018.promise.d.ts:31:26
    31     finally(onfinally?: (() => void) | undefined | null): Promise<T>
                                ~~~~~~~~~~
    The expected type comes from the return type of this signature.


Found 1 error.

Playground Link:
Couldn't manage to use es2018 with TypeScript Playground.
Related Issues:

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions