Skip to content

Conversation

@G-Rath
Copy link
Contributor

@G-Rath G-Rath commented Apr 6, 2023

The current types are incorrect because this plugin is exported using module.exports which is not equivalent to export default; while TypeScript handles this under the hood for native TS files (which is why those don't error), attempting to use this module with require in JS files checked by TypeScript will result in an error:

image

This is because TypeScript expects such modules to be exporting a default property that should be used in CommonJS, so instead it wants us to do { default: RemoveEmptyScriptsPlugin }:

image

This property does not actually exist at runtime though:

image

Instead, the correct way to type a module.exports based export is to use export =, and then to use a namespace to export additional types and interfaces (as there can only be one top-level export).

@webdiscus webdiscus merged commit f858feb into webdiscus:master Apr 7, 2023
@webdiscus
Copy link
Owner

@G-Rath

Thank you!

@G-Rath G-Rath deleted the patch-1 branch April 7, 2023 21:38
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.

2 participants