-
-
Notifications
You must be signed in to change notification settings - Fork 4.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Format TS expressions when any script tag has
lang="ts"
(#14587)
Co-authored-by: fisker <lionkay@gmail.com>
- Loading branch information
Showing
4 changed files
with
106 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
#### Format TS expressions when any script tag has `lang="ts"` (#14587 by @seiyab) | ||
|
||
<!-- prettier-ignore --> | ||
```vue | ||
<!-- Input --> | ||
<script></script> | ||
<script setup lang="ts"></script> | ||
<template> | ||
{{ (x as number).toFixed(2) }} | ||
</template> | ||
<!-- Prettier stable --> | ||
<script></script> | ||
<script setup lang="ts"></script> | ||
<template> | ||
{{ (x as number).toFixed(2) }} | ||
</template> | ||
<!-- Prettier main --> | ||
<script></script> | ||
<script setup lang="ts"></script> | ||
<template> | ||
{{ (x as number).toFixed(2) }} | ||
</template> | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
21 changes: 21 additions & 0 deletions
21
tests/format/vue/multiparser/lang-ts-multiple-script-tags.vue
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
<script></script> | ||
<script></script> | ||
<script></script> | ||
<script></script> | ||
<script></script> | ||
<script></script> | ||
<script setup lang="ts"> | ||
let x: string | number = 1 | ||
</script> | ||
<script></script> | ||
<script></script> | ||
<script></script> | ||
<template> | ||
<span | ||
v-if=" (x as string).length > 0" | ||
v-for="a in [1,2, 3,4,5].map( (x : number) => x * x)" | ||
:foo=" (x as number).toFixed( 2) " | ||
> | ||
{{ (x as number).toFixed(2) }} | ||
</span> | ||
</template> |