patryk-developer
5/17/2018 - 6:26 PM

Typ any

error TS2322: Type '{ id: number; }' is not assignable to type '{ id: number; name: string; }'.9 Property 'name' is missing in type '{ id: number; }'.10

// typ any
// var item1 = { id: 1, name: "item 1" };
// item1 = { id: 2 };  //-- błąd: niezgodność typów

var item1 : any = { id: 1, name: "element 1" };
item1 = { id: 2 };

var item2 = <any>{ id: 1, name: "element 1" };
item2 = { id: 2 };