From 3edcadb14ec471b622083f0b9bea12e78b6cd691 Mon Sep 17 00:00:00 2001 From: Tomas Zijdemans Date: Sun, 19 Jul 2026 14:09:16 +0200 Subject: [PATCH] refactor: convert @ts-ignore to @ts-expect-error where the error always fires --- _tools/check_docs.ts | 4 ++-- collections/includes_value_test.ts | 2 +- collections/sliding_windows_test.ts | 4 ++-- crypto/crypto_test.ts | 2 +- csv/unstable_stringify_test.ts | 8 ++++---- random/_test_utils.ts | 6 +++--- testing/mock.ts | 2 +- text/unstable_dedent_test.ts | 4 ++-- 8 files changed, 16 insertions(+), 16 deletions(-) diff --git a/_tools/check_docs.ts b/_tools/check_docs.ts index 653d6350a07e..1f5c5a932501 100644 --- a/_tools/check_docs.ts +++ b/_tools/check_docs.ts @@ -131,7 +131,7 @@ function assertHasParamTag( ); if (tag === undefined) return; assert( - // @ts-ignore doc is defined + // @ts-expect-error doc is defined tag.doc !== undefined, `@param tag for ${param} must have a description`, document, @@ -205,7 +205,7 @@ function assertHasTypeParamTags( ); if (tag === undefined) return; assert( - // @ts-ignore doc is defined + // @ts-expect-error doc is defined tag.doc !== undefined, `@typeParam tag for ${typeParamName} must have a description`, document, diff --git a/collections/includes_value_test.ts b/collections/includes_value_test.ts index 22ad99a1966d..d141ac0bc857 100644 --- a/collections/includes_value_test.ts +++ b/collections/includes_value_test.ts @@ -105,7 +105,7 @@ Deno.test("includesValue() handles NaN value", () => { Deno.test("includesValue() prevents enumerable prototype check", () => { class Foo {} - // @ts-ignore: for test + // @ts-expect-error: for test Foo.prototype.a = "hello"; const input = new Foo() as Record; diff --git a/collections/sliding_windows_test.ts b/collections/sliding_windows_test.ts index b1711f30509a..bef41993de59 100644 --- a/collections/sliding_windows_test.ts +++ b/collections/sliding_windows_test.ts @@ -152,13 +152,13 @@ Deno.test({ "Cannot create sliding windows: step must be a positive integer, current value is NaN", ); slidingWindowsThrowsTest( - // @ts-ignore: for test + // @ts-expect-error: for test [[1, 2, 3, 4, 5], "invalid"], RangeError, "Cannot create sliding windows: size must be a positive integer, current value is invalid", ); slidingWindowsThrowsTest( - // @ts-ignore: for test + // @ts-expect-error: for test [[1, 2, 3, 4, 5], 3, { step: "invalid" }], RangeError, "Cannot create sliding windows: step must be a positive integer, current value is invalid", diff --git a/crypto/crypto_test.ts b/crypto/crypto_test.ts index 61e21d302be6..c5642618c741 100644 --- a/crypto/crypto_test.ts +++ b/crypto/crypto_test.ts @@ -1769,7 +1769,7 @@ Deno.test("digest() throws on invalid algorithm", async () => { // runtime and its wording differs across versions (e.g. "Unrecognized // algorithm name" vs. "Algorithm 'invalid' is not supported"). await assertRejects( - // @ts-ignore Algorithm name is invalid on purpose + // @ts-expect-error Algorithm name is invalid on purpose async () => await stdCrypto.subtle.digest("invalid", new Uint8Array(0)), DOMException, ); diff --git a/csv/unstable_stringify_test.ts b/csv/unstable_stringify_test.ts index f9ab4622be30..287c2aab608f 100644 --- a/csv/unstable_stringify_test.ts +++ b/csv/unstable_stringify_test.ts @@ -37,7 +37,7 @@ Deno.test("(unstable) stringify", async (t) => { const options = { columns: true }; const data = [{ a: 1 }]; assertThrows( - // @ts-ignore: for test + // @ts-expect-error: for test () => stringify(data, options), "Cannot stringify data as the columns option is invalid: columns must be an array or undefined", ); @@ -52,7 +52,7 @@ Deno.test("(unstable) stringify", async (t) => { const options = { columns: { v: true } }; const data = [{ a: 1 }]; assertThrows( - // @ts-ignore: for test + // @ts-expect-error: for test () => stringify(data, options), "Cannot stringify data as the columns option is invalid: columns must be an array or undefined", ); @@ -67,7 +67,7 @@ Deno.test("(unstable) stringify", async (t) => { const options = { columns: 127 }; const data = [{ a: 1 }]; assertThrows( - // @ts-ignore: for test + // @ts-expect-error: for test () => stringify(data, options), "Cannot stringify data as the columns option is invalid: columns must be an array or undefined", ); @@ -82,7 +82,7 @@ Deno.test("(unstable) stringify", async (t) => { const options = { columns: "i am a string" }; const data = [{ a: 1 }]; assertThrows( - // @ts-ignore: for test + // @ts-expect-error: for test () => stringify(data, options), "Cannot stringify data as the columns option is invalid: columns must be an array or undefined", ); diff --git a/random/_test_utils.ts b/random/_test_utils.ts index eb8b568a404a..82f9a6b9d2cf 100644 --- a/random/_test_utils.ts +++ b/random/_test_utils.ts @@ -37,7 +37,7 @@ export function mockLittleEndian(littleEndian: boolean) { const TypedArray = globalThis[`${type}Array`]; const MockTypedArray = class extends TypedArray { - // @ts-ignore missing super() call + // @ts-expect-error missing super() call constructor(...args: any[]) { const target = new TypedArray(...args); const dv = new DataView( @@ -101,11 +101,11 @@ export function mockLittleEndian(littleEndian: boolean) { } }; - // @ts-ignore mock + // @ts-expect-error mock globalThis[`${type}Array`] = MockTypedArray; stack.defer(() => { - // @ts-ignore restore mock + // @ts-expect-error restore mock globalThis[`${type}Array`] = TypedArray; }); } diff --git a/testing/mock.ts b/testing/mock.ts index 76a2f53ef203..bf6b18ef16cc 100644 --- a/testing/mock.ts +++ b/testing/mock.ts @@ -725,7 +725,7 @@ function constructorSpy< ): ConstructorSpy { const original = constructor; const calls: SpyCall[] = []; - // @ts-ignore TS2509: Can't know the type of `original` statically. + // @ts-expect-error TS2509: Can't know the type of `original` statically. const spy = class extends original { // deno-lint-ignore constructor-super constructor(...args: Args) { diff --git a/text/unstable_dedent_test.ts b/text/unstable_dedent_test.ts index 6569f040c2c2..354c7858b2fb 100644 --- a/text/unstable_dedent_test.ts +++ b/text/unstable_dedent_test.ts @@ -90,7 +90,7 @@ Deno.test("dedent() handles multiline substitution", () => { }); Deno.test("dedent() handles mixed tabs and spaces", async (t) => { - // @ts-ignore augmenting globalThis so we don't need to resort to bare `eval` + // @ts-expect-error augmenting globalThis so we don't need to resort to bare `eval` using _ = stub(globalThis, "dedent", dedent); await t.step("with partial common prefix", () => { @@ -109,7 +109,7 @@ Deno.test("dedent() handles mixed tabs and spaces", async (t) => { }); Deno.test("dedent() handles blank lines correctly", async (t) => { - // @ts-ignore augmenting globalThis so we don't need to resort to bare `eval` + // @ts-expect-error augmenting globalThis so we don't need to resort to bare `eval` using _ = stub(globalThis, "dedent", dedent); for (const lineEnding of ["\n", "\r\n"]) {