diff --git a/book-content/chapters/16-the-utils-folder.md b/book-content/chapters/16-the-utils-folder.md index 3694077..d4bb8b6 100644 --- a/book-content/chapters/16-the-utils-folder.md +++ b/book-content/chapters/16-the-utils-folder.md @@ -496,8 +496,9 @@ function assertIsAlbum(input: unknown): asserts input is Album { "artist" in input && "year" in input ) { - throw new Error("Not an Album!"); + return; } + throw new Error("Not an Album!"); } ``` @@ -522,8 +523,9 @@ function assertIsAlbum(input: unknown): asserts input is Album { "artist" in input && "year" in input ) { - throw new Error("Not an Album!"); + return; } + throw new Error("Not an Album!"); } // ---cut--- function getAlbumTitle(item: unknown) { @@ -548,11 +550,12 @@ For example, if the `assertIsAlbum` function doesn't check for all the required ```typescript function assertIsAlbum(input: unknown): asserts input is Album { if (typeof input === "object") { - throw new Error("Not an Album!"); + return; } + throw new Error("Not an Album!"); } -let item = null; +let item: unknown = null; assertIsAlbum(item); @@ -877,7 +880,7 @@ it("Should accept a custom error", () => { Your task is to update the `addCodeToError` type signature to enforce the required constraints so that `TError` is required to have a `message` property and can optionally have a `code` property. - + ### Exercise 5: Combining Generic Types and Functions