strictNullChecks
Në shqip përdoret i njëjti emër.
ShpjegimiSQ
Me strictNullChecks të ndezur, null dhe undefined s'janë më pjesë e çdo tipi. Po mund të mungojë një vlerë (string | undefined), TypeScript-i të detyron ta kontrollosh para se ta përdorësh — dhe zhduken shumë gabime „cannot read properties of undefined“.
EnglishEN
With strictNullChecks on, null and undefined are no longer part of every type. If a value might be missing (string | undefined), TypeScript makes you check it before using it — and lots of “cannot read properties of undefined” errors disappear.
Si ta mendosh
Si të kontrollosh xhepin para se të nxjerrësh çelësat: ndoshta s'i ke marrë.
Lexoje në anglisht
Like checking your pocket before reaching for the keys: maybe you didn't bring them.
Shembull koditypescript
function gjatesia(s?: string) {
// return s.length; // Gabim: s mund të jetë undefined
return s?.length ?? 0;
}