diff --git a/src/synopt.ts b/src/synopt.ts index b6c9e6d..8e9d6d6 100644 --- a/src/synopt.ts +++ b/src/synopt.ts @@ -41,13 +41,11 @@ type Options = { [key: string]: boolean | string | string[]; }; -type ErrorResult = { ok: false; error: string }; -type OkResult = { ok: true; options: T }; -type Result = OkResult | ErrorResult; +type Result = { ok: false; error: string } | { ok: true; options: T }; -const Ok = (options: T): OkResult => ({ ok: true, options }); +const Ok = (options: T): Result => ({ ok: true, options }); -const Err = (error: string): ErrorResult => ({ +const Err = (error: string): Result => ({ ok: false, error, }); @@ -140,13 +138,13 @@ const createCommand = (name?: string): Command => { * @param {object} [options] - Options for this declaration. Example `{ boolean: true, required: true }` * @return {Command} The option declaration representation object */ - option: (...args): Command => { + option: (...args: DeclarationTuple): Command => { const declaration = parseDeclaration(args); ensureNamesUnique(declaration, state.optionDeclarations); state.optionDeclarations.push(declaration); return command; }, - parse: (args): Result => { + parse: (args: string[]): Result => { const options: Options = {}; try {