Skip to content

Commit

Permalink
Add TS types for Codegen (#46484)
Browse files Browse the repository at this point in the history
Summary:
Pull Request resolved: #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
  • Loading branch information
cipolleschi authored and facebook-github-bot committed Sep 16, 2024
1 parent 52718b5 commit 20b1415
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions packages/react-native/types/modules/Codegen.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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;
}

0 comments on commit 20b1415

Please sign in to comment.