我无法弄清楚 ParsedAuthorizationResponse 是如何实现的,以及我如何以不同的方式设置它的值。最终,我想返回某个值/类型作为承诺。
我以为这会奏效,但没有
let PAR;
if (status === 'COMPLETED') {
PAR = new ParsedAuthorizationResponse('AUTHORIZED')
} else throw new Error('Authorization failed')
return Promise<PAR>;
}
//Also tried this but didn't work
type ParsedAuthorizationResponse PAR = 'AUTHORIZED';
return new Promise<PAR>;
Run Code Online (Sandbox Code Playgroud) javascript return-type type-conversion typescript typescript-generics