-
Notifications
You must be signed in to change notification settings - Fork 13.1k
Watch for changes in types roots #11002
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
Watch for changes in types roots #11002
Conversation
src/server/utilities.ts
Outdated
|
|
||
| return Math.max.apply(Math, paths.map(path => { | ||
| if (host.directoryExists(path)) { | ||
| return host.getModifiedTime(path); |
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 returns a Date, but this function should return a number (Math.max probably converts it implicitly here).
|
👍 |
src/server/project.ts
Outdated
| } | ||
|
|
||
| watchTypeRoots(callback: (project: ConfiguredProject, path: string) => void) { | ||
| const roots = ts.getEffectiveTypeRoots(this.getCompilerOptions(), this.projectService.host); |
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.getEffectiveTypeRoots() ?
src/server/project.ts
Outdated
| if (roots) { | ||
| for (const root of roots) { | ||
| this.projectService.logger.info(`Add type root watcher for: ${root}`); | ||
| watchers.push(this.projectService.host.watchDirectory(root, path => callback(this, path), true)); |
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.
why recursive? we only care about the top level.
src/server/editorServices.ts
Outdated
| } | ||
|
|
||
| private onTypeRootFileChanged(project: ConfiguredProject, fileName: string) { | ||
| this.updateConfiguredProject(project); |
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.
consider adding a log message here.
src/server/editorServices.ts
Outdated
| } | ||
|
|
||
| private onTypeRootFileChanged(project: ConfiguredProject, fileName: string) { | ||
| this.updateConfiguredProject(project); |
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.
why not this.throttledOperations.schedule ? in case there is a flurry of these, e.g. npm install
|
@vladima can you take a look. |
Watch for changes in type roots and reload the project when that happens.
Only tested in VS code so far