Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Missing Request in exported types #1939

Closed
2 tasks done
etnbrd opened this issue Dec 6, 2021 · 1 comment · Fixed by #1940
Closed
2 tasks done

Missing Request in exported types #1939

etnbrd opened this issue Dec 6, 2021 · 1 comment · Fixed by #1940

Comments

@etnbrd
Copy link
Contributor

etnbrd commented Dec 6, 2021

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.
@etnbrd
Copy link
Contributor Author

etnbrd commented Dec 6, 2021

I tried to fix this issue with #1940

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant