Skip to content
Closed
4 changes: 3 additions & 1 deletion packages/react-native/Libraries/Blob/File.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,12 @@
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @flow
* @flow strict-local
* @format
*/

// flowlint unsafe-getters-setters:off

'use strict';

import type {BlobOptions} from './BlobTypes';
Expand Down
4 changes: 3 additions & 1 deletion packages/react-native/Libraries/Blob/FileReader.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,12 @@
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @flow
* @flow strict-local
* @format
*/

// flowlint unsafe-getters-setters:off

import type {EventCallback} from '../../src/private/webapis/dom/events/EventTarget';
import type Blob from './Blob';

Expand Down
16 changes: 10 additions & 6 deletions packages/react-native/Libraries/Blob/URL.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,12 @@
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @flow
* @flow strict-local
* @format
*/

// flowlint unsafe-getters-setters:off

import type Blob from './Blob';

import NativeBlobModule from './NativeBlobModule';
Expand Down Expand Up @@ -79,6 +81,7 @@ export class URL {
// $FlowFixMe[missing-local-annot]
constructor(url: string, base?: string | URL) {
let baseUrl = null;
// $FlowFixMe[sketchy-null-string]
if (!base || validateBaseUrl(url)) {
this._url = url;
if (this._url.includes('#')) {
Expand Down Expand Up @@ -112,13 +115,14 @@ export class URL {
if (baseUrl.endsWith('/')) {
baseUrl = baseUrl.slice(0, baseUrl.length - 1);
}
if (!url.startsWith('/')) {
url = `/${url}`;
let path = url;
if (!path.startsWith('/')) {
path = `/${path}`;
}
if (baseUrl.endsWith(url)) {
url = '';
if (baseUrl.endsWith(path)) {
path = '';
}
this._url = `${baseUrl}${url}`;
this._url = `${baseUrl}${path}`;
}
}

Expand Down
4 changes: 3 additions & 1 deletion packages/react-native/Libraries/Blob/URLSearchParams.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,12 @@
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @flow
* @flow strict-local
* @format
*/

// flowlint unsafe-getters-setters:off

// Small subset from whatwg-url: https://github.com/jsdom/whatwg-url/tree/master/src
// The reference code bloat comes from Unicode issues with URLs, so those won't work here.
export class URLSearchParams {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @flow
* @flow strict-local
* @format
*/

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @flow
* @flow strict-local
* @format
*/

Expand Down Expand Up @@ -115,7 +115,7 @@ const ActivityIndicator: component(
style,
...restProps
}: {
ref?: any,
ref?: React.RefSetter<ActivityIndicatorInstance>,
...ActivityIndicatorProps,
}) => {
let sizeStyle;
Expand Down
11 changes: 7 additions & 4 deletions packages/react-native/Libraries/Components/Button.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @flow
* @flow strict-local
* @format
*/

Expand Down Expand Up @@ -232,7 +232,7 @@ const Button: component(
} = props;
const buttonStyles: Array<ViewStyleProp> = [styles.button];
const textStyles: Array<TextStyleProp> = [styles.text];
if (color) {
if (Boolean(color)) {
if (Platform.OS === 'ios') {
textStyles.push({color: color});
} else {
Expand All @@ -256,7 +256,7 @@ const Button: component(
? {..._accessibilityState, disabled}
: _accessibilityState;

if (disabled) {
if (disabled === true) {
buttonStyles.push(styles.buttonDisabled);
textStyles.push(styles.textDisabled);
}
Expand All @@ -279,7 +279,10 @@ const Button: component(
accessible={accessible}
accessibilityActions={accessibilityActions}
onAccessibilityAction={onAccessibilityAction}
accessibilityLabel={ariaLabel || accessibilityLabel}
accessibilityLabel={
// $FlowFixMe[sketchy-null-string]
ariaLabel || accessibilityLabel
}
accessibilityHint={accessibilityHint}
accessibilityLanguage={accessibilityLanguage}
accessibilityRole="button"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,12 @@
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @flow
* @flow strict-local
* @format
*/

// flowlint unsafe-getters-setters:off

import type {
MeasureInWindowOnSuccessCallback,
MeasureLayoutOnSuccessCallback,
Expand Down Expand Up @@ -204,7 +206,7 @@ class DrawerLayoutAndroid
);
}

setNativeProps(nativeProps: Object) {
setNativeProps(nativeProps: {...}) {
nullthrows(this._nativeRef.current).setNativeProps(nativeProps);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @flow
* @flow strict-local
* @format
*/

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @flow
* @flow strict-local
* @format
*/

Expand Down Expand Up @@ -127,7 +127,7 @@ export interface DrawerLayoutAndroidMethods {
onSuccess: MeasureLayoutOnSuccessCallback,
onFail?: () => void,
): void;
setNativeProps(nativeProps: Object): void;
setNativeProps(nativeProps: {...}): void;
}

export type DrawerLayoutAndroidInstance = DrawerLayoutAndroidMethods;
49 changes: 32 additions & 17 deletions packages/react-native/Libraries/Components/StatusBar/StatusBar.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @flow
* @flow strict-local
* @format
*/

Expand Down Expand Up @@ -101,13 +101,25 @@ export type StatusBarProps = Readonly<{

type StackProps = {
barStyle: ?{
value: StatusBarProps['barStyle'],
value: StatusBarStyle,
animated: boolean,
},
hidden: ?{
value: boolean,
animated: boolean,
transition: StatusBarProps['showHideTransition'],
transition: StatusBarAnimation,
},
};

type ResolvedStackProps = {
barStyle: {
value: StatusBarStyle,
animated: boolean,
},
hidden: {
value: boolean,
animated: boolean,
transition: StatusBarAnimation,
},
};

Expand All @@ -126,13 +138,16 @@ function getAutoBarStyle(): 'light-content' | 'dark-content' {
* barStyle to a concrete value.
*/
function mergePropsStack(
propsStack: Array<Object>,
defaultValues: Object,
): Object {
const merged: StackProps = propsStack.reduce(
propsStack: Array<StackProps>,
defaultValues: ResolvedStackProps,
): ResolvedStackProps {
const merged: ResolvedStackProps = propsStack.reduce(
(prev, cur) => {
for (const prop in cur) {
// $FlowFixMe[invalid-computed-prop] dynamic merge over the known StackProps keys
if (cur[prop] != null) {
// $FlowFixMe[invalid-computed-prop] dynamic merge over the known StackProps keys
// $FlowFixMe[prop-missing] dynamic merge over the known StackProps keys
prev[prop] = cur[prop];
}
}
Expand All @@ -141,7 +156,7 @@ function mergePropsStack(
{...defaultValues},
);

if (merged.barStyle?.value === 'auto') {
if (merged.barStyle.value === 'auto') {
merged.barStyle = {...merged.barStyle, value: getAutoBarStyle()};
}

Expand Down Expand Up @@ -224,18 +239,18 @@ function createStackEntry(props: StatusBarProps): StackProps {
class StatusBar extends React.Component<StatusBarProps> {
static _propsStack: Array<StackProps> = [];

static _defaultProps: any = createStackEntry({
barStyle: 'default',
hidden: false,
});
static _defaultProps: ResolvedStackProps = {
barStyle: {value: 'default', animated: false},
hidden: {value: false, animated: false, transition: 'fade'},
};

// Timer for updating the native module values at the end of the frame.
static _updateImmediate: ?number = null;

// The current merged values from the props stack. `barStyle.value` is stored
// in its resolved form (never `'auto'`), so diff comparisons reflect what
// was actually sent to the native module.
static _currentValues: ?StackProps = null;
static _currentValues: ?ResolvedStackProps = null;

// Number of mounted `StatusBar` instances. Used to lazily subscribe to color
// scheme changes only while at least one instance is on screen.
Expand Down Expand Up @@ -264,10 +279,10 @@ class StatusBar extends React.Component<StatusBarProps> {
* changing the status bar hidden property.
*/
static setHidden(hidden: boolean, animation?: StatusBarAnimation) {
animation = animation || 'none';
const resolvedAnimation = animation ?? 'none';
StatusBar._defaultProps.hidden.value = hidden;
if (Platform.OS === 'ios') {
NativeStatusBarManagerIOS.setHidden(hidden, animation);
NativeStatusBarManagerIOS.setHidden(hidden, resolvedAnimation);
} else if (Platform.OS === 'android') {
NativeStatusBarManagerAndroid.setHidden(hidden);
}
Expand All @@ -279,11 +294,11 @@ class StatusBar extends React.Component<StatusBarProps> {
* @param animated Animate the style change.
*/
static setBarStyle(style: StatusBarStyle, animated?: boolean) {
animated = animated || false;
const resolvedAnimated = animated ?? false;
StatusBar._defaultProps.barStyle.value = style;
const resolvedStyle = style === 'auto' ? getAutoBarStyle() : style;
if (Platform.OS === 'ios') {
NativeStatusBarManagerIOS.setStyle(resolvedStyle, animated);
NativeStatusBarManagerIOS.setStyle(resolvedStyle, resolvedAnimated);
} else if (Platform.OS === 'android') {
NativeStatusBarManagerAndroid.setStyle(resolvedStyle);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @flow
* @flow strict-local
* @format
*/

Expand Down Expand Up @@ -331,7 +331,7 @@ const TouchableMixinImpl = {
*/
/* $FlowFixMe[missing-this-annot] The 'this' type annotation(s) required by
* Flow's LTI update could not be added via codemod */
touchableHandleResponderTerminationRequest: function (): any {
touchableHandleResponderTerminationRequest: function (): boolean {
return !this.props.rejectResponderTermination;
},

Expand All @@ -340,7 +340,7 @@ const TouchableMixinImpl = {
*/
/* $FlowFixMe[missing-this-annot] The 'this' type annotation(s) required by
* Flow's LTI update could not be added via codemod */
touchableHandleStartShouldSetResponder: function (): any {
touchableHandleStartShouldSetResponder: function (): boolean {
return !this.props.disabled;
},

Expand Down
8 changes: 5 additions & 3 deletions packages/react-native/Libraries/Core/Timers/immediateShim.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @flow
* @flow strict-local
* @format
* @deprecated
*/
Expand All @@ -22,7 +22,10 @@ const clearedImmediates: Set<number> = new Set();
* @param {function} func Callback to be invoked before the end of the
* current JavaScript execution loop.
*/
export function setImmediate(callback: Function, ...args: any): number {
export function setImmediate<TArgs extends Array<unknown>>(
callback: (...args: TArgs) => unknown,
...args: TArgs
): number {
if (arguments.length < 1) {
throw new TypeError(
'setImmediate must be called with at least one argument (a function to call)',
Expand All @@ -41,7 +44,6 @@ export function setImmediate(callback: Function, ...args: any): number {
clearedImmediates.delete(id);
}

// $FlowFixMe[incompatible-type]
global.queueMicrotask(() => {
if (!clearedImmediates.has(id)) {
callback.apply(undefined, args);
Expand Down
Loading
Loading