Skip to content

Make regex lookahead check more strict - #1018

Closed
RedCMD (RedCMD) wants to merge 7 commits into
microsoft:masterfrom
RedCMD:patch-1
Closed

Make regex lookahead check more strict#1018
RedCMD (RedCMD) wants to merge 7 commits into
microsoft:masterfrom
RedCMD:patch-1

Conversation

@RedCMD

Copy link
Copy Markdown

Fixes #1024

Regex on new line breaks js/ts highlighter

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add testcase which this fixes

@jimmy-zhening-luo

Copy link
Copy Markdown

RedCMD (@RedCMD) , bump. Here's an example of valid TypeScript that transpiles to correct JavaScript but fails highlighting in my IDE:

Example

protected url(string: string) {
  const regex = /^(([^:/?#]+):)?(\/\/([^/?#]*))?([^?#]*)(\?([^#]*))?(#(.*))?/u;
  
  // Hereafter, highlighting broken
  const parts = regex.exec(string);
  
  if (parts === null)
    throw new Error("Input unparseable as URL");
  else
    return {
      scheme: parts[2],
      host: parts[4],
      path: parts[5],
      query: parts[7],
      fragment: parts[9],
    };
}

Environment

  • TypeScript versions 5.4.5 to 5.6.2 checked
  • Targets ES6
  • Strictest compiler options
  • Is correctly highlighted in VSCode, but fails in my IDE which depends on the latest TypeScript TmLanguage

@RedCMD

Copy link
Copy Markdown
Author

Jimmy Zhening Luo (@jimmy-zhening-luo) what IDE do you use?
can you send a screenshot?
should prob make a new bug report

@RedCMD

Copy link
Copy Markdown
Author

Before:
image

After:
image

Comment thread TypeScript.YAML-tmLanguage Outdated
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Regex on new line breaks js/ts highlighter

6 participants