Skip to content

Commit abe873d

Browse files
huntiemeta-codesync[bot]
authored andcommitted
Fix missing and incorrect AccessibilityInfo types (#56708)
Summary: Pull Request resolved: #56708 **Context** Claude-driven audit of Flow source code vs existing public TypeScript API (manual). **Changes** Alignments to the `AccessibilityInfo` module for both the source Flow types and manual TS types: - **Flow**: Move `grayscaleChanged` and `invertColorsChanged` into shared `AccessibilityEventDefinitions` — both events are registered on both platforms in the `EventNames` map. - **TS**: Add missing event types (`accessibilityServiceChanged`, `announcementFinished`, `darkerSystemColorsChanged`, `highTextContrastChanged`, `windowStateChange`) and platform-specific JSDoc to `AccessibilityChangeEventName` members. Changelog: [General][Fixed] - Fix missing and incorrect types in `AccessibilityInfo` TypeScript definitions Reviewed By: christophpurrer Differential Revision: D104057500
1 parent 91702e5 commit abe873d

3 files changed

Lines changed: 29 additions & 16 deletions

File tree

packages/react-native/Libraries/Components/AccessibilityInfo/AccessibilityInfo.d.ts

Lines changed: 22 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,24 @@ import {HostInstance} from '../../../types/public/ReactNativeTypes';
1111
import {EmitterSubscription} from '../../vendor/emitter/EventEmitter';
1212

1313
type AccessibilityChangeEventName =
14-
| 'change' // deprecated, maps to screenReaderChanged
15-
| 'boldTextChanged' // iOS-only Event
16-
| 'grayscaleChanged' // iOS-only Event
17-
| 'invertColorsChanged' // iOS-only Event
14+
/** Android only */
15+
| 'accessibilityServiceChanged'
16+
/** iOS only */
17+
| 'announcementFinished'
18+
/** iOS only */
19+
| 'boldTextChanged'
20+
/** @deprecated Maps to 'screenReaderChanged' */
21+
| 'change'
22+
/** iOS only */
23+
| 'darkerSystemColorsChanged'
24+
| 'grayscaleChanged'
25+
/** Android only */
26+
| 'highTextContrastChanged'
27+
| 'invertColorsChanged'
1828
| 'reduceMotionChanged'
19-
| 'highTextContrastChanged' // Android-only Event
20-
| 'darkerSystemColorsChanged' // iOS-only Event
21-
| 'screenReaderChanged'
22-
| 'reduceTransparencyChanged'; // iOS-only Event
29+
/** iOS only */
30+
| 'reduceTransparencyChanged'
31+
| 'screenReaderChanged';
2332

2433
type AccessibilityChangeEvent = boolean;
2534

@@ -38,7 +47,11 @@ type AccessibilityAnnouncementFinishedEventHandler = (
3847
event: AccessibilityAnnouncementFinishedEvent,
3948
) => void;
4049

41-
type AccessibilityEventTypes = 'click' | 'focus' | 'viewHoverEnter';
50+
type AccessibilityEventTypes =
51+
| 'click'
52+
| 'focus'
53+
| 'viewHoverEnter'
54+
| 'windowStateChange';
4255

4356
/**
4457
* @see https://reactnative.dev/docs/accessibilityinfo

packages/react-native/Libraries/Components/AccessibilityInfo/AccessibilityInfo.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,16 +28,16 @@ type AccessibilityEventDefinitionsAndroid = {
2828
type AccessibilityEventDefinitionsIOS = {
2929
announcementFinished: [{announcement: string, success: boolean}],
3030
boldTextChanged: [boolean],
31-
grayscaleChanged: [boolean],
32-
invertColorsChanged: [boolean],
33-
reduceTransparencyChanged: [boolean],
3431
darkerSystemColorsChanged: [boolean],
32+
reduceTransparencyChanged: [boolean],
3533
};
3634

3735
type AccessibilityEventDefinitions = {
3836
...AccessibilityEventDefinitionsAndroid,
3937
...AccessibilityEventDefinitionsIOS,
4038
change: [boolean], // screenReaderChanged
39+
grayscaleChanged: [boolean],
40+
invertColorsChanged: [boolean],
4141
reduceMotionChanged: [boolean],
4242
screenReaderChanged: [boolean],
4343
};

packages/react-native/ReactNativeApi.d.ts

Lines changed: 4 additions & 4 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<<eeffa8d1c270f98debd70024251b4a1a>>
7+
* @generated SignedSource<<d6790c241d1bd46a735efba34eeb4742>>
88
*
99
* This file was generated by scripts/js-api/build-types/index.js.
1010
*/
@@ -1055,6 +1055,8 @@ declare type AccessibilityEventDefinitions =
10551055
AccessibilityEventDefinitionsAndroid &
10561056
AccessibilityEventDefinitionsIOS & {
10571057
change: [boolean]
1058+
grayscaleChanged: [boolean]
1059+
invertColorsChanged: [boolean]
10581060
reduceMotionChanged: [boolean]
10591061
screenReaderChanged: [boolean]
10601062
}
@@ -1071,8 +1073,6 @@ declare type AccessibilityEventDefinitionsIOS = {
10711073
]
10721074
boldTextChanged: [boolean]
10731075
darkerSystemColorsChanged: [boolean]
1074-
grayscaleChanged: [boolean]
1075-
invertColorsChanged: [boolean]
10761076
reduceTransparencyChanged: [boolean]
10771077
}
10781078
declare type AccessibilityEventTypes =
@@ -6052,7 +6052,7 @@ declare type WrapperComponentProvider = (
60526052
) => React.ComponentType<any>
60536053
export {
60546054
AccessibilityActionEvent, // 5c5928b9
6055-
AccessibilityInfo, // ccbcce2f
6055+
AccessibilityInfo, // 539eb4b3
60566056
AccessibilityProps, // 5a2836fc
60576057
AccessibilityRole, // f2f2e066
60586058
AccessibilityState, // b0c2b3f7

0 commit comments

Comments
 (0)