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

Make regex lookahead check more strict #1018

Open
wants to merge 7 commits into
base: master
Choose a base branch
from

Conversation

RedCMD
Copy link

@RedCMD RedCMD commented Feb 13, 2024

Fixes #1024

Regex on new line breaks js/ts highlighter

Copy link
Member

@sheetalkamat sheetalkamat left a comment

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

@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
Author

RedCMD commented Oct 5, 2024

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

@RedCMD
Copy link
Author

RedCMD commented Oct 5, 2024

Before:
image

After:
image

TypeScript.YAML-tmLanguage Outdated Show resolved Hide resolved
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