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
This commit is contained in:
Riccardo Cipolleschi
2024-09-16 06:28:33 -07:00
committed by Blake Friedman
parent 94d4bfd7c8
commit a09df751eb
+6
View File
@@ -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<string>;
// 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<T> = (
handler: (arg: T) => void | Promise<void>,
) => EventSubscription;
}