microsoft / TypeScript-TmLanguage

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

[Bug] Typescript highlight issue #876

Open Mister-Hope opened 3 years ago

Mister-Hope commented 3 years ago

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

Steps to Reproduce:

image

export type PageOptions<
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
  Data extends Record<string, any>,
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
  Custom extends Record<string, any>
> = (Custom &
  Partial<WechatMiniprogram.Page.Data<Data>> &
  Partial<WechatMiniprogram.Page.ILifetime & ExtendedPageLifeCycles> &
  Partial<ExtendedPageProperties> & {
    options?: WechatMiniprogram.Component.ComponentOptions;
  }) &
  ThisType<PageInstance<Data, Custom>>;

export interface PageConstructor {
  <
    // eslint-disable-next-line @typescript-eslint/no-explicit-any
    Data extends Record<string, any>,
    // eslint-disable-next-line @typescript-eslint/no-explicit-any
    Custom extends Record<string, any>
  >(
    name: string,
    options: PageOptions<Data, Custom>
  ): void;
}

I think this issue exist for quite a long time.

This may also happens in certain forms with generics.

yvvt0379 commented 3 years ago

Do you mean that the 'extends' in the 'export type' block and the 'extends' in the 'export interface' is highlighted in different colors?

Mister-Hope commented 3 years ago

Yes, the generics functions in interface display differently, and the highlight class is also not matching the ast

orta commented 2 years ago

What causes this is the new lines after the <:

Screen Shot 2021-07-21 at 8 22 48 AM

I'd be open to a well scoped PR which fixes this but doesn't break the existing tests. I think this could be quite hard, as when I last chatted with some of the team about this repo - dealing with odd newlines can often have strange cascading effects.

Mister-Hope commented 2 years ago

Just feed back here, the newline is added by prettier, I don't like that line either, but my team is using prettier to make styles constant. I do agree that without prettier, rare people write code like this so it's an edge case