[@types/react-native] Add missing 'unknown' and 'extension' values to AppStateStatus (#46464)

* [@types/react-native] Add missing 'unknown' value to AppStateStatus

* Added test

* Add 'extension' app state value, as per fcb667059d/React/CoreModules/RCTAppState.mm (L27)
This commit is contained in:
Caleb Clarke 2020-08-11 04:08:38 -07:00 committed by GitHub
parent 253b176a48
commit e182b4dfdb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 10 additions and 1 deletions

View File

@ -7238,13 +7238,15 @@ export type AlertType = 'default' | 'plain-text' | 'secure-text' | 'login-passwo
* active - The app is running in the foreground
* background - The app is running in the background. The user is either in another app or on the home screen
* inactive [iOS] - This is a transition state that currently never happens for typical React Native apps.
* unknown [iOS] - Initial value until the current app state is determined
* extension [iOS] - The app is running as an app extension
*
* For more information, see Apple's documentation: https://developer.apple.com/library/ios/documentation/iPhone/Conceptual/iPhoneOSProgrammingGuide/TheAppLifeCycle/TheAppLifeCycle.html
*
* @see https://facebook.github.io/react-native/docs/appstate#app-states
*/
export type AppStateEvent = 'change' | 'memoryWarning' | 'blur' | 'focus';
export type AppStateStatus = 'active' | 'background' | 'inactive';
export type AppStateStatus = 'active' | 'background' | 'inactive' | 'unknown' | 'extension';
export interface AppStateStatic {
currentState: AppStateStatus;

View File

@ -106,6 +106,7 @@ import {
ColorValue,
TextLayoutEventData,
LayoutChangeEvent,
AppStateStatus,
} from 'react-native';
declare module 'react-native' {
@ -440,6 +441,12 @@ function appStateTest() {
AppState.addEventListener('focus', appStateListener);
}
let appState: AppStateStatus = 'active';
appState = 'background';
appState = 'inactive';
appState = 'unknown';
appState = 'extension';
// ViewPagerAndroid
export class ViewPagerAndroidTest {
render() {