Unnamed repository; edit this file 'description' to name the repository.
Auto merge of #15252 - tetsuharuohzeki:enable-unknonw-catch, r=lnicola
editor/code: Enable TypeScript's `--useUnknownInCatchVariables` option This enables TypeScript's [`--useUnknownInCatchVariables`](https://www.typescriptlang.org/tsconfig#useUnknownInCatchVariables).
bors 2023-07-10
parent 2f6d545 · parent 444bc5b · commit 6f2e8aa
-rw-r--r--editors/code/src/commands.ts4
-rw-r--r--editors/code/src/util.ts32
-rw-r--r--editors/code/tests/unit/index.ts3
-rw-r--r--editors/code/tsconfig.json1
4 files changed, 5 insertions, 35 deletions
diff --git a/editors/code/src/commands.ts b/editors/code/src/commands.ts
index 17202e5345..94ec5e99c6 100644
--- a/editors/code/src/commands.ts
+++ b/editors/code/src/commands.ts
@@ -373,7 +373,7 @@ export function ssr(ctx: CtxInit): Cmd {
selections,
});
} catch (e) {
- return e.toString();
+ return String(e);
}
return null;
},
@@ -1156,7 +1156,7 @@ export function viewMemoryLayout(ctx: CtxInit): Cmd {
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
- <style>
+ <style>
* {
box-sizing: border-box;
}
diff --git a/editors/code/src/util.ts b/editors/code/src/util.ts
index b6b779e266..b6240234aa 100644
--- a/editors/code/src/util.ts
+++ b/editors/code/src/util.ts
@@ -1,4 +1,3 @@
-import * as lc from "vscode-languageclient/node";
import * as vscode from "vscode";
import { strict as nativeAssert } from "assert";
import { exec, ExecOptions, spawnSync } from "child_process";
@@ -57,37 +56,6 @@ export const log = new (class {
}
})();
-export async function sendRequestWithRetry<TParam, TRet>(
- client: lc.LanguageClient,
- reqType: lc.RequestType<TParam, TRet, unknown>,
- param: TParam,
- token?: vscode.CancellationToken
-): Promise<TRet> {
- // The sequence is `10 * (2 ** (2 * n))` where n is 1, 2, 3...
- for (const delay of [40, 160, 640, 2560, 10240, null]) {
- try {
- return await (token
- ? client.sendRequest(reqType, param, token)
- : client.sendRequest(reqType, param));
- } catch (error) {
- if (delay === null) {
- log.warn("LSP request timed out", { method: reqType.method, param, error });
- throw error;
- }
- if (error.code === lc.LSPErrorCodes.RequestCancelled) {
- throw error;
- }
-
- if (error.code !== lc.LSPErrorCodes.ContentModified) {
- log.warn("LSP request failed", { method: reqType.method, param, error });
- throw error;
- }
- await sleep(delay);
- }
- }
- throw "unreachable";
-}
-
export function sleep(ms: number) {
return new Promise((resolve) => setTimeout(resolve, ms));
}
diff --git a/editors/code/tests/unit/index.ts b/editors/code/tests/unit/index.ts
index 2fa223bed4..c231927bb0 100644
--- a/editors/code/tests/unit/index.ts
+++ b/editors/code/tests/unit/index.ts
@@ -1,3 +1,4 @@
+import * as assert from "node:assert/strict";
import { readdir } from "fs/promises";
import * as path from "path";
@@ -30,6 +31,7 @@ class Suite {
await test.promise;
ok(` ✔ ${test.name}`);
} catch (e) {
+ assert.ok(e instanceof Error);
error(` ✖︎ ${test.name}\n ${e.stack}`);
failed += 1;
}
@@ -50,6 +52,7 @@ export class Context {
await ctx.run();
ok(`✔ ${name}`);
} catch (e) {
+ assert.ok(e instanceof Error);
error(`✖︎ ${name}\n ${e.stack}`);
throw e;
}
diff --git a/editors/code/tsconfig.json b/editors/code/tsconfig.json
index 4b107a5d25..87fd14072f 100644
--- a/editors/code/tsconfig.json
+++ b/editors/code/tsconfig.json
@@ -12,7 +12,6 @@
"newLine": "LF",
// These disables some enhancement type checking options
// to update typescript version without any code change.
- "useUnknownInCatchVariables": false,
"exactOptionalPropertyTypes": false
},
"exclude": ["node_modules", ".vscode-test"],