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: Do not require esModuleInterop in consuming TypeScript projects #346

Merged
merged 1 commit into from Aug 30, 2023

Conversation

dschmidt
Copy link
Contributor

@dschmidt dschmidt commented Jul 6, 2023

node:stream type is defined like this:

declare module 'node:stream' {
    import stream = require('stream');
    export = stream;
}

The "correct" way to import from this module in TypeScript is import * as Stream from ' node:stream'. Using the default import import Stream from 'node:stream' works only when esModuleInterop is enabled, which should not be required of consuming projects.

This fixes this error when using the library without esModuleInterop enabled:

TS1259: Module '"node:stream"' can only be default-imported using the 'esModuleInterop' flag

3 import Stream from "node:stream";
         ~~~~~~

  node_modules/@types/node/stream.d.ts:1338:5
    1338     export = stream;
             ~~~~~~~~~~~~~~~~
    This module is declared with using 'export =', and can only be used with a default import when using the 'esModuleInterop' flag

@dschmidt
Copy link
Contributor Author

dschmidt commented Aug 1, 2023

ping 😅

@perry-mitchell
Copy link
Owner

Thanks for this @susnux, and sorry for the long delay.

@perry-mitchell perry-mitchell merged commit 8745d05 into perry-mitchell:master Aug 30, 2023
@perry-mitchell
Copy link
Owner

Released in 5.3.0

@dschmidt
Copy link
Contributor Author

Thanks 😇

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

3 participants