I want to transform an object in a function so that all keys are converted from Camel case to Pascal case.
My Declaration:
export interface INodeMailerResponseLower {
accepted: string[];
rejected: string[];
envelopeTime: number;
messageTime: number;
messageSize: number;
response: string;
messageId: string;
}
export interface INodeMailerResponseUpper {
Accepted: string[];
Rejected: string[];
EnvelopeTime: number;
MessageTime: number;
MessageSize: number;
Response: string;
MessageId: string;
}
My Implementation:
import { upperFirst } from 'lodash';
const response: INodeMailerResponseLower; // << insert object values here
const formattedResponse: INodeMailerResponseUpper = Object.keys(response).reduce((acc, key) => {
acc[upperFirst(key)] = response[key];
return acc;
}, {});
An Error Occured:
Type '{}' is missing the following properties from type 'INodeMailerResponseUpper': Accepted, Rejected, EnvelopeTime, MessageTime, and 3 more.ts(2740)
Inquiry: How can I correctly define the type for my accumulator when using reduce method?