Skip to content

Commit 7e09ae4

Browse files
authored
Fix Typo
change the property and interface definition naming of 'backround' to 'background'. The words 'backround' and 'background' are used in the same context. I don't know if it is a typo or not, but it would make sense to use 'background'.
1 parent 158368f commit 7e09ae4

File tree

1 file changed

+18
-18
lines changed

1 file changed

+18
-18
lines changed

src/content/9/en/part9d.md

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -333,7 +333,7 @@ const courseParts = [
333333
name: "Deeper type usage",
334334
exerciseCount: 14,
335335
description: "Confusing description",
336-
backroundMaterial: "https://type-level-typescript.com/template-literal-types"
336+
backgroundMaterial: "https://type-level-typescript.com/template-literal-types"
337337
},
338338
];
339339
```
@@ -362,11 +362,11 @@ interface CoursePartGroup {
362362
kind: "group"
363363
}
364364

365-
interface CoursePartBackround {
365+
interface CoursePartBackground {
366366
name: string;
367367
exerciseCount: number;
368368
description: string;
369-
backroundMaterial: string;
369+
backgroundMaterial: string;
370370
kind: "background"
371371
}
372372
```
@@ -407,7 +407,7 @@ const App = () => {
407407
name: "Deeper type usage",
408408
exerciseCount: 14,
409409
description: "Confusing description",
410-
backroundMaterial: "https://type-level-typescript.com/template-literal-types",
410+
backgroundMaterial: "https://type-level-typescript.com/template-literal-types",
411411
kind: "background" // highlight-line
412412
},
413413
]
@@ -452,13 +452,13 @@ interface CoursePartGroup extends CoursePartBase {
452452
kind: "group"
453453
}
454454

455-
interface CoursePartBackround extends CoursePartBase {
455+
interface CoursePartBackground extends CoursePartBase {
456456
description: string;
457-
backroundMaterial: string;
457+
backgroundMaterial: string;
458458
kind: "background"
459459
}
460460

461-
type CoursePart = CoursePartBasic | CoursePartGroup | CoursePartBackround;
461+
type CoursePart = CoursePartBasic | CoursePartGroup | CoursePartBackground;
462462
```
463463
464464
### More type narrowing
@@ -483,7 +483,7 @@ One handy way to narrow these kinds of types in TypeScript is to use *switch cas
483483
484484
![vscode showing part. and then the attributes](../../images/9/64new.png)
485485
486-
In the above example, TypeScript knows that a *part* has the type *CoursePart* and it can then infer that *part* is of either type *CoursePartBasic*, *CoursePartGroup* or *CoursePartBackround* based on the value of the attribute *kind*.
486+
In the above example, TypeScript knows that a *part* has the type *CoursePart* and it can then infer that *part* is of either type *CoursePartBasic*, *CoursePartGroup* or *CoursePartBackground* based on the value of the attribute *kind*.
487487
488488
The specific technique of type narrowing where a union type is narrowed based on literal attribute value is called [discriminated union](https://www.typescriptlang.org/docs/handbook/2/narrowing.html#discriminated-unions).
489489
@@ -492,10 +492,10 @@ Note that the narrowing can naturally be also done with *if* clause. We could eg
492492
```js
493493
courseParts.forEach(part => {
494494
if (part.kind === 'background') {
495-
console.log('see the following:', part.backroundMaterial)
495+
console.log('see the following:', part.backgroundMaterial)
496496
}
497497

498-
// can not refer to part.backroundMaterial here!
498+
// can not refer to part.backgroundMaterial here!
499499
});
500500
```
501501
@@ -523,14 +523,14 @@ default:
523523
return assertNever(part);
524524
```
525525
526-
and remove the case that handles the type *CoursePartBackround*, we would see the following error:
526+
and remove the case that handles the type *CoursePartBackground*, we would see the following error:
527527
528528
![vscode error Argument of Ttype CoursePart not assignable to type never](../../images/9/66new.png)
529529
530530
The error message says that
531531
532532
```text
533-
'CoursePartBackround' is not assignable to parameter of type 'never'.
533+
'CoursePartBackground' is not assignable to parameter of type 'never'.
534534
```
535535
536536
which tells us that we are using a variable somewhere where it should never be used. This tells us that something needs to be fixed.
@@ -561,13 +561,13 @@ interface CoursePartGroup extends CoursePartBase {
561561
kind: "group"
562562
}
563563

564-
interface CoursePartBackround extends CoursePartBase {
564+
interface CoursePartBackground extends CoursePartBase {
565565
description: string;
566-
backroundMaterial: string;
566+
backgroundMaterial: string;
567567
kind: "background"
568568
}
569569

570-
type CoursePart = CoursePartBasic | CoursePartGroup | CoursePartBackround;
570+
type CoursePart = CoursePartBasic | CoursePartGroup | CoursePartBackground;
571571

572572
const courseParts: CoursePart[] = [
573573
{
@@ -592,7 +592,7 @@ const courseParts: CoursePart[] = [
592592
name: "Deeper type usage",
593593
exerciseCount: 14,
594594
description: "Confusing description",
595-
backroundMaterial: "https://type-level-typescript.com/template-literal-types",
595+
backgroundMaterial: "https://type-level-typescript.com/template-literal-types",
596596
kind: "background"
597597
},
598598
{
@@ -604,9 +604,9 @@ const courseParts: CoursePart[] = [
604604
];
605605
```
606606
607-
Now we know that both interfaces *CoursePartBasic* and *CoursePartBackround* share not only the base attributes but also an attribute called *description*, which is a string in both interfaces.
607+
Now we know that both interfaces *CoursePartBasic* and *CoursePartBackground* share not only the base attributes but also an attribute called *description*, which is a string in both interfaces.
608608
609-
Your first task is to declare a new interface that includes the *description* attribute and extends the *CoursePartBase* interface. Then modify the code so that you can remove the *description* attribute from both *CoursePartBasic* and *CoursePartBackround* without getting any errors.
609+
Your first task is to declare a new interface that includes the *description* attribute and extends the *CoursePartBase* interface. Then modify the code so that you can remove the *description* attribute from both *CoursePartBasic* and *CoursePartBackground* without getting any errors.
610610
611611
Then create a component *Part* that renders all attributes of each type of course part. Use a switch case-based exhaustive type checking! Use the new component in component *Content*.
612612

0 commit comments

Comments
 (0)