So, I would simplify a little bit. I work with Cognito, and I have the list of possibble attributes, I'll shorten it to:
export type CognitoUserAttributes = {
email?: string;
name?: string;
email_verified?: string | boolean;
address?: Record<string, unknown>;
};
and I receive them in such a format:
[
{Name: 'email_verified', Value: 'true'},
{Name: 'name', Value: 'John'},
{Name: 'email', Value: '[email protected]'}
]
How could I create a type, which will give me strict typing of key/value pairs?
Variables doesn't work in syntax like this:
export type CognitoUserAttributesResponse = {
Name: keyof CognitoUserAttributes;
Value: CognitoUserAttributes[keyof CognitoUserAttributes];
};
And this type doesn't do the work, since every key could be every possible value.