From 4ce09ce88a31fc24fa8669cdb9e81b05eb23915b Mon Sep 17 00:00:00 2001 From: Jean Lauliac Date: Thu, 3 Nov 2016 04:50:20 -0700 Subject: [PATCH] RM Polyfill.js: @flow Reviewed By: davidaurelio Differential Revision: D4118256 fbshipit-source-id: b9d906cd94c0548c28a62fa636c6da7bcf894ba9 --- react-packager/src/node-haste/Module.js | 22 +++++++++++--------- react-packager/src/node-haste/ModuleCache.js | 1 + react-packager/src/node-haste/Polyfill.js | 22 +++++++++++++++++++- 3 files changed, 34 insertions(+), 11 deletions(-) diff --git a/react-packager/src/node-haste/Module.js b/react-packager/src/node-haste/Module.js index 864846ae..e8ca4634 100644 --- a/react-packager/src/node-haste/Module.js +++ b/react-packager/src/node-haste/Module.js @@ -56,6 +56,17 @@ export type FastFs = { }; export type DepGraphHelpers = {isNodeModulesDir: (filePath: string) => boolean}; +export type ConstructorArgs = { + file: string, + fastfs: FastFs, + moduleCache: ModuleCache, + cache: Cache, + extractor: Extractor, + transformCode: TransformCode, + depGraphHelpers: DepGraphHelpers, + options: Options, +}; + class Module { path: string; @@ -81,16 +92,7 @@ class Module { transformCode, depGraphHelpers, options, - }: { - file: string, - fastfs: FastFs, - moduleCache: ModuleCache, - cache: Cache, - extractor: Extractor, - transformCode: TransformCode, - depGraphHelpers: DepGraphHelpers, - options: Options, - }) { + }: ConstructorArgs) { if (!isAbsolutePath(file)) { throw new Error('Expected file to be absolute path but got ' + file); } diff --git a/react-packager/src/node-haste/ModuleCache.js b/react-packager/src/node-haste/ModuleCache.js index 4cdee481..4377ac84 100644 --- a/react-packager/src/node-haste/ModuleCache.js +++ b/react-packager/src/node-haste/ModuleCache.js @@ -137,6 +137,7 @@ class ModuleCache { } createPolyfill({file}: {file: string}) { + /* $FlowFixMe: there are missing arguments. */ return new Polyfill({ file, cache: this._cache, diff --git a/react-packager/src/node-haste/Polyfill.js b/react-packager/src/node-haste/Polyfill.js index b2578f02..8a282520 100644 --- a/react-packager/src/node-haste/Polyfill.js +++ b/react-packager/src/node-haste/Polyfill.js @@ -1,9 +1,29 @@ +/** + * Copyright (c) 2013-present, Facebook, Inc. + * All rights reserved. + * + * 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 + */ + 'use strict'; const Module = require('./Module'); +import type {ConstructorArgs} from './Module'; + class Polyfill extends Module { - constructor(options) { + + _id: string; + _dependencies: Array; + + constructor(options: ConstructorArgs & { + id: string, + dependencies: Array, + }) { super(options); this._id = options.id; this._dependencies = options.dependencies;