typecheck.macro
typecheck.macro copied to clipboard
[Proposal] Support decoders
typecheck.macro now supports arbitrary runtime constraints. However, it does not yet support decoders, which can deserialize values. It's complicated to implement this because, we can't arbitrarily mutate the input. For example:
x => {
// Obviously this doesn't affect the value of the passed in parameter
// outside of this function
x = 3
}
We can still mutate fields in the input. But, we can't re-assign the input itself. This doesn't just apply to the passed in input. We also need to deal with the following issue:
for (let x of some_array) {
// this won't affect the actual element
// in the array
x = 5
}
Of course, we can solve this issue by using a numerical for-loop, instead of a for-each loop, but that only solves this particular case.
Does anyone have thoughts?