Angular typescript class incorrectly extends base class, type of property are incompatbile

Discussão em 'Angular' iniciado por user1169587, Março 24, 2025.

  1. user1169587

    user1169587 Guest

    angular 5, In class 'RecordManagerComponent' there is an public object property 'info' defined as follow:

    export class RecordManagerComponent {
    public info: { form_status: string, proj_title_cntr_no: string, block_t:
    string, floor: string, contractor: string, test: string };
    .....
    }


    then I create another class extends from 'RecordManagerComponent' named 'F48ItemSearchComponent' and defined an object property 'info' as follow:

    export class F48ItemSearchComponent extends RecordManagerComponent {
    public info: { form_status: string, proj_title_cntr_no: string, block_t:
    string, floor: string, contractor: string };
    .....
    }


    but there is error as follow:


    ERROR in src/app/structure/inspect/components/f48/f48-item-search/f48-item-search.component.ts(33,14): error TS2415: Class 'F48ItemSearchComponent' incorrectly extends base class 'RecordManagerComponent'. Types of property 'info' are incompatible. Type '{ form_status: string; proj_title_cntr_no: string; block_t: string; floor: string; contractor: st...' is not assignable to type '{ form_status: string; proj_title_cntr_no: string; block_t: string; floor: string; contractor: st...'. Two different types with this name exist, but they are unrelated. Property 'test' is missing in type '{ form_status: string; proj_title_cntr_no: string; block_t: string; floor: string; contractor: st...'.
    ​

    why? I must rename the 'info' in child class 'F48ItemSearchComponent'?

    Continue reading...

Compartilhe esta Página