TypeScript

Recursive types

Në shqip: Tipet rekursive

ShpjegimiSQ

Një tip mund t'i referohet vetes — kështu përshkruan struktura që s'kanë fund të caktuar, si pemët, menytë me nënmeny ose çdo vlerë JSON.

EnglishEN

A type can refer to itself — that's how you describe structures with no fixed depth, like trees, menus with submenus or any JSON value.

Si ta mendosh

Si kukullat ruse: brenda secilës mund të ketë një tjetër.

Lexoje në anglisht

Like Russian dolls: inside each one there may be another.

Shembull koditypescript

type Meny = { titulli: string; nenmeny?: Meny[] };
type JSONVlere = string | number | boolean | null | JSONVlere[] | { [k: string]: JSONVlere };

Terma të lidhur