microsoft / TypeScript-TmLanguage

TextMate grammar files for TypeScript for VS Code, Sublime Text, and Atom.
MIT License
397 stars 125 forks source link

Rendering of code broken after using `require.resolve` in the code #949

Closed meeroslav closed 1 year ago

meeroslav commented 1 year ago

Does this issue occur when all extensions are disabled?: Yes

Steps to Reproduce:

  1. Clone https://github.com/nrwl/nx/
  2. Open packages/nx/src/utils/package-json.ts
  3. Scroll to line 128

Current behavior: The function call to require.resolve is marked with red parenthesis despite no error existing (nor being shown) and all the code after that line has broken visual representation.

Expected behavior: Code should still maintain the proper theme in files that contain require.resolve

Screenshot 2022-12-13 at 10 17 01

VSCodeTriageBot commented 1 year ago

Thanks for creating this issue! It looks like you may be using an old version of VS Code, the latest stable release is 1.74.0. Please try upgrading to the latest version and checking whether this issue remains.

Happy Coding!

meeroslav commented 1 year ago

The latest version has the same error

mjbvz commented 1 year ago

Minimal example:


export interface PackageJson {
    exports?:
    | string
    | Record<
        string,
        string | { types?: string; require?: string; import?: string }
    >;
}

export function foo() { }
sheetalkamat commented 1 year ago

This is limitation of grammar because there is no way to look beyond or before single line types do not cross line so at the end of string type scope ends and everything beyond will be expression. Moving | on same line will help with the continuation of the scope.

sheetalkamat commented 1 year ago

Duplicate of #761