Skip to content
This repository has been archived by the owner on Jan 1, 2025. It is now read-only.

Commit

Permalink
Merge branch 'main' into update-package
Browse files Browse the repository at this point in the history
  • Loading branch information
0ldh authored Dec 9, 2024
2 parents 6aa5e95 + c1b97f3 commit 6ee3c17
Show file tree
Hide file tree
Showing 52 changed files with 123 additions and 490 deletions.
9 changes: 1 addition & 8 deletions .flowconfig
Original file line number Diff line number Diff line change
Expand Up @@ -39,13 +39,6 @@ module.name_mapper='relay-test-utils' -> '<PROJECT_ROOT>/node_modules/relay-test
exact_by_default=true
babel_loose_array_spread=true
enums=true
exact_empty_objects=true

inference_mode=constrain_writes

experimental.enforce_local_inference_annotations=true
experimental.enforce_this_annotations=true
experimental.enforce_class_annotations=true

[strict]
deprecated-type
Expand All @@ -59,4 +52,4 @@ untyped-type-import
all=warn

[version]
^0.185.2
^0.207.0
2 changes: 1 addition & 1 deletion .github/workflows/nodejs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:

strategy:
matrix:
node-version: [14.x, 16.x]
node-version: [16.x, 18.x]
os: [ubuntu-latest, windows-latest, macOS-latest]
react: ['17.0.2', '18.1.0']

Expand Down
6 changes: 3 additions & 3 deletions flow-typed/jest.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* LICENSE file in the root directory of this source tree.
*/

type JestMockFn<TArguments: $ReadOnlyArray<*>, TReturn> = {
type JestMockFn<TArguments: $ReadOnlyArray<any>, TReturn> = {
(...args: TArguments): TReturn,
/**
* An object for introspecting mock calls
Expand Down Expand Up @@ -620,7 +620,7 @@ interface JestExpectType {
* Use .toBeInstanceOf(Class) to check that an object is an instance of a
* class.
*/
toBeInstanceOf(cls: Class<*>): void;
toBeInstanceOf(cls: Class<any>): void;
/**
* .toBeNull() is the same as .toBe(null) but the error messages are a bit
* nicer.
Expand Down Expand Up @@ -811,7 +811,7 @@ type JestObjectType = {
* Returns a new, unused mock function. Optionally takes a mock
* implementation.
*/
fn<TArguments: $ReadOnlyArray<*>, TReturn>(
fn<TArguments: $ReadOnlyArray<any>, TReturn>(
implementation?: (...args: TArguments) => TReturn
): JestMockFn<TArguments, TReturn>,
/**
Expand Down
48 changes: 36 additions & 12 deletions flow-typed/npm/jest_v26.x.x.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// flow-typed signature: 9a1f9054d272cf6383233b8bfb639f84
// flow-typed version: 4efeddffd8/jest_v26.x.x/flow_>=v0.104.x
// flow-typed signature: 681725d1525989df4ff4c352015f5c2b
// flow-typed version: 9a968c602c/jest_v26.x.x/flow_>=v0.201.x

type JestMockFn<TArguments: $ReadOnlyArray<*>, TReturn> = {
type JestMockFn<TArguments: $ReadOnlyArray<any>, TReturn> = {
(...args: TArguments): TReturn,
/**
* An object for introspecting mock calls
Expand Down Expand Up @@ -259,6 +259,9 @@ type DomTestingLibraryType = {
// 5.x
toHaveDisplayValue(value: string | string[]): void,
toBeChecked(): void,
toBeEmptyDOMElement(): void,
toBePartiallyChecked(): void,
toHaveDescription(text: string | RegExp): void,
...
};

Expand Down Expand Up @@ -624,7 +627,7 @@ interface JestExpectType {
* Use .toBeInstanceOf(Class) to check that an object is an instance of a
* class.
*/
toBeInstanceOf(cls: Class<*>): void;
toBeInstanceOf(cls: Class<any>): void;
/**
* .toBeNull() is the same as .toBe(null) but the error messages are a bit
* nicer.
Expand Down Expand Up @@ -801,6 +804,14 @@ type JestObjectType = {
* Returns the number of fake timers still left to run.
*/
getTimerCount(): number,
/**
* Set the current system time used by fake timers.
* Simulates a user changing the system clock while your program is running.
* It affects the current time but it does not in itself cause
* e.g. timers to fire; they will fire exactly as they would have done
* without the call to jest.setSystemTime().
*/
setSystemTime(now?: number | Date): void,
/**
* The same as `mock` but not moved to the top of the expectation by
* babel-jest.
Expand All @@ -815,18 +826,22 @@ type JestObjectType = {
* Returns a new, unused mock function. Optionally takes a mock
* implementation.
*/
fn<TArguments: $ReadOnlyArray<*>, TReturn>(
fn<TArguments: $ReadOnlyArray<any>, TReturn>(
implementation?: (...args: TArguments) => TReturn,
): JestMockFn<TArguments, TReturn>,
/**
* Determines if the given function is a mocked function.
*/
isMockFunction(fn: Function): boolean,
/**
* Alias of `createMockFromModule`.
*/
genMockFromModule(moduleName: string): any,
/**
* Given the name of a module, use the automatic mocking system to generate a
* mocked version of the module for you.
*/
genMockFromModule(moduleName: string): any,
createMockFromModule(moduleName: string): any,
/**
* Mocks a module with an auto-mocked version when it is being required.
*
Expand All @@ -845,7 +860,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<T>(m: $Flow$ModuleRef<T> | string): T,
/**
* Returns a mock module instead of the actual module, bypassing all checks
* on whether the module should be required normally or not.
Expand Down Expand Up @@ -1032,11 +1047,20 @@ declare var it: {
* @param {Function} Test
* @param {number} Timeout for the test, in milliseconds.
*/
skip(
name: JestTestName,
fn?: (done: JestDoneFn) => ?Promise<mixed>,
timeout?: number,
): void,
skip: {|
(
name: JestTestName,
fn?: (done: JestDoneFn) => ?Promise<mixed>,
timeout?: number,
): void,
each(
...table: Array<Array<mixed> | mixed> | [Array<string>, string]
): (
name: JestTestName,
fn?: (...args: Array<any>) => ?Promise<mixed>,
timeout?: number,
) => void,
|},
/**
* Highlight planned tests in the summary output
*
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@
"eslint-plugin-relay": "^1.8.3",
"eslint-plugin-rulesdir": "^0.2.0",
"eslint-plugin-unused-imports": "^2.0.0",
"flow-bin": "^0.185.2",
"flow-bin": "0.207.0",
"flow-copy-source": "^2.0.9",
"flow-interfaces-chrome": "^0.6.0",
"flow-typed": "^3.7.0",
Expand Down
10 changes: 4 additions & 6 deletions packages-ext/recoil-devtools/src/pages/Popup/Items/ItemLabel.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@
* @format
* @oncall recoil
*/

'use strict';

import type {Node} from '../../../types/DevtoolsTypes';

const {getStyle} = require('../../../utils/getStyle');
Expand All @@ -30,13 +32,9 @@ type KeyProps = {
isRoot?: boolean,
};

function ItemLabel({
name,
node,
isRoot = false,
}: KeyProps): React$Element<'span'> {
function ItemLabel({name, node, isRoot = false}: KeyProps): React$MixedElement {
return (
<span style={getStyle(styles, {label: true, isRoot: isRoot})}>
<span style={getStyle(styles, {label: true, isRoot})}>
<NodeName name={name} node={node} />:
</span>
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
* @format
* @oncall recoil
*/

'use strict';

import type {Node} from '../../../types/DevtoolsTypes';
Expand Down Expand Up @@ -35,10 +36,7 @@ type KeyProps = {
node: ?Node,
};

export default function NodeName({
name,
node,
}: KeyProps): React$Element<'span'> {
export default function NodeName({name, node}: KeyProps): React$MixedElement {
return (
<span style={styles.label}>
{node?.type === 'selector' && (
Expand Down
4 changes: 3 additions & 1 deletion packages/recoil-relay/RecoilRelay_graphQLMutationEffect.js
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ function graphQLMutationEffect<
const mutationID = ++currentMutationID;
const mutationVariables = variables(newValue);
if (mutationVariables != null) {
commitMutation<$FlowFixMe>(environment, {
commitMutation(environment, {
mutation,
variables: mutationVariables,
onError: error => {
Expand All @@ -100,6 +100,8 @@ function graphQLMutationEffect<
},
updater,
optimisticUpdater,
/* $FlowFixMe[incompatible-call] error exposed when improving flow
* typing of commitMutation */
optimisticResponse: optimisticResponse?.(newValue),
uploadables,
});
Expand Down
1 change: 0 additions & 1 deletion packages/recoil-relay/RecoilRelay_graphQLSelectorFamily.js
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,6 @@ function graphQLSelectorFamily<
variables: vars,
// $FlowIssue[incompatible-call] Type is opaque, no way to refine
subscription: query,
// $FlowFixMe[missing-local-annot]
mapResponse: response => ({source: 'remote', response}),
}),
mutations &&
Expand Down
1 change: 0 additions & 1 deletion packages/recoil-sync/RecoilSync.js
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,6 @@ function readAtomItems<T>(
: readFromStorageRequired(itemKey);

if (RecoilLoadable.isLoadable(value)) {
// $FlowIssue[incompatible-type]
const loadable: Loadable<mixed> = value;
if (loadable.state === 'hasError') {
throw loadable.contents;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,6 @@ testRecoil('Many items to one atom', async () => {
return;
}
for (const key of Object.keys(newValue)) {
// $FlowFixMe[prop-missing]
write(key, newValue[key]);
}
},
Expand Down
3 changes: 1 addition & 2 deletions packages/recoil/adt/Recoil_Loadable.js
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,6 @@ class LoadingLoadable<T> extends BaseLoadable<T> {
return nextLoadable.contents;
}
}
// $FlowIssue[incompatible-return]
return next;
})
// $FlowFixMe[incompatible-call]
Expand Down Expand Up @@ -274,9 +273,9 @@ function loadableAll<
output
: // Object.getOwnPropertyNames() has consistent key ordering with ES6
// $FlowIssue[incompatible-call]
// $FlowFixMe[incompatible-return] Pre-supress errors for Flow 0.207.0
output.map(outputs =>
Object.getOwnPropertyNames(inputs).reduce(
// $FlowFixMe[invalid-computed-prop]
(out, key, idx) => ({...out, [key]: outputs[idx]}),
{},
),
Expand Down
36 changes: 1 addition & 35 deletions packages/recoil/core/Recoil_ReactMode.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,23 +15,6 @@ const React = require('react');
const gkx = require('recoil-shared/util/Recoil_gkx');
const recoverableViolation = require('recoil-shared/util/Recoil_recoverableViolation');

export opaque type MutableSource = {};

const createMutableSource: <StoreState, Version>(
{current: StoreState},
() => Version,
) => MutableSource =
// flowlint-next-line unclear-type:off
(React: any).createMutableSource ?? (React: any).unstable_createMutableSource;

const useMutableSource: <StoreState, T>(
MutableSource,
() => T,
(StoreState, () => void) => () => void,
) => T =
// flowlint-next-line unclear-type:off
(React: any).useMutableSource ?? (React: any).unstable_useMutableSource;

// https://github.com/reactwg/react-18/discussions/86
const useSyncExternalStore: <T>(
subscribe: (() => void) => () => void,
Expand Down Expand Up @@ -73,11 +56,7 @@ function currentRendererSupportsUseSyncExternalStore(): boolean {
return isUseSyncExternalStoreSupported;
}

type ReactMode =
| 'TRANSITION_SUPPORT'
| 'SYNC_EXTERNAL_STORE'
| 'MUTABLE_SOURCE'
| 'LEGACY';
type ReactMode = 'TRANSITION_SUPPORT' | 'SYNC_EXTERNAL_STORE' | 'LEGACY';

/**
* mode: The React API and approach to use for syncing state with React
Expand All @@ -98,17 +77,6 @@ function reactMode(): {mode: ReactMode, early: boolean, concurrent: boolean} {
return {mode: 'SYNC_EXTERNAL_STORE', early: true, concurrent: false};
}

if (
gkx('recoil_mutable_source') &&
useMutableSource != null &&
typeof window !== 'undefined' &&
!window.$disableRecoilValueMutableSource_TEMP_HACK_DO_NOT_USE
) {
return gkx('recoil_suppress_rerender_in_callback')
? {mode: 'MUTABLE_SOURCE', early: true, concurrent: true}
: {mode: 'MUTABLE_SOURCE', early: false, concurrent: false};
}

return gkx('recoil_suppress_rerender_in_callback')
? {mode: 'LEGACY', early: true, concurrent: false}
: {mode: 'LEGACY', early: false, concurrent: false};
Expand All @@ -122,8 +90,6 @@ function isFastRefreshEnabled(): boolean {
}

module.exports = {
createMutableSource,
useMutableSource,
useSyncExternalStore,
currentRendererSupportsUseSyncExternalStore,
reactMode,
Expand Down
Loading

0 comments on commit 6ee3c17

Please sign in to comment.