TypeScript

Type assertions (as)

Në shqip: Pohimet e tipit

ShpjegimiSQ

Me as i thua TypeScript-it „më beso, e di unë çfarë tipi është“ — p.sh. document.getElementById("x") as HTMLInputElement. S'e kontrollon gjatë ekzekutimit, prandaj po gabove, gabimi del më vonë.

EnglishEN

With as you tell TypeScript “trust me, I know what type this is” — e.g. document.getElementById("x") as HTMLInputElement. It isn't checked at runtime, so if you're wrong the error shows up later.

Si ta mendosh

Si t'i thuash rojes „unë jam me grupin“ pa treguar biletën — mund të hysh, por po gënjeve, do ta kuptojnë më vonë.

Lexoje në anglisht

Like telling the steward “I'm with the group” without showing a ticket — you get in, but if you lied, they'll find out later.

Shembull koditypescript

const input = document.getElementById("kerko") as HTMLInputElement;
console.log(input.value);

Terma të lidhur