mirror of
https://github.com/microsoft/TypeScript.git
synced 2025-11-18 17:21:48 +00:00
Ensure that file watcher is closed only once for affected file locations that share watcher because of different names but same real path (#50150)
* Add test where clearing affected files watcher that also is shared by real path causes Debug failure * Ensure that file watcher is closed only once for affected file locations that share watcher because of different names but same real path * Lift up package json map
This commit is contained in:
@@ -116,7 +116,14 @@ interface Array<T> { length: number; [n: number]: T; }`
|
||||
|
||||
function createWatcher<T>(map: MultiMap<Path, T>, path: Path, callback: T): FileWatcher {
|
||||
map.add(path, callback);
|
||||
return { close: () => map.remove(path, callback) };
|
||||
let closed = false;
|
||||
return {
|
||||
close: () => {
|
||||
Debug.assert(!closed);
|
||||
map.remove(path, callback);
|
||||
closed = true;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
export function getDiffInKeys<T>(map: ESMap<string, T>, expectedKeys: readonly string[]) {
|
||||
|
||||
Reference in New Issue
Block a user