diff options
author | Kitson Kelly <me@kitsonkelly.com> | 2020-06-02 14:24:44 +1000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-06-02 00:24:44 -0400 |
commit | 3fe6bc1b82a10bed1d907b749b1cc200659df612 (patch) | |
tree | 02e14128039d015a7256494a50476f61785e6f33 /std | |
parent | 8b1b4766a1e747437a2b88fcadc26162a1bec640 (diff) |
fix: Better use of @ts-expect-error (#6038)
Diffstat (limited to 'std')
-rw-r--r-- | std/mime/multipart_test.ts | 4 | ||||
-rw-r--r-- | std/node/global.ts | 4 | ||||
-rw-r--r-- | std/node/module.ts | 24 | ||||
-rw-r--r-- | std/signal/test.ts | 4 | ||||
-rw-r--r-- | std/ws/mod.ts | 2 |
5 files changed, 17 insertions, 21 deletions
diff --git a/std/mime/multipart_test.ts b/std/mime/multipart_test.ts index 07f27b39d..858dc3919 100644 --- a/std/mime/multipart_test.ts +++ b/std/mime/multipart_test.ts @@ -145,8 +145,8 @@ test("multipartMultipartWriter3", async function (): Promise<void> { ); await assertThrowsAsync( async (): Promise<void> => { - // @ts-expect-error - await mw.writeFile("bar", "file", null); + // eslint-disable-next-line @typescript-eslint/no-explicit-any + await mw.writeFile("bar", "file", null as any); }, Error, "closed" diff --git a/std/node/global.ts b/std/node/global.ts index 7d147cc4b..0cb6b8b06 100644 --- a/std/node/global.ts +++ b/std/node/global.ts @@ -5,5 +5,5 @@ Object.defineProperty(globalThis, Symbol.toStringTag, { configurable: true, }); -// @ts-expect-error -globalThis["global"] = globalThis; +// eslint-disable-next-line @typescript-eslint/no-explicit-any +(globalThis as any)["global"] = globalThis; diff --git a/std/node/module.ts b/std/node/module.ts index 71c25beac..13b2ac325 100644 --- a/std/node/module.ts +++ b/std/node/module.ts @@ -262,10 +262,11 @@ class Module { if (requireStack.length > 0) { message = message + "\nRequire stack:\n- " + requireStack.join("\n- "); } - const err = new Error(message); - // @ts-expect-error + const err = new Error(message) as Error & { + code: string; + requireStack: string[]; + }; err.code = "MODULE_NOT_FOUND"; - // @ts-expect-error err.requireStack = requireStack; throw err; } @@ -732,12 +733,10 @@ function tryPackage( if (actual === false) { actual = tryExtensions(path.resolve(requestPath, "index"), exts, isMain); if (!actual) { - // eslint-disable-next-line no-restricted-syntax const err = new Error( `Cannot find module '${filename}'. ` + 'Please verify that the package.json has a valid "main" entry' - ); - // @ts-expect-error + ) as Error & { code: string }; err.code = "MODULE_NOT_FOUND"; throw err; } @@ -881,8 +880,7 @@ function applyExports(basePath: string, expansion: string): string { const e = new Error( `Package exports for '${basePath}' do not define ` + `a '${mappingKey}' subpath` - ); - // @ts-expect-error + ) as Error & { code?: string }; e.code = "MODULE_NOT_FOUND"; throw e; } @@ -973,7 +971,7 @@ function resolveExportsTarget( } } } - let e: Error; + let e: Error & { code?: string }; if (mappingKey !== ".") { e = new Error( `Package exports for '${basePath}' do not define a ` + @@ -982,7 +980,6 @@ function resolveExportsTarget( } else { e = new Error(`No valid exports main found for '${basePath}'`); } - // @ts-expect-error e.code = "MODULE_NOT_FOUND"; throw e; } @@ -1006,8 +1003,7 @@ const CircularRequirePrototypeWarningProxy = new Proxy( {}, { // eslint-disable-next-line @typescript-eslint/no-explicit-any - get(target, prop): any { - // @ts-expect-error + get(target: Record<string, any>, prop: string): any { if (prop in target) return target[prop]; emitCircularRequireWarning(prop); return undefined; @@ -1058,8 +1054,8 @@ type RequireWrapper = ( function wrapSafe(filename: string, content: string): RequireWrapper { // TODO: fix this const wrapper = Module.wrap(content); - // @ts-expect-error - const [f, err] = Deno.core.evalContext(wrapper, filename); + // eslint-disable-next-line @typescript-eslint/no-explicit-any + const [f, err] = (Deno as any).core.evalContext(wrapper, filename); if (err) { throw err; } diff --git a/std/signal/test.ts b/std/signal/test.ts index 13c2998db..ef79a303b 100644 --- a/std/signal/test.ts +++ b/std/signal/test.ts @@ -9,8 +9,8 @@ test({ fn() { assertThrows( () => { - // @ts-expect-error - signal(); + // eslint-disable-next-line @typescript-eslint/no-explicit-any + (signal as any)(); }, Error, "No signals are given. You need to specify at least one signal to create a signal stream." diff --git a/std/ws/mod.ts b/std/ws/mod.ts index 97c77baab..f98e70d92 100644 --- a/std/ws/mod.ts +++ b/std/ws/mod.ts @@ -491,7 +491,7 @@ export async function handshake( throw new Error("ws: invalid status line: " + statusLine); } - // @ts-expect-error + assert(m.groups); const { version, statusCode } = m.groups; if (version !== "HTTP/1.1" || statusCode !== "101") { throw new Error( |