In this pseudo-real-world example, the
countCells function was used only in the file where it was defined, so all the necessary compile-time guards were provided using TypeScript. Intentionally, to avoid unnecessary checking for argument shape (because why do something that’s provided by the tooling, right?) no explicit checks were added to
This is something I’m stealing from React land. When deprecation a function in React, the team generally marks that function with a
UNSAFE_ prefix. So you, as a library user, know that this feature is going to get removed in the future. You may use it today, but marking it as such makes the decision to use it an explicit opt-in.
So I’m starting to write the small, reusable functions that don’t have any explicit checks like so:
I think this’ll work nicely :)