Skip to content

Commit

Permalink
Fix TurboModuleRegistry TS type (#35885)
Browse files Browse the repository at this point in the history
Summary:
TurboModuleRegistry export functions and not a TurboModuleRegistry object. See https://github.com/facebook/react-native/blob/main/Libraries/TurboModule/TurboModuleRegistry.js#L37

## Changelog

[GENERAL] [FIXED] - Fix TurboModuleRegistry TS type

Pull Request resolved: #35885

Test Plan:
Tested that the import doesn't generate a type error when used correctly.

```ts
import * as TurboModuleRegistry from 'react-native/Libraries/TurboModule/TurboModuleRegistry';

export default TurboModuleRegistry.get<Spec>('RNCSafeAreaContext');
```

Reviewed By: christophpurrer

Differential Revision: D42604208

Pulled By: NickGerleman

fbshipit-source-id: e6259df24aaf6e37b32cc4b51947294fd655837e
  • Loading branch information
janicduplessis authored and facebook-github-bot committed Jan 19, 2023
1 parent 71c4f57 commit c289442
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 5 deletions.
6 changes: 2 additions & 4 deletions Libraries/TurboModule/TurboModuleRegistry.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,5 @@

import {TurboModule} from './RCTExport';

export const TurboModuleRegistry: {
get<T extends TurboModule>(name: string): T | null;
getEnforcing<T extends TurboModule>(name: string): T;
};
export function get<T extends TurboModule>(name: string): T | null;
export function getEnforcing<T extends TurboModule>(name: string): T;
2 changes: 1 addition & 1 deletion types/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ export * from '../Libraries/StyleSheet/StyleSheetTypes';
export * from '../Libraries/StyleSheet/processColor';
export * from '../Libraries/Text/Text';
export * from '../Libraries/TurboModule/RCTExport';
export * from '../Libraries/TurboModule/TurboModuleRegistry';
export * as TurboModuleRegistry from '../Libraries/TurboModule/TurboModuleRegistry';
export * from '../Libraries/Types/CoreEventTypes';
export * from '../Libraries/Utilities/Appearance';
export * from '../Libraries/Utilities/BackHandler';
Expand Down

0 comments on commit c289442

Please sign in to comment.