Skip to content

Conversation

@RyanCavanaugh
Copy link
Member

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

Only tested in VS code so far


return Math.max.apply(Math, paths.map(path => {
if (host.directoryExists(path)) {
return host.getModifiedTime(path);
Copy link
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
Member

billti commented Sep 20, 2016

👍

}

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

Choose a reason for hiding this comment

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

this.getEffectiveTypeRoots() ?

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

}

private onTypeRootFileChanged(project: ConfiguredProject, fileName: string) {
this.updateConfiguredProject(project);
Copy link
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.

}

private onTypeRootFileChanged(project: ConfiguredProject, fileName: string) {
this.updateConfiguredProject(project);
Copy link
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
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