Skip to content

export interceptor to type def file#3318

Merged
mcollina merged 3 commits into
nodejs:mainfrom
jakecastelli:fix-3308
Jun 12, 2024
Merged

export interceptor to type def file#3318
mcollina merged 3 commits into
nodejs:mainfrom
jakecastelli:fix-3308

Conversation

@jakecastelli

Copy link
Copy Markdown
Member

Fixes: #3308

Status

@mcollina mcollina left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for opening a PR! Can you please add a unit test? we use tsd for typescript

@jakecastelli

jakecastelli commented Jun 10, 2024

Copy link
Copy Markdown
Member Author

Sure, thanks for letting me know! Added a unit test to verify the behaviour.

Test would fail without the export to def file
> undici@6.18.2 test:typescript
> tsd && tsc --skipLibCheck test/imports/undici-import.ts

test/imports/undici-import.ts:2:10 - error TS2614: Module '"../../"' has no exported member 'interceptors'. Did you mean to use 'import interceptors from "../../"' instead?

2 import { interceptors } from '../../'
           ~~~~~~~~~~~~


Found 1 error in test/imports/undici-import.ts:2

I added a dummy call interceptors.createRedirectInterceptor({}) just to ensure member can be accessed without any type error, not sure if its necessary.

@mcollina mcollina left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

Comment thread test/imports/undici-import.ts Outdated
@mcollina

Copy link
Copy Markdown
Member

@metcoder95 ptal

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 this pull request may close these issues.

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

3 participants