ParseError: '3.0' was parsed as a number but could not be narrowed to a literal value.
I'm not sure yet, where does this come from, but does it say anything to you?
11 Replies
Ok, here is a type:
I take it I use a wrong syntax?
Changing
3.0
to 3
seems to fix the issue:
Hm, dunno why it makes a differenceWell to be fair the error message is pretty good 😛
"'3.0' was parsed as a number but could not be narrowed to a literal value. Avoid unnecessary leading or trailing zeros and other abnormal notation"
This restriction has to do with how TS infers numeric literals, it can't accurately infer
3.0
since it's redundant to add .0
But yuck 🙂
Be like that. Thinking that 3.0 is abnormal hahah
I could probably remove it here TBH, it's really only important for static inference it was just a 1:1 thing and it doesn't matter for bounds anyways
And I wrote 3.0 automatically, because I wrote 0.1 🙂 Same precision, university education you know
Yeah I get it, I think I could remove it.
Personally I would not write it like that because I find having exactly one representation of each unique value more important than matching decimal places but I did drop out of school so maybe that's why 😛
You were boring there? 🙂
Something like that
hah
I did update this to no longer fail in beta (the numeric literal parsing is only done for a standalone number literal)
That should have been the behavior anyways since it works that way on the types so you can add dynamic bounds
👍🏻