We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
As project prettier-plugin-organize-imports implemented organize imports based on vue-typescript (in prettier-plugin-organize-imports#55 and prettier-plugin-organize-imports#56), I found these two issues:
prettier-plugin-organize-imports
vue-typescript
In vue files with both script and script setup, the imports of both blocks are merged into one of them.
script
script setup
Example input:
<template> <BComp v-model="value"></BComp> </template> <script lang="ts"> import { defineComponent } from "vue"; export default defineComponent({ inheritAttrs: false }); </script> <script setup lang="ts"> import BComp from "./BComp.vue"; import { ref } from "vue"; const value = ref(""); </script>
Current output:
<template> <BComp v-model="value"></BComp> </template> <script lang="ts"> import { defineComponent, ref } from "vue"; import BComp from "./BComp.vue"; export default defineComponent({ inheritAttrs: false }); </script> <script setup lang="ts"> const value = ref(""); </script>
Diff:
@@ -3,13 +3,11 @@ </template> <script lang="ts"> -import { defineComponent } from "vue"; +import { defineComponent, ref } from "vue"; +import BComp from "./BComp.vue"; export default defineComponent({ inheritAttrs: false }); </script> <script setup lang="ts"> -import BComp from "./BComp.vue"; -import { ref } from "vue"; - const value = ref(""); </script>
Expected output: No change, the same as input.
Imports that are only used in the template, are removed (except for components).
<template> <AComp v-model="value" v-some-directive></AComp> </template> <script setup lang="ts"> import AComp from "./AComp.vue"; import { value, vSomeDirective } from "./utils"; </script>
<template> <AComp v-model="value" v-some-directive></AComp> </template> <script setup lang="ts"> import AComp from "./AComp.vue"; </script>
@@ -4,5 +4,4 @@ <script setup lang="ts"> import AComp from "./AComp.vue"; -import { value, vSomeDirective } from "./utils"; </script>
These examples are available in this repro.
The text was updated successfully, but these errors were encountered:
Hi @Shayan-To, I think this problem can be avoid by update typescript version to 4.7.3, can you confirm this?
Sorry, something went wrong.
Hi @johnsoncodehk!
I added typescript to the repro project I sent here, and tried version 4.7.4 and 4.7.3, and the behavior is no different from before.
typescript
4.7.4
4.7.3
I pushed a commit to the same repro gist so you can see whether I did something wrong.
c40153a
No branches or pull requests
As project
prettier-plugin-organize-imports
implemented organize imports based onvue-typescript
(in prettier-plugin-organize-imports#55 and prettier-plugin-organize-imports#56), I found these two issues:In vue files with both
script
andscript setup
, the imports of both blocks are merged into one of them.Example input:
Current output:
Diff:
Expected output: No change, the same as input.
Imports that are only used in the template, are removed (except for components).
Example input:
Current output:
Diff:
Expected output: No change, the same as input.
These examples are available in this repro.
The text was updated successfully, but these errors were encountered: