From 82d1d05f44407d7182d7afb389447c8fbf58348a Mon Sep 17 00:00:00 2001 From: Gregor MacLennan Date: Thu, 23 Nov 2023 11:21:34 +0900 Subject: [PATCH] fix: fix brittle types (#385) --- types/brittle.d.ts | 57 ++++++++++++++++++++++------------------------ 1 file changed, 27 insertions(+), 30 deletions(-) diff --git a/types/brittle.d.ts b/types/brittle.d.ts index 357ca4837..5cf4c8ce8 100644 --- a/types/brittle.d.ts +++ b/types/brittle.d.ts @@ -47,43 +47,40 @@ declare module 'brittle' { timeout(ms: number): void comment(message: string): void end(): void - test( + test: TestFn + } + + type TestCallback = (t: TestInstance) => void | Promise + + interface TestFn { + // The brittle docs suggest the return value is `Promise` but this is not the case. + ( name: string, options: TestOptions, callback: (t: TestInstance) => void | Promise - ): Promise - test( + ): Promise + ( name: string, callback: (t: TestInstance) => void | Promise - ): Promise - test(name: string, options: TestOptions): TestInstance - test(options: TestOptions): TestInstance + ): Promise + (callback: (t: TestInstance) => void | Promise): Promise + (name: string, options: TestOptions): TestInstance + (name: string): TestInstance + (): TestInstance + // The docs suggest the below is possible, but it isn't + // (options: TestOptions): TestInstance } - type TestCallback = (t: TestInstance) => void | Promise + interface Test extends TestFn { + test: Test + solo: TestFn + skip: TestFn + } - function test( - name: string, - options: TestOptions, - callback: TestCallback - ): Promise - function test(name: string, callback: TestCallback): Promise - function test(name: string, options: TestOptions): TestInstance - function test(options: TestOptions): TestInstance - function solo( - name: string, - options: TestOptions, - callback: TestCallback - ): Promise - function solo(name: string, callback: TestCallback): Promise - function solo(options: TestOptions): TestInstance - function skip( - name: string, - options: TestOptions, - callback: TestCallback - ): Promise - function skip(name: string, callback: TestCallback): void - function configure(options: TestOptions): void + export const solo: TestFn + export const skip: TestFn + export const test: Test + export function configure(options: TestOptions): void - export { test, solo, skip, configure } + export default test }