From ff698f542eb7a564746866c814c47104fa716dd7 Mon Sep 17 00:00:00 2001 From: Eli White Date: Thu, 10 Oct 2024 14:20:49 -0700 Subject: [PATCH] Make RN ColorScheme a Union (#46872) Summary: Pull Request resolved: https://github.com/facebook/react-native/pull/46872 This can now be flow typed as a union because the codegen supports it. Changelog: [Internal] Reviewed By: yungsters Differential Revision: D63681874 fbshipit-source-id: 97783df5ae71292dd10602dee0bea39743e62234 --- .../src/private/specs/modules/NativeAppearance.js | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/packages/react-native/src/private/specs/modules/NativeAppearance.js b/packages/react-native/src/private/specs/modules/NativeAppearance.js index c12236e7a53c8e..d7bc36160eaf81 100644 --- a/packages/react-native/src/private/specs/modules/NativeAppearance.js +++ b/packages/react-native/src/private/specs/modules/NativeAppearance.js @@ -12,21 +12,15 @@ import type {TurboModule} from '../../../../Libraries/TurboModule/RCTExport'; import * as TurboModuleRegistry from '../../../../Libraries/TurboModule/TurboModuleRegistry'; -export type ColorSchemeName = 'light' | 'dark'; +export type ColorSchemeName = 'light' | 'dark' | 'unspecified'; export type AppearancePreferences = { - // TODO: (hramos) T52919652 Use ?ColorSchemeName once codegen supports union - // types. - /* 'light' | 'dark' */ - colorScheme?: ?string, + colorScheme?: ?ColorSchemeName, }; export interface Spec extends TurboModule { - // TODO: (hramos) T52919652 Use ?ColorSchemeName once codegen supports union - // types. - /* 'light' | 'dark' */ - +getColorScheme: () => ?string; - +setColorScheme: (colorScheme: string) => void; + +getColorScheme: () => ?ColorSchemeName; + +setColorScheme: (colorScheme: ColorSchemeName) => void; // RCTEventEmitter +addListener: (eventName: string) => void;