Skip to content

Commit

Permalink
Tighten type definition of Module
Browse files Browse the repository at this point in the history
  • Loading branch information
SimenB committed Oct 7, 2017
1 parent 97a74bb commit baadeae
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,11 @@ describe('Runtime requireModule', () => {
'RegularModule',
);
expect(Object.keys(exports.module)).toEqual([
'children',
'exports',
'filename',
'id',
'loaded',
'children',
'parent',
'paths',
]);
Expand All @@ -50,6 +50,7 @@ describe('Runtime requireModule', () => {
'RegularModule',
);
expect(exports.parent).toEqual({
children: [],
exports: {},
filename: 'mock.js',
id: 'mockParent',
Expand Down
7 changes: 5 additions & 2 deletions packages/jest-runtime/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,14 +29,14 @@ import {run as cilRun} from './cli';
import {options as cliOptions} from './cli/args';

type Module = {|
children?: Array<any>,
children: Array<Module>,
exports: any,
filename: string,
id: string,
loaded: boolean,
parent?: Module,
paths?: Array<Path>,
require?: Function,
require?: (id: string) => any,
|};

type HasteMapOptions = {|
Expand Down Expand Up @@ -77,6 +77,7 @@ const getModuleNameMapper = (config: ProjectConfig) => {
};

const mockParentModule: Module = {
children: [],
exports: {},
filename: 'mock.js',
id: 'mockParent',
Expand Down Expand Up @@ -318,6 +319,7 @@ class Runtime {
// circular dependencies that may arise while evaluating the module can
// be satisfied.
const localModule: Module = {
children: [],
exports: {},
filename: modulePath,
id: modulePath,
Expand Down Expand Up @@ -391,6 +393,7 @@ class Runtime {

if (manualMock) {
const localModule: Module = {
children: [],
exports: {},
filename: modulePath,
id: modulePath,
Expand Down

0 comments on commit baadeae

Please sign in to comment.