ts-runtime
ts-runtime copied to clipboard
disallow NaN for number types
How about an option to throw when NaN is assigned to a number type?
Right now this library allows things like const x: number = parseFloat("hello");
...which makes sense as default behaviour because typeof NaN === "number" in JavaScript, but it'd be useful to be able to use this library to do things like safely parse values in a querystring, coming from a redis cache, etc. etc.
So could it be another cli option or something?
This is definitely a good idea. I'm currently thinking about utilizing typescript-json-schema, which would mean quite a number of changes to the project, but I will keep this in mind.
Hi - is 1.0 still being worked on? Is there a branch?
I'm still exploring different ways of checking types at runtime to improve performance (one being #13 after looking into #10), however, my time was limited. There is currently no remote branch.