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

'interceptors' export doesn't work like in the docs #3308

Closed
jrr opened this issue Jun 4, 2024 · 1 comment · Fixed by #3318
Closed

'interceptors' export doesn't work like in the docs #3308

jrr opened this issue Jun 4, 2024 · 1 comment · Fixed by #3318
Labels
bug Something isn't working good first issue Good for newcomers Types Changes related to the TypeScript definitions

Comments

@jrr
Copy link

jrr commented Jun 4, 2024

Bug Description

I'm trying to use the built-in retry interceptor, like in this docs example:

const { Client, interceptors } = require("undici");
const { retry } = interceptors;
error TS2614: Module '"undici"' has no exported member 'interceptors'. Did you mean to use 'import interceptors from "undici"' instead?

import { Client, interceptors } from "undici";
                 ~~~~~~~~~~~~

Following TypeScript's suggestion, this seems to work:

import { Client } from "undici";
import undici from "undici";
const { interceptors } = undici;
const { retry } = interceptors;

That's a decent workaround for now, but it'd be great if the export could work as the doc describes.

Using undici v6.18.2, the latest as of this writing.

@jrr jrr added the bug Something isn't working label Jun 4, 2024
@metcoder95
Copy link
Member

It might be the way that the TS has defined the exported types. A PR is always welcomed

@metcoder95 metcoder95 added good first issue Good for newcomers Types Changes related to the TypeScript definitions labels Jun 5, 2024
jakecastelli pushed a commit to jakecastelli/undici that referenced this issue Jun 10, 2024
mcollina pushed a commit that referenced this issue Jun 12, 2024
* export interceptor to type def file

Fixes: #3308

* fixup! add a test

* fixup! add retry, redirect, dump and remove createRedirectInterceptor

---------

Co-authored-by: jake li <jake.li@sine.co>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working good first issue Good for newcomers Types Changes related to the TypeScript definitions
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants