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

fix: import BodyReadable and Dispatcher correctly #1424

Merged
merged 3 commits into from May 25, 2022

Conversation

RA80533
Copy link
Contributor

@RA80533 RA80533 commented May 9, 2022

This PR is a continuation of the changes made in #1059.

BodyReadable is imported with the assumption that allowSyntheticDefaultImports is enabled. This is restrictive to consumers wishing to use undici's type definitions without its enablement.

The following imports have been fixed:

  • BodyReadable in test/types/readable.test-d.ts
  • BodyReadable in types/dispatcher.d.ts
  • Dispatcher in types/mock-interceptor.d.ts

@codecov-commenter
Copy link

codecov-commenter commented May 9, 2022

Codecov Report

Merging #1424 (5976004) into main (55d72ac) will not change coverage.
The diff coverage is n/a.

@@           Coverage Diff           @@
##             main    #1424   +/-   ##
=======================================
  Coverage   94.27%   94.27%           
=======================================
  Files          49       49           
  Lines        4248     4248           
=======================================
  Hits         4005     4005           
  Misses        243      243           

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 55d72ac...5976004. Read the comment docs.

@RA80533 RA80533 changed the title fix: import BodyReadable correctly fix: import BodyReadable and Dispatcher correctly May 9, 2022
@@ -1,5 +1,5 @@
import { expectAssignable } from 'tsd'
import BodyReadable from '../../types/readable'
import BodyReadable = require('../../types/readable')
Copy link
Collaborator

Choose a reason for hiding this comment

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

is it possible for us to test both ways? I want to ensure we are not breaking allowSyntheticDefaultImports=true users

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It is! There is no impact for configurations with the setting enabled.

Copy link
Contributor

@NMinhNguyen NMinhNguyen left a comment

Choose a reason for hiding this comment

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

What if instead BodyReadable was changed to be a named export? Because import require is a TypeScript-ism that doesn't really have an equivalent in regular JavaScript

@mcollina
Copy link
Member

@Ethan-Arrowood could you review?

Copy link
Member

@mcollina mcollina left a comment

Choose a reason for hiding this comment

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

lgtm

@mcollina mcollina merged commit 6855006 into nodejs:main May 25, 2022
@Ethan-Arrowood
Copy link
Collaborator

Oh sorry I was waiting for another test case - but if it works still no worries

KhafraDev pushed a commit to KhafraDev/undici that referenced this pull request Jun 23, 2022
* fix: import `BodyReadable` correctly

* fix: import `Dispatcher` correctly

* chore: fix `BodyReadable`'s import
metcoder95 pushed a commit to metcoder95/undici that referenced this pull request Dec 26, 2022
* fix: import `BodyReadable` correctly

* fix: import `Dispatcher` correctly

* chore: fix `BodyReadable`'s import
crysmags pushed a commit to crysmags/undici that referenced this pull request Feb 27, 2024
* fix: import `BodyReadable` correctly

* fix: import `Dispatcher` correctly

* chore: fix `BodyReadable`'s import
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.

None yet

5 participants