mirror of
https://github.com/facebook/react.git
synced 2025-11-01 09:12:30 +00:00
[flow] enable enforce_local_inference_annotations (#25921)
This setting is an incremental path to the next Flow version enforcing type annotations on most functions (except some inline callbacks). Used ``` node_modules/.bin/flow codemod annotate-functions-and-classes --write . ``` to add a majority of the types with some hand cleanup when for large inferred objects that should just be `Fiber` or weird constructs including `any`. Suppressed the remaining issues. Builds on #25918
This commit is contained in:
@@ -10,19 +10,19 @@
|
||||
import * as React from 'react';
|
||||
import {Fragment} from 'react';
|
||||
|
||||
function wrapWithHoc(Component, index) {
|
||||
function wrapWithHoc(Component: () => any, index: number) {
|
||||
function HOC() {
|
||||
return <Component />;
|
||||
}
|
||||
|
||||
const displayName = Component.displayName || Component.name;
|
||||
const displayName = (Component: any).displayName || Component.name;
|
||||
|
||||
// $FlowFixMe[incompatible-type] found when upgrading Flow
|
||||
HOC.displayName = `withHoc${index}(${displayName})`;
|
||||
return HOC;
|
||||
}
|
||||
|
||||
function wrapWithNested(Component, times) {
|
||||
function wrapWithNested(Component: () => any, times: number) {
|
||||
for (let i = 0; i < times; i++) {
|
||||
Component = wrapWithHoc(Component, i);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user