Repository navigation
Conversation
flow-typed/jest.js is hand-maintained, so it drifted from the Jest API: it was missing getMockImplementation() until react#2163, and the missing declaration surfaced only as an internal Flow error, hidden in OSS behind $FlowFixMe[prop-missing]. scripts/__tests__/checkJestLibdef-test.js fails when a jest-mock MockInstance method is missing from JestMockFn, so the next omission fails OSS CI instead. It brings the libdef up to date first, adding getMockName() and withImplementation().
vzaidman
marked this pull request as draft
November 3, 2026 20:16
Extract MockInstance members with the TypeScript compiler API and JestMockFn members with flow-parser, instead of brace counting and regexes over source text.
Contributor
Author
|
Dropping this: the check is too specific and sketchy. The libdef additions (getMockName, withImplementation) go with it; getMockImplementation stays via #2163. |
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
flow-typed/jest.js is hand-maintained, so it drifted from the Jest API: it was missing getMockImplementation() until #2163, and the missing declaration surfaced only as an internal Flow error, hidden in OSS behind $FlowFixMe[prop-missing].
scripts/tests/checkJestLibdef-test.js fails when a jest-mock MockInstance method is missing from JestMockFn, comparing against the jest-mock types pinned in node_modules (jest-mock internals _isMockFunction / _protoImpl are intentionally excluded). The next omission fails OSS CI instead of internal Flow. Member extraction uses the TypeScript compiler API for the .d.ts side and flow-parser for the Flow side, not regexes over source text.
Generating flow-typed/jest.js from the TypeScript definitions was evaluated and is not viable: flowgen 1.21.0 crashes on jest-mock's own index.d.ts (TypeError in its printer), and the file also covers more than jest-mock (expect, test, fake timers) from several sources, so there is no single TS source to generate it from. flow-api-translator in this repo goes the other direction (Flow to TS).
It brings the libdef up to date first, adding getMockName() and withImplementation().
Validation: