From e182b4dfdb6694b883e15ed71c825b4f84c2cdd2 Mon Sep 17 00:00:00 2001 From: Caleb Clarke Date: Tue, 11 Aug 2020 04:08:38 -0700 Subject: [PATCH] [@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 https://github.com/facebook/react-native/blob/fcb667059d3156327c141eadeed7f3cb771d8f79/React/CoreModules/RCTAppState.mm#L27 --- types/react-native/index.d.ts | 4 +++- types/react-native/test/index.tsx | 7 +++++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/types/react-native/index.d.ts b/types/react-native/index.d.ts index 8e92b18e8a..2ef5ddc70a 100644 --- a/types/react-native/index.d.ts +++ b/types/react-native/index.d.ts @@ -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; diff --git a/types/react-native/test/index.tsx b/types/react-native/test/index.tsx index 3984db771f..1763422d8c 100644 --- a/types/react-native/test/index.tsx +++ b/types/react-native/test/index.tsx @@ -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() {