Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(types): correct chalkColor type #2420

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 3 additions & 3 deletions @commitlint/format/src/format.ts
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
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