diff --git a/packages/metro-bundler/src/JSTransformer/index.js b/packages/metro-bundler/src/JSTransformer/index.js index 22d75daf..081a0489 100644 --- a/packages/metro-bundler/src/JSTransformer/index.js +++ b/packages/metro-bundler/src/JSTransformer/index.js @@ -51,7 +51,7 @@ function makeFarm(worker, methods, timeout, maxConcurrentWorkers) { class Transformer { - _workers: {[name: string]: mixed}; + _workers: {[name: string]: Function}; _transformModulePath: string; _transform: ( transform: string, diff --git a/packages/metro-bundler/src/worker-farm/lib/farm.js b/packages/metro-bundler/src/worker-farm/lib/farm.js index 4624edf4..3bf82848 100644 --- a/packages/metro-bundler/src/worker-farm/lib/farm.js +++ b/packages/metro-bundler/src/worker-farm/lib/farm.js @@ -5,6 +5,8 @@ * This source code is licensed under the BSD-style license found in the * LICENSE file in the root directory of this source tree. An additional grant * of patent rights can be found in the PATENTS file in the same directory. + * + * @flow */ /* eslint-disable */ @@ -25,7 +27,7 @@ const extend = require('xtend') , ProcessTerminatedError = require('errno').create('ProcessTerminatedError') , MaxConcurrentCallsError = require('errno').create('MaxConcurrentCallsError') -function Farm (options, path) { +function Farm (options: {}, path: string) { this.options = extend(DEFAULT_OPTIONS, options) this.path = path this.activeCalls = 0 diff --git a/packages/metro-bundler/src/worker-farm/lib/fork.js b/packages/metro-bundler/src/worker-farm/lib/fork.js index 63d19d1e..a246df6b 100644 --- a/packages/metro-bundler/src/worker-farm/lib/fork.js +++ b/packages/metro-bundler/src/worker-farm/lib/fork.js @@ -5,31 +5,34 @@ * This source code is licensed under the BSD-style license found in the * LICENSE file in the root directory of this source tree. An additional grant * of patent rights can be found in the PATENTS file in the same directory. + * + * @flow */ -/* eslint-disable */ -const childProcess = require('child_process') - , childModule = require.resolve('./child/index') +'use strict'; -function fork (forkModule) { - var child = childProcess.fork(childModule, { - env: process.env - , cwd: process.cwd() - }) +const childProcess = require('child_process'); +const childModule = require.resolve('./child/index'); - child.send({ module: forkModule }) +function fork(forkModule: string) { + const child = childProcess.fork(childModule, { + env: process.env, + cwd: process.cwd(), + }); + + child.send({module: forkModule}); // return a send() function for this child return { - send : function (data) { - try { - child.send(data) - } catch (e) { - // this *should* be picked up by onExit and the operation requeued - } + send(data: {}) { + try { + child.send(data); + } catch (e) { + // this *should* be picked up by onExit and the operation requeued } - , child : child - } + }, + child, + }; } -module.exports = fork +module.exports = fork; diff --git a/packages/metro-bundler/src/worker-farm/lib/index.js b/packages/metro-bundler/src/worker-farm/lib/index.js index 19cd3508..73bd6fa5 100644 --- a/packages/metro-bundler/src/worker-farm/lib/index.js +++ b/packages/metro-bundler/src/worker-farm/lib/index.js @@ -5,6 +5,8 @@ * This source code is licensed under the BSD-style license found in the * LICENSE file in the root directory of this source tree. An additional grant * of patent rights can be found in the PATENTS file in the same directory. + * + * @flow */ /* eslint-disable */ @@ -12,20 +14,14 @@ const Farm = require('./farm') var farms = [] // keep record of farms so we can end() them if required -function farm (options, path, methods) { - if (typeof options == 'string') { - methods = path - path = options - options = {} - } - +function farm(options: {}, path: string, methods: Array): {[name: string]: Function} { var f = new Farm(options, path) , api = f.setup(methods) farms.push({ farm: f, api: api }) // return the public API - return api + return (api: any) } function end (api, callback) {