microsoft / microsoft/TypeScript-TmLanguage

`typeof` with `<` breaks syntax highlighting

Open
#978 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
TypeScript
Stars
471
Forks
149
PR merge metrics
No merged PRs in 30d

Description

JavaScript and TypeScript Nightly version: v5.1.20230416

Code

typeof x < ''; function f() {}

For context, here's the whole code where I noticed it (common in minified js):

var gt = typeof globalThis < "u" ? globalThis : typeof window < "u" ? window : typeof global < "u" ? global : typeof self < "u" ? self : {};

Actual behaviour: typeof with < or <= gets interpreted as the begin of a type parameter and breaks all syntax highlighting after it.
image
image

Expected behaviour: should be a relational operator.
image

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Reproduce the issue with the two TypeScript and JavaScript snippets in the report, beginning with the repository's TextMate grammar. Verify that < and <= after typeof remain highlighted as relational operators and that highlighting continues through the rest of each snippet.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, typescript
Domain
tooling
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.