Skip to content

Commit 09fc3b3

Browse files
committed
address cr feedback
1 parent bf5faa0 commit 09fc3b3

File tree

3 files changed

+16
-13
lines changed

3 files changed

+16
-13
lines changed

src/harness/unittests/tsserverProjectSystem.ts

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3067,12 +3067,15 @@ namespace ts.projectSystem {
30673067
const projectService = createProjectService(host);
30683068
projectService.openClientFile(file1.path);
30693069

3070-
const project = projectService.inferredProjects[0];
3071-
const sourceFileForFile1 = project.getSourceFile(<Path>file1.path);
3072-
const sourceFileForModuleFile = project.getSourceFile(<Path>moduleFile.path);
3073-
3074-
assert.isNotNull(sourceFileForFile1);
3075-
assert.isNotNull(sourceFileForModuleFile);
3070+
let project = projectService.inferredProjects[0];
3071+
let options = project.getCompilerOptions();
3072+
assert.isTrue(options.maxNodeModuleJsDepth === 2);
3073+
3074+
// Assert the option sticks
3075+
projectService.setCompilerOptionsForInferredProjects({ target: ScriptTarget.ES2016 });
3076+
project = projectService.inferredProjects[0];
3077+
options = project.getCompilerOptions();
3078+
assert.isTrue(options.maxNodeModuleJsDepth === 2);
30763079
});
30773080
});
30783081

src/server/editorServices.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1073,7 +1073,7 @@ namespace ts.server {
10731073
: new InferredProject(this, this.documentRegistry, this.compilerOptionsForInferredProjects);
10741074

10751075
if (root.scriptKind === ScriptKind.JS || root.scriptKind === ScriptKind.JSX) {
1076-
project.isJsInferredProject = true;
1076+
project.setAsJsInferredProject();
10771077
}
10781078

10791079
project.addRoot(root);

src/server/project.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -713,14 +713,14 @@ namespace ts.server {
713713
})();
714714

715715
private _isJsInferredProject = false;
716-
set isJsInferredProject(newValue: boolean) {
717-
if (newValue && !this._isJsInferredProject) {
718-
this.setCompilerOptions(this.getCompilerOptions());
719-
}
720-
this._isJsInferredProject = newValue;
716+
717+
setAsJsInferredProject() {
718+
this._isJsInferredProject = true;
719+
this.setCompilerOptions();
721720
}
722721

723-
setCompilerOptions(newOptions: CompilerOptions) {
722+
setCompilerOptions(newOptions?: CompilerOptions) {
723+
newOptions = newOptions ? newOptions : this.getCompilerOptions();
724724
if (!newOptions) {
725725
return;
726726
}

0 commit comments

Comments
 (0)