Switch from class to class-like to include all types in commander namespace
Before adoption: this commit came in with the history the project adopted, so no landing records it.
authored by John Gee · committed by John Gee · parent 08a5f02 · Browse files · 1 file·+11 added−34 removed
This commit
State
Before adoption: this commit came in with the history the project adopted, so no landing records it.
Diff stats
1 file+11 added−34 removed
- other:+11 added−34 removed
Provenance
- Commit
41c6985- Tree
48bd9d0- Author
John Gee <john@ruru.gen.nz>- Committer
John Gee <john@ruru.gen.nz>- Parent
08a5f02
1 file changed+11 added−34 removed
modified:typings/index.d.ts+11 added-34 removed
3 unmodified lines4 // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped5 6 ///<reference types="node" />7 8-declare namespace local {8+declare namespace commander {9 10- class CommanderError extends Error {10+ interface CommanderError extends Error {11 code: string;12 exitCode: number;13 message: string;14 nestedError?: string;15-16- constructor(exitCode: number, code: string, message: string);15 }16+ type CommanderErrorConstructor = { new (exitCode: number, code: string, message: string): CommanderError };17 19- class Option {18+ interface Option {19 flags: string;20 required: boolean; // A value must be supplied when the option is specified.21 optional: boolean; // A value is optional when the option is specified.22 mandatory: boolean; // The option must have a value after parsing, which usually means it must be specified on command line.23 bool: boolean;24 short?: string;25 long: string;26 description: string;28-29- /**30- * Initialize a new `Option` with the given `flags` and `description`.31- *32- * @param {string} flags33- * @param {string} [description]34- */35- constructor(flags: string, description?: string);27 }28+ type OptionConstructor = { new (flags: string, description?: string): Option };29 38- class Command extends NodeJS.EventEmitter {30+ interface Command extends NodeJS.EventEmitter {31 [key: string]: any; // options as properties32 33 args: string[];34 35 /**44- * Initialize a new `Command`.45- *46- * @param {string} [name]47- */48- constructor(name?: string);49-50- /**36 * Set the program version to `str`. 37 *38 * This method auto-registers the "-V, --version" flag39 * which will print the version number when passed.22 unmodified lines62 * @param nameAndArgs - command name and arguments, args are `<required>` or `[optional]` and last may also be `variadic...`63 * @param opts - configuration options64 * @returns new command65 */81- command(nameAndArgs: string, opts?: commander.CommandOptions): Command;66+ command(nameAndArgs: string, opts?: CommandOptions): Command;67 /**68 * Define a command, implemented in a separate executable file.69 * 70 * @remarks204 unmodified lines275 * Output help information and exit.276 */277 help(cb?: (str: string) => string): never;278 }279+ type CommandConstructor = { new (name?: string): Command };280 295-}281 297-declare namespace commander {298-299- type Command = local.Command300-301- type Option = local.Option302-282 interface CommandOptions {283 noHelp?: boolean;284 isDefault?: boolean;285 executableFile?: string;4 unmodified lines290 unknown: string[];291 }292 293 interface CommanderStatic extends Command {315- Command: typeof local.Command;316- Option: typeof local.Option;317- CommandOptions: CommandOptions;318- ParseOptionsResult: ParseOptionsResult;319- CommanderError : typeof local.CommanderError;294+ Command: CommandConstructor;295+ Option: OptionConstructor;296+ CommanderError:CommanderErrorConstructor;297 }298 299 }300 2 unmodified lines