Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ const ActivityIndicator = (
*/

const ActivityIndicatorWithRef: component(
ref: React.RefSetter<HostComponent<mixed>>,
ref: React.RefSetter<HostComponent<empty>>,
...props: Props
) = React.forwardRef(ActivityIndicator);
ActivityIndicatorWithRef.displayName = 'ActivityIndicator';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,9 @@ import type {HostComponent} from '../../../Renderer/shims/ReactNativeTypes';
import requireNativeComponent from '../../../ReactNative/requireNativeComponent';
import * as React from 'react';

const RCTRefreshControl: HostComponent<mixed> =
requireNativeComponent<mixed>('RCTRefreshControl');
const RCTRefreshControl: HostComponent<{}> = requireNativeComponent<{}>(
'RCTRefreshControl',
);

class RefreshControlMock extends React.Component<{...}> {
static latestRef: ?RefreshControlMock;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import type {Double} from '../../Types/CodegenTypes';
import codegenNativeCommands from '../../Utilities/codegenNativeCommands';
import * as React from 'react';

type ScrollViewNativeComponentType = HostComponent<mixed>;
type ScrollViewNativeComponentType = HostComponent<{...}>;
interface NativeCommands {
+flashScrollIndicators: (
viewRef: React.ElementRef<ScrollViewNativeComponentType>,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import * as NativeComponentRegistry from '../../NativeComponent/NativeComponentR
import codegenNativeCommands from '../../Utilities/codegenNativeCommands';
import RCTTextInputViewConfig from './RCTTextInputViewConfig';

type NativeType = HostComponent<mixed>;
type NativeType = HostComponent<{...}>;

type NativeCommands = TextInputNativeCommands<NativeType>;

Expand All @@ -35,11 +35,11 @@ export const __INTERNAL_VIEW_CONFIG: PartialViewConfig = {
},
};

const MultilineTextInputNativeComponent: HostComponent<mixed> =
NativeComponentRegistry.get<mixed>(
const MultilineTextInputNativeComponent: HostComponent<{...}> =
NativeComponentRegistry.get<{...}>(
'RCTMultilineTextInputView',
() => __INTERNAL_VIEW_CONFIG,
);

// flowlint-next-line unclear-type:off
export default ((MultilineTextInputNativeComponent: any): HostComponent<mixed>);
export default ((MultilineTextInputNativeComponent: any): HostComponent<{...}>);
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import * as NativeComponentRegistry from '../../NativeComponent/NativeComponentR
import codegenNativeCommands from '../../Utilities/codegenNativeCommands';
import RCTTextInputViewConfig from './RCTTextInputViewConfig';

type NativeType = HostComponent<mixed>;
type NativeType = HostComponent<{...}>;

type NativeCommands = TextInputNativeCommands<NativeType>;

Expand All @@ -31,11 +31,13 @@ export const __INTERNAL_VIEW_CONFIG: PartialViewConfig = {
...RCTTextInputViewConfig,
};

const SinglelineTextInputNativeComponent: HostComponent<mixed> =
NativeComponentRegistry.get<mixed>(
const SinglelineTextInputNativeComponent: HostComponent<{...}> =
NativeComponentRegistry.get<{...}>(
'RCTSinglelineTextInputView',
() => __INTERNAL_VIEW_CONFIG,
);

// flowlint-next-line unclear-type:off
export default ((SinglelineTextInputNativeComponent: any): HostComponent<mixed>);
export default ((SinglelineTextInputNativeComponent: any): HostComponent<{
...
}>);
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ export function setRuntimeConfigProvider(
* The supplied `viewConfigProvider` may or may not be invoked and utilized,
* depending on how `setRuntimeConfigProvider` is configured.
*/
export function get<Config>(
export function get<Config: {...}>(
name: string,
viewConfigProvider: () => PartialViewConfig,
): HostComponent<Config> {
Expand Down Expand Up @@ -121,7 +121,7 @@ export function get<Config>(
* that the return value of this is not `HostComponent` because the returned
* component instance is not guaranteed to have native methods.
*/
export function getWithFallback_DEPRECATED<Config>(
export function getWithFallback_DEPRECATED<Config: {...}>(
name: string,
viewConfigProvider: () => PartialViewConfig,
): React.ComponentType<Config> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -136,8 +136,8 @@ export function isProfilingRenderer(): boolean {
}

export function isChildPublicInstance(
parentInstance: ReactFabricHostComponent | HostComponent<mixed>,
childInstance: ReactFabricHostComponent | HostComponent<mixed>,
parentInstance: ReactFabricHostComponent | HostComponent<empty>,
childInstance: ReactFabricHostComponent | HostComponent<empty>,
): boolean {
return require('../Renderer/shims/ReactNative').isChildPublicInstance(
parentInstance,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,9 @@ const getNativeComponentAttributes = require('./getNativeComponentAttributes');
*
*/

const requireNativeComponent = <T>(uiViewClassName: string): HostComponent<T> =>
const requireNativeComponent = <T: {...}>(
uiViewClassName: string,
): HostComponent<T> =>
((createReactNativeComponentClass(uiViewClassName, () =>
getNativeComponentAttributes(uiViewClassName),
): any): HostComponent<T>);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ export type NativeComponentType<T> = HostComponent<T>;
// `requireNativeComponent` is not available in Bridgeless mode.
// e.g. This function runs at runtime if `codegenNativeComponent` was not called
// from a file suffixed with NativeComponent.js.
function codegenNativeComponent<Props>(
function codegenNativeComponent<Props: {...}>(
componentName: string,
options?: Options,
): NativeComponentType<Props> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import * as React from 'react';

function takesHostComponentInstance(instance: HostInstance | null): void {}

const MyHostComponent = (('Host': any): HostComponent<mixed>);
const MyHostComponent = (('Host': any): HostComponent<{...}>);

<MyHostComponent
ref={hostComponentRef => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1658,7 +1658,7 @@ type Props = $ReadOnly<{|
size?: ?IndicatorSize,
|}>;
declare const ActivityIndicatorWithRef: component(
ref: React.RefSetter<HostComponent<mixed>>,
ref: React.RefSetter<HostComponent<empty>>,
...props: Props
);
declare export default typeof ActivityIndicatorWithRef;
Expand Down Expand Up @@ -2269,7 +2269,7 @@ declare module.exports: typeof Wrapper & ScrollViewComponentStatics;
`;

exports[`public API should not change unintentionally Libraries/Components/ScrollView/ScrollViewCommands.js 1`] = `
"type ScrollViewNativeComponentType = HostComponent<mixed>;
"type ScrollViewNativeComponentType = HostComponent<{ ... }>;
interface NativeCommands {
+flashScrollIndicators: (
viewRef: React.ElementRef<ScrollViewNativeComponentType>
Expand Down Expand Up @@ -2765,20 +2765,20 @@ declare export default typeof RCTInputAccessoryViewNativeComponent;
`;

exports[`public API should not change unintentionally Libraries/Components/TextInput/RCTMultilineTextInputNativeComponent.js 1`] = `
"type NativeType = HostComponent<mixed>;
"type NativeType = HostComponent<{ ... }>;
type NativeCommands = TextInputNativeCommands<NativeType>;
declare export const Commands: NativeCommands;
declare export const __INTERNAL_VIEW_CONFIG: PartialViewConfig;
declare export default HostComponent<mixed>;
declare export default HostComponent<{ ... }>;
"
`;

exports[`public API should not change unintentionally Libraries/Components/TextInput/RCTSingelineTextInputNativeComponent.js 1`] = `
"type NativeType = HostComponent<mixed>;
"type NativeType = HostComponent<{ ... }>;
type NativeCommands = TextInputNativeCommands<NativeType>;
declare export const Commands: NativeCommands;
declare export const __INTERNAL_VIEW_CONFIG: PartialViewConfig;
declare export default HostComponent<mixed>;
declare export default HostComponent<{ ... }>;
"
`;

Expand Down Expand Up @@ -6479,11 +6479,11 @@ exports[`public API should not change unintentionally Libraries/NativeComponent/
verify: boolean,
}
): void;
declare export function get<Config>(
declare export function get<Config: { ... }>(
name: string,
viewConfigProvider: () => PartialViewConfig
): HostComponent<Config>;
declare export function getWithFallback_DEPRECATED<Config>(
declare export function getWithFallback_DEPRECATED<Config: { ... }>(
name: string,
viewConfigProvider: () => PartialViewConfig
): React.ComponentType<Config>;
Expand Down Expand Up @@ -7659,8 +7659,8 @@ declare export function unstable_batchedUpdates<T>(
): void;
declare export function isProfilingRenderer(): boolean;
declare export function isChildPublicInstance(
parentInstance: ReactFabricHostComponent | HostComponent<mixed>,
childInstance: ReactFabricHostComponent | HostComponent<mixed>
parentInstance: ReactFabricHostComponent | HostComponent<empty>,
childInstance: ReactFabricHostComponent | HostComponent<empty>
): boolean;
declare export function getNodeFromInternalInstanceHandle(
internalInstanceHandle: InternalInstanceHandle
Expand Down Expand Up @@ -7727,7 +7727,7 @@ exports[`public API should not change unintentionally Libraries/ReactNative/rend
`;

exports[`public API should not change unintentionally Libraries/ReactNative/requireNativeComponent.js 1`] = `
"declare const requireNativeComponent: <T>(
"declare const requireNativeComponent: <T: { ... }>(
uiViewClassName: string
) => HostComponent<T>;
declare export default typeof requireNativeComponent;
Expand Down Expand Up @@ -9280,7 +9280,7 @@ exports[`public API should not change unintentionally Libraries/Utilities/codege
excludedPlatforms?: $ReadOnlyArray<\\"iOS\\" | \\"android\\">,
|}>;
export type NativeComponentType<T> = HostComponent<T>;
declare function codegenNativeComponent<Props>(
declare function codegenNativeComponent<Props: { ... }>(
componentName: string,
options?: Options
): NativeComponentType<Props>;
Expand Down Expand Up @@ -9702,7 +9702,7 @@ declare module.exports: {
get Platform(): Platform,
get PlatformColor(): PlatformColor,
get processColor(): processColor,
get requireNativeComponent(): <T>(
get requireNativeComponent(): <T: { ... }>(
uiViewClassName: string
) => HostComponent<T>,
get RootTagContext(): RootTagContext,
Expand Down
2 changes: 1 addition & 1 deletion packages/react-native/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -375,7 +375,7 @@ module.exports = {
get processColor(): processColor {
return require('./Libraries/StyleSheet/processColor').default;
},
get requireNativeComponent(): <T>(
get requireNativeComponent(): <T: {...}>(
uiViewClassName: string,
) => HostComponent<T> {
return require('./Libraries/ReactNative/requireNativeComponent').default;
Expand Down