I have a model Participant which can have two types: Establishment or Provider:
export class Participant {
id?: number;
name?: string;
ltype: 'Provider' | 'Establishment';
get isProvider(): boolean {
return this.ltype === 'Provider';
}
get isEstablishment(): boolean {
return this.ltype === 'Establishment';
}
get opposite(): string {
if (this.ltype === 'Provider') {
return 'Establishment';
}
return 'Provider';
}
}
All good, no error till here. But when I try to initialize it:
const filter: Participant = {
ltype: 'Provider'
};
It throws:
Type '{ ltype: "Provider"; }' is not assignable to type 'Participant'.
Property 'isProvider' is missing in type '{ ltype: "Provider"; }'.
I can't get rid off the above error.
I don't think it matters, but this code is for an Angular 4 application.
Thanks in advance.
