Export DeviceInfoConstants type from the native module's specs (#39135)

Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/39135

## Changelog:
[Internal] -

Expose constants type from DeviceInfo native module - this makes codegen generate the corresponding data structure, making the native module implementation shorter (in C++ in particular).

Reviewed By: christophpurrer

Differential Revision: D48620784

fbshipit-source-id: 40ae83ebec92e0a470c20ef1ad16f8392e2bf8b0
This commit is contained in:
Ruslan Shestopalyuk
2023-08-24 14:38:26 -07:00
committed by Facebook GitHub Bot
parent 10a076f6e2
commit 8955bfb87c
@@ -34,6 +34,11 @@ export type DimensionsPayload = {|
screenPhysicalPixels?: DisplayMetricsAndroid,
|};
export type DeviceInfoConstants = {|
+Dimensions: DimensionsPayload,
+isIPhoneX_deprecated?: boolean,
|};
export interface Spec extends TurboModule {
+getConstants: () => {|
+Dimensions: DimensionsPayload,
@@ -42,13 +47,10 @@ export interface Spec extends TurboModule {
}
const NativeModule: Spec = TurboModuleRegistry.getEnforcing<Spec>('DeviceInfo');
let constants = null;
let constants: ?DeviceInfoConstants = null;
const NativeDeviceInfo = {
getConstants(): {|
+Dimensions: DimensionsPayload,
+isIPhoneX_deprecated?: boolean,
|} {
getConstants(): DeviceInfoConstants {
if (constants == null) {
constants = NativeModule.getConstants();
}