Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

That's very clever!


We have this nifty util in our codebase:

```ts

/*

* A function that asserts that a value is never.

* Useful for exhaustiveness checks in switch statements.

*/

export function assertNever(x: never): never {

  // eslint-disable-next-line @typescript-eslint/restrict-template-expressions

  throw new Error(`Unexpected object: ${x}`)
}

```




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: