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

12$: diagnostic: typeof operator should warn when comparing to invalid string literals #1213

Open
CoderMuffin opened this issue Mar 18, 2024 · 2 comments
Labels
for hire Get paid for working on this task: https://quick-lint-js.com/hiring.html good first issue Good for newcomers and C++ beginners

Comments

@CoderMuffin
Copy link
Contributor

CoderMuffin commented Mar 18, 2024

When performing checks like typeof x == "string", it is perfectly possible to misspell it as something like typeof x == "strng" (missing i), which will always return false. Maybe there should be a warning for this?

More generally, expressions of the form typeof <a> [== or != or === or !==] <b> where b is a string and not "undefined", "object", "boolean", "number", "bigint", "string", "symbol" or "function"

I would be happy to implement this if approved and no-one else wants to :)

@CoderMuffin CoderMuffin changed the title [diagnostic] typeof operator should warn when comparing to invalid string literals diagnostic: typeof operator should warn when comparing to invalid string literals Mar 20, 2024
@strager
Copy link
Collaborator

strager commented Apr 27, 2024

This is a great idea! I'll put 12$ on it.

@strager strager added good first issue Good for newcomers and C++ beginners for hire Get paid for working on this task: https://quick-lint-js.com/hiring.html labels Apr 27, 2024
@strager strager changed the title diagnostic: typeof operator should warn when comparing to invalid string literals 12$: diagnostic: typeof operator should warn when comparing to invalid string literals Apr 27, 2024
@milanjijo
Copy link

Hey Strager, I would love to try and tackle this issue!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
for hire Get paid for working on this task: https://quick-lint-js.com/hiring.html good first issue Good for newcomers and C++ beginners
Projects
None yet
Development

No branches or pull requests

3 participants