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

TS Syntax highlight broken for multiline generic arguments of function in object #1028

Open
wolflu05 opened this issue Apr 30, 2024 · 2 comments
Assignees

Comments

@wolflu05
Copy link

wolflu05 commented Apr 30, 2024

Type: Bug

When having a function with generic type params in an object and the generic type params wrap into multiple lines, the TS syntax highlighting is broken.

To reproduce, just paste the following code in a .ts file and see the broken output:

const myObj = {
  test<
    A extends Record<string, any>,
    C extends Record<string, any>,
    B extends Record<string, any>,
  >(a: A, b: B, c: C): Record<string, any>[] {
    if ('hello' in a) {
      console.log('Test');
    }
    return [a, b, c];
  },
};

For reference, I added the same function but outside of the object which shows the correct/broken highlight in comparison:
image

VS Code version: Code 1.88.1 (e170252f762678dec6ca2cc69aba1570769a5d39, 2024-04-10T17:42:52.765Z)
OS version: Darwin x64 22.6.0
Modes:

@mjbvz mjbvz transferred this issue from microsoft/vscode Apr 30, 2024
@MCFX2
Copy link

MCFX2 commented Jun 17, 2024

Issues like this have been repeatedly opened and closed as wontfix/design limitation. See #767 and its siblings.

Unfortunately this issue has been known for 5 years and activity here has slowed significantly, down to just basically bare minimum maintenance. The best advice I can give you is "try to format your code a different way", or consider using a different editor.

@wolflu05
Copy link
Author

Issues like this have been repeatedly opened and closed as wontfix/design limitation. See #767 and its siblings.

This is very sad, as typescript is not just any language, it's a language created by Microsoft.

The best advice I can give you is "try to format your code a different way", or consider using a different editor.

So you suggest I should create an issue at prettier to not break generic arguments into multiple lines if the function is defined in an object? I don't think it's prettiers responsibility to handle this case, and such an issue would be closed as wontfix, as it's actually the wanted behavior.

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

No branches or pull requests

3 participants