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
Format TypeScript expressions in Vue template attributes #14506
Format TypeScript expressions in Vue template attributes #14506
Conversation
it's ready for review 🚀 |
tests/format/vue/ts-expression/__snapshots__/jsfmt.spec.js.snap
Outdated
Show resolved
Hide resolved
It seems we still missing some places, This place seems using wrong parser? Maybe we need |
For the former in #14506 (comment), I agree with you. I'll fix it. About the latter in #14506 (comment) , I need more investigation. I'll see #14506 (comment) too. |
Can you change base to |
f14bf65
to
9bbb0d5
Compare
9bbb0d5
to
b8a2fbb
Compare
<template> | ||
<MyComponent :src="100000000000000000000000000000000000000000000000000000000000000000000000000"/> | ||
</template> | ||
<script lang="ts"></script> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you can put all attributes in one component, and please add final_new_line.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, I see it's copied from tests/format/vue/vue/expression-binding.vue, can you put them together instead of move it to another dir. maybe tests/format/vue/vue/expression-binding-ts.vue
?
…sts/format/vue/vue/expression-binding-ts.vue
|
Prettier pr-14506 --parser vue Input: <script lang="ts"></script>
<template>
<ul>
<li v-for="a:number
of x as number">{{a}}</li>
</ul>
</template> Output: <script lang="ts"></script>
<template>
<ul>
<li
v-for="a:number
of x as number"
>
{{ a }}
</li>
</ul>
</template>
|
Thanks, I'll also fix v-for. I think I need to fix following as you said before. I think it relates to v-slot. However, v-slot with TS seems to work mysteriously. Maybe I'm misunderstanding... 🤔 Edit: |
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
src/language-html/embed.js
Outdated
return printVueFor(getValue(), attributeTextToDoc); | ||
return printVueFor(getValue(), attributeTextToDoc, { | ||
ts: options.__should_parse_vue_template_with_ts, | ||
}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's pass options
, we may need access other props in future.
tests/format/vue/v-for/ts.vue
Outdated
v-for="([longLongProp, longLongProp, [longLongProp, longLongProp='Hello, Prettier!', [longLongProp, longLongProp, anotherLongLongProp=[longLongProp, longLongProp, anotherLongLongProp, yetAnotherLongLongProp], yetAnotherLongLongProp], yetAnotherLongLongProp], yetAnotherLongLongProp], index) of longLongLongLongLongLongLongLongList" | ||
> | ||
</div> | ||
</template> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: add a new line at last.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, I found that I had disabled editorconfig plugin mistakenly 😅
Looks great! Thank you for your hard work. I'll take another look tomorrow. |
# Conflicts: # src/language-js/parse/parsers.js
Nice work! Thanks. You may interest #14575 |
Thank so much for your friendly supports. |
Description
Fix #14432
Checklist
(If changing the API or CLI) I’ve documented the changes I’ve made (in thedocs/
directory).changelog_unreleased/*/XXXX.md
file followingchangelog_unreleased/TEMPLATE.md
.✨Try the playground for this PR✨