I'm facing a challenge related to inheritance while building my initial angular 5 application. The error message I encounter is: Property 'message' does not exist on type 'CouponEvent', as reported by the angular-cli.
export class Event {
public _eventId: number;
public _type: string;
public _name: string;
public _sendDate: Date;
public _message: string;
constructor(){}
public get message(): string {
return this._message;
}
public get type(): string {
return this._type;
}
public get name(): string {
return this._name;
}
public get sendDate(): Date {
return this._sendDate;
}
public get eventId():number {
return this._eventId;
}
}
import './Event';
export class CouponEvent extends Event {
_expirationDate: Date;
get expirationDate(): Date {
return this._expirationDate;
}
}
While working with my util class, I encountered an issue trying to format the message and event.message was not found.
import { Injectable } from '@angular/core';
import {Event} from '../models/Event';
import {CouponEvent} from '../models/CouponEvent';
@Injectable()
export class UtilService {
formatMessage(event: CouponEvent): string {
let msg = event.message.replace(/\${code}/gi,event.code);
const date = event.expirationDate.toString
msg = event.message.replace(/\${expiration}/gi,date);
return msg;
}
}
I would greatly appreciate any assistance in resolving this matter. As this is my first experience with TypeScript, I am somewhat confused about why it is not functioning correctly.
Thank you for your suggestions!