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/node | |
parent | 8b1b4766a1e747437a2b88fcadc26162a1bec640 (diff) |
fix: Better use of @ts-expect-error (#6038)
Diffstat (limited to 'std/node')
-rw-r--r-- | std/node/global.ts | 4 | ||||
-rw-r--r-- | std/node/module.ts | 24 |
2 files changed, 12 insertions, 16 deletions
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; } |