forked from microsoft/react-native-macos
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Unify and cleanup Platform Flow typing (facebook#38731)
Summary: Pull Request resolved: facebook#38731 Changelog: [Internal] Reviewed By: yungsters Differential Revision: D47965692 fbshipit-source-id: ad61acd28a3362b64fa90f413a876c29c1166132
- Loading branch information
1 parent
08688d3
commit 55fd026
Showing
4 changed files
with
99 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
84 changes: 84 additions & 0 deletions
84
packages/react-native/Libraries/Utilities/Platform.flow.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
/** | ||
* Copyright (c) Meta Platforms, Inc. and affiliates. | ||
* | ||
* This source code is licensed under the MIT license found in the | ||
* LICENSE file in the root directory of this source tree. | ||
* | ||
* @flow strict | ||
* @format | ||
*/ | ||
|
||
export type PlatformSelectSpec<T> = { | ||
default?: T, | ||
native?: T, | ||
ios?: T, | ||
android?: T, | ||
... | ||
}; | ||
|
||
type IOSPlatform = { | ||
__constants: null, | ||
OS: $TEMPORARY$string<'ios'>, | ||
// $FlowFixMe[unsafe-getters-setters] | ||
get Version(): string, | ||
// $FlowFixMe[unsafe-getters-setters] | ||
get constants(): {| | ||
forceTouchAvailable: boolean, | ||
interfaceIdiom: string, | ||
isTesting: boolean, | ||
isDisableAnimations?: boolean, | ||
osVersion: string, | ||
reactNativeVersion: {| | ||
major: number, | ||
minor: number, | ||
patch: number, | ||
prerelease: ?number, | ||
|}, | ||
systemName: string, | ||
|}, | ||
// $FlowFixMe[unsafe-getters-setters] | ||
get isPad(): boolean, | ||
// $FlowFixMe[unsafe-getters-setters] | ||
get isTV(): boolean, | ||
// $FlowFixMe[unsafe-getters-setters] | ||
get isTesting(): boolean, | ||
// $FlowFixMe[unsafe-getters-setters] | ||
get isDisableAnimations(): boolean, | ||
select: <T>(spec: PlatformSelectSpec<T>) => T, | ||
}; | ||
|
||
type AndroidPlatform = { | ||
__constants: null, | ||
OS: $TEMPORARY$string<'android'>, | ||
// $FlowFixMe[unsafe-getters-setters] | ||
get Version(): number, | ||
// $FlowFixMe[unsafe-getters-setters] | ||
get constants(): {| | ||
isTesting: boolean, | ||
isDisableAnimations?: boolean, | ||
reactNativeVersion: {| | ||
major: number, | ||
minor: number, | ||
patch: number, | ||
prerelease: ?number, | ||
|}, | ||
Version: number, | ||
Release: string, | ||
Serial: string, | ||
Fingerprint: string, | ||
Model: string, | ||
ServerHost?: string, | ||
uiMode: string, | ||
Brand: string, | ||
Manufacturer: string, | ||
|}, | ||
// $FlowFixMe[unsafe-getters-setters] | ||
get isTV(): boolean, | ||
// $FlowFixMe[unsafe-getters-setters] | ||
get isTesting(): boolean, | ||
// $FlowFixMe[unsafe-getters-setters] | ||
get isDisableAnimations(): boolean, | ||
select: <T>(spec: PlatformSelectSpec<T>) => T, | ||
}; | ||
|
||
export type Platform = IOSPlatform | AndroidPlatform; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters