Skip to content

Can not get return type when util.promisify an function with overloading definations #26048

Closed
@huan

Description

@huan

TypeScript Version: 3.1.0-dev.201xxxxx

Search Terms:

Code

  import util from 'util'

  class Test {
    public test (s: string, callback: (error: Error | null, r: number) => void): void
    public test (s: string, s1: string, callback: (error: Error | null, r: number) => void): void

    public test (
      ...args: any[]
    ): void {
      return
    }
  }

  const t = new Test()
  const func = util.promisify(t.test)
  // const func: (arg1: string) => Promise<{}>

Expected behavior:

func's type should be const func: (arg1: string) => Promise<number>

Actual behavior:

func's type is const func: (arg1: string) => Promise<{}>

Promise<{}> should be Promise<number>

Playground Link:

Related Issues:

Metadata

Metadata

Assignees

No one assigned

    Labels

    QuestionAn issue which isn't directly actionable in code

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions