Prettier 2.8.6
Playground link
Input:
<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
|
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>
Prettier 2.8.6
Playground link
Input:
Output:
Expected behavior:
Should parse as TS. Vue playground
Problem is here
prettier/src/language-html/print-preprocess.js
Lines 413 to 426 in c6e026e
Should check any
<script>instead of only checking the first<script>