satisfies vs type annotation
Në shqip: satisfies kundrejt shënimit të tipit
ShpjegimiSQ
const k: Konfig = {...} e „harron“ formën e saktë dhe mban vetëm Konfig. const k = {...} satisfies Konfig kontrollon që përshtatet, por ruan tipin e saktë — kështu ke autocomplete të plotë.
EnglishEN
const c: Config = {...} “forgets” the exact shape and keeps only Config. const c = {...} satisfies Config checks it fits but keeps the exact type — so you get full autocomplete.
Si ta mendosh
Si një inspektor që e miraton shtëpinë pa ia ndryshuar planin.
Lexoje në anglisht
Like an inspector who approves the house without altering its plan.
Shembull koditypescript
const ngjyrat = { kuqe: "#f00", blu: [0, 0, 255] } satisfies Record<string, string | number[]>;
ngjyrat.kuqe.toUpperCase(); // ✓ e di që është string