From 94d146c650dd9beb34eefe49791fb3ee282a2662 Mon Sep 17 00:00:00 2001 From: jneira Date: Wed, 13 Oct 2021 23:57:17 +0200 Subject: [PATCH] Fix some new ts errors/warnings --- src/docsBrowser.ts | 4 ++-- src/hlsBinaries.ts | 16 ++++++++-------- src/utils.ts | 2 +- 3 files changed, 11 insertions(+), 11 deletions(-) diff --git a/src/docsBrowser.ts b/src/docsBrowser.ts index 01ed532a..bbe011c6 100644 --- a/src/docsBrowser.ts +++ b/src/docsBrowser.ts @@ -65,7 +65,7 @@ export namespace DocsBrowser { `; - } catch (e) { + } catch (e: any) { await window.showErrorMessage(e); } return panel; @@ -89,7 +89,7 @@ export namespace DocsBrowser { if (inWebView) { await commands.executeCommand('workbench.action.closeActiveEditor'); } - } catch (e) { + } catch (e: any) { await window.showErrorMessage(e); } } diff --git a/src/hlsBinaries.ts b/src/hlsBinaries.ts index 5ddfab77..02769261 100644 --- a/src/hlsBinaries.ts +++ b/src/hlsBinaries.ts @@ -211,13 +211,13 @@ async function getLatestReleaseMetadata(context: ExtensionContext, storagePath: : undefined; const opts: https.RequestOptions = releasesUrl ? { - host: releasesUrl.host, - path: releasesUrl.path, - } + host: releasesUrl.host, + path: releasesUrl.path, + } : { - host: 'api.github.com', - path: '/repos/haskell/haskell-language-server/releases', - }; + host: 'api.github.com', + path: '/repos/haskell/haskell-language-server/releases', + }; const offlineCache = path.join(storagePath, 'latestApprovedRelease.cache.json'); @@ -225,7 +225,7 @@ async function getLatestReleaseMetadata(context: ExtensionContext, storagePath: try { const cachedInfo = await promisify(fs.readFile)(offlineCache, { encoding: 'utf-8' }); return validate.parseAndValidate(cachedInfo, cachedReleaseValidator); - } catch (err) { + } catch (err: any) { // If file doesn't exist, return null, otherwise consider it a failure if (err.code === 'ENOENT') { return null; @@ -268,7 +268,7 @@ async function getLatestReleaseMetadata(context: ExtensionContext, storagePath: // Cache the latest successfully fetched release information await promisify(fs.writeFile)(offlineCache, JSON.stringify(latestInfoParsed), { encoding: 'utf-8' }); return latestInfoParsed; - } catch (githubError) { + } catch (githubError: any) { // Attempt to read from the latest cached file try { const cachedInfoParsed = await readCachedReleaseData(); diff --git a/src/utils.ts b/src/utils.ts index c79025a5..5f31cbfa 100644 --- a/src/utils.ts +++ b/src/utils.ts @@ -233,7 +233,7 @@ export async function downloadFile(titleMsg: string, src: string, dest: string): inFlightDownloads.set(src, new Map([[dest, downloadTask]])); } return await downloadTask; - } catch (e) { + } catch (e: any) { await promisify(fs.unlink)(downloadDest).catch(ignoreFileNotExists); throw new Error(`Failed to download ${src}:\n${e.message}`); }