Skip to content

Commit 35fed36

Browse files
authored
use consistent Promise<T> return type for callback (#23)
1 parent 64b8c62 commit 35fed36

File tree

6 files changed

+9
-5
lines changed

6 files changed

+9
-5
lines changed

exercises/03.async/01.solution.await/README.mdx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,10 @@ This will allow me to await the `callback()` if it happens to be `async` too.
1010

1111
<CodeFile file="setup.ts" range="22-26" highlight="24" />
1212

13+
<callout-info>To let TypeScript know that `callback` is now, potentially, an asynchronous function, I will adjust its return type to include `Promise<void>`:</callout-info>
14+
15+
<CodeFile file="setup.ts" range="5-10" highlight="7" />
16+
1317
If I run the tests now, I can correctly see the assertion on `greetByResponse()` failing the relevant test:
1418

1519
```txt nocopy nonumber lines=3-4

exercises/03.async/02.problem.rejections/setup.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ interface Assertions {
1010

1111
declare global {
1212
var expect: (actual: unknown) => Assertions
13-
var test: (title: string, callback: () => void) => void
13+
var test: (title: string, callback: () => void | Promise<void>) => void
1414
var beforeAll: (callback: () => void) => void
1515
var afterAll: (callback: () => void) => void
1616
}

exercises/03.async/02.solution.rejections/setup.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ interface Assertions {
77

88
declare global {
99
var expect: (actual: unknown) => Assertions
10-
var test: (title: string, callback: () => void) => void
10+
var test: (title: string, callback: () => void | Promise<void>) => void
1111
var beforeAll: (callback: () => void) => void
1212
var afterAll: (callback: () => void) => void
1313
}

exercises/03.async/03.problem.waitFor/setup.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ interface Assertions {
77

88
declare global {
99
var expect: (actual: unknown) => Assertions
10-
var test: (title: string, callback: () => void) => void
10+
var test: (title: string, callback: () => void | Promise<void>) => void
1111
var beforeAll: (callback: () => void) => void
1212
var afterAll: (callback: () => void) => void
1313
}

exercises/03.async/03.solution.waitFor/setup.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ interface Assertions {
77

88
declare global {
99
var expect: (actual: unknown) => Assertions
10-
var test: (title: string, callback: () => void) => void
10+
var test: (title: string, callback: () => void | Promise<void>) => void
1111
var beforeAll: (callback: () => void) => void
1212
var afterAll: (callback: () => void) => void
1313
}

exercises/04.vitest/01.problem.using-vitest/setup.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ interface Assertions {
77

88
declare global {
99
var expect: (actual: unknown) => Assertions
10-
var test: (title: string, callback: () => void) => void
10+
var test: (title: string, callback: () => void | Promise<void>) => void
1111
var beforeAll: (callback: () => void) => void
1212
var afterAll: (callback: () => void) => void
1313
}

0 commit comments

Comments
 (0)