diff --git a/Part_9/courseinfo/src/components/Part.tsx b/Part_9/courseinfo/src/components/Part.tsx index ff07deb..a11f64d 100644 --- a/Part_9/courseinfo/src/components/Part.tsx +++ b/Part_9/courseinfo/src/components/Part.tsx @@ -1,5 +1,11 @@ import { CoursePart } from '../types'; +const assertNever = (value: never): never => { + throw new Error( + `Unhandled discriminated union member: ${JSON.stringify(value)}` + ) +} + const Part = ({ coursePart }: { coursePart: CoursePart }): JSX.Element => { switch(coursePart.kind) { case "base": @@ -33,7 +39,7 @@ const Part = ({ coursePart }: { coursePart: CoursePart }): JSX.Element => { ); default: - return
+ return assertNever(coursePart) } };