Add option disableSourceOfProjectReferenceRedirect to disable using sources of project reference redirect from editor

This commit is contained in:
Sheetal Nandi
2019-07-10 15:21:24 -07:00
parent 824c22c460
commit b631850978
13 changed files with 110 additions and 51 deletions

View File

@@ -2583,7 +2583,7 @@ namespace ts.server {
if (!configFileName) return undefined;
const configuredProject = this.findConfiguredProjectByProjectName(configFileName) ||
this.createAndLoadConfiguredProject(configFileName, `Creating project for original file: ${originalFileInfo.fileName}${location !== originalLocation ? " for location " + location.fileName : ""}`);
this.createAndLoadConfiguredProject(configFileName, `Creating project for original file: ${originalFileInfo.fileName}${location !== originalLocation ? " for location: " + location.fileName : ""}`);
if (configuredProject === project) return originalLocation;
updateProjectIfDirty(configuredProject);
// Keep this configured project as referenced from project

View File

@@ -1540,11 +1540,12 @@ namespace ts.server {
}
/* @internal */
useSourceInsteadOfReferenceRedirect = () => !!this.languageServiceEnabled;
useSourceOfProjectReferenceRedirect = () => !!this.languageServiceEnabled &&
!this.getCompilerOptions().disableSourceOfProjectReferenceRedirect;
fileExists(file: string): boolean {
// Project references go to source file instead of .d.ts file
if (this.useSourceInsteadOfReferenceRedirect() && this.projectReferenceCallbacks) {
if (this.useSourceOfProjectReferenceRedirect() && this.projectReferenceCallbacks) {
const source = this.projectReferenceCallbacks.getSourceOfProjectReferenceRedirect(file);
if (source) return isString(source) ? super.fileExists(source) : true;
}
@@ -1553,7 +1554,7 @@ namespace ts.server {
directoryExists(path: string): boolean {
if (super.directoryExists(path)) return true;
if (!this.useSourceInsteadOfReferenceRedirect() || !this.projectReferenceCallbacks) return false;
if (!this.useSourceOfProjectReferenceRedirect() || !this.projectReferenceCallbacks) return false;
if (!this.mapOfDeclarationDirectories) {
this.mapOfDeclarationDirectories = createMap();