From 94633d5e339f60bd4c06d42574e41e424651b2c6 Mon Sep 17 00:00:00 2001 From: Nathan Yee Date: Mon, 9 Dec 2024 07:15:24 -0800 Subject: [PATCH] JavaScript: Cognito - Add type annotation on authService.ts (#7123) Added type hints on authService.ts to avoid "No overload matches this call." error --- .../frontend-client/src/authService.ts | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/javascriptv3/example_code/cognito-identity-provider/scenarios/cognito-developer-guide-react-example/frontend-client/src/authService.ts b/javascriptv3/example_code/cognito-identity-provider/scenarios/cognito-developer-guide-react-example/frontend-client/src/authService.ts index 17e7124a942..b4cf8220dfd 100644 --- a/javascriptv3/example_code/cognito-identity-provider/scenarios/cognito-developer-guide-react-example/frontend-client/src/authService.ts +++ b/javascriptv3/example_code/cognito-identity-provider/scenarios/cognito-developer-guide-react-example/frontend-client/src/authService.ts @@ -6,6 +6,9 @@ import { InitiateAuthCommand, SignUpCommand, ConfirmSignUpCommand, + type InitiateAuthCommandInput, + type SignUpCommandInput, + type ConfirmSignUpCommandInput, } from "@aws-sdk/client-cognito-identity-provider"; import config from "./config.json"; @@ -14,7 +17,7 @@ export const cognitoClient = new CognitoIdentityProviderClient({ }); export const signIn = async (username: string, password: string) => { - const params = { + const params: InitiateAuthCommandInput = { AuthFlow: "USER_PASSWORD_AUTH", ClientId: config.clientId, AuthParameters: { @@ -44,7 +47,7 @@ export const signIn = async (username: string, password: string) => { }; export const signUp = async (email: string, password: string) => { - const params = { + const params: SignUpCommandInput = { ClientId: config.clientId, Username: email, Password: password, @@ -67,7 +70,7 @@ export const signUp = async (email: string, password: string) => { }; export const confirmSignUp = async (username: string, code: string) => { - const params = { + const params: ConfirmSignUpCommandInput = { ClientId: config.clientId, Username: username, ConfirmationCode: code,