News for hackers. Stuff that matters.
Re:TIL: `satisfies` is my favorite TypeScript keyword by Normal_gaussian on Sunday November 23, 2025 @07:42AM (#46023129)
This is what I do:

   class AbsurdError extends Error {
     constructor(public value: unknown, message: string) {
       super(message);
       this.name = 'AbsurdError';
     }
   }
   
   function absurd(value: never, message: string) {
     throw new AbsurdError(value, message);
   }
Including an error message and an error type helps if one does slip through to runtime. Additionally, the AbsurdError can be caught and escalated appropriately. And finally the absurd function can be used in an inline ternary etc. where alternatives like throw cannot.

There are no comments on this comment yet.