-
Notifications
You must be signed in to change notification settings - Fork 12.9k
Set maxNodeModuleJsDepth for inferred projects #11603
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
@@ -126,6 +126,13 @@ namespace ts.server { | |||
this.compilerOptions.allowNonTsExtensions = true; | |||
} | |||
|
|||
if (this.projectKind === ProjectKind.Inferred) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should we check also that the project has .js files?
@zhengbli can you refresh this PR. |
@mhegazy updated with a new implementation. Now the inferred project has a property called "isJsInferredProject" which serves as compilerOptions-independent flag so "js inferred project" can have different behavior than the normal inferred projects. |
private _isJsInferredProject = false; | ||
set isJsInferredProject(newValue: boolean) { | ||
if (newValue && !this._isJsInferredProject) { | ||
this.setCompilerOptions(this.getCompilerOptions()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this looks odd
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
also before calling setCompilerOptions
this._isJsInferredProject
is not yet set so I'm not sure how control flow should enter if
statement below if this._isJsInferredProject
was false
+ if (this._isJsInferredProject && typeof newOptions.maxNodeModuleJsDepth !== "number") {
+ newOptions.maxNodeModuleJsDepth = 2;
+ }
@@ -3051,4 +3051,29 @@ namespace ts.projectSystem { | |||
service.checkNumberOfProjects({ externalProjects: 1 }); | |||
}); | |||
}); | |||
|
|||
describe("maxNodeModuleJsDepth for inferred projects", () => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can you have a test that actually verifies the value of maxModuleDepth
(i.e. that we are not looking into folders that are located deeper)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated the test
@@ -715,6 +712,26 @@ namespace ts.server { | |||
} | |||
})(); | |||
|
|||
private _isJsInferredProject = false; | |||
set isJsInferredProject(newValue: boolean) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
personal nit: I'm not a big fan of set-only accessors, can you turn it into method instead?
Fixes #11116