Hacker News new | past | comments | ask | show | jobs | submit login

Beautiful.

----------------------------

This controller is intentionally written in a very verbose style. You will notice:

1. Every 'if' statement has a matching 'else' (exception: simple error checks for a client API call)

2. Things that may seem obvious are commented explicitly We call this style 'space shuttle style'. Space shuttle style is meant to ensure that every branch and condition is considered and accounted for - the same way code is written at NASA for applications like the space shuttle.

----------------------------

^^^^

This bit reminds me of exhaustive checks in typescript code. I try to use them all the time.

https://www.typescriptlang.org/docs/handbook/2/narrowing.htm...




The newer `satisfies never` is great for this purpose. It’s also convenient with if else chains if that’s more one’s style.



Hah, years of writing ts for various contracts and I had no idea that never could be used like this. Thanks!




Join us for AI Startup School this June 16-17 in San Francisco!

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

Search: