diff --git a/@commitlint/format/src/format.ts b/@commitlint/format/src/format.ts index a0707ca413..bd7101954c 100644 --- a/@commitlint/format/src/format.ts +++ b/@commitlint/format/src/format.ts @@ -66,7 +66,7 @@ export function formatResult( const problems = [...errors, ...warnings].map((problem) => { const sign = signs[problem.level] || ''; const color: ChalkColor = colors[problem.level] || ('white' as const); - const decoration = enabled ? ((chalk as any)[color] as any)(sign) : sign; + const decoration = enabled ? chalk[color](sign) : sign; const name = enabled ? chalk.grey(`[${problem.name}]`) : `[${problem.name}]`; @@ -76,7 +76,7 @@ export function formatResult( const sign = selectSign(result); const color = selectColor(result); - const deco = enabled ? (chalk[color] as any)(sign) : sign; + const deco = enabled ? chalk[color](sign) : sign; const el = errors.length; const wl = warnings.length; const hasProblems = problems.length > 0; @@ -109,7 +109,7 @@ function selectSign(result: FormattableResult): string { return (result.warnings || []).length ? '⚠' : '✔'; } -function selectColor(result: FormattableResult): keyof typeof chalk { +function selectColor(result: FormattableResult): ChalkColor { if ((result.errors || []).length > 0) { return 'red'; } diff --git a/@commitlint/types/src/format.ts b/@commitlint/types/src/format.ts index ba50d8a79f..f48bda09af 100644 --- a/@commitlint/types/src/format.ts +++ b/@commitlint/types/src/format.ts @@ -26,7 +26,7 @@ export interface FormattableReport { results?: (FormattableResult & WithInput)[]; } -export type ChalkColor = keyof typeof chalk; +export type ChalkColor = typeof chalk.Color | typeof chalk.Modifiers; export interface FormatOptions { color?: boolean;