From 892c8352cae25db8e5b5df27451e1bc0290a9558 Mon Sep 17 00:00:00 2001 From: Andrew Coates <30809111+acoates-ms@users.noreply.github.com> Date: Tue, 16 Jul 2024 13:41:48 -0700 Subject: [PATCH] Use more accurate type in LinkingManager spec file (#45450) Summary: The `LinkingModule.getInitialURL` method is declared as returning a `Proimise` but looking at the implementation it can also return null: https://github.com/facebook/react-native/blob/a96272e27eeee0c7a26e73bb32e55d3ef8d741aa/packages/react-native/Libraries/LinkingIOS/RCTLinkingManager.mm#L166 which is returned by https://github.com/facebook/react-native/blob/a96272e27eeee0c7a26e73bb32e55d3ef8d741aa/packages/react-native/Libraries/Linking/Linking.js#L96 which happens to expand the type to the correct type for most external users. React-native-window's turbomodule codegen is more type strict, and so cannot return null with the current spec. ## Changelog: [INTERNAL] [FIXED] - Use more accurate type in LinkingManager spec file Pull Request resolved: https://github.com/facebook/react-native/pull/45450 Test Plan: Type change only, so should only affect build time change which will be caught by CI. Have verified that this type change allows react-native-windows to return null. Reviewed By: robhogan Differential Revision: D59816089 Pulled By: zeyap fbshipit-source-id: 9810f150ce84b503883e72b1f29518d2e62258b6 --- .../src/private/specs/modules/NativeLinkingManager.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/react-native/src/private/specs/modules/NativeLinkingManager.js b/packages/react-native/src/private/specs/modules/NativeLinkingManager.js index 2a8b73810aa..60d1aa0f1fe 100644 --- a/packages/react-native/src/private/specs/modules/NativeLinkingManager.js +++ b/packages/react-native/src/private/specs/modules/NativeLinkingManager.js @@ -14,7 +14,7 @@ import * as TurboModuleRegistry from '../../../../Libraries/TurboModule/TurboMod export interface Spec extends TurboModule { // Common interface - +getInitialURL: () => Promise; + +getInitialURL: () => Promise; +canOpenURL: (url: string) => Promise; +openURL: (url: string) => Promise; +openSettings: () => Promise;