diff --git a/packages/typescript-estree/src/create-program/createWatchProgram.ts b/packages/typescript-estree/src/create-program/createWatchProgram.ts index 836afbc2b5ee..63de99cadff5 100644 --- a/packages/typescript-estree/src/create-program/createWatchProgram.ts +++ b/packages/typescript-estree/src/create-program/createWatchProgram.ts @@ -316,16 +316,18 @@ function createWatchProgram( // But because of https://github.com/microsoft/TypeScript/pull/37308 we cannot just set it to undefined // instead save it and call before getProgram is called let callback: (() => void) | undefined; - watchCompilerHost.setTimeout = (cb, _ms, ...args) => { + watchCompilerHost.setTimeout = (cb, _ms, ...args): unknown => { callback = cb.bind(/*this*/ undefined, ...args); }; - watchCompilerHost.clearTimeout = () => { + watchCompilerHost.clearTimeout = (): void => { callback = undefined; }; const watch = ts.createWatchProgram(watchCompilerHost); const originalGetProgram = watch.getProgram; - watch.getProgram = () => { - if (callback) callback(); + watch.getProgram = (): ts.SemanticDiagnosticsBuilderProgram => { + if (callback) { + callback(); + } callback = undefined; return originalGetProgram.call(watch); };