From c7a7d0bd17be408c587164eea7cdd28b5820c559 Mon Sep 17 00:00:00 2001 From: Tim Seckinger Date: Sat, 23 Feb 2019 20:20:28 +0100 Subject: [PATCH] fix partial Module type errors --- packages/jest-runtime/src/index.ts | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/packages/jest-runtime/src/index.ts b/packages/jest-runtime/src/index.ts index eaa14985d7ce..2651f7807517 100644 --- a/packages/jest-runtime/src/index.ts +++ b/packages/jest-runtime/src/index.ts @@ -45,7 +45,9 @@ type InternalModuleOptions = { isInternalModule: boolean; }; -type ModuleRegistry = {[key: string]: Module}; +type InitialModule = Partial & + Pick; +type ModuleRegistry = {[key: string]: InitialModule}; type ResolveOptions = Parameters[1]; type BooleanObject = {[key: string]: boolean}; @@ -323,7 +325,7 @@ class Runtime { // We must register the pre-allocated module object first so that any // circular dependencies that may arise while evaluating the module can // be satisfied. - const localModule: Module = { + const localModule: InitialModule = { children: [], exports: {}, filename: modulePath, @@ -412,7 +414,7 @@ class Runtime { } } if (isManualMock) { - const localModule: Module = { + const localModule: InitialModule = { children: [], exports: {}, filename: modulePath, @@ -621,7 +623,7 @@ class Runtime { } private _execModule( - localModule: Module, + localModule: InitialModule, options: InternalModuleOptions | null | undefined, moduleRegistry: ModuleRegistry, from: Config.Path | null | undefined, @@ -828,7 +830,7 @@ class Runtime { } private _createRequireImplementation( - from: Module, + from: InitialModule, options: InternalModuleOptions | null | undefined, ): LocalModuleRequire { // TODO: somehow avoid having to type the arguments - they should come from `LocalModuleRequire`