Skip to content

Instantly share code, notes, and snippets.

@rauschma
Last active February 1, 2025 12:16
Show Gist options
  • Save rauschma/7f23068c0dd00bba3f59df955101e421 to your computer and use it in GitHub Desktop.
Save rauschma/7f23068c0dd00bba3f59df955101e421 to your computer and use it in GitHub Desktop.
assert-type: API for asserting types
// This code is now an npm package: https://github.com/rauschma/asserttt
@rauschma
Copy link
Author

@hcschuetz: Helpful, thanks!

While it's cool to see how some type testing utils can be implemented in user code, I'd much prefer it to be provided by TypeScript itself.

A agree! But it looks like the TypeScript team does not: microsoft/TypeScript#27024

While the name UnsupportedValueError fits case 1, I'd suggest the name UnexpectedValueError, which would fit both cases.

I was thinking of a switch over operating systems and someone passing in a value (=operating system) that is not supported. In a way, these three words all seem applicable: unsupported, illegal, unexpected.

“Unexpected” does seem like the best choice, because the term “illegal” has its own issues.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment