Граф коммитов

76 Коммитов

Автор SHA1 Сообщение Дата
Moti Zilberman 05ff52b656 Update Jest type definitions to v29
Summary:
@public

Changelog: [Internal]

TSIA

Reviewed By: jacdebug

Differential Revision: D42570767

fbshipit-source-id: 26deffc1a749ed9403a71dcef64db02d0bf652e8
2023-01-18 10:52:29 -08:00
Sam Zhou e480211a54 Fix or expose previously hidden type errors to prepare for LTI mode
Summary:
Changelog:
[Internal]

Differential Revision: D40600946

fbshipit-source-id: d169402eb16204ac62788806d6d3fb900776f3d2
2022-10-22 12:32:34 -07:00
Jordan Brown 46642928c4 Defaults for jest.fn's type parameters
Summary:
This diff adds defaults to Jest.fn's type params.

An upcoming change to flow will be more restrictive about how we implicitly instantiation type arguments. Since the argument to jest.fn is often omitted, this signature is the single biggest offender of our new rules. To reduce the error diff, I'm adding reasonable defaults so that the mocked function can still behave like a function without adding extra flow errors where there were none before.

Changelog: [Internal]

Reviewed By: SamChou19815

Differential Revision: D40394215

fbshipit-source-id: 2df596b6ba8b54680694e08c432a1e7c94dc2df0
2022-10-14 14:32:35 -07:00
Rob Hogan 09a910f80b Prepare for Jest 27+ by making legacy fake timer use explicit
Summary:
Jest 27 [flips defaults](https://jestjs.io/blog/2021/05/25/jest-27#flipping-defaults), making "modern" fake timers (ie, `sinonjs/fake-timers`) the default, over "legacy", which we currently use.

We're not quite ready for modern timers yet, partly due to Promise polyfills (https://github.com/facebook/react-native/pull/34659), and also some internal issues with specific tests.

This makes our use of legacy timers explicit in preparation for an update to Jest. A switch to modern timers may follow later.

Changelog:
[Internal][Changed] - Prepare for Jest 27+ by making legacy fake timer use explicit

Reviewed By: jacdebug

Differential Revision: D39383719

fbshipit-source-id: 6a3dc6f8547cc76f7702a5a39c9b30a184303f17
2022-09-12 04:59:18 -07:00
John Porto c37f719567 Migrates off getInstrumentedStats' deprecated fields
Summary:
This diffs replaces uses of the deprecated fields from HermesInternal.getInstrumentedStats() with the ones from Hermes' TimedRuntime.

Changelog:
[General][Added] - JSITimerInternal descriptor

Reviewed By: rubennorte

Differential Revision: D36625701

fbshipit-source-id: fbdb554e5cfb0b3556fcbe01f9e2930ace66a619
2022-07-06 20:00:15 -07:00
Rick Hanlon 93b50be8c2 Replace use-subscripton with use-sync-external-store (#33770)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/33770

React has replaced use-subscription with the React 18 compatible use-sync-external-store.

Changelog:
[General][Changed] - Replace use-subscripton with use-sync-external-store

Reviewed By: ryancat

Differential Revision: D35592432

fbshipit-source-id: cc2016f66940e53f3614e110bafb02240bae1ae4
2022-05-05 19:58:19 -07:00
Moti Zilberman 35800962c1 Deprecate nonstandard Promise.prototype.done
Summary:
Deprecates the nonstandard `Promise.prototype.done` method. This also removes one call site within React Native itself that relied on this method.

As part of this we are also removing React Native's custom Flow definition for `Promise` in favour of the standard one built into Flow. This will flag uses of `done` as type errors for anyone using the default app template's `.flowconfig`.

In a future release of React Native, we will remove the `done` method from the built-in `Promise` polyfill.

Changelog:
[General][Deprecated] - Deprecate the Promise.prototype.done method and log a warning when it's called in development.

Reviewed By: yungsters

Differential Revision: D34222667

fbshipit-source-id: 4b9708ac20c45b3966fdb93e883ab7f8d80017c1
2022-02-17 09:15:03 -08:00
Andres Suarez 8bd3edec88 Update copyright headers from Facebook to Meta
Reviewed By: aaronabramov

Differential Revision: D33367752

fbshipit-source-id: 4ce94d184485e5ee0a62cf67ad2d3ba16e285c8f
2021-12-30 15:11:21 -08:00
Xuan Huang d5689b959a Inherit type of queueMicrotask from Flow
Summary:
Changelog: [Internal]

Now that Flow releases include a type def of `queueMicrotask`,
we can just inherit it from Flow

Reviewed By: yungsters

Differential Revision: D31754482

fbshipit-source-id: f42f8ec955f898d7a964ff85b6061d4840590d4d
2021-10-19 11:30:58 -07:00
Andrei Shikov 8f7e23ae44 Update format to fix CircleCI failure (#32095)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/32095

Found by running `yarn run prettier` and including relevant files

Changelog:
[Internal] Fix formatting of `global.js`

Reviewed By: cortinico

Differential Revision: D30573273

fbshipit-source-id: 94854d3d3178533ad8a6323006eaca279a931fa7
2021-08-26 10:30:55 -07:00
Xuan Huang a8e2415a91 Type global queueMicrotask
Summary:
Changelog: [Internal]

This diff
- add `queueMicrotask` to eslint and metro so it's globally available.
- add `queueMicrotask` to the global libdef of react native so the type
  is available to `global.queueMicrotask` (which is common) as well.

Reviewed By: yungsters

Differential Revision: D30158144

fbshipit-source-id: 00a62193b838745c91179ff1e983636200560690
2021-08-26 01:06:44 -07:00
Xuan Huang e60ad0837e Type more globals
Summary:
Changelog: [Internal]

This diff add types to some of the common globals so uses of
them through `global` are now typed.

All the globals are marked as read-only for their intented uses.
However, some of them do have write cites (mostly are in tests to
deliberately set up a special test environment). Those write cites
are considered as "necessary evil" and annotated as `FlowFixMe`.

Reviewed By: yungsters

Differential Revision: D30158145

fbshipit-source-id: 93a99063361a4b7a1e33d9fc97a661be30a4d8f9
2021-08-26 01:06:44 -07:00
Nicola Corti dcfa0dc392 Fix broken CI with a run of prettier
Summary:
This Diff is fixing a broken CircleCI on OSS due to
not properly formatted .js files. See https://app.circleci.com/pipelines/github/facebook/react-native/10040/workflows/923cb408-b09c-4425-87c1-2677a7af9681/jobs/213822

The offending diff was D29986749 (ff4b33672a)

Changelog:
[Internal] - Fix broken CI due to not formatted js files

Reviewed By: ShikaSD

Differential Revision: D30515439

fbshipit-source-id: 560de04347a8746065981b534ed96f0956d94b9c
2021-08-24 11:14:46 -07:00
Xuan Huang ff4b33672a Add Flow libdefs for HermesInternalType
Summary:
Changelog: [Internal]

This diff add a flow libdefs for the `HermesInternalType` to type
`HermesInternal` as the first accurately typed `global` property,
and filled all the type holes.

Reviewed By: yungsters

Differential Revision: D29986749

fbshipit-source-id: a94be7919f989b5085f6b264e55145a85020fea9
2021-08-24 00:12:21 -07:00
Xuan Huang b931aa735f Add Flow libdefs for `global`
Summary:
Changelog: [Internal]

Currently, `global` is typed as `any` and any `global` properties
accesses are untyped. This diff add a flow libdefs for the `global`
object as a start point.

Reviewed By: yungsters

Differential Revision: D30000895

fbshipit-source-id: ab6988d01921a3c2a3434b534b2f69083570fb6d
2021-08-09 15:46:16 -07:00
Tim Yung 54e19a6b7f RN: Remove `fbjs` Dependency
Summary:
Removes `fbjs` dependency from `react-native` because it is no longer referenced.

Changelog:
[General][Changed] - Removed `fbjs` dependency from `react-native`.

Reviewed By: cpojer

Differential Revision: D23358201

fbshipit-source-id: 1945590d2e7ea853434c716a151fc1058718d471
2020-08-28 12:16:26 -07:00
Michael Bolin 0b9ea60b4f Back out "Upgrade Prettier from 1.17 to 2.0.2."
Differential Revision: D20639755

fbshipit-source-id: 5028563f9cf0527a30b4259daac50cdc03934bfd
2020-03-24 21:47:35 -07:00
Michael Bolin cf44650b3f Upgrade Prettier from 1.17 to 2.0.2.
Summary:
This gets us on the latest Prettier 2.x:
https://prettier.io/blog/2020/03/21/2.0.0.html

Notably, this adds support for TypeScript 3.8,
which introduces new syntax, such as `import type`.

Reviewed By: zertosh

Differential Revision: D20636268

fbshipit-source-id: fca5833d003804333a05ba16325bbbe0e06d6c8a
2020-03-24 20:24:47 -07:00
Eli White 57efe44759 Move flow definitions to react-native
Summary:
These definitions make these libraries act as flow strict. We have them internally but need them in react native to be able to make files in react native flow strict.

Internally our flowconfig includes all the configs in react-native-github.

Changelog:
[Internal]: Add flow strict type definitions for modules

Reviewed By: zackargyle

Differential Revision: D18839594

fbshipit-source-id: d523e15f00a9cfa66d3789bb249655bcbe6d04eb
2019-12-05 16:06:45 -08:00
George Zahariev 8553e1acc4 Exact-by-default codemod for react-native-github
Summary:
We are rolling out exact-by-default syntax to xplat/js.

I had to manually move around some comments to preserve proper placement.

Changelog: [Internal]

Reviewed By: jbrown215

Differential Revision: D18633611

fbshipit-source-id: 48f7468dcc55b1d00985419d035a61c6820b3abe
2019-11-21 09:42:57 -08:00
Jordan Brown 48cb80892d Manually fix places the codemod doesnt hit
Summary:
Generating this diff was difficult. We _will_ fix the issues with jscodeshift, but i don't want to block the syntax change on that.

To get this diff, I first codemodded all of xplat to use exact-by-default. Then i turned on implicit-inexact-object:error enforcement to get a list of errors showing places that violated the lint. With that, I used this to generate a list of `sed` commands to add `...`:

```
flow --json | jq '.errors | .[] | .message | .[] | .loc | {source, "line": .end."line", "column": .end."column"} | "\(.column),\(.line),\(.source)"' | sort -n -r | sed 's/"//g' | while read -r line; do echo $line; awk -F',' "{ print \"sed -i '\"\$2\"s/./...&/\"\$1\"' \" \$3 }"; done
```

Then I ran prettier, reverted generated files, and manually fixed up suppressions that got messed up.

Changelog: [Internal]

Reviewed By: gkz

Differential Revision: D18516431

fbshipit-source-id: 6cf940dce411fb179e7ebaff764bd5113a07989f
2019-11-19 13:38:18 -08:00
Yoga Setiawan d7c222a6a7 Update Broken Link #devcjog25 (#27025)
Summary:
Update broken link  https://github.com/facebook/react-native/blob/master/react-native-cli/CONTRIBUTING.md to https://github.com/facebook/react-native/blob/master/CONTRIBUTING.md
## Changelog
Pull Request resolved: https://github.com/facebook/react-native/pull/27025

Differential Revision: D18173631

Pulled By: cpojer

fbshipit-source-id: c3634c43c4de7e39e56ec31ef17b9f31db517128
2019-10-28 12:11:45 -07:00
Andres Suarez e1cfeaddd4 Move non-license comments out of license header
Summary: Changelog: [General] [Fixed] - License header cleanup

Reviewed By: cpojer

Differential Revision: D17749100

fbshipit-source-id: edca9c73a065e9fc311109cd6efeb1f75451a55a
2019-10-15 20:12:12 -07:00
Jan Kassens a494227d6c copy jest flow declaration from www
Summary:
Copies part of the changes to the flow declarations from www to get the stricter
definitions of `it.each`.

Reviewed By: jstejada

Differential Revision: D17857908

fbshipit-source-id: aafc8e3848d6291a9d527e334ab5d54c5ca635fd
2019-10-10 12:07:18 -07:00
Jan Kassens c13e5d0b43 fix jest's test.table flow type
Summary:
The current flow type disallows passing in an `Array<string>` since the current
type signature would allow just to append to the `Array`, `$ReadOnlyArray`
doesn't allow writing.

@public

Reviewed By: jstejada

Differential Revision: D16354977

fbshipit-source-id: a83c1227c1a15225487ac8672818d8b319dce32f
2019-07-18 09:38:47 -07:00
Florian Schoellhammer 2bf8c8bcd6 Unit Test 12 - Fix Storage Mock
Summary:
**Final Goal**
Currently unit test by default unmock everything and dependencies have to be explicitely mocked. The goal is to mock everything by default and whitelist (unmock) explicitely.

**This Diff**
Fixes the typing in the mock and add unit tests

Differential Revision: D16198318

fbshipit-source-id: d2bb71e9c940f4aeb48f8ac92bf3c5444ebc2025
2019-07-12 11:17:53 -07:00
Christoph Nakazawa 93b9ac74e5 Remove Map/Set from RN Open Source
Summary:
This is the same diff as D14786123 but with one of the buck targets fixed that only failed on continuous and didn't run during land time.

 This moves Map/Set to fb internal. We do not need them in open source any more but we still need this in some apps at FB that use an old version of JSC.

Reviewed By: rickhanlonii

Differential Revision: D15713305

fbshipit-source-id: caec43c76a6255b2af1693c13d8dea31d7d674f5
2019-06-07 06:39:28 -07:00
Felix Oghina 63bc4b4aac @build-break Back out "[RN] Remove Map/Set from RN Open Source"
Summary: Backing out D14786123 as it's causing failures on fbandroid/stable.

Differential Revision:
D15693250
Ninja: sheriff

fbshipit-source-id: 526054d4f0dab2a811f2328540e7418ece9810b1
2019-06-06 04:58:26 -07:00
Christoph Nakazawa 022470ce62 Remove Map/Set from RN Open Source
Summary: This moves Map/Set to fb internal. We do not need them in open source any more but we still need this in some apps at FB that use an old version of JSC.

Reviewed By: TheSavior

Differential Revision: D14786123

fbshipit-source-id: 1c49b47d547ad30f2d93c00b44382cf410100b67
2019-06-06 03:08:16 -07:00
Sam Goldman ab1a42762c Make RelayObservable Source return type disjoint
Summary:
In Flow v0.99 we are changing function type annotations to be strict about their
static properties. This causes a small issue with the union of a Subcription and
`() => mixed` function type, where the latter is now understood to possibly have
an `unsubscribe` property with a mixed type.

This causes the following refinement check, which appears lower in this file, to
cause an error in the next version of Flow:

```
if (cleanup) {
  if (cleanup.unsubscribe) {
    cleanup.unsubscribe(); // <-- error here
  }
  // ...
}
```

In Flow v0.99, because `() => mixed` statics are now checked, Flow sees that
`cleanup.unsubscribe` might be `mixed`, which passes the conditional but could
cause an exception when called.

I also needed to change JestMockFn to have exact statics, because tests
sometimes use a value with that type in place of the cleanup function. That runs
into the `{} <: {+p?: void}` rule, which is an error. `{||} <: {+p?:void}` is
not an error.

Reviewed By: josephsavona

Differential Revision: D15522655

fbshipit-source-id: 2ae3c9016e2b07abaac79827082d2f8743623eb5
2019-05-28 12:13:49 -07:00
Chad Smith e293f8e01f add getEnv to jest's type definition
Reviewed By: AGS-

Differential Revision: D14858004

fbshipit-source-id: 38ef0283f5605f6a13d179d8c68dd26c63adb910
2019-04-09 14:56:01 -07:00
Nicolas Charpentier 5d06c7495d Replace our local types by flow-typed (#20320)
Summary:
These comments were confusing since we don't use flow-typed.

cc bvaughn.

I have replaced our local types by flow-typed, removed metro custom stub and deleted `flow-github` directory.

As result, createReactClass, PropTypes and Metro types won't be distributed to RN users. If you need it, you should relay on flow-typed.
Pull Request resolved: https://github.com/facebook/react-native/pull/20320

Reviewed By: TheSavior

Differential Revision: D13517157

Pulled By: rickhanlonii

fbshipit-source-id: e52c0b6114114a706f6152b2031c600e3dece0d2
2018-12-20 04:42:34 -08:00
Christoph Nakazawa 4148976a83 Use `invariant` instead of `fbjs/lib/invariant`
Summary: This is one more step to remove `fbjs` from `react-native-github`. This changes both the internal and external code to use `invariant` from zertosh instead of the copy in fbjs.

Reviewed By: yungsters

Differential Revision: D13195941

fbshipit-source-id: 73564ca1715110e7da9c7ef56dc57374d61377e0
2018-12-03 00:07:02 -08:00
empyrical 2da60a8f45 Prettify remaining unprettified files (#21327)
Summary:
This PR is the result of running `yarn prettify` on the codebase - which caught a few files that were not prettified. This will make instructing people to run prettify a bit less complicated, since unrelated files will not show up in diffs.
Pull Request resolved: https://github.com/facebook/react-native/pull/21327

Differential Revision: D10046057

Pulled By: TheSavior

fbshipit-source-id: 2c771a3c758c72816c707e32ee2f4587e466f277
2018-09-25 19:50:08 -07:00
Héctor Ramos 1151c096da Update copyright headers to yearless format
Summary: This change drops the year from the copyright headers and the LICENSE file.

Reviewed By: yungsters

Differential Revision: D9727774

fbshipit-source-id: df4fc1e4390733fe774b1a160dd41b4a3d83302a
2018-09-11 15:33:07 -07:00
Spencer Ahrens 09e6e6c329 Update jest flow type to latest v23
Summary: Copied https://raw.githubusercontent.com/flow-typed/flow-typed/master/definitions/npm/jest_v23.x.x/flow_v0.39.x-/jest_v23.x.x.js

Reviewed By: yungsters

Differential Revision: D9762910

fbshipit-source-id: 626c456ea51ca636194a56f6b0878b66b7fb3842
2018-09-11 11:16:59 -07:00
Tim Yung 5023b105e4 JS: Switch to `nullthrows` Package [1/4]
Summary:
Switches to the `nullthrows` package instead of using `fbjs/lib/nullthrows`.

The version of `nullthrows` in `fbjs` is outdated and already missing features that exist in the standalone `nullthrows` package.

Also, this mitigates the inevitable collision between `nullthrows` (as a Haste module) and `nullthrows` (as a `node_modules` dependency).

Reviewed By: zertosh

Differential Revision: D9733178

fbshipit-source-id: 1b589d48c1ed57cebf2088b796ad72e212534c0a
2018-09-10 01:46:48 -07:00
Wayne Cheng 86f8e9e760 Adding flow strict to as many xplat files as possible
Summary:
ag -L --ignore __snapshots__ 'flow strict$|noflow|generated|The controller you requested could not be found.' | ag '\.js$' | xargs ag -l 'flow' | sort > ~/temp
  cat ~/temp | xargs ag -L 'flow strict' | xargs sed -i '' 's/flow$/flow strict/'
  cat ~/temp | xargs ag -L 'flow strict$' | xargs sed -i '' 's/flow strict-local$/flow strict/'
  until flow; do flow check --json | jq -r '.errors[].message[0].path' | sort | uniq | xargs hg revert; done

allow_many_files
The controller you requested could not be found.
The controller you requested could not be found.

Reviewed By: yungsters

Differential Revision: D9003523

fbshipit-source-id: d0c9fbfe3c32e65d57819fa040d06cd6ebbd59cc
2018-07-27 12:31:42 -07:00
Tim Yung f8b4850425 Jest: Upgrade Flow Definition in RN + Metro
Reviewed By: sahrens

Differential Revision: D8371076

fbshipit-source-id: 12d03c545ca190a5fda1ff319e5ea906173d2241
2018-06-11 17:49:25 -07:00
Eli White 4aeefa5484 Open source Flow definition for Jest
Reviewed By: sahrens

Differential Revision: D8347198

fbshipit-source-id: 0b6194bfd14bad09db7dcd462f0bf342c9c6fe44
2018-06-10 22:38:39 -07:00
Eli White 053c7b2a84 Adding a Stringish type
Reviewed By: yungsters

Differential Revision: D7984925

fbshipit-source-id: b58bff2fa172f8127d70986accb45af1afca4d68
2018-05-13 02:01:05 -07:00
Eli White 36fcbaa56d Prettier the rest of ReactNative
Reviewed By: yungsters

Differential Revision: D7974340

fbshipit-source-id: 5fe457a8a9be4bd360fc3af9acb5c1136b2be0d7
2018-05-11 13:52:30 -07:00
Eli White 86b6f5d39e Add Prettier to some files
Reviewed By: sahrens

Differential Revision: D7958196

fbshipit-source-id: 05a04380a4a1f3abd4cc3a9034fc70deaa4a444b
2018-05-10 16:16:35 -07:00
Sophie Alpert 1490ab12ef Update license headers for MIT license
Summary:
Includes React Native and its dependencies Fresco, Metro, and Yoga. Excludes samples/examples/docs.

find: ^(?:( *)|( *(?:[\*~#]|::))( )? *)?Copyright (?:\(c\) )?(\d{4})\b.+Facebook[\s\S]+?BSD[\s\S]+?(?:this source tree|the same directory)\.$
replace: $1$2$3Copyright (c) $4-present, Facebook, Inc.\n$2\n$1$2$3This source code is licensed under the MIT license found in the\n$1$2$3LICENSE file in the root directory of this source tree.

Reviewed By: TheSavior, yungsters

Differential Revision: D7007050

fbshipit-source-id: 37dd6bf0ffec0923bfc99c260bb330683f35553e
2018-02-16 18:31:53 -08:00
Sam Goldman 632f1202ab Switch `declare function exports` to `declare module.exports`
Reviewed By: calebmer

Differential Revision: D6579552

fbshipit-source-id: a46f27cca8065e9f3c46739f6a874dfb346c0c7d
2017-12-18 17:25:08 -08:00
Sam Goldman 5f8d8e90c2 Switch to `declare module.exports` syntax
Reviewed By: gabelevi

Differential Revision: D6571796

fbshipit-source-id: 6a6d98b05953f40b825a260f44765689e91269a8
2017-12-14 16:31:14 -08:00
Uts Sikder dd2fc4022e remove unnecessary and error inducing method from Map flow type
Reviewed By: mroch

Differential Revision: D6198877

fbshipit-source-id: 77a058072f439339a92fa07702a0429c4ca3282f
2017-11-01 16:32:19 -07:00
Jimmy Mayoukou 4eccb16935 Add finally method to Promise flow definition
Summary:
The `finally` method definition was missing, while it really exists causing a flow error when using it.

Added the method definition and make sure flow doesn't throw any error anymore on a real-life example.
Closes https://github.com/facebook/react-native/pull/16115

Differential Revision: D6017950

Pulled By: shergin

fbshipit-source-id: 296f3467152eb6eedac817a89cf075e9f906a389
2017-10-09 22:02:09 -07:00
Caleb Meredith 292b19d339 Update typings for Promise.all() for D5827319
Reviewed By: samwgoldman

Differential Revision: D5830645

fbshipit-source-id: db2bb0715aab58d3601712ee0b080abaa9f8f131
2017-09-26 11:38:31 -07:00
Caleb Meredith 90eaeb019b Upgrade fbsource/xplat/js to Flow v0.53.0
Reviewed By: avikchaudhuri

Differential Revision:
D5648819
Ninja: T20988071

fbshipit-source-id: 66e5b6747c79ae66b6eb69d40ede5e982c26174f
2017-08-17 18:45:01 -07:00