From a09df751ebfba5ef648037bf2aa13da96a259b01 Mon Sep 17 00:00:00 2001 From: Riccardo Cipolleschi Date: Mon, 16 Sep 2024 06:28:33 -0700 Subject: [PATCH] Add TS types for Codegen (#46484) Summary: Pull Request resolved: https://github.com/facebook/react-native/pull/46484 We recently realized that we don't have TS types for Codegen. These are needed to let our users use these types when writing Specs in TS ## Changelog [General][Added] - Add CodegenTypes for TS Reviewed By: christophpurrer Differential Revision: D62644516 fbshipit-source-id: 92bb7e8998d31806f6eb63319fb6d406fcd65ad8 --- packages/react-native/types/modules/Codegen.d.ts | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/packages/react-native/types/modules/Codegen.d.ts b/packages/react-native/types/modules/Codegen.d.ts index dd7ddcadf17ee0..698c922fe6b75a 100644 --- a/packages/react-native/types/modules/Codegen.d.ts +++ b/packages/react-native/types/modules/Codegen.d.ts @@ -41,6 +41,7 @@ declare module 'react-native/Libraries/Utilities/codegenNativeComponent' { declare module 'react-native/Libraries/Types/CodegenTypes' { import type {NativeSyntheticEvent} from 'react-native'; + import type {EventSubscription} from 'react-native/Libraries/vendor/emitter/EventEmitter'; // Event types // We're not using the PaperName, it is only used to codegen view config settings @@ -59,6 +60,7 @@ declare module 'react-native/Libraries/Types/CodegenTypes' { export type Float = number; export type Int32 = number; export type UnsafeObject = object; + export type UnsafeMixed = unknown; type DefaultTypes = number | boolean | string | ReadonlyArray; // Default handling, ignore the unused value @@ -71,4 +73,8 @@ declare module 'react-native/Libraries/Types/CodegenTypes' { Type extends DefaultTypes, Value extends Type | string | undefined | null, > = Type | undefined | null; + + export type EventEmitter = ( + handler: (arg: T) => void | Promise, + ) => EventSubscription; }