Skip to content

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Migrate files in Libraries/PermissionsAndroid and Libraries/PushNotif…
Browse files Browse the repository at this point in the history
…icationIOS to use export syntax

Summary:
## Motivation
Modernising the RN codebase to allow for modern Flow tooling to process it.

## This diff
- Migrates files in `Libraries/PermissionsAndroid/*.js` and `Libraries/PushNotificationIOS/*.js` to use the `export` syntax.
- Updates deep-imports of these files to use `.default`
- Updates jest mocks
- Updates the current iteration of API snapshots (intended).

Changelog:
[General][Breaking] - Deep imports to modules inside `Libraries/PermissionsAndroid` and `Libraries/PushNotificationIOS` with `require` syntax has to be appended with '.default'.

Differential Revision: D68832494
iwoplaza authored and facebook-github-bot committed Jan 29, 2025
1 parent e4d1cf8 commit 890a6bc
Showing 4 changed files with 7 additions and 6 deletions.
Original file line number Diff line number Diff line change
@@ -296,4 +296,4 @@ class PermissionsAndroid {

const PermissionsAndroidInstance: PermissionsAndroid = new PermissionsAndroid();

module.exports = PermissionsAndroidInstance;
export default PermissionsAndroidInstance;
Original file line number Diff line number Diff line change
@@ -566,4 +566,4 @@ class PushNotificationIOS {
}
}

module.exports = PushNotificationIOS;
export default PushNotificationIOS;
Original file line number Diff line number Diff line change
@@ -7062,7 +7062,7 @@ declare class PermissionsAndroid {
): Promise<{ [permission: PermissionType]: PermissionStatus, ... }>;
}
declare const PermissionsAndroidInstance: PermissionsAndroid;
declare module.exports: PermissionsAndroidInstance;
declare export default typeof PermissionsAndroidInstance;
"
`;

@@ -7309,7 +7309,7 @@ declare class PushNotificationIOS {
getData(): ?Object;
getThreadID(): ?string;
}
declare module.exports: PushNotificationIOS;
declare export default typeof PushNotificationIOS;
"
`;

5 changes: 3 additions & 2 deletions packages/react-native/index.js
Original file line number Diff line number Diff line change
@@ -300,7 +300,7 @@ module.exports = {
return require('./Libraries/Interaction/PanResponder').default;
},
get PermissionsAndroid(): PermissionsAndroid {
return require('./Libraries/PermissionsAndroid/PermissionsAndroid');
return require('./Libraries/PermissionsAndroid/PermissionsAndroid').default;
},
get PixelRatio(): PixelRatio {
return require('./Libraries/Utilities/PixelRatio').default;
@@ -312,7 +312,8 @@ module.exports = {
"It can now be installed and imported from '@react-native-community/push-notification-ios' instead of 'react-native'. " +
'See https://github.com/react-native-push-notification/ios',
);
return require('./Libraries/PushNotificationIOS/PushNotificationIOS');
return require('./Libraries/PushNotificationIOS/PushNotificationIOS')
.default;
},
get Settings(): Settings {
return require('./Libraries/Settings/Settings').default;

0 comments on commit 890a6bc

Please sign in to comment.