Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use @types/node for vm module #13738

Merged
merged 4 commits into from Sep 8, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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 @@ -4242,10 +4242,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 @@ -5727,6 +5727,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