10$: warn on 'typeof x === undefined'
strager opened this issue ยท 17 comments
typeof x === undefined
is always false. typeof
returns a string. The programmer meant typeof x === "undefined"
instead.
Hi brother. Can I implement the changes required in this fix? Also, we have to implement the changes in C++ right?
@Master-Helix Sure! Here's our contributor guide: https://quick-lint-js.com/contribute/ Let me know if you need more assistance.
We have to make the changes everywhere in the repo for typeof x === undefined right?
@Master-Helix What do you mean by 'everywhere in the repo'? For this task you definitely won't need to change (or even look at) most source files in quick-lint-js.
You have tagged it under the C++ domain but it is related to JS files. And I can see the changes required are already there
You have tagged it under the C++ domain but it is related to JS files.
quick-lint-js is a JavaScript checker/linter. quick-lint-js is written in C++. For this task you will be modifying C++ code.
And I can see the changes required are already there
I don't know what changes you're referring to. I pasted typeof x === undefined
into the quick-lint-js playground and saw no diagnostics/warnings.
You have tagged it under the C++ domain but it is related to JS files.
quick-lint-js is a JavaScript checker/linter. quick-lint-js is written in C++. For this task you will be modifying C++ code.
And I can see the changes required are already there
I don't know what changes you're referring to. I pasted
typeof x === undefined
into the quick-lint-js playground and saw no diagnostics/warnings.
I understood. Continuing on the fix
You have tagged it under the C++ domain but it is related to JS files.
quick-lint-js is a JavaScript checker/linter. quick-lint-js is written in C++. For this task you will be modifying C++ code.
And I can see the changes required are already there
I don't know what changes you're referring to. I pasted
typeof x === undefined
into the quick-lint-js playground and saw no diagnostics/warnings.
I can see the red warning under typeof.
No brother. I am running this directly from your master branch without making any changes. Can you confirm it ?
I can see the red warning under typeof.
Hmm, did you make code changes? I don't see what you see:
const x = undefined; if (typeof x === undefined) { console.log("x is undefined"); }
I can reproduce by typing typeof
with the mathematical sans-serif small ๐.
const x = undefined;
if (ty๐eof x === undefined) {
console.log("x is undefined");
}
I guess the issue is with the font on the playground then ? The syntax should work irrespective of the font used
@Master-Helix On the demo, can you run JSON.stringify(document.querySelector('textarea').textContent)
in the browser's JS console and share the result? This will help rule out issues like what @vegerot mentioned.
@Master-Helix On the demo, can you run
JSON.stringify(document.querySelector('textarea').textContent)
in the browser's JS console and share the result? This will help rule out issues like what @vegerot mentioned.
Sure.
I would be interested in attempting to resolve this issue unless either of @Master-Helix or @vegerot wanted to? (I am only asking because I saw the unassignment)
@CoderMuffin Sure, you can tackle this task.
@strager Not sure if you get notified so I just wanted to let you know that I have submitted a pull request with the first draft for these changes :)