packager: HasteMap: @flow + fixes

Summary: Add Flow types, revealing a few problems, such as `isHaste` having the wrong return value in the "pseudo-mocks". But since the buck worker is in fact working, I guess these functions were never called... The point of typing this file is that I'm going to start aggressively pruning dead code in `node-haste` and hopefully, eventually, get rid of `Moduleish` and `Packageish`.

Reviewed By: davidaurelio

Differential Revision: D5052379

fbshipit-source-id: dab3f18f05fcf43fbbc48b589170b1cf367d6a48
This commit is contained in:
Jean Lauliac
2017-05-12 10:26:50 -07:00
committed by Facebook Github Bot
parent ffe18867f2
commit 4ae8e5e21a
7 changed files with 66 additions and 31 deletions

View File

@@ -49,21 +49,26 @@ export type ModuleMap = {
): ?string,
};
type Packageish = {
export type Packageish = {
isHaste(): boolean,
getName(): Promise<string>,
path: string,
redirectRequire(toModuleName: string): string | false,
getMain(): string,
+root: string,
};
type Moduleish = {
export type Moduleish = {
+path: string,
isHaste(): boolean,
getName(): Promise<string>,
getPackage(): ?Packageish,
hash(): string,
readCached(transformOptions: TransformWorkerOptions): CachedReadResult,
readFresh(transformOptions: TransformWorkerOptions): Promise<ReadResult>,
};
type ModuleishCache<TModule, TPackage> = {
export type ModuleishCache<TModule, TPackage> = {
getPackage(
name: string,
platform?: string,