You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Referring to "Raising exception vs. having undefined behavior" from here.
In this codebase, we use parseInt(value) in places where the C# version does (int) value. If the cast is impossible, this produces a runtime error in the C# version whereas we'll keep going with whatever parseInt has returned.
Typescript has no special casting powers (as doesn't do that), so we're left with regular javascript. I guess the best thing to do would be to introduce another helper function that will parseInt the value, but throw if the result is NaN?
The text was updated successfully, but these errors were encountered:
Referring to "Raising exception vs. having undefined behavior" from here.
In this codebase, we use
parseInt(value)
in places where the C# version does(int) value
. If the cast is impossible, this produces a runtime error in the C# version whereas we'll keep going with whateverparseInt
has returned.Typescript has no special casting powers (
as
doesn't do that), so we're left with regular javascript. I guess the best thing to do would be to introduce another helper function that willparseInt
the value, but throw if the result isNaN
?The text was updated successfully, but these errors were encountered: