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

Ternary operator bug in CardEnumOptions component #477

Open
nateplusplus opened this issue Jul 29, 2023 · 0 comments
Open

Ternary operator bug in CardEnumOptions component #477

nateplusplus opened this issue Jul 29, 2023 · 0 comments
Labels
bug Something isn't working

Comments

@nateplusplus
Copy link
Contributor

While refactoring to TypeScript (#456), I noticed a potential issue within the following snippet:

switch (type) {
case 'string':
newVal = ev.target.value;
break;
case 'number':
case 'integer':
newVal = parseFloat(ev.target.value);
if (Number.isInteger(newVal))
newVal = parseInt(ev.target.value, 10);
if (Number.isNaN(newVal)) newVal = type === 'string' ? '' : 0;
break;
default:

On line 64, we know that type is a number or integer, so the ternary condition type === 'string' will never be true. This means if newVal is NaN, it will never be set to an empty string and will always be set to 0. I'm not sure if that is an issue, but wanted to flag this.

@raymond-lam raymond-lam added the bug Something isn't working label Sep 10, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants