Skip to content

Commit ef8bdad

Browse files
authoredJan 21, 2021
fix(types): correct chalkColor type (#2420)
* fix(types): correct chalkColor type * fix(types): correct chalkColor type part 2
1 parent 60998cd commit ef8bdad

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed
 

‎@commitlint/format/src/format.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ export function formatResult(
6666
const problems = [...errors, ...warnings].map((problem) => {
6767
const sign = signs[problem.level] || '';
6868
const color: ChalkColor = colors[problem.level] || ('white' as const);
69-
const decoration = enabled ? ((chalk as any)[color] as any)(sign) : sign;
69+
const decoration = enabled ? chalk[color](sign) : sign;
7070
const name = enabled
7171
? chalk.grey(`[${problem.name}]`)
7272
: `[${problem.name}]`;
@@ -76,7 +76,7 @@ export function formatResult(
7676
const sign = selectSign(result);
7777
const color = selectColor(result);
7878

79-
const deco = enabled ? (chalk[color] as any)(sign) : sign;
79+
const deco = enabled ? chalk[color](sign) : sign;
8080
const el = errors.length;
8181
const wl = warnings.length;
8282
const hasProblems = problems.length > 0;
@@ -109,7 +109,7 @@ function selectSign(result: FormattableResult): string {
109109
return (result.warnings || []).length ? '⚠' : '✔';
110110
}
111111

112-
function selectColor(result: FormattableResult): keyof typeof chalk {
112+
function selectColor(result: FormattableResult): ChalkColor {
113113
if ((result.errors || []).length > 0) {
114114
return 'red';
115115
}

‎@commitlint/types/src/format.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ export interface FormattableReport {
2626
results?: (FormattableResult & WithInput)[];
2727
}
2828

29-
export type ChalkColor = keyof typeof chalk;
29+
export type ChalkColor = typeof chalk.Color | typeof chalk.Modifiers;
3030

3131
export interface FormatOptions {
3232
color?: boolean;

0 commit comments

Comments
 (0)
Please sign in to comment.