This handles when packages are symbol links in mono repo like scenarios to use source files instead of output d.ts from project reference (#34743)

* Fix incorrect outDir usage instead of out

* Handle symlinks of packages in mono repo like packages
Fixes #34723

* Added clarified comment
This commit is contained in:
Sheetal Nandi
2019-10-29 10:49:14 -07:00
committed by GitHub
parent 554bd24734
commit dbef230eb8
4 changed files with 226 additions and 18 deletions

View File

@@ -2271,7 +2271,19 @@ namespace ts {
// Get source file from normalized fileName
function findSourceFile(fileName: string, path: Path, isDefaultLib: boolean, ignoreNoDefaultLib: boolean, refFile: RefFile | undefined, packageId: PackageId | undefined): SourceFile | undefined {
if (useSourceOfProjectReferenceRedirect) {
const source = getSourceOfProjectReferenceRedirect(fileName);
let source = getSourceOfProjectReferenceRedirect(fileName);
// If preserveSymlinks is true, module resolution wont jump the symlink
// but the resolved real path may be the .d.ts from project reference
// Note:: Currently we try the real path only if the
// file is from node_modules to avoid having to run real path on all file paths
if (!source &&
host.realpath &&
options.preserveSymlinks &&
isDeclarationFileName(fileName) &&
stringContains(fileName, nodeModulesPathPart)) {
const realPath = host.realpath(fileName);
if (realPath !== fileName) source = getSourceOfProjectReferenceRedirect(realPath);
}
if (source) {
const file = isString(source) ?
findSourceFile(source, toPath(source), isDefaultLib, ignoreNoDefaultLib, refFile, packageId) :