Enable flow type for a file and fix a related typo/bug

Reviewed By: rafeca

Differential Revision: D6473575

fbshipit-source-id: 7b96b6bfb2aff96e6d4697ad29fd96fb85d1ceda
This commit is contained in:
Peter van der Zee 2017-12-05 01:26:02 -08:00 committed by Facebook Github Bot
parent 5c06a80fd7
commit dfa05cbcd4
2 changed files with 8 additions and 6 deletions

View File

@ -120,7 +120,7 @@ type Options = {|
class Bundler {
_opts: Options;
_getModuleId: ({path: string}) => number;
_getModuleId: (path: string) => number;
_transformer: Transformer;
_resolverPromise: Promise<Resolver>;
_projectRoots: $ReadOnlyArray<string>;

View File

@ -6,20 +6,22 @@
* 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
* @format
*/
'use strict';
function createModuleIdFactory(): (path: string) => number {
const fileToIdMap = new Map();
const fileToIdMap: Map<string, number> = new Map();
let nextId = 0;
return (path: string) => {
if (!fileToIdMap.has(path)) {
fileToIdMap.set(path, nextId);
nextId += 1;
let id = fileToIdMap.get(path);
if (typeof id !== 'number') {
id = nextId++;
fileToIdMap.set(path, id);
}
return fileToIdMap.get(path);
return id;
};
}