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

Export InvalidOptionArgumentError in esm #1756

Merged
merged 3 commits into from Jun 20, 2022
Merged

Commits on Jun 18, 2022

  1. Export InvalidOptionArgumentError in esm

    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.
    Caleb ツ Everett committed Jun 18, 2022
    Copy the full SHA
    7e49856 View commit details
    Browse the repository at this point in the history

Commits on Jun 19, 2022

  1. Update esm.mjs

    Co-authored-by: John Gee <john@ruru.gen.nz>
    everett1992 and shadowspawn committed Jun 19, 2022
    Copy the full SHA
    f4c1cb3 View commit details
    Browse the repository at this point in the history
  2. Fix indentation

    shadowspawn committed Jun 19, 2022
    Copy the full SHA
    487a6d5 View commit details
    Browse the repository at this point in the history