Flow upgrade to 0.205.1 (#26796)

Just a small upgrade to keep us current and remove unused suppressions
(probably fixed by some upgrade since).

- `*` is no longer allowed and has been an alias for `any` for a while
now.
This commit is contained in:
Jan Kassens 2023-05-09 10:45:50 -04:00 committed by GitHub
parent 7ac5e9a602
commit fda1f0b902
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
21 changed files with 38 additions and 46 deletions

View File

@ -65,8 +65,8 @@
"eslint-plugin-react-internal": "link:./scripts/eslint-rules",
"fbjs-scripts": "^3.0.1",
"filesize": "^6.0.1",
"flow-bin": "^0.202.0",
"flow-remove-types": "^2.202.0",
"flow-bin": "^0.205.1",
"flow-remove-types": "^2.205.1",
"glob": "^7.1.6",
"glob-stream": "^6.1.0",
"google-closure-compiler": "^20230206.0.0",

View File

@ -291,7 +291,6 @@ export function processReply(
// Possibly a Date, whose toJSON automatically calls toISOString
// $FlowFixMe[incompatible-use]
const originalValue = parent[key];
// $FlowFixMe[method-unbinding]
if (originalValue instanceof Date) {
return serializeDateFromDateJSON(value);
}

View File

@ -167,7 +167,6 @@ function onDisconnected() {
disconnectedCallback();
}
// $FlowFixMe[missing-local-annot]
function onError({code, message}: $FlowFixMe) {
safeUnmount();

View File

@ -11,7 +11,7 @@
/* eslint-disable no-unused-vars */
type JestMockFn<TArguments: $ReadOnlyArray<*>, TReturn> = {
type JestMockFn<TArguments: $ReadOnlyArray<any>, TReturn> = {
(...args: TArguments): TReturn,
/**
* An object for introspecting mock calls
@ -626,7 +626,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.
@ -815,7 +815,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>,
/**

View File

@ -16,7 +16,6 @@ import {COMPACT_VERSION_NAME} from './utils';
let welcomeHasInitialized = false;
// $FlowFixMe[missing-local-annot]
function welcome(event: $FlowFixMe) {
if (
event.source !== window ||

View File

@ -244,7 +244,6 @@ export function attach(
parentIDStack.pop();
return result;
} catch (err) {
// $FlowFixMe[incompatible-type] found when upgrading Flow
parentIDStack = [];
throw err;
} finally {
@ -281,7 +280,6 @@ export function attach(
parentIDStack.pop();
return result;
} catch (err) {
// $FlowFixMe[incompatible-type] found when upgrading Flow
parentIDStack = [];
throw err;
} finally {
@ -318,7 +316,6 @@ export function attach(
parentIDStack.pop();
return result;
} catch (err) {
// $FlowFixMe[incompatible-type] found when upgrading Flow
parentIDStack = [];
throw err;
} finally {
@ -350,7 +347,6 @@ export function attach(
return result;
} catch (err) {
// $FlowFixMe[incompatible-type] found when upgrading Flow
parentIDStack = [];
throw err;
} finally {

View File

@ -54,7 +54,10 @@ let supportsUserTiming =
let supportsUserTimingV3 = false;
if (supportsUserTiming) {
const CHECK_V3_MARK = '__v3';
const markOptions = ({}: {startTime?: number});
const markOptions: {
detail?: mixed,
startTime?: number,
} = {};
Object.defineProperty(markOptions, 'startTime', {
get: function () {
supportsUserTimingV3 = true;
@ -64,7 +67,6 @@ if (supportsUserTiming) {
});
try {
// $FlowFixMe[extra-arg]: Flow expects the User Timing level 2 API.
performance.mark(CHECK_V3_MARK, markOptions);
} catch (error) {
// Ignore

View File

@ -45,7 +45,6 @@ const resource: Resource<
(element: Element) => {
const request = inProgressRequests.get(element);
if (request != null) {
// $FlowFixMe[incompatible-call] found when upgrading Flow
return request.promise;
}

View File

@ -472,7 +472,6 @@ function addTrappedEventListener(
if (enableLegacyFBSupport && isDeferredListenerForLegacyFBSupport) {
const originalListener = listener;
// $FlowFixMe[missing-this-annot]
// $FlowFixMe[definition-cycle]
listener = function (...p) {
removeEventListener(
targetContainer,

View File

@ -46,7 +46,6 @@ if (document.body != null) {
}
});
// documentElement must already exist at this point
// $FlowFixMe[incompatible-call]
domBodyObserver.observe(document.documentElement, {childList: true});
}

View File

@ -13,6 +13,7 @@ import {dispatchEvent} from './ReactFabricEventEmitter';
import {
DefaultEventPriority,
DiscreteEventPriority,
type EventPriority,
} from 'react-reconciler/src/ReactEventPriorities';
import {HostText} from 'react-reconciler/src/ReactWorkTags';
@ -317,7 +318,7 @@ export function shouldSetTextContent(type: string, props: Props): boolean {
return false;
}
export function getCurrentEventPriority(): * {
export function getCurrentEventPriority(): EventPriority {
const currentEventPriority = fabricGetCurrentEventPriority
? fabricGetCurrentEventPriority()
: null;

View File

@ -24,7 +24,10 @@ import {
} from './ReactNativeComponentTree';
import ReactNativeFiberHostComponent from './ReactNativeFiberHostComponent';
import {DefaultEventPriority} from 'react-reconciler/src/ReactEventPriorities';
import {
DefaultEventPriority,
type EventPriority,
} from 'react-reconciler/src/ReactEventPriorities';
const {get: getViewConfigForType} = ReactNativeViewConfigRegistry;
@ -217,9 +220,10 @@ export function getChildHostContext(
}
}
export function getPublicInstance(instance: Instance): * {
export function getPublicInstance(instance: Instance): PublicInstance {
// $FlowExpectedError[prop-missing] For compatibility with Fabric
if (instance.canonical != null && instance.canonical.publicInstance != null) {
// $FlowFixMe[incompatible-return]
return instance.canonical.publicInstance;
}
@ -262,7 +266,7 @@ export function shouldSetTextContent(type: string, props: Props): boolean {
return false;
}
export function getCurrentEventPriority(): * {
export function getCurrentEventPriority(): EventPriority {
return DefaultEventPriority;
}

View File

@ -657,7 +657,6 @@ export function createSignatureFunctionForTransform(): <T>(
// in HOC chains like _s(hoc1(_s(hoc2(_s(actualFunction))))).
if (!savedType) {
// We're in the innermost call, so this is the actual type.
// $FlowFixMe[escaped-generic] discovered when updating Flow
savedType = type;
hasCustomHooks = typeof getCustomHooks === 'function';
}

View File

@ -270,7 +270,6 @@ module.exports = function register() {
$$id: {value: moduleId},
$$async: {value: false},
});
// $FlowFixMe[incompatible-call] found when upgrading Flow
this.exports = new Proxy(clientReference, proxyHandlers);
}

View File

@ -946,7 +946,6 @@ export function resolveModelToJSON(
// Possibly a Date, whose toJSON automatically calls toISOString
// $FlowFixMe[incompatible-use]
const originalValue = parent[key];
// $FlowFixMe[method-unbinding]
if (originalValue instanceof Date) {
return serializeDateFromDateJSON(value);
}

View File

@ -8,7 +8,10 @@
*/
import isArray from 'shared/isArray';
import {DefaultEventPriority} from 'react-reconciler/src/ReactEventPriorities';
import {
DefaultEventPriority,
type EventPriority,
} from 'react-reconciler/src/ReactEventPriorities';
export type Type = string;
export type Props = Object;
@ -211,7 +214,7 @@ export function createTextInstance(
};
}
export function getCurrentEventPriority(): * {
export function getCurrentEventPriority(): EventPriority {
return DefaultEventPriority;
}
export function shouldAttemptEagerTransition(): boolean {

View File

@ -224,7 +224,6 @@ export function useCacheRefresh(): <T>(?() => T, ?T) => void {
export function use<T>(usable: Usable<T>): T {
const dispatcher = resolveDispatcher();
// $FlowFixMe[not-a-function] This is unstable, thus optional
return dispatcher.use(usable);
}

View File

@ -164,7 +164,6 @@ export function describeObjectForErrorMessage(
if (typeof value === 'string') {
substr = value;
} else if (typeof value === 'object' && value !== null) {
// $FlowFixMe[incompatible-call] found when upgrading Flow
substr = '{' + describeObjectForErrorMessage(value) + '}';
} else {
substr = '{' + describeValueForErrorMessage(value) + '}';
@ -191,7 +190,6 @@ export function describeObjectForErrorMessage(
const value = array[i];
let substr;
if (typeof value === 'object' && value !== null) {
// $FlowFixMe[incompatible-call] found when upgrading Flow
substr = describeObjectForErrorMessage(value);
} else {
substr = describeValueForErrorMessage(value);
@ -228,7 +226,6 @@ export function describeObjectForErrorMessage(
typeof value === 'object' &&
value !== null
) {
// $FlowFixMe[incompatible-call] found when upgrading Flow
substr = describeObjectForErrorMessage(value);
} else {
substr = describeValueForErrorMessage(value);
@ -261,7 +258,6 @@ export function describeObjectForErrorMessage(
const value = object[name];
let substr;
if (typeof value === 'object' && value !== null) {
// $FlowFixMe[incompatible-call] found when upgrading Flow
substr = describeObjectForErrorMessage(value);
} else {
substr = describeValueForErrorMessage(value);

View File

@ -41,6 +41,7 @@ function shallowEqual(objA: mixed, objB: mixed): boolean {
const currentKey = keysA[i];
if (
!hasOwnProperty.call(objB, currentKey) ||
// $FlowFixMe[incompatible-use] lost refinement of `objB`
!is(objA[currentKey], objB[currentKey])
) {
return false;

View File

@ -32,10 +32,9 @@ untyped-type-import=error
[options]
%CI_MAX_WORKERS%
munge_underscores=false
inference_mode=lti
# Substituted by createFlowConfig.js:
%REACT_RENDERER_FLOW_OPTIONS%
[version]
^0.202.0
^0.205.1

View File

@ -8050,22 +8050,22 @@ flatted@^3.1.0:
resolved "https://registry.yarnpkg.com/flatted/-/flatted-3.2.7.tgz#609f39207cb614b89d0765b477cb2d437fbf9787"
integrity sha512-5nqDSxl8nn5BSNxyR3n4I6eDmbolI6WT+QqR547RwxQapgjQBmtktdP+HTBb/a/zLsbzERTONyUB5pefh5TtjQ==
flow-bin@^0.202.0:
version "0.202.0"
resolved "https://registry.yarnpkg.com/flow-bin/-/flow-bin-0.202.0.tgz#1e2eb221252c2ab55c997e5eb921902f3181cc4e"
integrity sha512-Yz+yNapJMWWV6Z6pZnBR+naMhFbFJbmMS8ZBQCFUHRqN1TTw7uwitYxRj8DyzLyTpcPReSAjWbWawWPsXJot3w==
flow-bin@^0.205.1:
version "0.205.1"
resolved "https://registry.yarnpkg.com/flow-bin/-/flow-bin-0.205.1.tgz#5faf24e60df8d36f4deafef20e44863c5b295315"
integrity sha512-pGQ/ZFr9hnbhRmc+K3K1Ui9BwDivlesNEd2mZbm5pCnxEUvbbj9nXHlTD4s4qO0k+LBKYLMZzQwBVYyRUE380g==
flow-parser@^0.202.0:
version "0.202.0"
resolved "https://registry.yarnpkg.com/flow-parser/-/flow-parser-0.202.0.tgz#534178266d3ceec5368415e59990db97eece5bd0"
integrity sha512-ZiXxSIXK3zPmY3zrzCofFonM2T+/3Jz5QZKJyPVtUERQEJUnYkXBQ+0H3FzyqiyJs+VXqb/UNU6/K6sziVYdxw==
flow-parser@^0.205.1:
version "0.205.1"
resolved "https://registry.yarnpkg.com/flow-parser/-/flow-parser-0.205.1.tgz#337464aaf027b00b2514610386cf21a5f7c94137"
integrity sha512-+RF/e1Et6ZX2I/UG7SGAz3Z8+ulj9xKYLu5AD7Wi8H2llzncU8ZpdKfLR50pPvj4g2a/FbZWkXYL7qHc+zXJNA==
flow-remove-types@^2.202.0:
version "2.202.0"
resolved "https://registry.yarnpkg.com/flow-remove-types/-/flow-remove-types-2.202.0.tgz#0718ce34169148b5e61d25658f531e4236d00a62"
integrity sha512-G6shwCpTpZWSU0HtRLmE+S6zyD1otzKXo5D0jZ92OpfNHgSYIohfUSM+njYK8d2O841AIhq8H0mMYWgc/j5ySw==
flow-remove-types@^2.205.1:
version "2.205.1"
resolved "https://registry.yarnpkg.com/flow-remove-types/-/flow-remove-types-2.205.1.tgz#76ff3ab6386e6bb9eb7eb170ce7688931a9b7e5e"
integrity sha512-HExM8nCVx9dpNAAe7zKH45Ii+FL6ufoQAGntMdvfCtYjhTVSkaO3MfHp/r0D8qNeAwcvGBfw7+GqQtgXm/zr2g==
dependencies:
flow-parser "^0.202.0"
flow-parser "^0.205.1"
pirates "^3.0.2"
vlq "^0.2.1"