mirror of
https://github.com/microsoft/TypeScript.git
synced 2025-11-18 17:21:48 +00:00
Do not watch script infos that are part of global typings location
This commit is contained in:
@@ -2258,6 +2258,8 @@ namespace ts {
|
||||
* Adds a trailing directory separator to a path, if it does not already have one.
|
||||
* @param path The path.
|
||||
*/
|
||||
export function ensureTrailingDirectorySeparator(path: Path): Path;
|
||||
export function ensureTrailingDirectorySeparator(path: string): string;
|
||||
export function ensureTrailingDirectorySeparator(path: string) {
|
||||
if (path.charAt(path.length - 1) !== directorySeparator) {
|
||||
return path + directorySeparator;
|
||||
|
||||
@@ -141,12 +141,15 @@ namespace ts.projectSystem {
|
||||
checkNumberOfProjects(projectService, { configuredProjects: 1 });
|
||||
const p = configuredProjectAt(projectService, 0);
|
||||
checkProjectActualFiles(p, [file1.path, tsconfig.path]);
|
||||
checkWatchedFiles(host, [tsconfig.path, libFile.path, packageJson.path, "/a/b/bower_components", "/a/b/node_modules"]);
|
||||
|
||||
installer.installAll(/*expectedCount*/ 1);
|
||||
|
||||
checkNumberOfProjects(projectService, { configuredProjects: 1 });
|
||||
host.checkTimeoutQueueLengthAndRun(2);
|
||||
checkProjectActualFiles(p, [file1.path, jquery.path, tsconfig.path]);
|
||||
// should not watch jquery
|
||||
checkWatchedFiles(host, [tsconfig.path, libFile.path, packageJson.path, "/a/b/bower_components", "/a/b/node_modules"]);
|
||||
});
|
||||
|
||||
it("inferred project (typings installed)", () => {
|
||||
|
||||
@@ -389,6 +389,7 @@ namespace ts.server {
|
||||
public readonly useSingleInferredProject: boolean;
|
||||
public readonly useInferredProjectPerProjectRoot: boolean;
|
||||
public readonly typingsInstaller: ITypingsInstaller;
|
||||
private readonly globalCacheLocationDirectoryPath: Path;
|
||||
public readonly throttleWaitMilliseconds?: number;
|
||||
private readonly eventHandler?: ProjectServiceEventHandler;
|
||||
|
||||
@@ -423,6 +424,8 @@ namespace ts.server {
|
||||
}
|
||||
this.currentDirectory = this.host.getCurrentDirectory();
|
||||
this.toCanonicalFileName = createGetCanonicalFileName(this.host.useCaseSensitiveFileNames);
|
||||
this.globalCacheLocationDirectoryPath = this.typingsInstaller.globalTypingsCacheLocation &&
|
||||
ensureTrailingDirectorySeparator(this.toPath(this.typingsInstaller.globalTypingsCacheLocation));
|
||||
this.throttledOperations = new ThrottledOperations(this.host, this.logger);
|
||||
|
||||
if (this.typesMapLocation) {
|
||||
@@ -1725,7 +1728,10 @@ namespace ts.server {
|
||||
private watchClosedScriptInfo(info: ScriptInfo) {
|
||||
Debug.assert(!info.fileWatcher);
|
||||
// do not watch files with mixed content - server doesn't know how to interpret it
|
||||
if (!info.isDynamicOrHasMixedContent()) {
|
||||
// do not watch files in the global cache location
|
||||
if (!info.isDynamicOrHasMixedContent() &&
|
||||
(!this.globalCacheLocationDirectoryPath ||
|
||||
!startsWith(info.path, this.globalCacheLocationDirectoryPath))) {
|
||||
const { fileName } = info;
|
||||
info.fileWatcher = this.watchFactory.watchFilePath(
|
||||
this.host,
|
||||
|
||||
@@ -7847,6 +7847,7 @@ declare namespace ts.server {
|
||||
readonly useSingleInferredProject: boolean;
|
||||
readonly useInferredProjectPerProjectRoot: boolean;
|
||||
readonly typingsInstaller: ITypingsInstaller;
|
||||
private readonly globalCacheLocationDirectoryPath;
|
||||
readonly throttleWaitMilliseconds?: number;
|
||||
private readonly eventHandler?;
|
||||
readonly globalPlugins: ReadonlyArray<string>;
|
||||
|
||||
Reference in New Issue
Block a user