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

TypeScript <type arguments> are interpred as HTML tags in Vue templates #14817

Open
SIGSTACKFAULT opened this issue May 14, 2023 · 4 comments
Open
Labels
lang:vue Issues affecting Vue scope:dependency Issues that cannot be solved inside Prettier itself, and must be fixed in a dependency type:bug Issues identifying ugly output, or a defect in the program

Comments

@SIGSTACKFAULT
Copy link

Prettier 2.8.8
Playground link

--parser vue

Input:

<template>
  <p>Templates are formatted as well...
    </p>
  {{ Object.values<number>(foo) }}
</template>

<script lang=ts>
let Prettier = format => { your.js('though') }
  
const foo:any = {
    bar: 1,
    baz: 2,
}
</script>

<style>
.and { css: too !important }
</style>

Output:

SyntaxError: Unexpected closing tag "template". It may happen when the tag has already been closed by another tag. For more info see https://www.w3.org/TR/html5/syntax.html#closing-elements-that-have-implied-end-tags (5:1)
  3 |     </p>
  4 |   {{ Object.values<number>(foo) }}
> 5 | </template>
    | ^^^^^^^^^^^
  6 |
  7 | <script lang=ts>
  8 | let Prettier = format => { your.js('though') }

Expected behavior:

  • It at least doesn't crash
  • actually formatting it would be nice too
@sosukesuzuki sosukesuzuki added type:bug Issues identifying ugly output, or a defect in the program scope:dependency Issues that cannot be solved inside Prettier itself, and must be fixed in a dependency lang:vue Issues affecting Vue labels May 19, 2023
@fisker
Copy link
Member

fisker commented May 24, 2023

For now you can escape < as workaround. Vue SFC playground

@DaniilIsupov
Copy link

i have same problem
only as helps me, but this will only as temporary solution

@jemunk
Copy link

jemunk commented Jan 29, 2024

Any news on this?

@fisker

This comment was marked as off-topic.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
lang:vue Issues affecting Vue scope:dependency Issues that cannot be solved inside Prettier itself, and must be fixed in a dependency type:bug Issues identifying ugly output, or a defect in the program
Projects
None yet
Development

No branches or pull requests

5 participants