microsoft / TypeScript

TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
https://www.typescriptlang.org
Apache License 2.0
100.1k stars 12.37k forks source link

JavaScript: jsconfig.json based project -> Automatically updating imports after file move will not work on complex import statement chains #59242

Open andremarcondesteixeira opened 2 months ago

andremarcondesteixeira commented 2 months ago

Does this issue occur when all extensions are disabled?: Yes/No

Steps to Reproduce:

  1. Clone this repo: https://github.com/andremarcondesteixeira/vscodebug-auto-imports-wont-work-on-complex-import-chains
  2. Open the repository in VSCode
  3. Move the entire folder /js/custom-elements to inside the /js/presentation folder
  4. Notice that the import in the file /js/index.js was not automatically fixed
  5. Undo the moving of the files
  6. In the file /js/custom-elements/assets-list/assets-list-element.js, remove the import from the top of the file and comment out the code using the import
  7. Move again the entire folder /js/custom-elements to inside the /js/presentation folder
  8. Notice that this time, the import in the file /js/index.js was automatically fixed
  9. The behavior can some times be inconsistent or intermitent. It only seems to happen to me in complex import chains, mainly when the import chain goes back UP some levels in the file system and using relative file paths
andremarcondesteixeira commented 1 month ago

Why was this moved to Typescript? It has nothing to do with Typescript...

fatcerberus commented 1 month ago

The TypeScript language service deals with this, that’s why. jsconfig.json is effectively just a tsconfig.json with implied "allowJs": true.