mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-05-22 12:03:44 -05:00
Make sure project root paths of inferred projects are canonical when comparing
This commit is contained in:
@@ -590,9 +590,9 @@ namespace ts.server {
|
||||
// always set 'allowNonTsExtensions' for inferred projects since user cannot configure it from the outside
|
||||
// previously we did not expose a way for user to change these settings and this option was enabled by default
|
||||
compilerOptions.allowNonTsExtensions = true;
|
||||
|
||||
if (projectRootPath) {
|
||||
this.compilerOptionsForInferredProjectsPerProjectRoot.set(projectRootPath, compilerOptions);
|
||||
const canonicalProjectRootPath = projectRootPath && this.toCanonicalFileName(projectRootPath);
|
||||
if (canonicalProjectRootPath) {
|
||||
this.compilerOptionsForInferredProjectsPerProjectRoot.set(canonicalProjectRootPath, compilerOptions);
|
||||
}
|
||||
else {
|
||||
this.compilerOptionsForInferredProjects = compilerOptions;
|
||||
@@ -608,9 +608,9 @@ namespace ts.server {
|
||||
// root path
|
||||
// - Inferred projects with a projectRootPath, if the new options apply to that
|
||||
// project root path.
|
||||
if (projectRootPath ?
|
||||
project.projectRootPath === projectRootPath :
|
||||
!project.projectRootPath || !this.compilerOptionsForInferredProjectsPerProjectRoot.has(project.projectRootPath)) {
|
||||
if (canonicalProjectRootPath ?
|
||||
project.projectRootPath === canonicalProjectRootPath :
|
||||
!project.projectRootPath || !this.compilerOptionsForInferredProjectsPerProjectRoot.has(project.projectRootPath)) {
|
||||
project.setCompilerOptions(compilerOptions);
|
||||
project.compileOnSaveEnabled = compilerOptions.compileOnSave;
|
||||
project.markAsDirty();
|
||||
@@ -1596,9 +1596,10 @@ namespace ts.server {
|
||||
}
|
||||
|
||||
if (projectRootPath) {
|
||||
const canonicalProjectRootPath = this.toCanonicalFileName(projectRootPath);
|
||||
// if we have an explicit project root path, find (or create) the matching inferred project.
|
||||
for (const project of this.inferredProjects) {
|
||||
if (project.projectRootPath === projectRootPath) {
|
||||
if (project.projectRootPath === canonicalProjectRootPath) {
|
||||
return project;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1047,12 +1047,15 @@ namespace ts.server {
|
||||
super.setCompilerOptions(newOptions);
|
||||
}
|
||||
|
||||
/** this is canonical project root path */
|
||||
readonly projectRootPath: string | undefined;
|
||||
|
||||
/*@internal*/
|
||||
constructor(
|
||||
projectService: ProjectService,
|
||||
documentRegistry: DocumentRegistry,
|
||||
compilerOptions: CompilerOptions,
|
||||
readonly projectRootPath: string | undefined,
|
||||
projectRootPath: string | undefined,
|
||||
currentDirectory: string | undefined) {
|
||||
super(InferredProject.newName(),
|
||||
ProjectKind.Inferred,
|
||||
@@ -1064,6 +1067,7 @@ namespace ts.server {
|
||||
/*compileOnSaveEnabled*/ false,
|
||||
projectService.host,
|
||||
currentDirectory);
|
||||
this.projectRootPath = projectRootPath && projectService.toCanonicalFileName(projectRootPath);
|
||||
}
|
||||
|
||||
addRoot(info: ScriptInfo) {
|
||||
|
||||
Reference in New Issue
Block a user