josdejong / typed-function

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

Provide some API to access the currently-defined types #154

Open gwhitney opened 2 years ago

gwhitney commented 2 years ago

Right now there is no "publicly" exposed function for inquiring as to the types available in a typed-function instance. (There is just ._findType exposed "for unit testing only".) There should be some standardized public API for asking about the types present, perhaps at least read-only access to the typeList, or some other API if it would be more sensible. It might also be nice to be able to ask a typed-function if an entity is in some type, in its opinion.

josdejong commented 2 years ago

Yes, good point. For example methods typed.getTypes() and typed.getConversions(). These should maybe return a clone of the internal types and conversions so you can't mess with them.