stringham / move-ts

A Visual Studio Code plugin for updating relative imports when moving typescript files and folders in your workspace.
MIT License
52 stars 15 forks source link

Handle case when compiled *.d.ts is nearby #9

Closed wclr closed 7 years ago

wclr commented 7 years ago

It would be nice if move-ts could handle following case when compiled versions are nearby with the source:

some-file.ts --> moving this
some-file.d.ts
some-file.js

after moving some-file.ts references in other files do not change, probably because there is no error and it is importing now some-file.d.ts, which is probably not desirable in such cases.

Maybe it should move compiled versions with .ts file, maybe to ask about it or add an option if not introduce this behavior by default.

Current workaround would be to remove .d.ts/js before ts-move

stringham commented 7 years ago

I think this should work. Can you share a reproducible case?

wclr commented 7 years ago

What should work? It doesn't. 1) corresponding .d.ts/js files are not moved, 2) imports in other files are not changed.

Just try it.

stringham commented 7 years ago

I would not expect:

  1. for it to move .d.ts/js files.

I would expect that:

  1. Imports in other files are changed.

I just published a new version that should fix imports in other files being changed. Try updating and let me know if that doesn't work for you.

I'm not convinced that moving the corresponding compiled targets would be an expected behavior.

wclr commented 7 years ago

No it doesn't work for me. In example renameing config-map.ts -> `configMap.ts

ts-move It doesn't moved.ts/.js` and doesn't change import.

I'm not convinced that moving the corresponding compiled targets would be an expected behavior.

That why I proposed to ask (prompt) about it but also I would add a setting. In most cases, I would expect it to be desired default behavior at least for .d.ts file, because without this move it won't work properly.

stringham commented 7 years ago

There is code that assumes that the typings directory is not part of the workspace that you would want to manually update (since it's part of a build output)

files = files.filter((f) => {
    return f.fsPath.indexOf('typings') === -1 &&
        f.fsPath.indexOf('node_modules') === -1 &&
        f.fsPath.indexOf('jspm_packages') === -1;
});

We could make the exclude directories a configuration option.

stringham commented 7 years ago

If you'd like it to handle files in generated folders, please open another issue.

wclr commented 7 years ago

Ok thanks)