-
-
Notifications
You must be signed in to change notification settings - Fork 33
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
Use vue-typescript
(from Volar) for supporting vue, instead of directly using sfc compiler
#55
Comments
Thanks for the issue, however I'm not sure how to use that. The vue-tsc readme is pretty sparse and only says that it's for type-checking vue files, which is not what we would need here (we need a parser). Also looks like there's no proper programmatic API exposed (just a binary). Did you actually mean using vue-typescript?That's what your chat is talking about at least. I've skimmed through the source (cause there's no readme) and not really sure what to do with that either... really open to a PR for this but I don't currently have any spare time for it. I've checked #41 again, and reading through the comments I'm just not sure how to go about Vue support in general. There's these edge cases like removal of unused component imports even though they are used in the template, and without a holistic understanding and parsing of the whole Vue file it'll be difficult to get this right. TBH moving forward I think the best option might be to implement an option for #37 to only sort but not organize imports, and then enable that by default for Vue (so that no imports get removed automatically). Then just need to add the setup script support from the PR. |
You are right, I meant If (#37 is not particularly useful to me, as I want my unused imports to be actually removed. But I can see that it is indeed a useful feature.) |
Ok, so you're saying I can create a language service with |
Just tried and I get
So |
Hi @simonhaenisch, |
vue-tsc
(from Volar) for supporting vue, instead of directly using sfc compilervue-typescript
(from Volar) for supporting vue, instead of directly using sfc compiler
Hey @johnsoncodehk thanks for the info... I figured out now that I was importing from Anyway, my existing language service host instance is incompatible because it's missing a getVueCompilationSettings() {
return {};
} or where would i get the compilation settings from? I mean this type-checks but not sure it makes any sense. |
But |
I've made a PR but it's failing though... tried running it on a new file, and getting an error |
Hm ok i've had this same problem before and looks like it can be fixed by appending |
I can't get your error, it should failed with sorting import properties for me. And if I change
Yes it can handle .vue. But not sure why not works for you yet, the cicd has same result with me: https://github.com/simonhaenisch/prettier-plugin-organize-imports/runs/6915996161?check_suite_focus=true |
You can only see the error if you run it like
Yeah but then that would mean that the plugin didn't work as expected (because it sorts imports alphabetically) 🙃 Not sure why it doesn't work with Anyway, thanks for your help! |
@Shayan-To can you please try out version |
@simonhaenisch It seems |
@simonhaenisch @johnsoncodehk This is an unexpected change: @@ -61,22 +61,20 @@
</SimpleDialog>
</div>
</template>
<script lang="ts">
-import { defineComponent } from "vue";
-export default defineComponent({ inheritAttrs: false });
-</script>
-
-<script setup lang="ts">
import { TrackerDefinition, trackerDefinitions } from "src/data/trackers";
import { getObjectValues } from "src/utils";
import { imUsing } from "src/utils/vue";
import SimpleDialog from "src/view/components/SimpleDialog.vue";
-import { computed, Ref, toRefs } from "vue";
+import { computed, defineComponent, Ref, toRefs } from "vue";
import { SetupTrackerPages } from "./setup-tracker-pages";
+export default defineComponent({ inheritAttrs: false });
+</script>
+<script setup lang="ts">
imUsing(trackerDefinitions, SimpleDialog, getObjectValues);
const props = defineProps<{
selectedTracker: Ref<TrackerDefinition | null>;
currentPage: Ref<SetupTrackerPages>; I also found two more issues:
|
Well, at this point I'm not sure what to do about this 🤷🏻♂️ because now it's up to Regarding the difference between Prettier from VS Code vs CLI, I'm really not sure how that's possible, but I'm assuming the VS Code plugin has some special logic to run Prettier on file ranges based on their language, i. e. it would run in Or maybe you have set some of the |
@johnsoncodehk Should I open an issue on Volar repo? Should I provide a repro link? (I didn't provide a repro because it did the same on almost all my files.) |
@Shayan-To Yes please open an issue to Volar repo, repro link is not needed, but please describe current behavior and expected behavior. |
I was looking for a solution for #40, and I asked in the Volar Discord channel. and the main developer told me that:
So it seems like you can entrust the work of parsing and modifying Vue file to
vue-tsc
project.The text was updated successfully, but these errors were encountered: