Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix TurboModuleRegistry TS type #35885

Closed
wants to merge 2 commits into from

Conversation

janicduplessis
Copy link
Contributor

@janicduplessis janicduplessis commented Jan 19, 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

Test Plan

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

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

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

@facebook-github-bot facebook-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

Platform Engine Arch Size (bytes) Diff
android hermes arm64-v8a 8,465,416 +0
android hermes armeabi-v7a 7,785,948 +0
android hermes x86 8,938,528 +0
android hermes x86_64 8,796,959 +0
android jsc arm64-v8a 9,650,646 +0
android jsc armeabi-v7a 8,385,092 +0
android jsc x86 9,712,865 +0
android jsc x86_64 10,190,008 +0

Base commit: 0c150b2
Branch: main

@NickGerleman
Copy link
Contributor

NickGerleman commented Jan 19, 2023

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
Contributor

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

@facebook-github-bot
Copy link
Contributor

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

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

@NickGerleman merged this pull request in c289442.

@janicduplessis janicduplessis deleted the patch-15 branch January 19, 2023 14:30
@janicduplessis
Copy link
Contributor Author

janicduplessis commented Jan 19, 2023

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
OlimpiaZurek pushed a commit to OlimpiaZurek/react-native that referenced this pull request May 22, 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: facebook#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
@cipolleschi cipolleschi mentioned this pull request Oct 11, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
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. Merged This PR has been merged.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants