I am trying to push string to typescript array its throwing error `can not push to undefined" , is it correct way or i need to use spread operator ?
api.ts
const api: IConfigName = {name: "getKey"};
const Name = "Web";
api.optionalParam.push(Name);
IConfig.interface.ts
export interface IConfigName {
name: string;
optionalParam?: string[];
}
can not push to undefinedis not a real error, please post the actual error message. Are you seeing a runtime JavaScript error, or a compile-time TypeScript error? Are you usingstrictNullChecks?