Skip to content

Commit

Permalink
Update to flow 0.57.2 (#4694)
Browse files Browse the repository at this point in the history
  • Loading branch information
SimenB authored and cpojer committed Oct 15, 2017
1 parent 1261825 commit f5d7993
Show file tree
Hide file tree
Showing 25 changed files with 84 additions and 100 deletions.
3 changes: 2 additions & 1 deletion .flowconfig
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
.*/node_modules/fbjs/.*
.*/node_modules/jest-validate/.*
.*/node_modules/react-native/.*
.*/node_modules/graphql/.*
.*/vendor/jsonlint/.*
.*/examples/.*
.*/website/.*
Expand All @@ -13,4 +14,4 @@ module.name_mapper='^types/\(.*\)$' -> '<PROJECT_ROOT>/types/\1.js'
module.name_mapper='\(jest-[^/]*\)' -> '<PROJECT_ROOT>/packages/\1/src/index.js'

[version]
^0.53.1
^0.57.2
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,10 @@
"eslint-plugin-react": "^7.1.0",
"eslint-plugin-relay": "0.0.8",
"eslint-plugin-unicorn": "^2.1.2",
"flow-bin": "^0.53.1",
"flow-bin": "^0.57.2",
"glob": "^7.1.1",
"graceful-fs": "^4.1.11",
"immutable": "^4.0.0-rc.1",
"immutable": "^4.0.0-rc.7",
"istanbul-api": "^1.1.0",
"istanbul-lib-coverage": "^1.0.0",
"jasmine-reporters": "^2.2.0",
Expand Down Expand Up @@ -94,7 +94,7 @@
"test-examples": "node scripts/test_examples.js",
"test-pretty-format-perf": "node packages/pretty-format/perf/test.js",
"test": "yarn run typecheck && yarn run lint && yarn run jest && yarn run test-examples",
"typecheck": "flow check",
"typecheck": "flow check --include-warnings",
"watch": "yarn run build && node ./scripts/watch.js"
},
"workspaces": [
Expand Down
1 change: 0 additions & 1 deletion packages/eslint-plugin-jest/src/rules/no_focused_tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@

import type {EslintContext, CallExpression} from './types';

/* $FlowFixMe */
const testFunctions = Object.assign(Object.create(null), {
describe: true,
it: true,
Expand Down
2 changes: 0 additions & 2 deletions packages/eslint-plugin-jest/src/rules/no_identical_title.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@

import type {EslintContext, CallExpression} from './types';

/* $FlowFixMe */
const describeAliases = Object.assign(Object.create(null), {
describe: true,
'describe.only': true,
Expand All @@ -18,7 +17,6 @@ const describeAliases = Object.assign(Object.create(null), {
xdescribe: true,
});

/* $FlowFixMe */
const testCaseNames = Object.assign(Object.create(null), {
fit: true,
it: true,
Expand Down
2 changes: 1 addition & 1 deletion packages/jest-cli/src/lib/handle_deprecation_warnings.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import {KEYS} from '../constants';
export default (
pipe: stream$Writable | tty$WriteStream,
stdin: stream$Readable | tty$ReadStream = process.stdin,
) => {
): Promise<void> => {
return new Promise((resolve, reject) => {
if (typeof stdin.setRawMode === 'function') {
const messages = [
Expand Down
5 changes: 4 additions & 1 deletion packages/jest-cli/src/reporters/coverage_reporter.js
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,10 @@ export default class CoverageReporter extends BaseReporter {
this._checkThreshold(this._globalConfig, map);
}

_addUntestedFiles(globalConfig: GlobalConfig, contexts: Set<Context>) {
_addUntestedFiles(
globalConfig: GlobalConfig,
contexts: Set<Context>,
): Promise<void> {
const files = [];
contexts.forEach(context => {
const config = context.config;
Expand Down
4 changes: 2 additions & 2 deletions packages/jest-cli/src/test_scheduler.js
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ export default class TestScheduler {
}

_partitionTests(
testRunners: {[key: string]: TestRunner},
testRunners: {[key: string]: TestRunner, __proto__: null},
tests: Array<Test>,
) {
if (Object.keys(testRunners).length > 1) {
Expand Down Expand Up @@ -298,7 +298,7 @@ export default class TestScheduler {
contexts: Set<Context>,
aggregatedResults: AggregatedResult,
watcher: TestWatcher,
) {
): Promise<void> {
if (this._globalConfig.bail && aggregatedResults.numFailedTests !== 0) {
if (watcher.isWatchMode()) {
watcher.setState({interrupted: true});
Expand Down
4 changes: 2 additions & 2 deletions packages/jest-cli/src/watch.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@ export default function watch(
outputStream: stream$Writable | tty$WriteStream,
hasteMapInstances: Array<HasteMap>,
stdin?: stream$Readable | tty$ReadStream = process.stdin,
) {
// `globalConfig` will be consantly updated and reassigned as a result of
): Promise<void> {
// `globalConfig` will be constantly updated and reassigned as a result of
// watch mode interactions.
let globalConfig = initialGlobalConfig;

Expand Down
3 changes: 2 additions & 1 deletion packages/jest-config/src/set_from_argv.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,10 @@ export default function setFromArgv(
options: InitialOptions,
argv: Argv,
): InitialOptions {
// $FlowFixMe: Seems like flow doesn't approve of string values
const argvToOptions = Object.keys(argv)
.filter(key => argv[key] !== undefined && specialArgs.indexOf(key) === -1)
.reduce((options: Object, key) => {
.reduce((options: {[key: string]: mixed}, key) => {
switch (key) {
case 'coverage':
options.collectCoverage = argv[key];
Expand Down
9 changes: 6 additions & 3 deletions packages/jest-docblock/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,15 @@ export function strip(contents: string) {
return match && match[0] ? contents.substring(match[0].length) : contents;
}

export function parse(docblock: string): {[key: string]: string} {
export function parse(
docblock: string,
): {[key: string]: string, __proto__: null} {
return parseWithComments(docblock).pragmas;
}

export function parseWithComments(
docblock: string,
): {comments: string, pragmas: {[key: string]: string}} {
): {comments: string, pragmas: {[key: string]: string, __proto__: null}} {
const line = detectNewline(docblock) || EOL;

docblock = docblock
Expand Down Expand Up @@ -72,7 +74,8 @@ export function print({
pragmas = {},
}: {
comments?: string,
pragmas?: {[key: string]: string},
pragmas?: {[key: string]: string, __proto__: null},
__proto__: null,
}): string {
const line = detectNewline(comments) || EOL;
const head = '/**';
Expand Down
28 changes: 17 additions & 11 deletions packages/jest-editor-support/src/Snapshot.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,28 +24,34 @@ type SnapshotMetadata = {
};

const describeVariants = Object.assign(
(Object.create(null): {[string]: boolean}),
(Object.create(null): {[string]: boolean, __proto__: null}),
{
describe: true,
fdescribe: true,
xdescribe: true,
},
);
const base = Object.assign((Object.create(null): {[string]: boolean}), {
describe: true,
it: true,
test: true,
});
const decorators = Object.assign((Object.create(null): {[string]: boolean}), {
only: true,
skip: true,
});
const base = Object.assign(
(Object.create(null): {[string]: boolean, __proto__: null}),
{
describe: true,
it: true,
test: true,
},
);
const decorators = Object.assign(
(Object.create(null): {[string]: boolean, __proto__: null}),
{
only: true,
skip: true,
},
);

const validParents = Object.assign(
(Object.create(null): any),
base,
describeVariants,
Object.assign((Object.create(null): {[string]: boolean}), {
Object.assign((Object.create(null): {[string]: boolean, __proto__: null}), {
fit: true,
xit: true,
xtest: true,
Expand Down
10 changes: 8 additions & 2 deletions packages/jest-haste-map/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -326,6 +326,7 @@ class HasteMap extends EventEmitter {
): ?Promise<void> {
const setModule = (id: string, module: ModuleMetaData) => {
if (!map[id]) {
// $FlowFixMe
map[id] = Object.create(null);
}
const moduleMap = map[id];
Expand Down Expand Up @@ -666,6 +667,7 @@ class HasteMap extends EventEmitter {

if (mustCopy) {
mustCopy = false;
// $FlowFixMe
hasteMap = {
clocks: copy(hasteMap.clocks),
duplicates: copy(hasteMap.duplicates),
Expand Down Expand Up @@ -694,6 +696,7 @@ class HasteMap extends EventEmitter {
if (Object.keys(moduleMap).length === 0) {
delete hasteMap.map[moduleName];
} else {
// $FlowFixMe
hasteMap.map[moduleName] = moduleMap;
}
}
Expand Down Expand Up @@ -795,7 +798,7 @@ class HasteMap extends EventEmitter {
}
}

end() {
end(): Promise<void> {
clearInterval(this._changeInterval);
if (!this._watchers.length) {
return Promise.resolve();
Expand All @@ -805,7 +808,9 @@ class HasteMap extends EventEmitter {
this._watchers.map(
watcher => new Promise(resolve => watcher.close(resolve)),
),
).then(() => (this._watchers = []));
).then(() => {
this._watchers = [];
});
}

/**
Expand Down Expand Up @@ -847,6 +852,7 @@ class HasteMap extends EventEmitter {
}

_createEmptyMap(): InternalHasteMap {
// $FlowFixMe
return {
clocks: Object.create(null),
duplicates: Object.create(null),
Expand Down
2 changes: 1 addition & 1 deletion packages/jest-jasmine2/src/p_timeout.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export default function pTimeout(
clearTimeout: (timeoutID: number) => void,
setTimeout: (func: () => void, delay: number) => number,
onTimeout: () => any,
) {
): Promise<any> {
return new Promise((resolve, reject) => {
const timer = setTimeout(() => resolve(onTimeout()), ms);
promise.then(
Expand Down
4 changes: 3 additions & 1 deletion packages/jest-jasmine2/src/queue_runner.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,14 +70,16 @@ export default function queueRunner(options: Options) {
);
};

const result = options.queueableFns.reduce(
const result: Promise<void> = options.queueableFns.reduce(
(promise, fn) => promise.then(() => mapper(fn)),
Promise.resolve(),
);

return {
cancel: token.cancel.bind(token),
// $FlowFixMe
catch: result.catch.bind(result),
// $FlowFixMe
then: result.then.bind(result),
};
}
1 change: 0 additions & 1 deletion packages/jest-mock/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@ const FUNCTION_NAME_RESERVED_REPLACE = new RegExp(
'g',
);

// $FlowFixMe
const RESERVED_KEYWORDS = Object.assign(Object.create(null), {
arguments: true,
await: true,
Expand Down
1 change: 0 additions & 1 deletion packages/jest-repl/src/cli/repl.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ const evalCommand = (cmd, context, filename, callback, config) => {
}
result = vm.runInThisContext(cmd);
} catch (e) {
// $FlowFixMe: https://github.com/facebook/flow/pull/4713
return callback(isRecoverableError(e) ? new repl.Recoverable(e) : e);
}
return callback(null, result);
Expand Down
8 changes: 4 additions & 4 deletions packages/jest-resolve/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ type ModuleNameMapperConfig = {|
moduleName: string,
|};

type BooleanObject = {[key: string]: boolean};
type BooleanObject = {[key: string]: boolean, __proto__: null};

const NATIVE_PLATFORM = 'native';

Expand All @@ -64,9 +64,9 @@ const nodePaths = process.env.NODE_PATH
class Resolver {
_options: ResolverConfig;
_moduleMap: ModuleMap;
_moduleIDCache: {[key: string]: string};
_moduleNameCache: {[name: string]: Path};
_modulePathCache: {[path: Path]: Array<Path>};
_moduleIDCache: {[key: string]: string, __proto__: null};
_moduleNameCache: {[name: string]: Path, __proto__: null};
_modulePathCache: {[path: Path]: Array<Path>, __proto__: null};

constructor(moduleMap: ModuleMap, options: ResolverConfig) {
this._options = {
Expand Down
16 changes: 8 additions & 8 deletions packages/jest-runtime/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,14 +54,14 @@ type InternalModuleOptions = {|
type CoverageOptions = {
collectCoverage: boolean,
collectCoverageFrom: Array<Glob>,
collectCoverageOnlyFrom: ?{[key: string]: boolean},
collectCoverageOnlyFrom: ?{[key: string]: boolean, __proto__: null},
mapCoverage: boolean,
};

type ModuleRegistry = {[key: string]: Module};
type ModuleRegistry = {[key: string]: Module, __proto__: null};

type BooleanObject = {[key: string]: boolean};
type CacheFS = {[path: Path]: string};
type BooleanObject = {[key: string]: boolean, __proto__: null};
type CacheFS = {[path: Path]: string, __proto__: null};

const NODE_MODULES = path.sep + 'node_modules' + path.sep;
const SNAPSHOT_EXTENSION = 'snap';
Expand Down Expand Up @@ -91,16 +91,16 @@ class Runtime {
_explicitShouldMock: BooleanObject;
_internalModuleRegistry: ModuleRegistry;
_isCurrentlyExecutingManualMock: ?string;
_mockFactories: {[key: string]: () => any};
_mockMetaDataCache: {[key: string]: MockFunctionMetadata};
_mockRegistry: {[key: string]: any};
_mockFactories: {[key: string]: () => any, __proto__: null};
_mockMetaDataCache: {[key: string]: MockFunctionMetadata, __proto__: null};
_mockRegistry: {[key: string]: any, __proto__: null};
_moduleMocker: ModuleMocker;
_moduleRegistry: ModuleRegistry;
_resolver: Resolver;
_shouldAutoMock: boolean;
_shouldMockModuleCache: BooleanObject;
_shouldUnmockTransitiveDependenciesCache: BooleanObject;
_sourceMapRegistry: {[key: string]: string};
_sourceMapRegistry: {[key: string]: string, __proto__: null};
_scriptTransformer: ScriptTransformer;
_transitiveShouldMock: BooleanObject;
_unmockList: ?RegExp;
Expand Down
2 changes: 1 addition & 1 deletion packages/jest-runtime/src/script_transformer.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ import writeFileAtomic from 'write-file-atomic';
export type Options = {|
collectCoverage: boolean,
collectCoverageFrom: Array<Glob>,
collectCoverageOnlyFrom: ?{[key: string]: boolean},
collectCoverageOnlyFrom: ?{[key: string]: boolean, __proto__: null},
isInternalModule?: boolean,
mapCoverage: boolean,
|};
Expand Down
2 changes: 1 addition & 1 deletion packages/jest-worker/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ export default class {
_stdout: Readable;
_stderr: Readable;
_ending: boolean;
_cacheKeys: {[string]: Worker};
_cacheKeys: {[string]: Worker, __proto__: null};
_options: FarmOptions;
_workers: Array<Worker>;

Expand Down
Loading

0 comments on commit f5d7993

Please sign in to comment.