Skip to content

Commit a906567

Browse files
huntiefacebook-github-bot
authored andcommitted
Remove Touchable (base) from public API (#57420)
Summary: **Motivation** The public type for `Touchable` has zero overlap with its runtime value. This is an internal implementation object which is undocumented. https://www.internalfb.com/code/fbsource/[86267213ee84]/xplat/js/react-native-github/packages/react-native/Libraries/Components/Touchable/Touchable.d.ts?lines=18-24 https://www.internalfb.com/code/fbsource/[86267213ee84]/xplat/js/react-native-github/packages/react-native/Libraries/Components/Touchable/Touchable.js?lines=966-986 Replaces D110483989 / #57419. **Impact** This is a **breaking change** with few open source consumers. The `onTouchStart` etc prop typings are part of `ViewProps` today, which is a suitable replacement. Across projects I've been testing for the Strict TypeScript API rollout, the only load bearing consumer was Uniwind — where I've sent a PR to address this. - uni-stack/uniwind#592. Changelog: [General][Breaking] - The `Touchable` root export (undocumented) is removed. If you are extending `Touchable` as a type, please use `ViewProps` instead. Reviewed By: rubennorte Differential Revision: D110488985
1 parent 07c29e3 commit a906567

4 files changed

Lines changed: 16 additions & 72 deletions

File tree

packages/react-native/ReactNativeApi.d.ts

Lines changed: 1 addition & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
* This source code is licensed under the MIT license found in the
55
* LICENSE file in the root directory of this source tree.
66
*
7-
* @generated SignedSource<<637f1d0b012ebca68c9e020a52eb2803>>
7+
* @generated SignedSource<<e85dfe98c549ac9fff85a8d7b90b5fd3>>
88
*
99
* This file was generated by scripts/js-api/build-types/index.js.
1010
*/
@@ -403,16 +403,6 @@ declare const staggerImpl: (
403403
time: number,
404404
animations: Array<CompositeAnimation>,
405405
) => CompositeAnimation
406-
declare const States: {
407-
ERROR: "ERROR"
408-
NOT_RESPONDER: "NOT_RESPONDER"
409-
RESPONDER_ACTIVE_LONG_PRESS_IN: "RESPONDER_ACTIVE_LONG_PRESS_IN"
410-
RESPONDER_ACTIVE_LONG_PRESS_OUT: "RESPONDER_ACTIVE_LONG_PRESS_OUT"
411-
RESPONDER_ACTIVE_PRESS_IN: "RESPONDER_ACTIVE_PRESS_IN"
412-
RESPONDER_ACTIVE_PRESS_OUT: "RESPONDER_ACTIVE_PRESS_OUT"
413-
RESPONDER_INACTIVE_PRESS_IN: "RESPONDER_INACTIVE_PRESS_IN"
414-
RESPONDER_INACTIVE_PRESS_OUT: "RESPONDER_INACTIVE_PRESS_OUT"
415-
}
416406
declare const subtract: typeof $$AnimatedImplementation.subtract
417407
declare const subtractImpl: (
418408
a: AnimatedNode_default | number,
@@ -456,7 +446,6 @@ declare const ToastAndroid_default: {
456446
yOffset: number,
457447
) => void
458448
}
459-
declare const Touchable: typeof TouchableImpl_default
460449
declare const Touchable_default: (
461450
props: TouchableOpacityProps & {
462451
ref?: React.Ref<TouchableOpacityInstance>
@@ -468,33 +457,6 @@ declare const TouchableHighlight_default: (
468457
ref?: React.Ref<TouchableHighlightInstance>
469458
},
470459
) => React.ReactNode
471-
declare const TouchableImpl_default: {
472-
Mixin: typeof TouchableMixinImpl
473-
renderDebugView: ($$PARAM_0$$: {
474-
color: ColorValue
475-
hitSlop?: EdgeInsetsProp
476-
}) => null | React.ReactNode
477-
}
478-
declare const TouchableMixinImpl: {
479-
withoutDefaultFocusAndBlur: {}
480-
componentDidMount: () => void
481-
componentWillUnmount: () => void
482-
touchableGetInitialState: () => {
483-
touchable: {
484-
responderID: GestureResponderEvent["currentTarget"] | undefined
485-
touchState: TouchableState | undefined
486-
}
487-
}
488-
touchableHandleBlur: (e: BlurEvent) => void
489-
touchableHandleFocus: (e: FocusEvent) => void
490-
touchableHandleResponderGrant: (e: GestureResponderEvent) => void
491-
touchableHandleResponderMove: (e: GestureResponderEvent) => void
492-
touchableHandleResponderRelease: (e: GestureResponderEvent) => void
493-
touchableHandleResponderTerminate: (e: GestureResponderEvent) => void
494-
touchableHandleResponderTerminationRequest: () => any
495-
touchableHandleStartShouldSetResponder: () => any
496-
touchableLongPressCancelsPress: () => boolean
497-
}
498460
declare const TouchableOpacity: typeof Touchable_default
499461
declare const UIManager: typeof UIManager_default
500462
declare const UIManager_default: UIManagerJSInterface
@@ -5371,7 +5333,6 @@ declare type TimingAnimationConfig = Readonly<
53715333
}
53725334
>
53735335
declare type ToastAndroid = typeof ToastAndroid
5374-
declare type Touchable = typeof Touchable
53755336
declare type TouchableHighlight = typeof TouchableHighlight
53765337
declare type TouchableHighlightBaseProps = {
53775338
readonly activeOpacity?: number
@@ -5478,15 +5439,6 @@ declare type TouchableOpacityTVProps = {
54785439
readonly nextFocusRight?: number
54795440
readonly nextFocusUp?: number
54805441
}
5481-
declare type TouchableState =
5482-
| typeof States.ERROR
5483-
| typeof States.NOT_RESPONDER
5484-
| typeof States.RESPONDER_ACTIVE_LONG_PRESS_IN
5485-
| typeof States.RESPONDER_ACTIVE_LONG_PRESS_OUT
5486-
| typeof States.RESPONDER_ACTIVE_PRESS_IN
5487-
| typeof States.RESPONDER_ACTIVE_PRESS_OUT
5488-
| typeof States.RESPONDER_INACTIVE_PRESS_IN
5489-
| typeof States.RESPONDER_INACTIVE_PRESS_OUT
54905442
declare function TouchableWithoutFeedback(
54915443
props: TouchableWithoutFeedbackProps,
54925444
): React.ReactNode
@@ -6174,7 +6126,6 @@ export {
61746126
TextProps, // 58466ea1
61756127
TextStyle, // b62b8399
61766128
ToastAndroid, // 88a8969a
6177-
Touchable, // c15da0a2
61786129
TouchableHighlight, // 20ba0199
61796130
TouchableHighlightInstance, // b510c0eb
61806131
TouchableHighlightProps, // 337a9164

packages/react-native/__typetests__/index.tsx

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,6 @@ import {
124124
// @ts-ignore
125125
SectionListData,
126126
ToastAndroid,
127-
Touchable,
128127
LayoutAnimation,
129128
processColor,
130129
experimental_LayoutConformance as LayoutConformance,
@@ -487,22 +486,6 @@ class Welcome extends React.Component<
487486

488487
export default Welcome;
489488

490-
// TouchableTest
491-
function TouchableTest() {
492-
function basicUsage() {
493-
return Touchable.renderDebugView({
494-
color: 'mediumspringgreen',
495-
hitSlop: {bottom: 5, top: 5},
496-
});
497-
}
498-
499-
function defaultHitSlop() {
500-
return Touchable.renderDebugView({
501-
color: 'red',
502-
});
503-
}
504-
}
505-
506489
export class TouchableHighlightTest extends React.Component {
507490
buttonRef = React.createRef<React.ComponentRef<typeof TouchableHighlight>>();
508491

packages/react-native/index.js

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -149,9 +149,6 @@ module.exports = {
149149
get TextInput() {
150150
return require('./Libraries/Components/TextInput/TextInput').default;
151151
},
152-
get Touchable() {
153-
return require('./Libraries/Components/Touchable/Touchable').default;
154-
},
155152
get TouchableHighlight() {
156153
return require('./Libraries/Components/Touchable/TouchableHighlight')
157154
.default;
@@ -412,6 +409,21 @@ module.exports = {
412409
// #endregion
413410
} as ReactNativePublicAPI;
414411

412+
// `Touchable` has been removed from the public API types, but remains
413+
// re-exported at runtime here because of a hanging `react-native-svg` call
414+
// site (fbsource).
415+
// TODO(huntie): Remove this re-export once `react-native-svg` is updated.
416+
/* $FlowFixMe[prop-missing] This is intentional: `Touchable` is a value-only
417+
* re-export that is absent from the public API types. */
418+
/* $FlowFixMe[invalid-export] This is intentional: `Touchable` is a value-only
419+
* re-export that is absent from the public API types. */
420+
Object.defineProperty(module.exports, 'Touchable', {
421+
configurable: true,
422+
get() {
423+
return require('./Libraries/Components/Touchable/Touchable').default;
424+
},
425+
});
426+
415427
if (__DEV__) {
416428
/* $FlowFixMe[prop-missing] This is intentional: Flow will error when
417429
* attempting to access InteractionManager. */

packages/react-native/index.js.flow

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -175,8 +175,6 @@ export type {
175175
} from './Libraries/Components/TextInput/TextInput';
176176
export {default as TextInput} from './Libraries/Components/TextInput/TextInput';
177177

178-
export {default as Touchable} from './Libraries/Components/Touchable/Touchable';
179-
180178
export type {
181179
TouchableHighlightInstance,
182180
TouchableHighlightProps,

0 commit comments

Comments
 (0)