Skip to content

Commit 346c7d4

Browse files
authored
straightford explicit types (#25253)
1 parent aca7f30 commit 346c7d4

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

52 files changed

+175
-139
lines changed

packages/react-debug-tools/src/ReactDebugHooks.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -783,7 +783,7 @@ export function inspectHooksOfFiber(
783783
fiber: Fiber,
784784
currentDispatcher: ?CurrentDispatcherRef,
785785
includeHooksSource?: boolean = false,
786-
) {
786+
): HooksTree {
787787
// DevTools will pass the current renderer's injected dispatcher.
788788
// Other apps might compile debug hooks as part of their app though.
789789
if (currentDispatcher == null) {

packages/react-dom/src/client/ReactDOMHostConfig.js

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -680,7 +680,7 @@ export function clearContainer(container: Container): void {
680680

681681
export const supportsHydration = true;
682682

683-
export function isHydratableResource(type: string, props: Props) {
683+
export function isHydratableResource(type: string, props: Props): boolean {
684684
return (
685685
type === 'link' &&
686686
typeof (props: any).precedence === 'string' &&
@@ -726,11 +726,13 @@ export function canHydrateSuspenseInstance(
726726
return ((instance: any): SuspenseInstance);
727727
}
728728

729-
export function isSuspenseInstancePending(instance: SuspenseInstance) {
729+
export function isSuspenseInstancePending(instance: SuspenseInstance): boolean {
730730
return instance.data === SUSPENSE_PENDING_START_DATA;
731731
}
732732

733-
export function isSuspenseInstanceFallback(instance: SuspenseInstance) {
733+
export function isSuspenseInstanceFallback(
734+
instance: SuspenseInstance,
735+
): boolean {
734736
return instance.data === SUSPENSE_FALLBACK_START_DATA;
735737
}
736738

packages/react-dom/src/client/inputValueTracking.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ export function track(node: ElementWithValueTracker) {
123123
node._valueTracker = trackValueOnNode(node);
124124
}
125125

126-
export function updateValueIfChanged(node: ElementWithValueTracker) {
126+
export function updateValueIfChanged(node: ElementWithValueTracker): boolean {
127127
if (!node) {
128128
return false;
129129
}

packages/react-dom/src/events/checkPassiveEvents.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99

1010
import {canUseDOM} from 'shared/ExecutionEnvironment';
1111

12-
export let passiveBrowserEventsSupported = false;
12+
export let passiveBrowserEventsSupported: boolean = false;
1313

1414
// Check if browser support events with passive listeners
1515
// https://developer.mozilla.org/en-US/docs/Web/API/EventTarget/addEventListener#Safely_detecting_option_support

packages/react-dom/src/shared/DOMProperty.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,10 +63,10 @@ export type PropertyInfo = {
6363
export const ATTRIBUTE_NAME_START_CHAR =
6464
':A-Z_a-z\\u00C0-\\u00D6\\u00D8-\\u00F6\\u00F8-\\u02FF\\u0370-\\u037D\\u037F-\\u1FFF\\u200C-\\u200D\\u2070-\\u218F\\u2C00-\\u2FEF\\u3001-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFFD';
6565
/* eslint-enable max-len */
66-
export const ATTRIBUTE_NAME_CHAR =
66+
export const ATTRIBUTE_NAME_CHAR: string =
6767
ATTRIBUTE_NAME_START_CHAR + '\\-.0-9\\u00B7\\u0300-\\u036F\\u203F-\\u2040';
6868

69-
export const VALID_ATTRIBUTE_NAME_REGEX = new RegExp(
69+
export const VALID_ATTRIBUTE_NAME_REGEX: RegExp = new RegExp(
7070
'^[' + ATTRIBUTE_NAME_START_CHAR + '][' + ATTRIBUTE_NAME_CHAR + ']*$',
7171
);
7272

packages/react-dom/src/shared/isCustomComponent.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
* @flow
88
*/
99

10-
function isCustomComponent(tagName: string, props: Object) {
10+
function isCustomComponent(tagName: string, props: Object): boolean {
1111
if (tagName.indexOf('-') === -1) {
1212
return typeof props.is === 'string';
1313
}

packages/react-is/src/ReactIs.js

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ let hasWarnedAboutDeprecatedIsAsyncMode = false;
8282
let hasWarnedAboutDeprecatedIsConcurrentMode = false;
8383

8484
// AsyncMode should be deprecated
85-
export function isAsyncMode(object: any) {
85+
export function isAsyncMode(object: any): boolean {
8686
if (__DEV__) {
8787
if (!hasWarnedAboutDeprecatedIsAsyncMode) {
8888
hasWarnedAboutDeprecatedIsAsyncMode = true;
@@ -95,7 +95,7 @@ export function isAsyncMode(object: any) {
9595
}
9696
return false;
9797
}
98-
export function isConcurrentMode(object: any) {
98+
export function isConcurrentMode(object: any): boolean {
9999
if (__DEV__) {
100100
if (!hasWarnedAboutDeprecatedIsConcurrentMode) {
101101
hasWarnedAboutDeprecatedIsConcurrentMode = true;
@@ -108,43 +108,43 @@ export function isConcurrentMode(object: any) {
108108
}
109109
return false;
110110
}
111-
export function isContextConsumer(object: any) {
111+
export function isContextConsumer(object: any): boolean {
112112
return typeOf(object) === REACT_CONTEXT_TYPE;
113113
}
114-
export function isContextProvider(object: any) {
114+
export function isContextProvider(object: any): boolean {
115115
return typeOf(object) === REACT_PROVIDER_TYPE;
116116
}
117-
export function isElement(object: any) {
117+
export function isElement(object: any): boolean {
118118
return (
119119
typeof object === 'object' &&
120120
object !== null &&
121121
object.$$typeof === REACT_ELEMENT_TYPE
122122
);
123123
}
124-
export function isForwardRef(object: any) {
124+
export function isForwardRef(object: any): boolean {
125125
return typeOf(object) === REACT_FORWARD_REF_TYPE;
126126
}
127-
export function isFragment(object: any) {
127+
export function isFragment(object: any): boolean {
128128
return typeOf(object) === REACT_FRAGMENT_TYPE;
129129
}
130-
export function isLazy(object: any) {
130+
export function isLazy(object: any): boolean {
131131
return typeOf(object) === REACT_LAZY_TYPE;
132132
}
133-
export function isMemo(object: any) {
133+
export function isMemo(object: any): boolean {
134134
return typeOf(object) === REACT_MEMO_TYPE;
135135
}
136-
export function isPortal(object: any) {
136+
export function isPortal(object: any): boolean {
137137
return typeOf(object) === REACT_PORTAL_TYPE;
138138
}
139-
export function isProfiler(object: any) {
139+
export function isProfiler(object: any): boolean {
140140
return typeOf(object) === REACT_PROFILER_TYPE;
141141
}
142-
export function isStrictMode(object: any) {
142+
export function isStrictMode(object: any): boolean {
143143
return typeOf(object) === REACT_STRICT_MODE_TYPE;
144144
}
145-
export function isSuspense(object: any) {
145+
export function isSuspense(object: any): boolean {
146146
return typeOf(object) === REACT_SUSPENSE_TYPE;
147147
}
148-
export function isSuspenseList(object: any) {
148+
export function isSuspenseList(object: any): boolean {
149149
return typeOf(object) === REACT_SUSPENSE_LIST_TYPE;
150150
}

packages/react-reconciler/src/ReactCurrentFiber.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ export function setIsRendering(rendering: boolean) {
7373
}
7474
}
7575

76-
export function getIsRendering() {
76+
export function getIsRendering(): void | boolean {
7777
if (__DEV__) {
7878
return isRendering;
7979
}

packages/react-reconciler/src/ReactEventPriorities.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ export function getCurrentUpdatePriority(): EventPriority {
5858
: (getCurrentUpdatePriority_old(): any);
5959
}
6060

61-
export function setCurrentUpdatePriority(priority: EventPriority) {
61+
export function setCurrentUpdatePriority(priority: EventPriority): void {
6262
return enableNewReconciler
6363
? setCurrentUpdatePriority_new((priority: any))
6464
: setCurrentUpdatePriority_old((priority: any));

packages/react-reconciler/src/ReactFiber.new.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -225,7 +225,7 @@ function shouldConstruct(Component: Function) {
225225
return !!(prototype && prototype.isReactComponent);
226226
}
227227

228-
export function isSimpleFunctionComponent(type: any) {
228+
export function isSimpleFunctionComponent(type: any): boolean {
229229
return (
230230
typeof type === 'function' &&
231231
!shouldConstruct(type) &&
@@ -355,7 +355,10 @@ export function createWorkInProgress(current: Fiber, pendingProps: any): Fiber {
355355
}
356356

357357
// Used to reuse a Fiber for a second pass.
358-
export function resetWorkInProgress(workInProgress: Fiber, renderLanes: Lanes) {
358+
export function resetWorkInProgress(
359+
workInProgress: Fiber,
360+
renderLanes: Lanes,
361+
): Fiber {
359362
// This resets the Fiber to what createFiber or createWorkInProgress would
360363
// have set the values to before during the first pass. Ideally this wouldn't
361364
// be necessary but unfortunately many code paths reads from the workInProgress

0 commit comments

Comments
 (0)