noUncheckedIndexedAccess
Në shqip përdoret i njëjti emër.
ShpjegimiSQ
Si parazgjedhje, TypeScript-i mendon që notat[10] është gjithmonë number — edhe nëse vargu ka vetëm 3 elemente. Me noUncheckedIndexedAccess, tipi bëhet number | undefined dhe të detyron ta kontrollosh.
EnglishEN
By default, TypeScript assumes grades[10] is always a number — even if the array has only 3 items. With noUncheckedIndexedAccess, the type becomes number | undefined and you're forced to check.
Si ta mendosh
Si të pyesësh për kutinë e 10-të të vezëve kur kutia ka vetëm 6 vende.
Lexoje në anglisht
Like asking about the 10th egg when the box only has 6 slots.
Shembull koditypescript
const notat = [5, 4, 3];
const x = notat[10]; // me opsionin: number | undefined
if (x !== undefined) console.log(x.toFixed(1));