Description
With some of the recent fixes, and doing changes to the code that I'm not familiar with, or the one I was familiar with a while ago,
It might be very useful to have some way to specify what values are expected for a method. With this, we would be able to understand what values are expected by the method and what cases should we handle within the method itself.
This could be extremely helpful for working with the code a parson is not fully familiar with, or the one he or she was familiar with a while ago. It also could benefit unit tests if we would know what values are allowed and what are not. Then we can build tests to cover all expected and non-expected values.
There is TypeScript and Flow, of course, but they are too heavyweight for our purpose, I think. We probably don't need to go full in with them. I think we might need something more lightweight and less intrusive.
Maybe something that, while in the debug mode, would check values during runtime and throw an error if an unexpected value is provided. This way will be able to catch cases when it is something out of expected range. In production this can be off, for better performance.
Or maybe we can agree on some extended JSDoc-type comments that will provide this information. If IDE supports it, it could generate helpful type hinting. Maybe we could also run some static type checks using that information.
Please share your thought and ideas on this. Thanks!