Skip to content

Commit

Permalink
fix(types): correct chalkColor type (#2420)
Browse files Browse the repository at this point in the history
* fix(types): correct chalkColor type

* fix(types): correct chalkColor type part 2
  • Loading branch information
armano2 authored Jan 21, 2021
1 parent 60998cd commit ef8bdad
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
6 changes: 3 additions & 3 deletions @commitlint/format/src/format.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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}]`;
Expand All @@ -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;
Expand Down Expand Up @@ -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';
}
Expand Down
2 changes: 1 addition & 1 deletion @commitlint/types/src/format.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit ef8bdad

Please sign in to comment.