-
Notifications
You must be signed in to change notification settings - Fork 12.5k
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
Don’t auto-import paths that are in a referenced project’s outDir #39267
Conversation
The failing unit tests make me want to refactor this further. We throw away too much info in |
But is this really intended behaviour? In real scenario (non editing) the package will still use outDir and not source.. And normal build will use |
Really, it depends on the referenced project’s |
Well from package point that may be true but from project references stand point the output is what matters (since you dont want to include the source file in your build) and hence i am not sure offering "src" vs "dist" is improvement. |
That depends on the relationship between the
Because the I can’t see any reason why you would ever want the latter. It’s not wrong on disk now, but what happens if you use |
Running into this as well - https://github.com/microsoft/vscode/issues/103087 https://github.com/bradennapier/typescript-auto-import-bug auto import completely broken |
This is superseded by #40253 |
@andrewbranch So this is like a breaking change in comparison to v3.9 if I understand correctly, right? In a monorepo setup (e.g. lerna & yarn workspaces), e.g. packages/shared is auto-symlinked to node_modules/shared. So in src+dist configuration, it's actually desired that IntelliSense suggests importing from shared/dist/ and not from shared/src/ - otherwise the paths won't just work at runtime. I posted some details here: #34677 (comment) The screenshot with an illustration on when it's desired to import from outDir packages/shared/dist/ is following: |
This didn’t get merged, so I would say it’s not a breaking change? |
This effect is reproducible on v4.x (e.g. on 4.0, on 4.0-beta etc.) too. So it's here for quite some time. |
The effect of this PR is not reproducible in any TypeScript version because it is not part of TypeScript. It was an experiment that failed and did not get merged. You may need to set up |
Fixes #38856
We started getting auto-imports from referenced project
outDir
s due to #37482. We do potentially need to look inoutDir
because the result could be thetypings
ormain
entry of the project’spackage.json
(which would be referenced in symlinked monorepo setups), in which case the resulting module specifier would be the bare non-relative package name. But if that file does not match thetypings
ormain
entry (or cannot be referenced through node_modules), we don’t want to use that file as a possible path to import, and we certainly don’t want it to crowd out the non-redirect source file.