Skip to content
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

Refactor support for Vetur #871

Open
octref opened this issue Aug 13, 2018 · 14 comments
Open

Refactor support for Vetur #871

octref opened this issue Aug 13, 2018 · 14 comments

Comments

@octref
Copy link
Member

octref commented Aug 13, 2018

Currently, TypeScript has a range of refactor support, such as extract to function. We should bring those in for <script> region.

Moreover, there are also Vue specific refactors that we could explore, for example: #820 (comment)

Being able to put a part of the current component's <template> into a new .vue file, with name and props auto populated seem very useful.

@hmnd
Copy link

hmnd commented Feb 17, 2019

Is this still planned? Would be really useful to have.

@beeplin
Copy link

beeplin commented Jul 3, 2019

Except for extract to function etc., it would be nice to support F2 (renaming) in .vue files.

@vinceramcesoliveros
Copy link

Just Necroing an issue that really needs to be solved in a large project that requires refactoring. I really want to know from someone who is handling big projects in VueJS and how do they refactor their components/variables/functions via F2(renaming) in vue files. I can easily refactor variables/functions in Javascript when //@ts-check is enabled. In Vue files, if I use Ctrl+F2 on a variable name and it has similar matches. it'll affect the whole app.

@arenddeboer
Copy link

I switched to writing all code into their own file and load it in the .vue file using

<script lang="ts" src="./MyComp.ts">
</script>

With plain Javascript you should of course drop the lang="ts" and use file.js
This makes the code eligible for refactoring everywhere.

@vinceramcesoliveros
Copy link

@arenddeboer does this work if it's in the template tags? (or lives in the template tag?). like changing from v-model="user" to v-model="person"(assume that I have change the variable name from the data property using F2 and not Ctrl+F2).

@yoyo930021
Copy link
Member

@Ram231
#610 (comment)

@arenddeboer
Copy link

@Ram231 nope, you are correct in that this does not refactor anything inside the template. But in my experience, there is still a lot to gain by moving it out into a .ts file. vscode seems to also perform much better.

@vinceramcesoliveros
Copy link

@Ram231 nope, you are correct in that this does not refactor anything inside the template. But in my experience, there is still a lot to gain by moving it out into a .ts file. vscode seems to also perform much better.

Pretty much I can relate to that(your way of separating JS/TS related code is somewhat similar to Mixins in vue). But handling the template tag is much more of a need here. It even affects my css class because it has a matching name.

@oliverw
Copy link

oliverw commented Oct 18, 2020

It is almost impossible to work on a larger codebase without any support for refactoring. Is this still in the works?

@yoyo930021
Copy link
Member

It is almost impossible to work on a larger codebase without any support for refactoring. Is this still in the works?

Follow #2016

@nicoespeon
Copy link

nicoespeon commented Nov 18, 2020

Hello here 👋

I think I can help with this specific question. If you're looking for automated refactoring for .vue files, I recently adapted one of my extension to support these: https://marketplace.visualstudio.com/items?itemName=nicoespeon.abracadabra

You can find more context around the decision here: nicoespeon/abracadabra#133

I don't do much Vue myself, but I'm using automated refactorings every day. With a little tweak, I was able to support Vue files for some users who needed it. I guess others can find it helpful too, while Vetur implements them 👍

@yoyo930021
Copy link
Member

yoyo930021 commented Nov 18, 2020

Hello here 👋

If you're looking for automated refactoring for .vue files, I recently adapted my extension to support these: https://marketplace.visualstudio.com/items?itemName=nicoespeon.abracadabra

You can find more context around the support decision here: nicoespeon/abracadabra#133

I don't do much Vue myself, but I'm using automated refactorings every day. With a little tweak, I was able to support Vue files as some users needed it. I guess others can find it helpful while Vetur implements them 👍

Thank you, We have not had enough time to develop this part.
But this has always been our goal.

If anyone interested, you can study this comment and this code.
And then send a PR.

@vinceramcesoliveros
Copy link

Hello here 👋

I think I can help with this specific question. If you're looking for automated refactoring for .vue files, I recently adapted one of my extension to support these: https://marketplace.visualstudio.com/items?itemName=nicoespeon.abracadabra

You can find more context around the decision here: nicoespeon/abracadabra#133

I don't do much Vue myself, but I'm using automated refactorings every day. With a little tweak, I was able to support Vue files for some users who needed it. I guess others can find it helpful too, while Vetur implements them 👍

Thanks! I stopped writing vue files because of rename symbol. might come back and try this extension to see the magic.

@weaversam8
Copy link

weaversam8 commented Sep 6, 2021

Per the discussion in nicoespeon/abracadabra#243, Nicolas has decided that the functionality to refactor components to a new file should live in Vetur rather than abracadabra. Adding that context to this issue, since this would be a MAJOR feature for Vue developers.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

9 participants