Intersection types (A & B)
Në shqip: Tipet intersection
ShpjegimiSQ
Një intersection type (A & B) i bashkon dy tipe: objekti duhet të ketë të gjitha fushat e të dyve. P.sh. Personi & Studenti ka edhe emrin, edhe numrin e studentit.
EnglishEN
An intersection type (A & B) combines two types: the object must have all the fields of both. E.g. Person & Student has both a name and a student number.
Si ta mendosh
Si dikush që është edhe lojtar, edhe kapiten: ka detyrat e të dyjave.
Lexoje në anglisht
Like someone who's both a player and the captain: they have the duties of both.
Shembull koditypescript
type Personi = { emri: string };
type Studenti = { nrStudenti: number };
const arta: Personi & Studenti = { emri: "Arta", nrStudenti: 1042 };