Skip to content

Arrow function with generic in TSX #96

Open
@alextes

Description

@alextes

I understand this is getting quite ambiguous for the parser 🙈.

In TSX files, arrow functions with generics look a lot like JSX. In this issue the TypeScript side suggests there will be no fix and that extending or having multiple generics are two ways in which the parser can tell the arrow function from JSX. Sadly, this syntax also breaks all highlighting coming after it. Example below.

const updateSet = <T extends {}>(choice, set: Set<T>): Set<T> =>
  choice.isShown ? set.delete(choice.id) : set.add(choice.id);
};
// broken highlighting after this point

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions