在TypeScript中,您可以设置参数类型,如下所示:
data source
如何为函数参数的参数设置类型?
例如,这是我想像的样子:
function x(y: string[], z?: Function)
答案 0 :(得分:0)
您正在使用粗箭头符号查找类型。
import {
CognitoRefreshToken,
CognitoAccessToken,
CognitoIdToken,
CognitoUserSession
} from "amazon-cognito-identity-js";
........................
..........................
const body = JSON.parse(event.body);
const RefreshToken = new CognitoRefreshToken({
RefreshToken: body.refreshToken
});
const IdToken = new CognitoIdToken({
IdToken: body.idToken
});
const AccessToken = new CognitoAccessToken({
AccessToken: body.accessToken
});
const sessionData = {
IdToken: IdToken,
AccessToken: AccessToken,
RefreshToken: RefreshToken
};
const cachedSession = new CognitoUserSession(sessionData);
if(cachedSession.isValid()) {
//session is valid
} else {
//session expired(idToken and accessToken has expired)
}