TypeScript

never

Në shqip përdoret i njëjti emër.

ShpjegimiSQ

never është tipi i vlerave që s'ndodhin kurrë — p.sh. një funksion që gjithmonë hedh gabim. Përdoret shumë për të kontrolluar që i ke trajtuar të gjitha rastet e një union-i: po harrove një, TypeScript-i ankohet.

EnglishEN

never is the type of values that never happen — e.g. a function that always throws. It's used a lot to check you've handled every case of a union: forget one and TypeScript complains.

Si ta mendosh

Si kutia „asgjë“ në formular: nëse dikush e plotëson, diçka ka shkuar keq.

Lexoje në anglisht

Like a “none of these” box that should never be ticked: if someone ticks it, something's wrong.

Shembull koditypescript

function gabim(msg: string): never {
  throw new Error(msg);
}

Terma të lidhur