Skip to content

Missing Request in exported types #1939

@etnbrd

Description

@etnbrd

Describe the bug

The Request class is exported as the default export from source/core/index.
In source/index, the types from source/core/index are exported with an aggregation, like so: export * from 'source/core/index.js':

export * from './core/index.js';

This re-export don't propagate the default export from source/core/index.js: https://developer.mozilla.org/en-US/docs/web/javascript/reference/statements/export
Hence the Request type is lost in the re-export.

It is not in the list of exported type: https://github.com/sindresorhus/got/blob/main/documentation/typescript.md
So, I am not sure if this missing type is by design, or not. Feel free to close if this type is expected to be hidden.

Actual behavior

import got from 'got'

let request: ReturnType<got.stream>
try {
  request = got.stream(url)
} catch(error) {
  // handle error
}

Expected behavior

import got, {Request} from 'got'

let request: Request
try {
  request = got.stream(url)
} catch(error) {
  // handle error
}

Checklist

  • I have read the documentation.
  • I have tried my code with the latest version of Node.js and Got.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions