I'm currently working with the CognitoIdentityClient class in the aws-sdk-js-v3 library, and I have come across a constructor that has me puzzled:
export class CognitoIdentityClient extends __Client<
__HttpHandlerOptions,
ServiceInputTypes,
ServiceOutputTypes,
CognitoIdentityClientResolvedConfig
> {
constructor(...[configuration]: __CheckOptionalClientConfig<CognitoIdentityClientConfig>) {
const _config_0 = __getRuntimeConfig(configuration || {});
[...]
}
}
What is the significance of the three dots and the brackets in this constructor? I tried calling it as follows, but encountered unexpected behavior:
new CognitoIdentityClient([myConfiguration]);
I attempted to create my own version, but I'm struggling to make it function properly:
test(...[myArgument]: string): void {
}
const myString: string = 'abc';
test(myString); // Argument of type '[string]' is not assignable to parameter of type 'string'.
test([myString]); // Argument of type '[string[]]' is not assignable to parameter of type 'string'
test(...myString); // Argument of type 'string[]' is not assignable to parameter of type 'string'