Reset the noEmitForJsFiles option when updating compiler options (#12570)
This commit is contained in:
parent
5108285df4
commit
3375fed667
|
@ -2729,6 +2729,65 @@ namespace ts.projectSystem {
|
|||
arguments: { projectFileName: projectName }
|
||||
}).response;
|
||||
assert.isTrue(diags.length === 0);
|
||||
|
||||
session.executeCommand(<server.protocol.SetCompilerOptionsForInferredProjectsRequest>{
|
||||
type: "request",
|
||||
command: server.CommandNames.CompilerOptionsForInferredProjects,
|
||||
seq: 3,
|
||||
arguments: { options: { module: ModuleKind.CommonJS } }
|
||||
});
|
||||
const diagsAfterUpdate = session.executeCommand(<server.protocol.CompilerOptionsDiagnosticsRequest>{
|
||||
type: "request",
|
||||
command: server.CommandNames.CompilerOptionsDiagnosticsFull,
|
||||
seq: 4,
|
||||
arguments: { projectFileName: projectName }
|
||||
}).response;
|
||||
assert.isTrue(diagsAfterUpdate.length === 0);
|
||||
});
|
||||
|
||||
it("for external project", () => {
|
||||
const f1 = {
|
||||
path: "/a/b/f1.js",
|
||||
content: "function test1() { }"
|
||||
};
|
||||
const host = createServerHost([f1, libFile]);
|
||||
const session = createSession(host);
|
||||
const projectService = session.getProjectService();
|
||||
const projectFileName = "/a/b/project.csproj";
|
||||
const externalFiles = toExternalFiles([f1.path]);
|
||||
projectService.openExternalProject(<protocol.ExternalProject>{
|
||||
projectFileName,
|
||||
rootFiles: externalFiles,
|
||||
options: {}
|
||||
});
|
||||
|
||||
checkNumberOfProjects(projectService, { externalProjects: 1 });
|
||||
|
||||
const diags = session.executeCommand(<server.protocol.CompilerOptionsDiagnosticsRequest>{
|
||||
type: "request",
|
||||
command: server.CommandNames.CompilerOptionsDiagnosticsFull,
|
||||
seq: 2,
|
||||
arguments: { projectFileName }
|
||||
}).response;
|
||||
assert.isTrue(diags.length === 0);
|
||||
|
||||
session.executeCommand(<server.protocol.OpenExternalProjectRequest>{
|
||||
type: "request",
|
||||
command: server.CommandNames.OpenExternalProject,
|
||||
seq: 3,
|
||||
arguments: {
|
||||
projectFileName,
|
||||
rootFiles: externalFiles,
|
||||
options: { module: ModuleKind.CommonJS }
|
||||
}
|
||||
});
|
||||
const diagsAfterUpdate = session.executeCommand(<server.protocol.CompilerOptionsDiagnosticsRequest>{
|
||||
type: "request",
|
||||
command: server.CommandNames.CompilerOptionsDiagnosticsFull,
|
||||
seq: 4,
|
||||
arguments: { projectFileName }
|
||||
}).response;
|
||||
assert.isTrue(diagsAfterUpdate.length === 0);
|
||||
});
|
||||
});
|
||||
|
||||
|
|
|
@ -248,9 +248,7 @@ namespace ts.server {
|
|||
this.compilerOptions.allowNonTsExtensions = true;
|
||||
}
|
||||
|
||||
if (this.projectKind === ProjectKind.Inferred || this.projectKind === ProjectKind.External) {
|
||||
this.compilerOptions.noEmitForJsFiles = true;
|
||||
}
|
||||
this.setInternalCompilerOptionsForEmittingJsFiles();
|
||||
|
||||
this.lsHost = new LSHost(this.projectService.host, this, this.projectService.cancellationToken);
|
||||
this.lsHost.setCompilationSettings(this.compilerOptions);
|
||||
|
@ -266,6 +264,12 @@ namespace ts.server {
|
|||
this.markAsDirty();
|
||||
}
|
||||
|
||||
private setInternalCompilerOptionsForEmittingJsFiles() {
|
||||
if (this.projectKind === ProjectKind.Inferred || this.projectKind === ProjectKind.External) {
|
||||
this.compilerOptions.noEmitForJsFiles = true;
|
||||
}
|
||||
}
|
||||
|
||||
getProjectErrors() {
|
||||
return this.projectErrors;
|
||||
}
|
||||
|
@ -637,6 +641,7 @@ namespace ts.server {
|
|||
this.lastCachedUnresolvedImportsList = undefined;
|
||||
}
|
||||
this.compilerOptions = compilerOptions;
|
||||
this.setInternalCompilerOptionsForEmittingJsFiles();
|
||||
this.lsHost.setCompilationSettings(compilerOptions);
|
||||
|
||||
this.markAsDirty();
|
||||
|
|
Loading…
Reference in a new issue