Skip to content

Commit

Permalink
Use @types/node for vm module (#13738)
Browse files Browse the repository at this point in the history
  • Loading branch information
TagawaHirotaka committed Sep 8, 2021
1 parent 40e43f5 commit 8c061f0
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 14 deletions.
1 change: 1 addition & 0 deletions package.json
Expand Up @@ -38,6 +38,7 @@
"@rollup/plugin-json": "^4.1.0",
"@rollup/plugin-node-resolve": "^13.0.0",
"@rollup/plugin-replace": "^2.4.2",
"@types/node": "^16.7.13",
"@typescript-eslint/eslint-plugin": "^4.18.0",
"@typescript-eslint/parser": "^4.18.0",
"babel-plugin-transform-charcodes": "^0.2.0",
Expand Down
18 changes: 8 additions & 10 deletions packages/babel-helper-transform-fixture-test-runner/src/index.ts
Expand Up @@ -23,7 +23,10 @@ const checkDuplicatedNodes = _checkDuplicatedNodes.default;

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 sharedTestContext = createContext();

Expand Down Expand Up @@ -79,12 +82,10 @@ function createContext() {
function runCacheableScriptInTestContext(
filename: string,
srcFn: () => string,
// todo(flow->ts) was Context type, but it is missing
context: any,
context: vm.Context,
moduleCache: any,
) {
// todo(flow->ts) improve types
let cached: any = cachedScripts.get(filename);
let cached = cachedScripts.get(filename);
if (!cached) {
const code = `(function (exports, require, module, __filename, __dirname) {\n${srcFn()}\n});`;
cached = {
Expand All @@ -102,9 +103,7 @@ function runCacheableScriptInTestContext(
produceCachedData: true,
});

// @ts-expect-error todo(flow->ts) improve types
if (script.cachedDataProduced) {
// @ts-expect-error todo(flow->ts) improve types
cached.cachedData = script.cachedData;
}

Expand All @@ -129,8 +128,7 @@ function runCacheableScriptInTestContext(
function runModuleInTestContext(
id: string,
relativeFilename: string,
// todo(flow->ts) was Context type, but it is missing
context: any,
context: vm.Context,
moduleCache: any,
) {
const filename = require.resolve(id, {
Expand Down Expand Up @@ -490,7 +488,7 @@ export default function (
// the options object with useless options
delete task.options.throws;

assert.throws(runTask, function (err) {
assert.throws(runTask, function (err: Error) {
assert.ok(
throwMsg === true || err.message.includes(throwMsg),
`
Expand Down
9 changes: 5 additions & 4 deletions yarn.lock
Expand Up @@ -4243,10 +4243,10 @@ __metadata:
languageName: node
linkType: hard

"@types/node@npm:*":
version: 14.14.31
resolution: "@types/node@npm:14.14.31"
checksum: 635dc8a0898a923621e02ca179e17baa39fdfa44f0096fcc1b7046c9b32317e74a99956a7b45ca0e8069874f51f4e7873a418239a318a4b6e7936f6510ac5992
"@types/node@npm:*, @types/node@npm:^16.7.13":
version: 16.7.13
resolution: "@types/node@npm:16.7.13"
checksum: e22d3b58e5c4b18d058b18ab75bb1bf27b2dcb83b798eac3cdb7a3b12725f7ee1343abc7b5d020d39869669045654ce7d38e952832a1f39f061da0fbebbf43df
languageName: node
linkType: hard

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

0 comments on commit 8c061f0

Please sign in to comment.