Issues trying to auto-import across project boundaries
See original GitHub issueTypeScript Version: 3.2.2, 3.3.0-rc
Search Terms: autoimport, project references, autocomplete
Code Full minimal repro: https://github.com/MLoughry/typescript-repro
See src/a/lib/index.ts
// If another file in the project already has an import from the other project,
// then attempting to auto-import `bar` will prompt you to import from 'obj/b/lib'
// If no other import is found within the project, no auto-import suggestions are found
console.log(bar);
Expected behavior:
Auto-import should work across project boundaries when an outDir
is specified (with or without paths
specified in tsconfig.json
)
Actual behavior:
- If there is already a cross-project import within the project: The auto-import attempts to import from the outDir.
- If there is no other cross-project import within the project: No import suggestions are found.
Issue Analytics
- State:
- Created 5 years ago
- Reactions:4
- Comments:9 (2 by maintainers)
Top Results From Across the Web
VSCode auto-import doesn't use library importPath #9465
In a workspace with both apps and libraries, the auto-import in VSCode doesn't attempt to import from libraries by name, but rather the...
Read more >Auto Import | IntelliJ IDEA Documentation - JetBrains
Show auto-import tooltip for. Select whether you want the IDE to show popups for Classes and/or for Static methods and fields.
Read more >Auto import in Visual Studio Code only offering absolute path ...
In Visual Studio Code, menu File β Preferences β Settings β User Settings, "typescript.preferences.importModuleSpecifier": "relative".
Read more >Repository auto-import - Pluralsight Help Center
Auto-import applies to all repo projects within a repo group. Toggle this feature on or off at any point. ... See more of...
Read more >MDM Port Status (with file) is showing Empty - SAP Community
Hi, We are having issues with Auto Import. This was working correctly some days back and has suddenly stopped. We restarted MDIS and...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
So, there are two issues here: one when the project has no other reference to the module, and another when it does.
Now that @sheetalkamat has laid them out, I can appreciate the perf implications of trying to fix the first issue (project has no other reference to module). However, would there be any perf implications to fixing the other issue (auto-import resolves to
outDir
file rather than source file)? It seems like just a matter of mapping theoutDir
path back to the source path, or am I mistaken?A big issue in our source code base as well. One single source tree with lots of tsconfig.json, all extending single tsconfig.base.json with
outDir: "build"
&composite: true
. References everywhere.In most cases VSC auto-imports from
build/
folder. Need to fix imports manually all the time.