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

Nonsensical comparisons with typeof and "null" #2962

Closed
evanw opened this issue Aug 31, 2020 · 2 comments
Closed

Nonsensical comparisons with typeof and "null" #2962

evanw opened this issue Aug 31, 2020 · 2 comments
Labels
Bug Bug awaiting resolution

Comments

@evanw
Copy link

evanw commented Aug 31, 2020

Describe the bug
This is a friendly FYI. This repo has some nonsensical code that compares the typeof operator with "null" even though that comparison will always be false (the value "null" is never returned by that operator). This came up because a build tool automatically reported the issue: evanw/esbuild#358.

There are at least two places in your code where this happens:

headers[i] = typeof col.value == "undefined" || typeof col.value == "null" ? "" : col.value;

and

switch(typeof col.value){
case "object":
value = JSON.stringify(col.value);
break;
case "undefined":
case "null":

I'm reporting this to you because this probably indicates the presence of a bug. Presumably this code is trying to check for col.value === undefined || col.value === null. There is probably a bug here because typeof null === "object" in JavaScript, not "null".

It's up to you if you want to do anything with this information. Even if it's not a bug, removing the nonsensical code would be appreciated because it would avoid this package being flagged by other tools.

Tabulator Info
This code is present on master.

@evanw evanw added the Possible Bug A possible bug that needs investigation label Aug 31, 2020
@olifolkerd
Copy link
Owner

Thanks for the heads up. I will get those fixed in the 4.8 release next weekend

Cheers

Oli :)

@olifolkerd olifolkerd added Bug Bug awaiting resolution and removed Possible Bug A possible bug that needs investigation labels Aug 31, 2020
@olifolkerd
Copy link
Owner

I have pushed fixes for these to the 4.8 branch for release next weekend.

Cheers

Oli :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Bug awaiting resolution
Projects
None yet
Development

No branches or pull requests

2 participants