phillip-le / phillip-le.github.io

https://phillip-le.github.io/
1 stars 0 forks source link

Partial utility type in mocks #63

Open phillip-le opened 2 months ago

phillip-le commented 2 months ago
type LogFn = (message: string, data?: Record<string, unknown>) => void;

type Logger = {
  info: LogFn;
  error: LogFn;
  child: Logger;
}

const partialLogger: Partial<Logger> = {
  error: vi.fn();
}
const logger = partialLogger as Logger;