Typescript / Angular 2: Property is missing in type Typescript / Angular 2: Property is missing in type typescript typescript

Typescript / Angular 2: Property is missing in type


You need to put the members in the class as well so that it will indeed implement the interface:

class ResultPage implements ResultPageInterface {    public entries: Array<any>;    public page_number: number;    public page_size: number;    public total_entries: number;    constructor() {        this.entries = [];    }}

You can also have the members private and use getters:

class ResultPage implements ResultPageInterface {    private _entries: Array<any>;    private _page_number: number;    private _page_size: number;    private _total_entries: number;    constructor() {        this._entries = [];    }    public get entries() {        return this._entries;    }    public get page_number() {        return this._page_number;    }    public get page_size() {        return this._page_size;    }    public get total_entries() {        return this._total_entries;    }}


implements ResultPageInterface you state that ResultPage implements ResultPageInterface but it actually doesn't.

It should be

export class ResultPage implements ResultPageInterface {  entries:Array<any>;  page_number:number;  page_size:number;  total_entries:number;}


Just in case if you do silly mistakes. I was getting the same error today.

ERROR in src/app/components/home/home.component.ts(11,3): error TS2322: Type 'undefined[]' is not assignable to type 'StreamData'.
Property 'messageId' is missing in type 'undefined[]'. src/app/components/home/home.component.ts(18,24): error TS2339: Property 'push' does not exist on type 'StreamData'.

I changed my code from dashboardData: StreamData = []; to dashboardData: StreamData[] = [];, that fixed the issue.