Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Throwing in case of failed cast #227

Closed
y-lohse opened this issue Sep 14, 2018 · 1 comment
Closed

Throwing in case of failed cast #227

y-lohse opened this issue Sep 14, 2018 · 1 comment

Comments

@y-lohse
Copy link
Owner

y-lohse commented Sep 14, 2018

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?

@y-lohse y-lohse mentioned this issue Sep 14, 2018
57 tasks
@y-lohse
Copy link
Owner Author

y-lohse commented Sep 14, 2018

We can probably use or update asNumberOrThrows for the checking part.

@smwhr smwhr closed this as completed May 24, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants