-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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
Export InvalidOptionArgumentError in esm #1756
Conversation
I upgraded a typescript project to native es modules and imported `InvalidOptionArgumentError` was undefined at runtime, tho typescript defined it as an alias to InvalidArgumentError. ``` import { InvalidOptionArgumentError } from 'commander' // ^ No type error here, typescript thinks InvalidOptionArgumentError should exist assert(InvalidOptionArgumentError != null); // But it doesn't, this will throw an error ``` A quick test showed that there was a difference between the commonjs and ecmascript module. The issue wasn't limited to typescript. ``` const { InvalidOptionArgumentError } = require('commander') assert(InvalidOptionArgumentError != null); ``` ``` import { InvalidOptionArgumentError } from 'commander' assert(InvalidOptionArgumentError != null); // This will throw an error ``` This commit fixes the issue by exporting InvalidOptionArgumentError from the esm entry point. Alternatively we could remove InvalidOptionArgumentError from typings, I'm happy as long as build and runtime match.
The esm export got dropped/renamed in #1508 when |
Co-authored-by: John Gee <[email protected]>
Looks like there was an indentation boobytrap in the suggestion I made, sorry about that! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM (just an indentation issue).
(Pushed indentation fix.) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
Thanks @everett1992 |
Released in Commander v9.4.0 |
After upgrading a typescript project to native es modules imports for
InvalidOptionArgumentError
were undefined at runtime butdefined in typescript as an alias to InvalidArgumentError.
A quick test showed that there was a difference between the commonjs and
ecmascript module. The issue wasn't limited to typescript.
This commit fixes the issue by exporting InvalidOptionArgumentError from
the esm entry point. Alternatively we could remove
InvalidOptionArgumentError from typings, I'm happy as long as build and
runtime match.