Skip to content

Commit 9c10a9d

Browse files
authored
Merge pull request #3784 from ronaldyonggi/source
Fix part 9c typos and missing method calls in material
2 parents 57f40cd + 9138a56 commit 9c10a9d

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

src/content/9/en/part9c.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1549,7 +1549,7 @@ export const toNewDiaryEntry = (object: unknown): NewDiaryEntry => {
15491549
const newEntry: NewDiaryEntry = {
15501550
weather: parseWeather(object.weather),
15511551
visibility: parseVisibility(object.visibility),
1552-
date: z.string().date().(object.date), // highlight-line
1552+
date: z.string().date().parse(object.date), // highlight-line
15531553
comment: z.string().optional().parse(object.comment) // highlight-line
15541554
};
15551555

@@ -1644,7 +1644,7 @@ export interface DiaryEntry {
16441644
export type NewDiaryEntry = Omit<DiaryEntry, 'id'>;
16451645
```
16461646
1647-
So besides the type _NewDiaryEntry_ we have also the Zod schema _NewEntrySchema_ that defines the shape of a new entry. We can use the shema to [infer](https://zod.dev/?id=type-inference) the type:
1647+
So besides the type _NewDiaryEntry_ we have also the Zod schema _NewEntrySchema_ that defines the shape of a new entry. We can use the schema to [infer](https://zod.dev/?id=type-inference) the type:
16481648
16491649
```js
16501650
import { z } from 'zod';
@@ -1674,7 +1674,7 @@ export interface DiaryEntry extends NewDiaryEntry {
16741674
16751675
This would remove all the duplication in the type and schema definitions but feels a bit backward so we decide to define the type _DiaryEntry_ explicitly with TypeScript.
16761676
1677-
Unfortunately the oppisite is not possible: we can not define the Zod schema based on TypeScript type definitions, and due to this, the duplication in the type and schema definitions is hard to avoid.
1677+
Unfortunately the opposite is not possible: we can not define the Zod schema based on TypeScript type definitions, and due to this, the duplication in the type and schema definitions is hard to avoid.
16781678
16791679
The current state of the source code can be found in the part2 branch of [this](https://github.com/fullstack-hy2020/flight-diary/tree/part2) GitHub repository.
16801680
@@ -1726,7 +1726,7 @@ const newDiaryParser = (req: Request, _res: Response, next: NextFunction) => {
17261726
};
17271727
```
17281728
1729-
The middleware just calls the shema parser to the request body. If the parsing thwrows an exception, that is passed to the error handling middleware.
1729+
The middleware just calls the schema parser to the request body. If the parsing throws an exception, that is passed to the error handling middleware.
17301730
17311731
So after the request passes this middleware, it <i>is known that the request body is a proper new diary entry</i>. We can tell this fact to TypeScript compiler by giving a type parameter to the _Request_ type:
17321732

0 commit comments

Comments
 (0)