diff --git a/flow/jest.js b/flow/jest.js index 1780dfa9f28..8975e3b33c8 100644 --- a/flow/jest.js +++ b/flow/jest.js @@ -4,13 +4,16 @@ * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. * - * Copied from https://raw.githubusercontent.com/flow-typed/flow-typed/master/definitions/npm/jest_v23.x.x/flow_v0.39.x-/jest_v23.x.x.js - * @flow strict + * Modified from https://raw.githubusercontent.com/flow-typed/flow-typed/master/definitions/npm/jest_v23.x.x/flow_v0.39.x-/jest_v23.x.x.js + * List of modifications: + * - fix some [] -> Array lint warnings + * - make it.each/describe.each take $ReadOnlyArray instead of Array + * - added definition for `isolateModules` + * + * TODO(T35016336) remove the .each modifications if flow-typed adopts them * @format */ -/* eslint-disable lint/no-unclear-flowtypes */ - type JestMockFn, TReturn> = {| (...args: TArguments): TReturn, /** @@ -272,7 +275,7 @@ type JestExtendedMatchersType = { * Use .toBeOneOf when checking if a value is a member of a given Array. * @param {Array.<*>} members */ - toBeOneOf(members: any[]): void, + toBeOneOf(members: Array): void, /** * Use `.toBeNil` when checking a value is `null` or `undefined`. @@ -300,13 +303,13 @@ type JestExtendedMatchersType = { * Use `.toIncludeAllMembers` when checking if an `Array` contains all of the same members of a given set. * @param {Array.<*>} members */ - toIncludeAllMembers(members: any[]): void, + toIncludeAllMembers(members: Array): void, /** * Use `.toIncludeAnyMembers` when checking if an `Array` contains any of the members of a given set. * @param {Array.<*>} members */ - toIncludeAnyMembers(members: any[]): void, + toIncludeAnyMembers(members: Array): void, /** * Use `.toSatisfyAll` when you want to use a custom matcher by supplying a predicate function that returns a `Boolean` for all values in an array. @@ -409,21 +412,21 @@ type JestExtendedMatchersType = { * * @param {Array.} keys */ - toContainKeys(keys: string[]): void, + toContainKeys(keys: Array): void, /** * Use `.toContainAllKeys` when checking if an object only contains all of the provided keys. * * @param {Array.} keys */ - toContainAllKeys(keys: string[]): void, + toContainAllKeys(keys: Array): void, /** * Use `.toContainAnyKeys` when checking if an object contains at least one of the provided keys. * * @param {Array.} keys */ - toContainAnyKeys(keys: string[]): void, + toContainAnyKeys(keys: Array): void, /** * Use `.toContainValue` when checking if an object contains the provided value. @@ -437,21 +440,21 @@ type JestExtendedMatchersType = { * * @param {Array.<*>} values */ - toContainValues(values: any[]): void, + toContainValues(values: Array): void, /** * Use `.toContainAllValues` when checking if an object only contains all of the provided values. * * @param {Array.<*>} values */ - toContainAllValues(values: any[]): void, + toContainAllValues(values: Array): void, /** * Use `.toContainAnyValues` when checking if an object contains at least one of the provided values. * * @param {Array.<*>} values */ - toContainAnyValues(values: any[]): void, + toContainAnyValues(values: Array): void, /** * Use `.toContainEntry` when checking if an object contains the provided entry. @@ -465,21 +468,21 @@ type JestExtendedMatchersType = { * * @param {Array.>} entries */ - toContainEntries(entries: [string, string][]): void, + toContainEntries(entries: Array<[string, string]>): void, /** * Use `.toContainAllEntries` when checking if an object only contains all of the provided entries. * * @param {Array.>} entries */ - toContainAllEntries(entries: [string, string][]): void, + toContainAllEntries(entries: Array<[string, string]>): void, /** * Use `.toContainAnyEntries` when checking if an object contains at least one of the provided entries. * * @param {Array.>} entries */ - toContainAnyEntries(entries: [string, string][]): void, + toContainAnyEntries(entries: Array<[string, string]>): void, /** * Use `.toBeExtensible` when checking if an object is extensible. @@ -542,7 +545,7 @@ type JestExtendedMatchersType = { * * @param {Array.} substring */ - toIncludeMultiple(substring: string[]): void, + toIncludeMultiple(substring: Array): void, }; interface JestExpectType { @@ -824,7 +827,7 @@ type JestObjectType = { * Returns the actual module instead of a mock, bypassing all checks on * whether the module should receive a mock implementation or not. */ - requireActual(moduleName: string): any, + requireActual(m: $Flow$ModuleRef | string): T, /** * Returns a mock module instead of the actual module, bypassing all checks * on whether the module should be required normally or not. @@ -952,11 +955,11 @@ declare var describe: { * * @param {table} table of Test */ - each( - table: $ReadOnlyArray>, + each | mixed>( + table: $ReadOnlyArray, ): ( name: JestTestName, - fn?: (...args: Array) => ?Promise, + fn?: (...args: TArguments) => ?Promise, ) => void, }; @@ -979,11 +982,11 @@ declare var it: { * * @param {table} table of Test */ - each( - table: $ReadOnlyArray>, + each | mixed>( + table: $ReadOnlyArray, ): ( name: JestTestName, - fn?: (...args: Array) => ?Promise, + fn?: (...args: TArguments) => ?Promise, ) => void, /** * Only run this test @@ -997,11 +1000,11 @@ declare var it: { fn?: (done: () => void) => ?Promise, timeout?: number, ): { - each( - table: $ReadOnlyArray>, + each | mixed>( + table: $ReadOnlyArray, ): ( name: JestTestName, - fn?: (...args: Array) => ?Promise, + fn?: (...args: TArguments) => ?Promise, ) => void, }, /** @@ -1028,17 +1031,6 @@ declare var it: { fn?: (done: () => void) => ?Promise, timeout?: number, ): void, - /** - * each runs this test against array of argument arrays per each run - * - * @param {table} table of Test - */ - each( - table: $ReadOnlyArray>, - ): ( - name: JestTestName, - fn?: (...args: Array) => ?Promise, - ) => void, }; declare function fit( name: JestTestName,