1
0
Fork 0
mirror of https://github.com/denoland/deno.git synced 2024-11-21 15:04:11 -05:00

feat(check): turn on useUnknownInCatchVariables (#25465)

Part of #25162

Closes #11826
This commit is contained in:
David Sherret 2024-09-05 15:22:31 +02:00 committed by GitHub
parent b54347c448
commit 15fce5b290
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
10 changed files with 18 additions and 16 deletions

4
Cargo.lock generated
View file

@ -1374,9 +1374,9 @@ dependencies = [
[[package]]
name = "deno_config"
version = "0.33.1"
version = "0.33.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "495df7ebed4feee5c0eb7631b0b86432bb6370638cf81d5eeb5769aab55fb2de"
checksum = "84d90b5eacfd6ee4ec978a11739c71eaeb19a575889f8c2b473430df84078fe2"
dependencies = [
"anyhow",
"deno_package_json",

View file

@ -65,7 +65,7 @@ winres.workspace = true
[dependencies]
deno_ast = { workspace = true, features = ["bundler", "cjs", "codegen", "proposal", "react", "sourcemap", "transforms", "typescript", "view", "visit"] }
deno_cache_dir = { workspace = true }
deno_config = { version = "=0.33.1", features = ["workspace", "sync"] }
deno_config = { version = "=0.33.2", features = ["workspace", "sync"] }
deno_core = { workspace = true, features = ["include_js_files_for_snapshotting"] }
deno_doc = { version = "0.148.0", features = ["html", "syntect"] }
deno_graph = { version = "=0.82.0" }

View file

@ -1,5 +1,5 @@
try {
Deno.readTextFileSync("a.txt");
} catch (err) {
console.log(err.message);
console.log((err as Error).message);
}

View file

@ -67,7 +67,7 @@ try {
// @ts-ignore testing invalid overloads
await Deno.resolveDns("example.com", "SSHFP", nameServer);
} catch (e) {
console.log(e.message);
console.log((e as Error).message);
}
try {
@ -78,7 +78,7 @@ try {
signal: ac.signal,
});
} catch (e) {
console.log(e.name);
console.log((e as Error).name);
}
try {
@ -89,5 +89,5 @@ try {
signal: ac.signal,
});
} catch (e) {
console.log(e.name);
console.log((e as Error).name);
}

View file

@ -8,6 +8,6 @@ Deno.test({}, async function queueTestDbClose() {
await db.listenQueue(() => {});
assertFalse(false);
} catch (e) {
assertEquals(e.message, "already closed");
assertEquals((e as Error).message, "already closed");
}
});

View file

@ -443,7 +443,7 @@ Deno.test(
// Note: we have to do the test this way as different OS's have
// different UDP size limits enabled, so we will just ensure if
// an error is thrown it is the one we are expecting.
assert(err.message.match(rx));
assert((err as Error).message.match(rx));
alice.close();
bob.close();
return;

View file

@ -161,7 +161,7 @@ Deno.test(
try {
await Deno.readFile("definitely-not-found.json");
} catch (e) {
assertEquals(e.code, "ENOENT");
assertEquals((e as { code: string }).code, "ENOENT");
}
},
);
@ -172,7 +172,7 @@ Deno.test(
try {
await Deno.readFile("tests/testdata/assets/");
} catch (e) {
assertEquals(e.code, "EISDIR");
assertEquals((e as { code: string }).code, "EISDIR");
}
},
);

View file

@ -298,7 +298,7 @@ for (
await core.read(rid, new Uint8Array(1));
fail();
} catch (e) {
assertEquals(e.message, `Uh oh (${type})!`);
assertEquals((e as Error).message, `Uh oh (${type})!`);
}
core.close(rid);
});
@ -429,7 +429,7 @@ function createStreamTest(
fail();
} catch (e) {
// We expect this to be thrown
assertEquals(e.message, "Expected error!");
assertEquals((e as Error).message, "Expected error!");
}
} else {
const buffer = new Uint8Array(1);
@ -471,7 +471,7 @@ for (const packetCount of [1, 1024]) {
}
fail();
} catch (e) {
assertEquals(e.message, "operation canceled");
assertEquals((e as Error).message, "operation canceled");
}
assertEquals(await promise, "resource closed");
});

View file

@ -588,7 +588,9 @@ async function receiveAlotSendNothing(conn: Deno.Conn) {
}
} catch (e) {
throw new Error(
`Got an error (${e.message}) after reading ${nread}/${largeAmount} bytes`,
`Got an error (${
(e as Error).message
}) after reading ${nread}/${largeAmount} bytes`,
{ cause: e },
);
}

View file

@ -74,7 +74,7 @@ Deno.test("Built-in Node modules have `node:` prefix", () => {
createRequire();
} catch (e) {
thrown = true;
const stackLines = e.stack.split("\n");
const stackLines = (e as Error).stack!.split("\n");
// Assert that built-in node modules have `node:<mod_name>` specifiers.
assert(stackLines.some((line: string) => line.includes("(node:module:")));
}