Skip to content

Commit

Permalink
fix: fix typings of todo modifier (#756)
Browse files Browse the repository at this point in the history
  • Loading branch information
wellwelwel committed Sep 10, 2024
1 parent d9851de commit 3ed7e77
Showing 1 changed file with 20 additions and 1 deletion.
21 changes: 20 additions & 1 deletion src/modules/helpers/modifiers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,30 @@ import { Write } from '../../services/write.js';
import { indentation } from '../../configs/indentation.js';
import { format } from '../../services/format.js';

export const todo = (message: string, _cb?: () => unknown) =>
export function todo(message: string): void;
export async function todo(
message: string,
_cb?: () => Promise<unknown>
): Promise<void>;
export function todo(message: string, _cb?: () => unknown): void;
export async function todo(
message: string | (() => unknown) | (() => Promise<unknown>),
_cb?: (() => unknown) | (() => Promise<unknown>)
): Promise<void> {
Write.log(
`${indentation.hasDescribe ? ' ' : ''}${format(`● ${message}`).cyan().bold()}`
);

/* c8 ignore start */ // Type guard
if (typeof _cb === 'function') {
const isAsync = _cb.constructor.name === 'AsyncFunction';

if (isAsync) return await Promise.resolve();
return;
}
/* c8 ignore stop */
}

export async function skip(
message: string,
_cb: () => Promise<unknown>
Expand Down

0 comments on commit 3ed7e77

Please sign in to comment.