Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: facebook/metro
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: v0.74.0
Choose a base ref
...
head repository: facebook/metro
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: v0.74.1
Choose a head ref
  • 15 commits
  • 75 files changed
  • 6 contributors

Commits on Jan 11, 2023

  1. Add @babel/plugin-proposal-numeric-separator to the babel plugins w…

    …hen not in Hermes (#681)
    
    Summary:
    Changelog:
    * **[Feature]**: Enable ES2021 numeric separator syntax in React Native
    
    **Summary**
    
    This PR solves issue #645. It adds `babel/plugin-proposal-numeric-separator` to the list of babel plugins when not using Hermes to more closely match ES2021. Now that ES2021 has been finalized, people will probably (?—I know I did) expect `1_000_000` to be treated as a valid number.
    
    As I noted in a [comment](#645 (comment)) in #645, should `babel/preset-env` be included instead of including many different plugins manually? Even for engines like Hermes which don't need all the same transforms as JSC, I don't think the unneeded transforms would drastically increase the bundle size, right?
    
    **Test plan**
    Tested it using a sample app on `"react-native": "0.65.0-rc.2"`. Solves the `react-native bundle` issue on iOS (only tested on device as I encountered issues compiling for the simulator) and Android production / release builds when not using Hermes.
    
    Pull Request resolved: #681
    
    Reviewed By: rubennorte
    
    Differential Revision: D29556107
    
    Pulled By: motiz88
    
    fbshipit-source-id: 2d66bf8993cb10dd1f020939f4ad1bbf49cccc19
    SConaway authored and facebook-github-bot committed Jan 11, 2023
    Copy the full SHA
    22bc39f View commit details

Commits on Jan 12, 2023

  1. Introduce BundlerResolution type

    Summary:
    Changelog: Internal
    
    ## This diff
    
    Creates a new object type, `BundlerResolution`, to represent the return value of the resolver as seen by the bundler (instead of returning just a single string value).
    
    This is a mostly mechanical refactor, but there are some further changes in `ModuleResolution.js` where we remove the reliance on `getModule()` and the `ModuleT` generic (and for `sourceFile` resolutions, we now *directly* return the resolver's output).
    
    The intention is to keep this close to the `Resolution` type that is in the resolver's public API (and in `resolveRequest` etc), and possibly remove the distinction between the two. *For now*, it's useful to continue to translate `assetFiles` and `empty` resolutions to `sourceFile` (inside `ModuleResolution.js`), without forcing all call sites to deal with the different resolution types.
    
    ## Next steps
    
    In future work, `BundlerResolution` will carry more information that will allow the bundler to invalidate resolutions correctly (e.g. candidate paths that were attempted before the successful resolution).
    
    Longer term, we might also want to use this structure to keep track of additional file dependencies that invalidate the *contents* of virtual modules (such as assets and `require.context` modules). Currently, asset modules are not invalidated correctly when a secondary asset file (e.g. a different scale variant of an image) is created/modified, and `require.context` invalidation is handled as a special case in DeltaBundler.
    
    Reviewed By: robhogan
    
    Differential Revision: D42442272
    
    fbshipit-source-id: 12a57bb669791043755c39ac10a284e11678044e
    motiz88 authored and facebook-github-bot committed Jan 12, 2023
    Copy the full SHA
    c6e1990 View commit details

Commits on Jan 13, 2023

  1. Break up InternalData into FileData+RawModuleMap (1/2)

    Summary:
    In order to efficiently look up symlinks, we need a more complex structure than a simple `Map` to represent known files. The plan is to:
     1. Separate manipulation of the `files` Map from (Haste) `ModuleMap` data.
     2. Move access to (and more importantly, mutation of) the `files` map into the `HasteFS` class, implementing a `MutableFileSystem extends FileSystem` interface.
     3. Add an alternative `TreeFS` implementation of this interface, with an internal prefix-tree data structure, that we'll use when symlinks are enabled.
     4. If and when we have proven reliability and performance parity, remove `HasteFS`.
    
    (Note that this also opens up the possibility of a "`LazyFS`" implementation, although for the moment the API will be synchronous)
    
    This diff is the first part of that change - split the use of `InternalData`, which is essentially the raw data as read and written from the cache, into two objects - `FileData` and `RawModuleMap` (pre-existing types). Introduce `CacheData` to represent the combination of the two, which is now used only by cache APIs.
    
    In the following diff, we'll replace the passing of `FileData` with an instance of `MutableFileSystem`.
    
    Point of interest: I think this files/Haste separation is also what Christoph had in mind jestjs/jest#1427.
    
    Changelog: [Internal]
    
    Reviewed By: jacdebug
    
    Differential Revision: D42303308
    
    fbshipit-source-id: a3fa34311818ca3a0214687e6895e0bd2ba6c7b3
    robhogan authored and facebook-github-bot committed Jan 13, 2023
    Copy the full SHA
    ef9af83 View commit details

Commits on Jan 15, 2023

  1. Mutate FileData through MutableFileSystem interface (2/2)

    Summary:
    In order to efficiently look up symlinks, we need a more complex structure than a simple `Map` to represent known files. The plan is to:
    1. Separate manipulation of the `files` Map from (Haste) `ModuleMap` data. (D42303308 (ef9af83))
     2. Move access to (and more importantly, mutation of) the `files` map into the `HasteFS` class, implementing a `MutableFileSystem extends FileSystem` interface.
     3. Add an alternative `TreeFS` implementation of this interface, with an internal prefix-tree data structure, that we'll use when symlinks are enabled.
     4. If and when we have proven reliability and performance parity, remove `HasteFS`.
    
    This diff is part 2 - we introduce a new `MutableFileSystem` interface with APIs equivalent to the previous direct mutation of `FileData`, and encapsulate all mutation of the map (and everything in it) within `HasteFS`.
    
    ## Startup performance
    Since we're introducing more indirection on some hot startup paths, we need to ensure there's no noticeable perf hit.
    
    The figures in the test plan are single samples but they are consistent over multiple runs - this diff took a few draft iterations to get the speed almost up to the level of raw map manipulation. The key turned out to be minimising path normalisation, since `HasteFS` previously expected absolute paths for all of its APIs and had to normalise everything - it now accepts absolute or relative paths, and has shortcuts for fully normalised relative paths. The `bulkAddOrRemove` API takes `FileData` objects (implicitly pre-normalised, relative paths) and is therefore able to process much faster than multiple calls to `addOrRemove`.
    
    Reviewed By: huntie
    
    Differential Revision: D42344528
    
    fbshipit-source-id: a47651154e18acb3490bb5158c40f88c2e365b8a
    robhogan authored and facebook-github-bot committed Jan 15, 2023
    Copy the full SHA
    0aa87d2 View commit details

Commits on Jan 16, 2023

  1. Emit file type of changed file even on deletion

    Summary:
    We introduced `ChangeEventMetadata` in D41494003 (5d4e7cc) as a direct replacement for `fs.Stat` - inheriting the expectation that it would be present iff the event describes a new/changed file.
    
    Now that we can (theoretically) emit events referring to symlinks, the consumer may (will) need to distinguish regular files from links - including for deletion events.
    
    This diff changes things around so that `ChangeEventMetadata` is *always* present for all event types, but some of its properties are no longer guaranteed.
    
    Changelog: [Internal]
    
    Reviewed By: motiz88
    
    Differential Revision: D42454102
    
    fbshipit-source-id: f930d53bded995ac68d45b409fd4b67be284824c
    robhogan authored and facebook-github-bot committed Jan 16, 2023
    Copy the full SHA
    bdeb55b View commit details

Commits on Jan 17, 2023

  1. Remove blog content from website

    Summary:
    - Remove long-outdated blog article from website (`/blog` was previously removed from nav) — we will use the React Native blog for future posts!
    - Replace blog link on Help page ("Stay up to date") with link to releases.
    - Remove unused `i18n/en.json` file.
    
    Reviewed By: jacdebug
    
    Differential Revision: D42536010
    
    fbshipit-source-id: 750098ec14c708338e622cb11ea5c48bcd7b79b9
    huntie authored and facebook-github-bot committed Jan 17, 2023
    Copy the full SHA
    64c0597 View commit details
  2. Add "Experimental" docs label

    Reviewed By: motiz88
    
    Differential Revision: D42533126
    
    fbshipit-source-id: 3c9a03d17e92b341e1373c26d10d338385634b1b
    huntie authored and facebook-github-bot committed Jan 17, 2023
    Copy the full SHA
    311fd86 View commit details
  3. Add experimental package exports config options

    Summary:
    Add new experimental/unstable config options which will be used by incoming package exports support.
    
    Changelog: **[Experimental]** Add `resolver.unstable_enablePackageExports` config option
    
    Reviewed By: motiz88
    
    Differential Revision: D42531005
    
    fbshipit-source-id: a73500523a96106d1551d8796996551f32321cdd
    huntie authored and facebook-github-bot committed Jan 17, 2023
    Copy the full SHA
    5c6897e View commit details

Commits on Jan 18, 2023

  1. Pre-suppress errors ahead of 0.197.0 release

    Summary: Changelog: [internal]
    
    Reviewed By: mroch
    
    Differential Revision: D42558696
    
    fbshipit-source-id: 3367fb1233c9630bd31b0ae9950f7b2f13438057
    SamChou19815 authored and facebook-github-bot committed Jan 18, 2023
    Copy the full SHA
    bdeff42 View commit details
  2. automatic update for docusaurus-plugin-internaldocs-fb@1.4.0

    Reviewed By: lblasa
    
    Differential Revision: D42547166
    
    fbshipit-source-id: c51d95670c19a4d152066e4d61bd9dd3d905e2ad
    antonk52 authored and facebook-github-bot committed Jan 18, 2023
    Copy the full SHA
    20920b0 View commit details
  3. Refactor metro-file-map worker

    Summary:
    Currently, `metro-file-map`'s worker exports a `worker` and a `getSha1` method, which have identical signatures but different behaviour. `worker` could be used for everything, except that it differs from `getSha1` in the following ways:
    
     - `worker` will check whether the file is a `package.json`, and if not, whether it passes a Haste / `computeDependencies` exclusion list *even if there's no work to be done*.
     - `worker` will re-use a memoised `hasteImpl` even if `hasteImplModulePath` is not given.
     - `worker` is not able to calculate the sha1 of binary files, because it reads contents in `utf8`.
    
    This diff changes things around a bit so that we can consolidate on the one `worker` export - the motivation primarily being to bring in symlink support without adding new code paths in several places.
    
     - Move lazy loading of `hasteImpl` to where it's required, and use it only if `hasteImplModulePath` is non-null.
     - Have `getContent` return a `Buffer` and decode it where necessary.
     - Don't parse a `package.json` as a Haste package unless new option `enableHastePackages = true`.
     - Don't check `exclusionList` (now `excludedExtensions`) unless there's something to do if the check passes.
    
    All this means we can delete `getSha1` and the `worker` can cover all of our needs - so we'll only have one place to add symlink target reads in the next diff.
    
    Changelog: [Internal]
    
    Reviewed By: jacdebug
    
    Differential Revision: D42537300
    
    fbshipit-source-id: 31faa076c3e7fc6ddf9c3e6a906b0f0796a1be51
    robhogan authored and facebook-github-bot committed Jan 18, 2023
    Copy the full SHA
    51df674 View commit details
  4. Gather symlink targets on crawl/change processing

    Summary:
    The groundwork has been done to store symlink targets in `metro-file-map`'s in-memory (and persisted) map, but we're not yet reading link targets.
    
    This diff adds a `readLink` worker option and sets it when appropriate within `_processFile`, and delegates to the worker for consistency with other operations that require a "visit" to gather metadata subsequent to a crawl result or change event.
    
    Symlink targets will then be stored for all symlinks in the cache, and we'll avoid any IO if their modification time doesn't change.
    
    Changelog: [Internal]
    
    Reviewed By: motiz88
    
    Differential Revision: D42546808
    
    fbshipit-source-id: 5c9737971f50dc90ade43f709ef896124023203e
    robhogan authored and facebook-github-bot committed Jan 18, 2023
    Copy the full SHA
    5ae4b0d View commit details
  5. Add resolver.unstable_enableSymlinks and remove symlinks+watchman r…

    …estriction
    
    Summary:
    **Note: this change does not mean that symlinks are respected by the resolver (yet)!**
    
    Add `resolver.unstable_enableSymlinks` (default: `false`) option to Metro config, and pass it though to the existing `enableSymlinks` option in `metro-file-map`.
    
    At this point this is purely for ease of testing end-to-end behaviour as we incrementally change Fast Refresh and resolution to cope with symlinks.
    
    Removes the Jest-inherited prohibition on using `enableSymlinks` with `useWatchman`, which is no longer necessary or relevant to the new implementation.
    
    **Bikeshed: Why under `resolver`?**
    Symlink support is mostly relevant to the resolver, in that if the resolver resolves to a file through a link, that fact is transparent to the rest of Metro. Third-party solutions for symlink-based projects have focused on the resolver. The fact that 90% of the work for this solution is within `metro-file-map` is an implementation detail of in-memory resolution. That said, we'll have an opportunity to revisit this when the config is promoted from `unstable_`
    
    Changlog: [Experimental] - Add `resolver.unstable_enableSymlinks` config for first phase of symlink support.
    
    Reviewed By: jacdebug
    
    Differential Revision: D42552674
    
    fbshipit-source-id: a6cfe38973b2a484af85f4a11274c4073710a883
    robhogan authored and facebook-github-bot committed Jan 18, 2023
    Copy the full SHA
    ed55455 View commit details
  6. Update Jest type definitions to v29

    Summary:
    @public
    
    Changelog: [Internal]
    
    TSIA
    
    Reviewed By: jacdebug
    
    Differential Revision: D42570767
    
    fbshipit-source-id: 26deffc1a749ed9403a71dcef64db02d0bf652e8
    motiz88 authored and facebook-github-bot committed Jan 18, 2023
    Copy the full SHA
    1d51ffd View commit details

Commits on Jan 19, 2023

  1. Release 0.74.1

    Summary: Bump Metro packages to 0.74.1
    
    Reviewed By: huntie
    
    Differential Revision: D42610594
    
    fbshipit-source-id: f9e105bdcc9415a78d6e729af9e4d31c70a961f2
    robhogan authored and facebook-github-bot committed Jan 19, 2023
    Copy the full SHA
    c438dd0 View commit details
Showing with 1,585 additions and 994 deletions.
  1. +69 −37 flow-typed/jest.js
  2. +1 −1 lerna.json
  3. +2 −2 packages/buck-worker-tool/package.json
  4. +1 −1 packages/metro-babel-register/package.json
  5. +2 −2 packages/metro-babel-transformer/package.json
  6. +2 −2 packages/metro-cache-key/package.json
  7. +3 −3 packages/metro-cache/package.json
  8. +3 −0 packages/metro-cache/src/__tests__/Cache-test.js
  9. +1 −1 packages/metro-cache/src/stores/__tests__/AutoCleanFileStore-test.js
  10. +1 −1 packages/metro-cache/src/stores/__tests__/FileStore-test.js
  11. +1 −1 packages/metro-cache/src/stores/__tests__/HttpGetStore-test.js
  12. +1 −1 packages/metro-cache/src/stores/__tests__/HttpStore-test.js
  13. +5 −5 packages/metro-config/package.json
  14. +44 −0 packages/metro-config/src/__tests__/__snapshots__/loadConfig-test.js.snap
  15. +1 −0 packages/metro-config/src/__tests__/loadConfig-test.js
  16. +6 −0 packages/metro-config/src/configTypes.flow.js
  17. +6 −0 packages/metro-config/src/defaults/index.js
  18. +2 −2 packages/metro-core/package.json
  19. +1 −1 packages/metro-file-map/package.json
  20. +92 −9 packages/metro-file-map/src/HasteFS.js
  21. +2 −2 packages/metro-file-map/src/Watcher.js
  22. +207 −160 packages/metro-file-map/src/__tests__/index-test.js
  23. +78 −14 packages/metro-file-map/src/__tests__/worker-test.js
  24. +3 −3 packages/metro-file-map/src/cache/DiskCacheManager.js
  25. +33 −12 packages/metro-file-map/src/flow-types.js
  26. +218 −187 packages/metro-file-map/src/index.js
  27. +9 −12 packages/metro-file-map/src/lib/{deepCloneInternalData.js → deepCloneRawModuleMap.js}
  28. +57 −55 packages/metro-file-map/src/worker.js
  29. +1 −1 packages/metro-hermes-compiler/package.json
  30. +1 −1 packages/metro-inspector-proxy/package.json
  31. +1 −1 packages/metro-memory-fs/package.json
  32. +1 −1 packages/metro-minify-terser/package.json
  33. +1 −1 packages/metro-minify-uglify/package.json
  34. +2 −1 packages/metro-react-native-babel-preset/package.json
  35. +1 −0 packages/metro-react-native-babel-preset/src/configs/main.js
  36. +4 −4 packages/metro-react-native-babel-transformer/package.json
  37. +1 −1 packages/metro-react-native-interop-tools/package.json
  38. +1 −1 packages/metro-resolver/package.json
  39. +3 −0 packages/metro-resolver/src/__tests__/index-test.js
  40. +5 −0 packages/metro-resolver/src/types.js
  41. +1 −1 packages/metro-runtime/package.json
  42. +3 −3 packages/metro-source-map/package.json
  43. +2 −2 packages/metro-symbolicate/package.json
  44. +7 −0 packages/metro-symbolicate/src/__tests__/ChromeHeapSnapshotProcessor-test.js
  45. +2 −2 packages/metro-transform-plugins/package.json
  46. +11 −11 packages/metro-transform-worker/package.json
  47. +22 −22 packages/metro/package.json
  48. +5 −0 packages/metro/src/DeltaBundler/DeltaCalculator.js
  49. +1 −1 packages/metro/src/DeltaBundler/Graph.js
  50. +2 −0 packages/metro/src/DeltaBundler/Serializers/helpers/__tests__/bytecode-test.js
  51. +2 −0 packages/metro/src/DeltaBundler/Serializers/helpers/__tests__/js-test.js
  52. +36 −12 packages/metro/src/DeltaBundler/__tests__/DeltaCalculator-context-test.js
  53. +20 −14 packages/metro/src/DeltaBundler/__tests__/DeltaCalculator-test.js
  54. +4 −1 packages/metro/src/DeltaBundler/__tests__/Graph-test.js
  55. +492 −301 packages/metro/src/DeltaBundler/__tests__/resolver-test.js
  56. +6 −1 packages/metro/src/DeltaBundler/types.flow.js
  57. +1 −1 packages/metro/src/HmrServer.js
  58. +1 −1 packages/metro/src/Server.js
  59. +4 −3 packages/metro/src/Server/__tests__/Server-test.js
  60. +5 −3 packages/metro/src/__tests__/HmrServer-test.js
  61. +3 −0 packages/metro/src/lib/formatBundlingError.js
  62. +3 −0 packages/metro/src/lib/getAppendScripts.js
  63. +1 −0 packages/metro/src/lib/getPrependedScripts.js
  64. +5 −2 packages/metro/src/lib/transformHelpers.js
  65. +15 −10 packages/metro/src/node-haste/DependencyGraph.js
  66. +21 −16 packages/metro/src/node-haste/DependencyGraph/ModuleResolution.js
  67. +1 −0 packages/metro/src/node-haste/DependencyGraph/createHasteMap.js
  68. +1 −1 packages/ob1/package.json
  69. +0 −8 website/blog/2017-11-22-train-approaching.md
  70. +0 −45 website/i18n/en.json
  71. +1 −1 website/package.json
  72. +16 −0 website/src/css/custom.scss
  73. +5 −1 website/src/pages/help/index.js
  74. +4 −4 website/yarn.lock
  75. +9 −1 yarn.lock
106 changes: 69 additions & 37 deletions flow-typed/jest.js
Original file line number Diff line number Diff line change
@@ -9,12 +9,13 @@
* @oncall react_native
*/

// Copied from https://raw.githubusercontent.com/flow-typed/flow-typed/master/definitions/npm/jest_v26.x.x/flow_v0.134.x-/jest_v26.x.x.js
// Modified from https://raw.githubusercontent.com/flow-typed/flow-typed/master/definitions/npm/jest_v29.x.x/flow_v0.134.x-/jest_v29.x.x.js
// Modifications are explained inline by comments beginning with `// MODIFIED`.

type JestMockFn<
TArguments: $ReadOnlyArray<any> = $ReadOnlyArray<any>,
TReturn = any,
> = {
// MODIFIED: Added ESLint suppression comment - no-unused-vars doesn't understand declaration files
/* eslint-disable no-unused-vars */

type JestMockFn<TArguments: $ReadOnlyArray<any>, TReturn> = {
(...args: TArguments): TReturn,
/**
* An object for introspecting mock calls
@@ -26,6 +27,12 @@ type JestMockFn<
* passed during the call.
*/
calls: Array<TArguments>,
/**
* An array containing the call arguments of the last call that was made
* to this mock function. If the function was not called, it will return
* undefined.
*/
lastCall: TArguments,
/**
* An array that contains all the object instances that have been
* instantiated from this mock function.
@@ -174,6 +181,32 @@ type JestPromiseType = {
*/
type JestTestName = string | Function;

type FakeableAPI =
| 'Date'
| 'hrtime'
| 'nextTick'
| 'performance'
| 'queueMicrotask'
| 'requestAnimationFrame'
| 'cancelAnimationFrame'
| 'requestIdleCallback'
| 'cancelIdleCallback'
| 'setImmediate'
| 'clearImmediate'
| 'setInterval'
| 'clearInterval'
| 'setTimeout'
| 'clearTimeout';

type FakeTimersConfig = {
advanceTimers?: boolean | number,
doNotFake?: Array<FakeableAPI>,
now?: number | Date,
timerLimit?: number,
legacyFakeTimers?: boolean,
...
};

/**
* Plugin: jest-styled-components
*/
@@ -231,7 +264,7 @@ type EnzymeMatchersType = {
toIncludeText(text: string): void,
toMatchElement(
element: React$Element<any>,
options?: {ignoreProps?: boolean, verbose?: boolean},
options?: {|ignoreProps?: boolean, verbose?: boolean|},
): void,
toMatchSelector(selector: string): void,
// 7.x
@@ -265,7 +298,7 @@ type DomTestingLibraryType = {
toHaveStyle(css: string | {[name: string]: any, ...}): void,
toHaveTextContent(
text: string | RegExp,
options?: {normalizeWhitespace: boolean},
options?: {|normalizeWhitespace: boolean|},
): void,
toHaveValue(value?: string | string[] | number): void,

@@ -570,14 +603,14 @@ type SnapshotDiffType = {
*/
toMatchDiffSnapshot(
valueB: any,
options?: {
options?: {|
expand?: boolean,
colors?: boolean,
contextLines?: number,
stablePatchmarks?: boolean,
aAnnotation?: string,
bAnnotation?: string,
},
|},
testName?: string,
): void,
...
@@ -591,11 +624,21 @@ interface JestExpectType {
JestStyledComponentsMatchersType &
JestExtendedMatchersType &
SnapshotDiffType;
/**
* If you have a mock function, you can use .lastCalledWith to test what
* arguments it was last called with.
*/
lastCalledWith(...args: Array<any>): void;
/**
* toBe just checks that a value is what you expect. It uses === to check
* strict equality.
*/
toBe(value: any): void;
/**
* Use .toBeCalledWith to ensure that a mock function was called with
* specific arguments.
*/
toBeCalledWith(...args: Array<any>): void;
/**
* Using exact equality with floating point numbers is a bad idea. Rounding
* means that intuitive things fail.
@@ -708,20 +751,12 @@ interface JestExpectType {
* specific arguments.
*/
toHaveBeenCalledWith(...args: Array<any>): void;
/**
* Use .toBeCalledWith to ensure that a mock function was called with
* specific arguments.
*/
toBeCalledWith(...args: Array<any>): void;
/**
* Use .toHaveBeenLastCalledWith to ensure that a mock function was last called
* with specific arguments.
*/
toHaveBeenLastCalledWith(...args: Array<any>): void;
/**
* If you have a mock function, you can use .lastCalledWith to test what
* arguments it was last called with.
*/
lastCalledWith(...args: Array<any>): void;
/**
* Check that an object has a .length property and it is set to a certain
@@ -837,7 +872,8 @@ type JestObjectType = {
* Returns a new, unused mock function. Optionally takes a mock
* implementation.
*/
fn<TArguments: $ReadOnlyArray<any> = $ReadOnlyArray<any>, TReturn = any>(
// MODIFIED: Added defaults to type arguments.
fn<TArguments: $ReadOnlyArray<mixed> = $ReadOnlyArray<any>, TReturn = any>(
implementation?: (...args: TArguments) => TReturn,
): JestMockFn<TArguments, TReturn>,
/**
@@ -907,13 +943,6 @@ type JestObjectType = {
* or setInterval() and setImmediate()).
*/
advanceTimersByTime(msToRun: number): void,
/**
* Executes only the macro task queue (i.e. all tasks queued by setTimeout()
* or setInterval() and setImmediate()).
*
* Renamed to `advanceTimersByTime`.
*/
runTimersToTime(msToRun: number): void,
/**
* Executes only the macro-tasks that are currently pending (i.e., only the
* tasks that have been queued by setTimeout() or setInterval() up to this
@@ -937,7 +966,7 @@ type JestObjectType = {
* (setTimeout, setInterval, clearTimeout, clearInterval, nextTick,
* setImmediate and clearImmediate).
*/
useFakeTimers(mode?: 'modern' | 'legacy'): JestObjectType,
useFakeTimers(fakeTimersConfig?: FakeTimersConfig): JestObjectType,
/**
* Instructs Jest to use the real versions of the standard timer functions.
*/
@@ -961,10 +990,10 @@ type JestObjectType = {

type JestSpyType = {calls: JestCallsType, ...};

type JestDoneFn = {
type JestDoneFn = {|
(error?: Error): void,
fail: (error: Error) => void,
};
|};

/** Runs this function after every test inside this context */
declare function afterEach(
@@ -1037,7 +1066,7 @@ declare var it: {
* @param {Function} Test
* @param {number} Timeout for the test, in milliseconds.
*/
only: {
only: {|
(
name: JestTestName,
fn?: (done: JestDoneFn) => ?Promise<mixed>,
@@ -1050,15 +1079,15 @@ declare var it: {
fn?: (...args: Array<any>) => ?Promise<mixed>,
timeout?: number,
) => void,
},
|},
/**
* Skip running this test
*
* @param {JestTestName} Name of Test
* @param {Function} Test
* @param {number} Timeout for the test, in milliseconds.
*/
skip: {
skip: {|
(
name: JestTestName,
fn?: (done: JestDoneFn) => ?Promise<mixed>,
@@ -1071,7 +1100,7 @@ declare var it: {
fn?: (...args: Array<any>) => ?Promise<mixed>,
timeout?: number,
) => void,
},
|},
/**
* Highlight planned tests in the summary output
*
@@ -1151,9 +1180,11 @@ type JestPrettyFormatColors = {
};

type JestPrettyFormatIndent = string => string;
type JestPrettyFormatRefs = Array<any>;
type JestPrettyFormatPrint = any => string;
type JestPrettyFormatStringOrNull = string | null;

type JestPrettyFormatOptions = {
type JestPrettyFormatOptions = {|
callToJSON: boolean,
edgeSpacing: string,
escapeRegex: boolean,
@@ -1164,14 +1195,14 @@ type JestPrettyFormatOptions = {
plugins: JestPrettyFormatPlugins,
printFunctionName: boolean,
spacing: string,
theme: {
theme: {|
comment: string,
content: string,
prop: string,
tag: string,
value: string,
},
};
|},
|};

type JestPrettyFormatPlugin = {
print: (
@@ -1208,7 +1239,8 @@ declare var expect: {
hasAssertions(): void,
any(value: mixed): JestAsymmetricEqualityType,
anything(): any,
arrayContaining(value: Array<mixed>): Array<mixed>,
// MODIFIED: Array -> $ReadOnlyArray
arrayContaining(value: $ReadOnlyArray<mixed>): Array<mixed>,
objectContaining(value: Object): Object,
/** Matches any received string that contains the exact expected string. */
stringContaining(value: string): string,
2 changes: 1 addition & 1 deletion lerna.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"lerna": "2.4.0",
"version": "0.74.0",
"version": "0.74.1",
"npmClient": "yarn",
"useWorkspaces": true
}
4 changes: 2 additions & 2 deletions packages/buck-worker-tool/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "buck-worker-tool",
"version": "0.74.0",
"version": "0.74.1",
"description": "Implementation of the Buck worker protocol for Node.js.",
"license": "MIT",
"main": "src/worker-tool.js",
@@ -13,7 +13,7 @@
"through": ">=2.2.7 <3"
},
"devDependencies": {
"metro-memory-fs": "0.74.0"
"metro-memory-fs": "0.74.1"
},
"scripts": {
"prepare-release": "test -d build && rm -rf src.real && mv src src.real && mv build src",
2 changes: 1 addition & 1 deletion packages/metro-babel-register/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "metro-babel-register",
"version": "0.74.0",
"version": "0.74.1",
"description": "🚇 babel/register configuration for Metro.",
"main": "src/babel-register.js",
"repository": {
4 changes: 2 additions & 2 deletions packages/metro-babel-transformer/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "metro-babel-transformer",
"version": "0.74.0",
"version": "0.74.1",
"description": "🚇 Base Babel transformer for Metro.",
"main": "src/index.js",
"repository": {
@@ -19,7 +19,7 @@
"dependencies": {
"@babel/core": "^7.20.0",
"hermes-parser": "0.8.0",
"metro-source-map": "0.74.0",
"metro-source-map": "0.74.1",
"nullthrows": "^1.1.1"
}
}
4 changes: 2 additions & 2 deletions packages/metro-cache-key/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "metro-cache-key",
"version": "0.74.0",
"version": "0.74.1",
"description": "🚇 Cache key utility.",
"main": "src/index.js",
"repository": {
@@ -13,6 +13,6 @@
},
"license": "MIT",
"devDependencies": {
"metro-memory-fs": "0.74.0"
"metro-memory-fs": "0.74.1"
}
}
6 changes: 3 additions & 3 deletions packages/metro-cache/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "metro-cache",
"version": "0.74.0",
"version": "0.74.1",
"description": "🚇 Cache layers for Metro.",
"main": "src/index.js",
"repository": {
@@ -12,11 +12,11 @@
"cleanup-release": "test ! -e build && mv src build && mv src.real src"
},
"dependencies": {
"metro-core": "0.74.0",
"metro-core": "0.74.1",
"rimraf": "^3.0.2"
},
"devDependencies": {
"metro-memory-fs": "0.74.0"
"metro-memory-fs": "0.74.1"
},
"license": "MIT"
}
3 changes: 3 additions & 0 deletions packages/metro-cache/src/__tests__/Cache-test.js
Original file line number Diff line number Diff line change
@@ -217,6 +217,7 @@ describe('Cache', () => {

describe('disabled cache', () => {
it('returns null for reads', async () => {
// $FlowFixMe[missing-empty-array-annot]
const cache = new Cache([]);

const result = await cache.get(Buffer.from('foo'));
@@ -225,6 +226,7 @@ describe('Cache', () => {
});

it('ignores writes', async () => {
// $FlowFixMe[missing-empty-array-annot]
const cache = new Cache([]);

await cache.set(Buffer.from('foo'), 'value');
@@ -234,6 +236,7 @@ describe('Cache', () => {
});

it('logs nothing', async () => {
// $FlowFixMe[missing-empty-array-annot]
const cache = new Cache([]);

await cache.set(Buffer.from('foo'), 'value');
Original file line number Diff line number Diff line change
@@ -19,7 +19,7 @@ describe('AutoCleanFileStore', () => {
jest
.resetModules()
.resetAllMocks()
.useFakeTimers('legacy') // Legacy fake timers are reset by `resetAllMocks()`
.useFakeTimers({legacyFakeTimers: true}) // Legacy fake timers are reset by `resetAllMocks()`
.mock('fs', () => new (require('metro-memory-fs'))());

AutoCleanFileStore = require('../AutoCleanFileStore');
Original file line number Diff line number Diff line change
@@ -18,7 +18,7 @@ describe('FileStore', () => {
jest
.resetModules()
.resetAllMocks()
.useFakeTimers('legacy') // Legacy fake timers are reset by `resetAllMocks()`
.useFakeTimers({legacyFakeTimers: true}) // Legacy fake timers are reset by `resetAllMocks()`
.mock('fs', () => new (require('metro-memory-fs'))());

FileStore = require('../FileStore');
Loading