Skip to content

Fix TurboModuleRegistry TS type - #35885

Closed
janicduplessis wants to merge 2 commits into
react:mainfrom
janicduplessis:patch-15
Closed

Fix TurboModuleRegistry TS type#35885
janicduplessis wants to merge 2 commits into
react:mainfrom
janicduplessis:patch-15

Conversation

@janicduplessis

@janicduplessisjanicduplessis commented Jan 19, 2023

Copy link
Copy Markdown
Contributor

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

Test Plan

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

import*asTurboModuleRegistryfrom'react-native/Libraries/TurboModule/TurboModuleRegistry';exportdefaultTurboModuleRegistry.get<Spec>('RNCSafeAreaContext');

@facebook-github-botfacebook-github-bot added CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. Contributor A React Native contributor. labels Jan 19, 2023
@analysis-bot

Copy link
Copy Markdown
PlatformEngineArchSize (bytes)Diff
androidhermesarm64-v8a8,465,416+0
androidhermesarmeabi-v7a7,785,948+0
androidhermesx868,938,528+0
androidhermesx86_648,796,959+0
androidjscarm64-v8a9,650,646+0
androidjscarmeabi-v7a8,385,092+0
androidjscx869,712,865+0
androidjscx86_6410,190,008+0

Base commit: 0c150b2
Branch: main

@NickGerleman

NickGerleman commented Jan 19, 2023

Copy link
Copy Markdown
Contributor

LGTM for importing TurboModuleRegistry from its path, though for most cases you should probably prefer using the public export for this instead of reaching into a file inside the package. I know there are places where our own documentation doesn't do this though.

@NickGerleman

Copy link
Copy Markdown
Contributor

I.e. prefer "import {TurboModuleRegistry} from 'react-native'"

@facebook-github-bot

Copy link
Copy Markdown
Contributor

@NickGerleman has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator.

@facebook-github-botfacebook-github-bot added the Merged This PR has been merged. label Jan 19, 2023
@facebook-github-bot

Copy link
Copy Markdown
Contributor

@NickGerleman merged this pull request in c289442.

@janicduplessis
janicduplessis deleted the patch-15 branch January 19, 2023 14:30
@janicduplessis

janicduplessis commented Jan 19, 2023

Copy link
Copy Markdown
ContributorAuthor

Yea I realized after working on this that it is also a public export from react-native.

kelset pushed a commit that referenced this pull request Jan 30, 2023
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
@cipolleschicipolleschi mentioned this pull request Oct 11, 2023
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA SignedThis label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed.ContributorA React Native contributor.MergedThis PR has been merged.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants

@janicduplessis@analysis-bot@NickGerleman@facebook-github-bot