“Type X is not assignable to type Y”
Në shqip: Gabimi „Type X is not assignable“
ShpjegimiSQ
Gabimi më i shpeshtë i TypeScript-it: po përpiqesh të vendosësh një vlerë që s'i përshtatet tipit — p.sh. string | undefined aty ku pritet string. Lexoje nga fundi: rreshti i fundit zakonisht thotë shkakun e vërtetë.
EnglishEN
TypeScript's most common error: you're trying to put in a value that doesn't fit the type — e.g. string | undefined where a string is expected. Read it from the bottom: the last line usually states the real cause.
Si ta mendosh
Si të provosh një këpucë 38 te një këmbë 42.
Lexoje në anglisht
Like trying a size-38 shoe on a size-42 foot.
Shembull koditypescript
const emri: string = localStorage.getItem("emri");
// ✗ Type 'string | null' is not assignable to type 'string'
const emri2 = localStorage.getItem("emri") ?? "";