diff --git a/extensions/typescript/src/features/bufferSyncSupport.ts b/extensions/typescript/src/features/bufferSyncSupport.ts index 05dbefb4a1a..64c8eea9a40 100644 --- a/extensions/typescript/src/features/bufferSyncSupport.ts +++ b/extensions/typescript/src/features/bufferSyncSupport.ts @@ -106,7 +106,7 @@ export default class BufferSyncSupport { private readonly disposables: Disposable[] = []; private readonly syncedBuffers: Map; - private pendingDiagnostics: { [key: string]: number; }; + private pendingDiagnostics = new Map(); private readonly diagnosticDelayer: Delayer; private checkGlobalTSCVersion: boolean; @@ -116,7 +116,6 @@ export default class BufferSyncSupport { this.diagnostics = diagnostics; this._validate = validate; - this.pendingDiagnostics = Object.create(null); this.diagnosticDelayer = new Delayer(300); this.syncedBuffers = new Map(); @@ -211,7 +210,7 @@ export default class BufferSyncSupport { return; } for (const filePath of this.syncedBuffers.keys()) { - this.pendingDiagnostics[filePath] = Date.now(); + this.pendingDiagnostics.set(filePath, Date.now()); } this.diagnosticDelayer.trigger(() => { this.sendPendingDiagnostics(); @@ -223,7 +222,7 @@ export default class BufferSyncSupport { return; } - this.pendingDiagnostics[file] = Date.now(); + this.pendingDiagnostics.set(file, Date.now()); const buffer = this.syncedBuffers.get(file); let delay = 300; if (buffer) { @@ -239,10 +238,10 @@ export default class BufferSyncSupport { if (!this._validate) { return; } - let files = Object.keys(this.pendingDiagnostics).map((key) => { + let files = Array.from(this.pendingDiagnostics.entries()).map(([key, value]) => { return { file: key, - time: this.pendingDiagnostics[key] + time: value }; }).sort((a, b) => { return a.time - b.time; @@ -252,7 +251,7 @@ export default class BufferSyncSupport { // Add all open TS buffers to the geterr request. They might be visible for (const file of this.syncedBuffers.keys()) { - if (!this.pendingDiagnostics[file]) { + if (!this.pendingDiagnostics.get(file)) { files.push(file); } } @@ -264,7 +263,7 @@ export default class BufferSyncSupport { }; this.client.execute('geterr', args, false); } - this.pendingDiagnostics = Object.create(null); + this.pendingDiagnostics.clear(); } private checkTSCVersion() {