Skip to content

Commit 7b8a70b

Browse files
committed
type fix
1 parent 7c0d256 commit 7b8a70b

File tree

2 files changed

+13
-5
lines changed

2 files changed

+13
-5
lines changed

src/node/internal/events.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,8 @@ import {
4242
validateObject,
4343
} from 'node-internal:validators';
4444

45+
import type publicProcessType from 'node-internal:public_process';
46+
4547
import { process } from 'node-internal:internal_process';
4648

4749
import { spliceOne } from 'node-internal:internal_utils';
@@ -514,7 +516,8 @@ function _addListener(
514516
// Because process is the internal process here, emitWarning will only ever
515517
// be defined when using the enable_nodejs_process_v2 flag, so the warning
516518
// is only logged under that condition.
517-
process.emitWarning?.(w);
519+
if ((process as typeof publicProcessType).emitWarning)
520+
(process as typeof publicProcessType).emitWarning(w);
518521
}
519522
}
520523

src/node/internal/internal_process.ts

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,8 @@ import {
1818
type ErrorWithDetail,
1919
default as processImpl,
2020
} from 'node-internal:process';
21-
import type processType from 'node-internal:public_process';
21+
import type publicProcessType from 'node-internal:public_process';
22+
import type legacyProcessType from 'node-internal:legacy_process';
2223

2324
export const platform = processImpl.platform;
2425

@@ -304,7 +305,9 @@ export function emitWarning(
304305
// Emit the warning event on the process object
305306
// Use nextTick to ensure the warning is emitted asynchronously
306307
queueMicrotask(() => {
307-
process.emit('warning', err);
308+
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
309+
if ((process as typeof publicProcessType).emit)
310+
(process as typeof publicProcessType).emit('warning', err);
308311
});
309312
}
310313

@@ -313,7 +316,9 @@ export function emitWarning(
313316
// process module regardless of whether legacy_process or public_process was selected,
314317
// since these are different process modules and implementations.
315318
// Internal APIs using process should therefore import this binding.
316-
export let process: typeof processType;
317-
export function _setProcess(_process: typeof processType) {
319+
export let process: typeof legacyProcessType | typeof publicProcessType;
320+
export function _setProcess(
321+
_process: typeof legacyProcessType | typeof publicProcessType
322+
): void {
318323
process = _process;
319324
}

0 commit comments

Comments
 (0)