ts-runtime icon indicating copy to clipboard operation
ts-runtime copied to clipboard

disallow NaN for number types

Open mmkal opened this issue 8 years ago • 3 comments

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?

mmkal avatar Oct 28 '17 01:10 mmkal

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.

fabiandev avatar Nov 01 '17 19:11 fabiandev

Hi - is 1.0 still being worked on? Is there a branch?

mmkal avatar Jan 26 '18 05:01 mmkal

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.

fabiandev avatar Jan 28 '18 11:01 fabiandev