-
-
Notifications
You must be signed in to change notification settings - Fork 6.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: migrate jest-haste-map to TypeScript
Showing
27 changed files
with
345 additions
and
298 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
234 changes: 120 additions & 114 deletions
234
packages/jest-haste-map/src/index.js → packages/jest-haste-map/src/index.ts
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,8 +7,6 @@ | |
* | ||
*/ | ||
|
||
'use strict'; | ||
|
||
import path from 'path'; | ||
import {relative, resolve} from '../fast_path'; | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,104 @@ | ||
/** | ||
* Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved. | ||
* | ||
* This source code is licensed under the MIT license found in the | ||
* LICENSE file in the root directory of this source tree. | ||
*/ | ||
|
||
import {Config} from '@jest/types'; | ||
import ModuleMap from './ModuleMap'; | ||
import HasteFS from './HasteFS'; | ||
|
||
export type IgnoreMatcher = (item: string) => boolean; | ||
export type Mapper = (item: string) => Array<string> | null; | ||
|
||
export type WorkerMessage = { | ||
computeDependencies: boolean; | ||
computeSha1: boolean; | ||
dependencyExtractor?: string; | ||
rootDir: string; | ||
filePath: string; | ||
hasteImplModulePath?: string; | ||
}; | ||
|
||
export type WorkerMetadata = { | ||
dependencies: Array<string> | undefined | null; | ||
id: string | undefined | null; | ||
module: ModuleMetaData | undefined | null; | ||
sha1: string | undefined | null; | ||
}; | ||
|
||
export type CrawlerOptions = { | ||
computeSha1: boolean; | ||
data: InternalHasteMap; | ||
extensions: Array<string>; | ||
forceNodeFilesystemAPI: boolean; | ||
ignore: IgnoreMatcher; | ||
mapper?: Mapper | null; | ||
rootDir: string; | ||
roots: Array<string>; | ||
}; | ||
|
||
export type HasteImpl = { | ||
getHasteName(filePath: Config.Path): string | void; | ||
}; | ||
|
||
export type FileData = Map<Config.Path, FileMetaData>; | ||
|
||
export type FileMetaData = [ | ||
/* id */ string, | ||
/* mtime */ number, | ||
/* size */ number, | ||
/* visited */ 0 | 1, | ||
/* dependencies */ Array<string>, | ||
/* sha1 */ string | null | undefined | ||
]; | ||
|
||
export type MockData = Map<string, Config.Path>; | ||
export type ModuleMapData = Map<string, ModuleMapItem>; | ||
export type WatchmanClocks = Map<Config.Path, string>; | ||
export type HasteRegExp = RegExp | ((str: string) => boolean); | ||
|
||
export type DuplicatesSet = Map<string, /* type */ number>; | ||
export type DuplicatesIndex = Map<string, Map<string, DuplicatesSet>>; | ||
|
||
export type InternalHasteMap = { | ||
clocks: WatchmanClocks; | ||
duplicates: DuplicatesIndex; | ||
files: FileData; | ||
map: ModuleMapData; | ||
mocks: MockData; | ||
}; | ||
|
||
export type HasteMap = { | ||
hasteFS: HasteFS; | ||
moduleMap: ModuleMap; | ||
__hasteMapForTest?: InternalHasteMap | null; | ||
}; | ||
|
||
export type RawModuleMap = { | ||
rootDir: Config.Path; | ||
duplicates: DuplicatesIndex; | ||
map: ModuleMapData; | ||
mocks: MockData; | ||
}; | ||
|
||
type ModuleMapItem = {[platform: string]: ModuleMetaData}; | ||
export type ModuleMetaData = [Config.Path, /* type */ number]; | ||
|
||
export type HType = { | ||
ID: 0; | ||
MTIME: 1; | ||
SIZE: 2; | ||
VISITED: 3; | ||
DEPENDENCIES: 4; | ||
SHA1: 5; | ||
PATH: 0; | ||
TYPE: 1; | ||
MODULE: 0; | ||
PACKAGE: 1; | ||
GENERIC_PLATFORM: 'g'; | ||
NATIVE_PLATFORM: 'native'; | ||
}; | ||
|
||
export type HTypeValue = HType[keyof HType]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
{ | ||
"extends": "../../tsconfig.json", | ||
"compilerOptions": { | ||
"rootDir": "src", | ||
"outDir": "build" | ||
}, | ||
"references": [ | ||
{"path": "../jest-worker"}, | ||
{"path": "../jest-serializer"}, | ||
{"path": "../jest-util"}, | ||
{"path": "../jest-types"} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters