-
-
Notifications
You must be signed in to change notification settings - Fork 4.6k
Closed
Copy link
Labels
good first issueGood fist issue!Good fist issue!lang:vueIssues affecting VueIssues affecting Vuelocked-due-to-inactivityPlease open a new issue and fill out the template instead of commenting.Please open a new issue and fill out the template instead of commenting.
Description
Prettier 2.8.6
Playground link
--parser vueInput:
<script></script>
<script setup lang="ts">
let x: string | number = 1
</script>
<template>
{{ (x as number).toFixed(2) }}
</template>Output:
<script></script>
<script setup lang="ts">
let x: string | number = 1;
</script>
<template>
{{ (x as number).toFixed(2) }}
</template>
Expected behavior:
Should parse as TS. Vue playground
Problem is here
prettier/src/language-html/print-preprocess.js
Lines 413 to 426 in c6e026e
| function markTsScript(ast, options) { | |
| if (options.parser === "vue") { | |
| const vueScriptTag = ast.children.find((child) => | |
| isVueScriptTag(child, options) | |
| ); | |
| if (!vueScriptTag) { | |
| return; | |
| } | |
| const { lang } = vueScriptTag.attrMap; | |
| if (lang === "ts" || lang === "typescript") { | |
| options.__should_parse_vue_template_with_ts = true; | |
| } | |
| } | |
| } |
Should check any <script> instead of only checking the first <script>
Metadata
Metadata
Assignees
Labels
good first issueGood fist issue!Good fist issue!lang:vueIssues affecting VueIssues affecting Vuelocked-due-to-inactivityPlease open a new issue and fill out the template instead of commenting.Please open a new issue and fill out the template instead of commenting.