From 001438e543c4042a85fb71987e3e596a2b2db25d Mon Sep 17 00:00:00 2001 From: Branden Rodgers Date: Wed, 15 Jan 2025 14:46:39 -0500 Subject: [PATCH] better type for builder --- commands/account/info.ts | 13 ++++++++++--- commands/doctor.ts | 1 + types/Yargs.ts | 4 ++-- 3 files changed, 13 insertions(+), 5 deletions(-) diff --git a/commands/account/info.ts b/commands/account/info.ts index db2abef71..75bf97eac 100644 --- a/commands/account/info.ts +++ b/commands/account/info.ts @@ -5,14 +5,21 @@ import { getAccessToken } from '@hubspot/local-dev-lib/personalAccessKey'; import { addConfigOptions } from '../../lib/commonOpts'; import { i18n } from '../../lib/lang'; import { getTableContents } from '../../lib/ui/table'; -import { CommonOptions } from '../../types/Yargs'; +import { CommonArguments } from '../../types/Yargs'; const i18nKey = 'commands.account.subcommands.info'; export const describe = i18n(`${i18nKey}.describe`); export const command = 'info [account]'; -export async function handler(options: CommonOptions): Promise { +type AccountInfoOptions = { + config?: string; + someNewField: number; +}; + +export async function handler( + options: CommonArguments +): Promise { const { derivedAccountId } = options; const config = getAccountConfig(derivedAccountId); // check if the provided account is using a personal access key, if not, show an error @@ -41,7 +48,7 @@ export async function handler(options: CommonOptions): Promise { } } -export function builder(yargs: Argv): Argv { +export function builder(yargs: Argv): Argv { addConfigOptions(yargs); yargs.example([ diff --git a/commands/doctor.ts b/commands/doctor.ts index 546110dc1..6fe0120b5 100644 --- a/commands/doctor.ts +++ b/commands/doctor.ts @@ -14,6 +14,7 @@ const { i18n } = require('../lib/lang'); export interface DoctorOptions { 'output-dir'?: string; + someNewField: number; } const i18nKey = 'commands.doctor'; diff --git a/types/Yargs.ts b/types/Yargs.ts index 3646d47cd..2ca6f6165 100644 --- a/types/Yargs.ts +++ b/types/Yargs.ts @@ -1,6 +1,6 @@ -import { Arguments } from 'yargs'; +import { ArgumentsCamelCase } from 'yargs'; -export type CommonOptions = Arguments< +export type CommonArguments = ArgumentsCamelCase< T & { derivedAccountId: number; providedAccountId?: number;