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

Auto update import paths and "move to a new file" refactoring does not work #51366

Closed
ivanvoznyakovsky opened this issue Jun 7, 2018 · 7 comments
Assignees
Labels
typescript Typescript support issues upstream Issue identified as 'upstream' component related (exists outside of VS Code)

Comments

@ivanvoznyakovsky
Copy link

  • VSCode Version: 1.24.0, 1.25.0-insider
  • OS Version: macOS 10.13.4

Import paths are not updated and it's not possible to refactor a class to a new file with a specific value of files in tsconfig.json.

Here's a test repo.

Without changing anything try to move file app/services/service1.ts to app/services/core folder. No request to update imports hence app/services/index.ts has broken import.
Open app/services/service1.ts and try to refactor out Service2 class to a new file. After clicking Move to a new file nothing happens. Literally nothing.
Now comment out "files": ["./app/app.ts"] in tsconfig.json or replace it with one of commented out lines for files and try to do all the above. All should work as expected.

Does this issue occur when all extensions are disabled?: Yes
Does this issue occur in insiders build?: Yes

@vscodebot
Copy link

vscodebot bot commented Jun 7, 2018

(Experimental duplicate detection)
Thanks for submitting this issue. Please also check if it is already covered by an existing one, like:

@mjbvz
Copy link
Collaborator

mjbvz commented Jun 7, 2018

For update paths: When you set "file: [./app/app.ts"], you've told typescript that only that one file is part of the project. That's why the references are not update in that case. You need to include at least the moved file and the referencing file in the same project

The move to file issue is a bug. I've opened microsoft/TypeScript#24757 to track this

@mjbvz mjbvz closed this as completed Jun 7, 2018
@mjbvz mjbvz added the upstream Issue identified as 'upstream' component related (exists outside of VS Code) label Jun 7, 2018
@ivanvoznyakovsky
Copy link
Author

For update paths: When you set "file: [./app/app.ts"], you've told typescript that only that one file is part of the project.

how is this possible? isn't it that by setting file: ["./app/app.ts"] I only tell TS that this is my entry point for the whole project. all the rest is imported down the road.
we have a project that has almost 50K ts files. are you suggesting to add all of them to files?

@mjbvz
Copy link
Collaborator

mjbvz commented Jun 8, 2018

Use include and/or exclude

@ivanvoznyakovsky
Copy link
Author

it's not a solution but rather a workaround on the bug that for some reason a file is not resolved to be included in the project.

@ivanvoznyakovsky
Copy link
Author

main purpose of file: ["./app/app.ts"] is to get a single file after compilation and not 50k of compiled files. doesn't it make sense?

@zuzusik
Copy link

zuzusik commented Jun 8, 2018

@mjbvz according to docs:

Any files that are referenced by files included via the "files" or "include" properties are also included

so looks like this feature is not aligned with core concepts - I would still consider this as a bug

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
typescript Typescript support issues upstream Issue identified as 'upstream' component related (exists outside of VS Code)
Projects
None yet
Development

No branches or pull requests

3 participants