Skip to content

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

Open
@CoderMuffin

Description

@CoderMuffin

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 :)

Metadata

Metadata

Assignees

No one assigned

    Labels

    for hireGet paid for working on this task: https://quick-lint-js.com/hiring.htmlgood first issueGood for newcomers and C++ beginners

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions