Skip to content

Syntax highlighting breaks after inline Typescript cast (:attr="x as foo") #3821

@richardtallent-erm

Description

@richardtallent-erm

Consider this example:

<RouterLink :to="action as string" class="mx-2 bg-red-400">My Link</RouterLink>

Syntax highlighting is breaking for the " class=" -- basically from the end quote through the starting quote of the next attribute of that tag/component.

Wrapping the expression in () fixes this, but then Prettier removes the unnecessary parenthesis.

Using :to="<string>action" works, but I tend to avoid that syntax option (for consistency, and because <> inside attributes feels wrong even though it's legal).

  • This is not limited to string, it's any cast.
  • The problem presents for any bound attribute/prop.
  • Still happens if the next attribute is wrapped to the next line

Metadata

Metadata

Assignees

No one assigned

    Labels

    duplicateThis issue or pull request already exists

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions