Skip to content

Drop default import of global Command (for CommonJS) #2016

@shadowspawn

Description

@shadowspawn

The default import of a global Command object (aka program) has been out of favour since Commander v5, deprecated since v7, removed from the TypeScript in v8, and never implemented for the explicit esm support (#1440).

In general with the deprecated features and behaviours, I am willing to leave them alone until they cause problems rather than aggressively remove them, to minimise breaking changes when people upgrade from old versions of Commander.

The global Command object was involved in recent problems with TypeScript (#2013 #2014), so I am suggesting removing it while I am still annoyed! 😠

To be clear, this will still work:

const { program } = require('commander');
program.parse();

And this:

const commander = require('commander');
const program = new commander.Command();
program.parse();

But this won't work anymore:

const commander = require('commander');
commander.parse();

Metadata

Metadata

Assignees

No one assigned

    Labels

    semver: majorReleasing requires a major version bump, not backwards compatible

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions