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 1 commit
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
12 changes: 4 additions & 8 deletions packages/babel-helper-transform-fixture-test-runner/src/index.ts
Expand Up @@ -79,12 +79,11 @@ 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: { code?: string; cachedData?: Buffer } =
cachedScripts.get(filename);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of here, can you move the type annotation to the cachedScripts definition? Something like new QuickLRU<string, { code: string; cachedData?: Buffer }>().

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 10a57fe

if (!cached) {
const code = `(function (exports, require, module, __filename, __dirname) {\n${srcFn()}\n});`;
cached = {
Expand All @@ -102,9 +101,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 +126,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
8 changes: 8 additions & 0 deletions yarn.lock
Expand Up @@ -4249,6 +4249,13 @@ __metadata:
languageName: node
linkType: hard

"@types/node@npm:^16.7.13":
version: 16.7.13
resolution: "@types/node@npm:16.7.13"
checksum: e22d3b58e5c4b18d058b18ab75bb1bf27b2dcb83b798eac3cdb7a3b12725f7ee1343abc7b5d020d39869669045654ce7d38e952832a1f39f061da0fbebbf43df
languageName: node
linkType: hard

"@types/normalize-package-data@npm:^2.4.0":
version: 2.4.0
resolution: "@types/normalize-package-data@npm:2.4.0"
Expand Down Expand Up @@ -5727,6 +5734,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