Skip to content

Watch for changes in types roots#11002

Merged
RyanCavanaugh merged 13 commits intomicrosoft:release-2.0.5from
RyanCavanaugh:watchForTypes
Sep 21, 2016
Merged

Watch for changes in types roots#11002
RyanCavanaugh merged 13 commits intomicrosoft:release-2.0.5from
RyanCavanaugh:watchForTypes

Conversation

@RyanCavanaugh
Copy link
Copy Markdown
Member

Watch for changes in type roots and reload the project when that happens.

Only tested in VS code so far

Comment thread src/server/utilities.ts Outdated

return Math.max.apply(Math, paths.map(path => {
if (host.directoryExists(path)) {
return host.getModifiedTime(path);
Copy link
Copy Markdown
Member

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).

@billti
Copy link
Copy Markdown
Member

billti commented Sep 20, 2016

👍

Comment thread src/server/project.ts Outdated
}

watchTypeRoots(callback: (project: ConfiguredProject, path: string) => void) {
const roots = ts.getEffectiveTypeRoots(this.getCompilerOptions(), this.projectService.host);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this.getEffectiveTypeRoots() ?

Comment thread 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));
Copy link
Copy Markdown
Contributor

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.

Comment thread src/server/editorServices.ts Outdated
}

private onTypeRootFileChanged(project: ConfiguredProject, fileName: string) {
this.updateConfiguredProject(project);
Copy link
Copy Markdown
Contributor

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.

Comment thread src/server/editorServices.ts Outdated
}

private onTypeRootFileChanged(project: ConfiguredProject, fileName: string) {
this.updateConfiguredProject(project);
Copy link
Copy Markdown
Contributor

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

@mhegazy
Copy link
Copy Markdown
Contributor

mhegazy commented Sep 20, 2016

@vladima can you take a look.

@RyanCavanaugh RyanCavanaugh merged commit 53232b9 into microsoft:release-2.0.5 Sep 21, 2016
@RyanCavanaugh RyanCavanaugh deleted the watchForTypes branch September 21, 2016 00:12
@microsoft microsoft locked and limited conversation to collaborators Jun 19, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants