( value: T | null | undefined, message: string, )
| 294 | } |
| 295 | |
| 296 | const getRequiredValue = <T,>( |
| 297 | value: T | null | undefined, |
| 298 | message: string, |
| 299 | ): T => { |
| 300 | if (value == null) { |
| 301 | throw new Error(message); |
| 302 | } |
| 303 | |
| 304 | return value; |
| 305 | }; |
| 306 | |
| 307 | const getPostTitle = (post: Pick<Post, 'title'>, label: string): string => |
| 308 | getRequiredValue(post.title, `Expected ${label} post title`); |
no outgoing calls
no test coverage detected