josdejong / typed-function

Runtime type-checking for JavaScript functions
MIT License
71 stars 19 forks source link

Add handler for typed function signature mismatch #125

Closed gwhitney closed 2 years ago

gwhitney commented 2 years ago

This way a client can implement custom behavior in the situation that a typed function call does not match any of its signatures. One specific application is to enable symbolic computation in mathjs (see demo PR to come momentarily).

This is not currently recommended for merging, although if the feature is of interest it's close: it would just need documentation, tests, and likely it would be good to expose createError as well for potential use in a client's onMismatch handler.

josdejong commented 2 years ago

O wow, such a handler makes a lot of sense! Even if we would not use it in mathjs on short term, it is a useful addition.

Can you work out this PR please? (add tests+docs)

josdejong commented 2 years ago

Thanks for writing docs and tests Glen, looks very neat 👌

josdejong commented 2 years ago

Published now in v2.1.0