Skip to content

Commit 921a6c0

Browse files
committed
updated types for les type defining
1 parent a8d062b commit 921a6c0

File tree

2 files changed

+16
-26
lines changed

2 files changed

+16
-26
lines changed

src/useAccessibilityInfo.ts

Lines changed: 5 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,5 @@
11
import {useEffect, useState} from 'react'
2-
import {AccessibilityInfo, AccessibilityEvent} from 'react-native'
3-
4-
type AccessibilityEventName =
5-
| 'boldTextChanged' // iOS-only Event
6-
| 'grayscaleChanged' // iOS-only Event
7-
| 'invertColorsChanged' // iOS-only Event
8-
| 'reduceMotionChanged'
9-
| 'screenReaderChanged'
10-
| 'reduceTransparencyChanged' // iOS-only Event
2+
import {AccessibilityInfo, AccessibilityChangeEventName} from 'react-native'
113

124
type AccessibilityInfoStaticInitializers =
135
| 'isBoldTextEnabled'
@@ -18,7 +10,7 @@ type AccessibilityInfoStaticInitializers =
1810
| 'isReduceTransparencyEnabled'
1911

2012
type AccessibilityEventToInfoStaticKeyMap = {
21-
[K in AccessibilityEventName]?: AccessibilityInfoStaticInitializers
13+
[K in AccessibilityChangeEventName]?: AccessibilityInfoStaticInitializers
2214
}
2315

2416
const EVENT_NAME_TO_INITIALIZER: AccessibilityEventToInfoStaticKeyMap = {
@@ -30,10 +22,8 @@ const EVENT_NAME_TO_INITIALIZER: AccessibilityEventToInfoStaticKeyMap = {
3022
reduceTransparencyChanged: 'isReduceTransparencyEnabled',
3123
}
3224

33-
type AccessibilityInfoChangeEventHandler = (event: AccessibilityEvent) => void
34-
3525
function useAccessibilityStateListener(
36-
eventName: AccessibilityEventName,
26+
eventName: AccessibilityChangeEventName,
3727
): boolean {
3828
const [isEnabled, setIsEnabled] = useState(false)
3929

@@ -47,13 +37,13 @@ function useAccessibilityStateListener(
4737
AccessibilityInfo[initializerKey]().then(setIsEnabled)
4838
AccessibilityInfo.addEventListener(
4939
eventName,
50-
<AccessibilityInfoChangeEventHandler>setIsEnabled,
40+
setIsEnabled,
5141
)
5242

5343
return () =>
5444
AccessibilityInfo.removeEventListener(
5545
eventName,
56-
<AccessibilityInfoChangeEventHandler>setIsEnabled,
46+
setIsEnabled,
5747
)
5848
}, [eventName])
5949

yarn.lock

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1614,13 +1614,13 @@
16141614

16151615
"@types/prop-types@*":
16161616
version "15.7.3"
1617-
resolved "https://registry.npmjs.org/@types/prop-types/-/prop-types-15.7.3.tgz#2ab0d5da2e5815f94b0b9d4b95d1e5f243ab2ca7"
1617+
resolved "https://registry.yarnpkg.com/@types/prop-types/-/prop-types-15.7.3.tgz#2ab0d5da2e5815f94b0b9d4b95d1e5f243ab2ca7"
16181618
integrity sha512-KfRL3PuHmqQLOG+2tGpRO26Ctg+Cq1E01D2DMriKEATHgWLfeNDmq9e29Q9WIky0dQ3NPkd1mzYH8Lm936Z9qw==
16191619

1620-
1621-
version "0.62.8"
1622-
resolved "https://registry.yarnpkg.com/@types/react-native/-/react-native-0.62.8.tgz#224602561f75b838ed6e3b5ea37093bb84cffd74"
1623-
integrity sha512-YEf0tH3xYJpQB12Vvzoy7cqPY3mvbbulTnG3G7ToKOuJuqigAN3K9NNAaxNAAm1zCj+UtObhzcaJtPRwX1z6Fw==
1620+
"@types/react-native@^0.62.8":
1621+
version "0.62.9"
1622+
resolved "https://registry.yarnpkg.com/@types/react-native/-/react-native-0.62.9.tgz#f75d4a8879e68ed3857d6f2f73dc0752a0505362"
1623+
integrity sha512-OcoE7SKz1PsvTGJK5fIwJu6kWdDFN+hH1vMI4GVTEBYhV5FAM5vKVUFCaSiEPJScyNyIEWAeQwFvI3a01+Grzg==
16241624
dependencies:
16251625
"@types/react" "*"
16261626

@@ -1632,9 +1632,9 @@
16321632
"@types/react" "*"
16331633

16341634
"@types/react@*":
1635-
version "16.9.25"
1636-
resolved "https://registry.npmjs.org/@types/react/-/react-16.9.25.tgz#6ae2159b40138c792058a23c3c04fd3db49e929e"
1637-
integrity sha512-Dlj2V72cfYLPNscIG3/SMUOzhzj7GK3bpSrfefwt2YT9GLynvLCCZjbhyF6VsT0q0+aRACRX03TDJGb7cA0cqg==
1635+
version "16.9.35"
1636+
resolved "https://registry.yarnpkg.com/@types/react/-/react-16.9.35.tgz#a0830d172e8aadd9bd41709ba2281a3124bbd368"
1637+
integrity sha512-q0n0SsWcGc8nDqH2GJfWQWUOmZSJhXV64CjVN5SvcNti3TdEaA3AH0D8DwNmMdzjMAC/78tB8nAZIlV8yTz+zQ==
16381638
dependencies:
16391639
"@types/prop-types" "*"
16401640
csstype "^2.2.0"
@@ -2823,9 +2823,9 @@ cssstyle@^2.2.0:
28232823
cssom "~0.3.6"
28242824

28252825
csstype@^2.2.0:
2826-
version "2.6.9"
2827-
resolved "https://registry.npmjs.org/csstype/-/csstype-2.6.9.tgz#05141d0cd557a56b8891394c1911c40c8a98d098"
2828-
integrity sha512-xz39Sb4+OaTsULgUERcCk+TJj8ylkL4aSVDQiX/ksxbELSqwkgt4d4RD7fovIdgJGSuNYqwZEiVjYY5l0ask+Q==
2826+
version "2.6.10"
2827+
resolved "https://registry.yarnpkg.com/csstype/-/csstype-2.6.10.tgz#e63af50e66d7c266edb6b32909cfd0aabe03928b"
2828+
integrity sha512-D34BqZU4cIlMCY93rZHbrq9pjTAQJ3U8S8rfBqjwHxkGPThWFjzZDQpgMJY0QViLxth6ZKYiwFBo14RdN44U/w==
28292829

28302830
dashdash@^1.12.0:
28312831
version "1.14.1"

0 commit comments

Comments
 (0)