Fix missing type for login-password alert prompt (#49757)

Summary:
When using the `login-password` prompt type, there is a TypeScript type mismatch issue. The `callbackOrButtons` parameter returns an object with `{login: string, password: string}` structure, but this type variation is not properly included in the **AlertType** type definition. This causes TypeScript to show type errors when using callback functions that expect credentials in the format `(credentials: {login: string, password: string}) => void`.

## Changelog:
- [General] [Fixed] Add missing type variation `{login: string, password: string}` to **AlertType** type definition to properly support `login-password` prompt callbacks

Pull Request resolved: https://github.com/facebook/react-native/pull/49757

Test Plan: This change is purely type-related and doesn't affect runtime behavior.

Reviewed By: NickGerleman

Differential Revision: D70797036

Pulled By: alanleedev

fbshipit-source-id: 8e27a39f0c8f49083730c683b41b69173715bd68
This commit is contained in:
Dawid Bartczak
2025-03-11 08:10:11 -07:00
committed by Facebook GitHub Bot
parent 8d7aca30e7
commit c6a075bcc7
2 changed files with 6 additions and 2 deletions
+4 -1
View File
@@ -12,7 +12,10 @@
*/
export interface AlertButton {
text?: string | undefined;
onPress?: ((value?: string) => void) | undefined;
onPress?:
| ((value?: string) => void)
| ((value?: {login: string; password: string}) => void)
| undefined;
isPreferred?: boolean | undefined;
style?: 'default' | 'cancel' | 'destructive' | undefined;
}
@@ -1137,7 +1137,8 @@ Alert.prompt(
{
text: 'OK',
isPreferred: true,
onPress: password => console.log('OK Pressed, password: ' + password),
onPress: (password?: string) =>
console.log('OK Pressed, password: ' + password),
},
],
'secure-text',