nodejs/undici

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

jrr opened this issue · 1 comments

jrr commented

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.

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