Skip to content
Myr

Types for version getter (#1982)

Before adoption: this commit came in with the history the project adopted, so no landing records it.

* Update types since .version() returns version. * Remove extra space

authored by John Gee · committed by GitHub · parent 4c095d1 · Browse files · 3 files+11 added−7 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

3 files+11 added−7 removed

  • other:+11 added−7 removed

3 files+11 added−7 removed

modified:lib/command.js+6 added-7 removed
1823 unmodified lines
1824 this.error(message, { code: 'commander.unknownCommand' });1825 }18261827 /**1828 * Set the program version to `str`.1828 * Get or set the program version.1829 *1830 * This method auto-registers the "-V, --version" flag1831 * which will print the version number when passed.1830 * This method auto-registers the "-V, --version" option which will print the version number.1831 *1833 * You can optionally supply the flags and description to override the defaults.1832 * You can optionally supply the flags and description to override the defaults.1833 *1835 * @param {string} str1834 * @param {string} [str]1835 * @param {string} [flags]1836 * @param {string} [description]1838 * @return {this | string} `this` command for chaining, or version string if no arguments1837 * @return {this | string | undefined} `this` command for chaining, or version string if no arguments1838 */18391840 version(str, flags, description) {1841 if (str === undefined) return this._version;1842 this._version = str;1843 flags = flags || '-V, --version';1844 description = description || 'output the version number';1845 const versionOption = this.createOption(flags, description);1847 this._versionOptionName = versionOption.attributeName();1846 this._versionOptionName = versionOption.attributeName(); // [sic] not defined in constructor, partly legacy, partly only needed at root1847 this.options.push(versionOption);1848 this.on('option:' + versionOption.name(), () => {1849 this._outputConfiguration.writeOut(`${str}\n`);1850 this._exit(0, 'commander.version', str);
358 unmodified lines
modified:typings/index.d.ts+4 added
292 unmodified lines
293 *294 * You can optionally supply the flags and description to override the defaults.295 */296 version(str: string, flags?: string, description?: string): this;297 /**298 * Get the program version.299 */300 version(): string | undefined;301302 /**303 * Define a command, implemented using an action handler.304 *
589 unmodified lines
modified:typings/index.test-d.ts+1 added
34 unmodified lines
35// version36expectType<commander.Command>(program.version('1.2.3'));37expectType<commander.Command>(program.version('1.2.3', '-r,--revision'));38expectType<commander.Command>(program.version('1.2.3', '-r,--revision', 'show revision information'));39expectType<string | undefined>(program.version());4041// command (and CommandOptions)42expectType<commander.Command>(program.command('action'));43expectType<commander.Command>(program.command('action', { isDefault: true, hidden: true, noHelp: true }));
439 unmodified lines