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

Support updating references in JS files #15

Open
OliverJAsh opened this issue Jan 23, 2018 · 9 comments
Open

Support updating references in JS files #15

OliverJAsh opened this issue Jan 23, 2018 · 9 comments

Comments

@OliverJAsh
Copy link

I have a TS project that uses the allowJs and checkJs compiler options.

Currently, if I use this extension to move a TS file/folder, none of the references from JS files are updated.

Is this due to

private extensions: string[] = ['.ts', '.tsx'];
?

Would this be easy to add support for?

@stringham
Copy link
Owner

Are you using es6 style import/export in your .js files?

@OliverJAsh
Copy link
Author

@stringham Yes we are.

@stringham
Copy link
Owner

It would be possible to make this work, but I don't know how to tell the difference between a generated Js file and one that is part of the sources we care about. A lot of projects put the compiled js files next to their ts sources.

To make it work, changing the following might do it:

  1. include .js and .jsx in the extensions array (we could make this user configurable).
  2. Set the movets.filesToScan user preference to include the javascript files you care about in your project.

I don't have a project to test this on though, but if we tried this, it definitely won't affect users who don't care about allowJs/checkJs.

@OliverJAsh
Copy link
Author

Couldn't we check if the file is in the dependency graph of the current TS project? I.e. by tracing the graph from the files, include and exclude options in tsconfig.json.

@tnrich
Copy link

tnrich commented Jan 16, 2020

@stringham @OliverJAsh I just tried @stringham 's suggestion above and it does indeed work for JS-only projects. I'm not sure about mixed js-ts projects. Maybe @OliverJAsh's suggestion would work:

Couldn't we check if the file is in the dependency graph of the current TS project? I.e. by tracing the graph from the files, include and exclude options in tsconfig.json.

@stringham I definitely think adding a "Move JS" command would be super useful. In the meantime I'm going to publish a fork of this repo that allows for JS to be moved.

@stringham
Copy link
Owner

@tnrich I'm happy to accept a pull request for this feature.

@tnrich
Copy link

tnrich commented Jan 16, 2020

@stringham I just published my fork which should do the trick for me. https://marketplace.visualstudio.com/items?itemName=tnrich.move-ts-js

I'm afraid that making a whole new command might be a bit too much work for me atm.

@OliverJAsh
Copy link
Author

VS Code now has this functionality out of the box, so isn't this package now redundant?

@tnrich
Copy link

tnrich commented Jan 16, 2020

@OliverJAsh I haven't found that it works very well.. Maybe I'm mistaken but don't all the files in question have to be open for the path updates to take place?

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

No branches or pull requests

3 participants