https://github.com/vilic/bug-repros/tree/typescript-32028
3.8.0-dev.20191023

3.6.3

_Originally posted by @vilic in https://github.com/microsoft/TypeScript/pull/32028#issuecomment-545388236_
Also from the issue comment
The auto import path seems to be affected by this change. E.g. previously I have a module of which the auto import path is shared but now it's shared/src/library.
Thesharedmodule is a linked module which is also one of the referenced projects, it haspackage.jsonwithtypesset tobld/library/index.d.tsand I guess that's why the auto import path worked assharedinstead ofshared/bld/library.
@vilic the repro you provided has some issues.. I don't see module resolution happening..
c:\temp\bug-repros>node node_modules\typescript\lib\tsc.js -v
Version 3.8.0-dev.20191023
c:\temp\bug-repros>node node_modules\typescript\lib\tsc.js -b -v --traceResolution
[11:10:54 AM] Projects in this build:
* shared/src/library/tsconfig.json
* app/src/program/tsconfig.json
* tsconfig.json
[11:10:54 AM] Project 'shared/src/library/tsconfig.json' is out of date because output file 'shared/bld/library/index.js' does not exist
[11:10:54 AM] Building project 'c:/temp/bug-repros/shared/src/library/tsconfig.json'...
[11:10:55 AM] Project 'app/src/program/tsconfig.json' is out of date because output file 'app/bld/program/bar.js' does not exist
[11:10:55 AM] Building project 'c:/temp/bug-repros/app/src/program/tsconfig.json'...
======== Resolving module 'shared' from 'c:/temp/bug-repros/app/src/program/bar.ts'. ========
Module resolution kind is not specified, using 'NodeJs'.
Loading module 'shared' from 'node_modules' folder, target file type 'TypeScript'.
Directory 'c:/temp/bug-repros/app/src/program/node_modules' does not exist, skipping all lookups in it.
Directory 'c:/temp/bug-repros/app/src/node_modules' does not exist, skipping all lookups in it.
Directory 'c:/temp/bug-repros/app/node_modules' does not exist, skipping all lookups in it.
File 'c:/temp/bug-repros/node_modules/shared.ts' does not exist.
File 'c:/temp/bug-repros/node_modules/shared.tsx' does not exist.
File 'c:/temp/bug-repros/node_modules/shared.d.ts' does not exist.
Directory 'c:/temp/bug-repros/node_modules/@types' does not exist, skipping all lookups in it.
Directory 'c:/temp/node_modules' does not exist, skipping all lookups in it.
Directory 'c:/node_modules' does not exist, skipping all lookups in it.
Loading module 'shared' from 'node_modules' folder, target file type 'JavaScript'.
Directory 'c:/temp/bug-repros/app/src/program/node_modules' does not exist, skipping all lookups in it.
Directory 'c:/temp/bug-repros/app/src/node_modules' does not exist, skipping all lookups in it.
Directory 'c:/temp/bug-repros/app/node_modules' does not exist, skipping all lookups in it.
File 'c:/temp/bug-repros/node_modules/shared.js' does not exist.
File 'c:/temp/bug-repros/node_modules/shared.jsx' does not exist.
Directory 'c:/temp/node_modules' does not exist, skipping all lookups in it.
Directory 'c:/node_modules' does not exist, skipping all lookups in it.
======== Module name 'shared' was not resolved. ========
app/src/program/bar.ts:1:19 - error TS2307: Cannot find module 'shared'.
1 import {foo} from 'shared';
~~~~~~~~
app/src/program/index.ts:1:1 - error TS2304: Cannot find name 'foo'.
1 foo;
~~~
Found 2 errors.
c:\temp\bug-repros>
@sheetalkamat Are you using yarn or npm? The repro is using yarn workspaces linking projects.
I have cloned and ran the tsc with nightly. If those aren't the steps to repro, please provide correct repro steps.
@sheetalkamat Steps after clone:
yarn under the project directory.yarn tsc --build (Expecting error Cannot find name 'foo'.)app/src/program/index.ts, and try auto fixes on identifier foo.BTW just confirmed that setting disableSourceOfProjectReferenceRedirect as true brings back the old behavior.
Is there any way to get intellisence proposals across referenced projects when the "shared" project has a directory of type declarations? So multiple d.ts files instead of just index.d.ts.
This is a really awesome cool fix! Looks like, at last, In April 2020, TS & VSCode become both monorepo-friendly!
I also prepared a repro steps where IntelliSense incorrectly proposes to auto-import files from src/ instead of dist/, but I can confirm that in 3.9.1-rc it stopped reproducing.
Just in case, here are these repro examples: https://github.com/DmitryKoterov/intellisense-composite
A screenshot from default/ folder from there (TS 3.8.3, wrong behavior):

And a screenshot from disableSourceOfProjectReferenceRedirect-true folder which sets disableSourceOfProjectReferenceRedirect=true (TS 3.8.3 still, the above behavior disappeared):

In TS 3.9.1-rc, the 1st screenshot stopped reproducing - and it's great!
@sheetalkamat Looks like it regressed in v4 (or the behavior changed intentionally?). I added the details here: https://github.com/microsoft/TypeScript/pull/32028#issuecomment-732731629
Starting from v4.0, VSCode's IntelliSense behavior has changed.
In v3.9, when having references in packages/client/tsconfig.json pointing to some other project packages/shared/ in the monorepo, AutoImport suggested to import files from "shared/dist/xyz" (which is correct: dist/ folder contains *.js and *.d.ts files compiled by the build step of that shared/ project in the monorepo, and the current PR ensures the seamless integration with src/). This behavior worked perfectly and allowed us to split the large TS codebase into independent projects which were built separately and then just referred each other via yarn workspaces (workspaces just create a symlink in top-level node_modules, like node_modules/~shared -> packages/shared). The PR of @sheetalkamat literally saved us in Jun 2019, because this closed the loop on supporting monorepos in TS and allowed to run parallel builds & watchers easily.
In v4.0 however, the behavior has changed: if packages/client/tsconfig.json has references directive, IntelliSense proposes to import from "shared/src/xyz" and not from shared/dist - which breaks the monorepo build pipeline (lerna-based).
I'm trying to find the corresponding issue or a PR or a changelog entry about this change of behavior, but I can't.
The repro repository: https://github.com/DmitryKoterov/intellisense-composite/tree/master/defaultV4
Here is a screenshot of IntelliSense trying to auto-import from src/ and not from dist/ of the monorepo's shared project in v4.2.0 (recent):

Most helpful comment
@sheetalkamat Steps after clone:
yarnunder the project directory.yarn tsc --build(Expecting errorCannot find name 'foo'.)app/src/program/index.ts, and try auto fixes on identifierfoo.BTW just confirmed that setting
disableSourceOfProjectReferenceRedirectastruebrings back the old behavior.