Use @types/node for vm module (#13738)

This commit is contained in:
TagawaHirotaka 2021-09-08 22:56:25 +09:00 committed by GitHub
parent 40e43f5a14
commit 8c061f0848
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 14 additions and 14 deletions

View File

@ -38,6 +38,7 @@
"@rollup/plugin-json": "^4.1.0", "@rollup/plugin-json": "^4.1.0",
"@rollup/plugin-node-resolve": "^13.0.0", "@rollup/plugin-node-resolve": "^13.0.0",
"@rollup/plugin-replace": "^2.4.2", "@rollup/plugin-replace": "^2.4.2",
"@types/node": "^16.7.13",
"@typescript-eslint/eslint-plugin": "^4.18.0", "@typescript-eslint/eslint-plugin": "^4.18.0",
"@typescript-eslint/parser": "^4.18.0", "@typescript-eslint/parser": "^4.18.0",
"babel-plugin-transform-charcodes": "^0.2.0", "babel-plugin-transform-charcodes": "^0.2.0",

View File

@ -23,7 +23,10 @@ const checkDuplicatedNodes = _checkDuplicatedNodes.default;
const EXTERNAL_HELPERS_VERSION = "7.100.0"; const EXTERNAL_HELPERS_VERSION = "7.100.0";
const cachedScripts = new QuickLRU({ maxSize: 10 }); const cachedScripts = new QuickLRU<
string,
{ code: string; cachedData?: Buffer }
>({ maxSize: 10 });
const contextModuleCache = new WeakMap(); const contextModuleCache = new WeakMap();
const sharedTestContext = createContext(); const sharedTestContext = createContext();
@ -79,12 +82,10 @@ function createContext() {
function runCacheableScriptInTestContext( function runCacheableScriptInTestContext(
filename: string, filename: string,
srcFn: () => string, srcFn: () => string,
// todo(flow->ts) was Context type, but it is missing context: vm.Context,
context: any,
moduleCache: any, moduleCache: any,
) { ) {
// todo(flow->ts) improve types let cached = cachedScripts.get(filename);
let cached: any = cachedScripts.get(filename);
if (!cached) { if (!cached) {
const code = `(function (exports, require, module, __filename, __dirname) {\n${srcFn()}\n});`; const code = `(function (exports, require, module, __filename, __dirname) {\n${srcFn()}\n});`;
cached = { cached = {
@ -102,9 +103,7 @@ function runCacheableScriptInTestContext(
produceCachedData: true, produceCachedData: true,
}); });
// @ts-expect-error todo(flow->ts) improve types
if (script.cachedDataProduced) { if (script.cachedDataProduced) {
// @ts-expect-error todo(flow->ts) improve types
cached.cachedData = script.cachedData; cached.cachedData = script.cachedData;
} }
@ -129,8 +128,7 @@ function runCacheableScriptInTestContext(
function runModuleInTestContext( function runModuleInTestContext(
id: string, id: string,
relativeFilename: string, relativeFilename: string,
// todo(flow->ts) was Context type, but it is missing context: vm.Context,
context: any,
moduleCache: any, moduleCache: any,
) { ) {
const filename = require.resolve(id, { const filename = require.resolve(id, {
@ -490,7 +488,7 @@ export default function (
// the options object with useless options // the options object with useless options
delete task.options.throws; delete task.options.throws;
assert.throws(runTask, function (err) { assert.throws(runTask, function (err: Error) {
assert.ok( assert.ok(
throwMsg === true || err.message.includes(throwMsg), throwMsg === true || err.message.includes(throwMsg),
` `

View File

@ -4243,10 +4243,10 @@ __metadata:
languageName: node languageName: node
linkType: hard linkType: hard
"@types/node@npm:*": "@types/node@npm:*, @types/node@npm:^16.7.13":
version: 14.14.31 version: 16.7.13
resolution: "@types/node@npm:14.14.31" resolution: "@types/node@npm:16.7.13"
checksum: 635dc8a0898a923621e02ca179e17baa39fdfa44f0096fcc1b7046c9b32317e74a99956a7b45ca0e8069874f51f4e7873a418239a318a4b6e7936f6510ac5992 checksum: e22d3b58e5c4b18d058b18ab75bb1bf27b2dcb83b798eac3cdb7a3b12725f7ee1343abc7b5d020d39869669045654ce7d38e952832a1f39f061da0fbebbf43df
languageName: node languageName: node
linkType: hard linkType: hard
@ -5728,6 +5728,7 @@ __metadata:
"@rollup/plugin-json": ^4.1.0 "@rollup/plugin-json": ^4.1.0
"@rollup/plugin-node-resolve": ^13.0.0 "@rollup/plugin-node-resolve": ^13.0.0
"@rollup/plugin-replace": ^2.4.2 "@rollup/plugin-replace": ^2.4.2
"@types/node": ^16.7.13
"@typescript-eslint/eslint-plugin": ^4.18.0 "@typescript-eslint/eslint-plugin": ^4.18.0
"@typescript-eslint/parser": ^4.18.0 "@typescript-eslint/parser": ^4.18.0
babel-plugin-transform-charcodes: ^0.2.0 babel-plugin-transform-charcodes: ^0.2.0