From 72990539c9ae5322233c5b2449130767cf3ad4aa Mon Sep 17 00:00:00 2001 From: Armano Date: Wed, 20 Jan 2021 22:46:08 +0100 Subject: [PATCH 1/2] fix(types): correct chalkColor type --- @commitlint/format/src/format.ts | 2 +- @commitlint/types/src/format.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/@commitlint/format/src/format.ts b/@commitlint/format/src/format.ts index a0707ca413..33c08b8c6e 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}]`; 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; From 61f08029eddaeb56874ad1b65f3818fc47f403c7 Mon Sep 17 00:00:00 2001 From: Armano Date: Wed, 20 Jan 2021 23:29:41 +0100 Subject: [PATCH 2/2] fix(types): correct chalkColor type part 2 --- @commitlint/format/src/format.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/@commitlint/format/src/format.ts b/@commitlint/format/src/format.ts index 33c08b8c6e..bd7101954c 100644 --- a/@commitlint/format/src/format.ts +++ b/@commitlint/format/src/format.ts @@ -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'; }