When attempting to add a string to a TypeScript array, I am encountering an error stating 'cannot push to undefined'. Is this the correct approach, or should I be using the spread operator instead?
api.ts
const api: IConfigName = {name: "getKey"};
const Name = "Web";
api.optionalParam.push(Name);
IConfig.interface.ts
export interface IConfigName {
name: string;
optionalParam?: string[];
}