Add float (or finite) type #1959
Unanswered
davetapley
asked this question in
Ideas
Replies: 1 comment
-
Hey @davetapley - sorry it took so long for us to get back to you. We would happily accept a PR to this effect if you're still interested. If you've lost interest in this, I will keep the conversation open and hopefully get this on the roadmap overall + let you know when we release one. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Since we already have an
integer
type:mobx-state-tree/packages/mobx-state-tree/src/types/primitives.ts
Lines 113 to 117 in 6a50d79
Do we want one or both of these?
float
type, which would restrict againstNaN
.finite
type, which would restrict againstNaN
and infinities (taking inspiration fromisFinite
).I'll concede that both could be implemented with
refinement
, but so couldinteger
and we already have that.This would have saved me from a bug where I am using
parseFloat
and aNaN
was sneaking in to my model.It would be great if I could just specify
float
in my model and have MST throw, instead of having to check forNaN
manually.Happy to make a PR if it will be accepted 🤞🏻
Beta Was this translation helpful? Give feedback.
All reactions