Vai al contenuto principale
ProdottiStrumenti desktopTASTECADVisualizzazione disegniTASTEFILESGestione fileTASTEFTPTrasferimento fileTASTESSHSpazio di lavoro remotoTASTEZIPCompressione ed estrazioneTASTEWINMGestione fileStrumenti per sviluppatoriTASTECODEAmbiente di sviluppo integrato per RustTASTESTUDIOAmbiente integrato di sviluppo e testTASTEETLIntegrazione dati (ETL)ServerTASTEREMOTEServer di desktop remotoTASTEGEOServer geospazialeTASTEMAILSpazio di lavoro emailInvestimentiTASTESTOCKApp desktop di trading automatico azionarioIniziaDownloadDocumentazioneAcquistaTutti i prodotti
Marketplace
Notizie
TecnologiaNotizieNotizie di sviluppo di oggiDocumentazioneLinguaggi di programmazioneRustTypeScriptJavaScriptPythonGoC#JavaCC++KotlinDartFramework frontend webNext.jsReactVue.js · NuxtSvelteKitAngularFramework serverSpring BootDjangoFastAPIASP.NET CoreNestJS · ExpressFramework per app e desktopTauriFlutterReact NativeElectronAlgoritmiBasi degli algoritmiAlgoritmi fondamentaliAlgoritmi avanzatiAlgoritmi pratici
CommunityProgettiLog di sviluppoPromptProblemi degli strumenti di IAVetrinaGuida alla community
CollaboraTrasferimento tecnicoRealizzazione del sito webRealizzazione di app desktopPipeline di rilascio e pagamentoPartner commercialeContatti
ServiziDesktop remotoPacchetti di installazione su misura
TASTEDEV
Prodotti

Strumenti desktop

TASTECADApri con leggerezza anche i disegni più complessiTASTEFILESSolo i file che servono, alla massima velocitàTASTEFTPLa via più ordinata per i tuoi fileTASTESSHUn legame più solido tra te e i tuoi serverTASTEZIPComprimi più veloce, estrai più sicuroTASTEWINMUn file manager a due pannelli pensato per la tastiera

Strumenti per sviluppatori

TASTECODEModifica, compila, esegui il debug e testa app Rust in un'unica finestraTASTESTUDIODalla modifica ai test remoti e alle correzioni IA approvateTASTEETLSposta i dati guardando i valori

Server

TASTEREMOTEUn desktop remoto che gira sul tuo serverTASTEGEOUn server geospaziale compatibile con GeoServer, ricostruito in RustTASTEMAILRiprendi il controllo della tua posta

Investimenti

TASTESTOCKTrading automatico azionario secondo le regole che decidi tu: quando e che cosa

Inizia

DownloadUltime versioni di ogni prodottoDocsCome usare ogni prodottoAcquistaAbbonamenti e licenze perpetueTutti i prodottiTutti i prodotti a colpo d’occhio
Tutti i prodotti
MarketplaceNotizie
Tecnologia

Notizie

Notizie di sviluppo di oggiAnnunci ufficiali su linguaggi, framework, GitHub e IADocumentazioneGuide a linguaggi, framework e algoritmi

Linguaggi di programmazione

RustTypeScriptJavaScriptPythonGoC#JavaCC++KotlinDart

Framework

Framework frontend webNext.jsReactVue.js · NuxtSvelteKitAngular
Framework serverSpring BootDjangoFastAPIASP.NET CoreNestJS · Express
Framework per app e desktopTauriFlutterReact NativeElectron

Algoritmi

Basi degli algoritmiAnalisi della complessità · Ordinamento · Ricerca · Strutture dati di base · Alberi e heapAlgoritmi fondamentaliVisita dei grafi · Cammini minimi e alberi ricoprenti · Programmazione dinamica · Algoritmi greedy · Divide et impera · BacktrackingAlgoritmi avanzatiAlgoritmi sulle stringhe · Matematica e teoria dei numeri · Manipolazione dei bit · Alberi di segmenti · Union-FindAlgoritmi praticiStrategia per colloqui di programmazione · Cache LRU · Rate limiting · Hashing consistente
Tutta la documentazione di sviluppo
Community
ProgettiScopri sviluppatori e lavoriLog di sviluppoDecisioni e lezioni appresePromptIstruzioni riutilizzabiliProblemi degli strumenti di IAProblemi e alternative di Claude, Codex, GeminiVetrinaRisultati completatiGuida alla communityCome sviluppiamo in modo aperto
Collabora
Trasferimento tecnicoApp native in Rust ed eguiRealizzazione del sito web10 lingue, account, documentazione e downloadRealizzazione di app desktopRust ed egui, senza WebViewPipeline di rilascio e pagamentoFirma, MSI, deb, rpm, AppImage, hashPartner commercialeConsigliaci e ricevi il 30%ContattiSviluppo, partnership e investimenti
Servizi
Desktop remotoRaggiungi il tuo computer dal browserPacchetti di installazione su misuraSolo il necessario, impostazioni precaricate
Acquista
IT
한국어EnglishDeutschEspañolFrançaisItalianoPortuguês (Brasil)日本語简体中文繁體中文
Accedi
Accedi
TASTEDEV

Dai piccoli strumenti a uno sviluppo migliore.

support@tastedev.netSostieni TASTEDEV
ProdottiGamma di prodottiAcquistaDocsDownloadMarketplaceAssistenza
CommunityProgettiLog di sviluppoPromptProblemi degli strumenti di IAVetrina
NormeChi siamoInformativa sulla privacyTermini di servizioCondizioni di abbonamentoRimborsiLinee guida della community
AccountAccediRegistrati
Visitatori
Oggi
Ieri
Visualizzazioni totali
Società
GXSOFT
Rappresentante
CHOI YOUNG GU
Numero di registrazione
853-44-00368
Indirizzo
9F V24, 351 Gyeongin-ro, Michuhol-gu, Incheon, Republic of Korea
Telefono
+82-10-4404-1523
E-mail
whitecalvin@tastedev.net
Responsabile privacy
CHOI YOUNG GU

© 2026 TASTEDEVLe informazioni sui prodotti si basano su fonti di sviluppo verificate.Rilasciato · in miglioramento

Documentazione di TypeScript
TypeScript
Getting StartedSyntax BasicsTypes and DataModules and PackagesErrors and TestingKey Concepts: The Type System
Discussioni

Guida a TypeScript · 2/6

Syntax Basics

Per ora questo capitolo è disponibile solo in inglese.

TypeScript's syntax is JavaScript's syntax. What it adds is a way to describe the types of variables, parameters, and return values. This chapter covers declarations, functions, arrow functions, and control flow, along with a practical rule of thumb for when to write types yourself and when to let the compiler infer them.

let and const

Declare variables with let or const. A const binding cannot be reassigned; a let binding can. Both are block-scoped, meaning they only exist inside the nearest pair of braces. The legacy var keyword is function-scoped and full of surprises, so leave it out of new code.

const appName = "TASTEDEV";   // cannot be reassigned
let count = 0;                // can change
count += 1;

const user = { name: "Kim", age: 30 };
user.age = 31;                // fine: properties are still mutable
// user = { name: "Lee", age: 20 }; // error: cannot assign to a const

if (count > 0) {
  const inner = "only visible inside this block";
  console.log(inner);
}

Note that const locks the binding, not the object it points to. A good default is to reach for const everywhere and switch to let only when a value genuinely needs to change. Readers then know at a glance which names can move.

Annotations and inference

Writing : Type after a name is a type annotation. Most of the time you can skip it, because TypeScript infers the type from the initial value.

let title: string = "Guide"; // annotated, but redundant
let pages = 120;              // inferred as number
const lang = "en";            // inferred as the literal type "en"

let total: number;            // no initializer, so annotate
total = pages * 2;

// pages = "many"; // error: string is not assignable to number

Because pages is a let, it gets the wide type number. lang is a const that can never change, so its type is the exact value "en". That is called a literal type, and it becomes important in chapters 3 and 6.

Places where an explicit annotation pays off:

  • Function parameters. There is nothing to infer from, so always annotate them.
  • Return types of exported functions. They act as a contract and stop accidental changes.
  • Variables declared without a value, and empty arrays you fill in later.

Functions

Annotate each parameter, and optionally the return type after the parameter list. Mark a parameter optional with ?, or give it a default value.

function add(a: number, b: number): number {
  return a + b;
}

function formatName(first: string, last?: string): string {
  return last ? `${first} ${last}` : first;
}

function repeat(text: string, times = 2): string {
  return text.repeat(times); // times is inferred as number
}

function sum(...values: number[]): number {
  return values.reduce((acc, v) => acc + v, 0);
}

function log(message: string): void {
  console.log(message); // no return value, so void
}

add(1, 2);           // 3
formatName("Ada");   // "Ada"
sum(1, 2, 3, 4);     // 10
Domande su questo capitolo?
Capitolo precedenteGetting StartedCapitolo successivoTypes and Data

Unlike plain JavaScript, TypeScript checks the number of arguments too. Calling add(1) is an error; if a parameter may be omitted, say so with ? or a default.

Arrow functions

Arrow functions are compact and do not bind their own this, which makes them ideal for callbacks. When you pass an arrow function as a callback, its parameter types are inferred from context, so you rarely need to annotate them.

const square = (n: number): number => n * n;

const toUpper = (s: string) => s.toUpperCase(); // return type inferred

const scores = [72, 95, 88];
const passed = scores.filter((score) => score >= 80); // score: number
const labels = scores.map((score, index) => `#${index + 1}: ${score}`);

type Comparator = (a: number, b: number) => number;
const ascending: Comparator = (a, b) => a - b;
console.log([...scores].sort(ascending));

Naming a function shape, as Comparator does here, lets you reuse the same signature across many functions.

Control flow

Conditionals and loops work exactly as in JavaScript. Use === and !== for comparisons; they never coerce types behind your back.

function grade(score: number): string {
  if (score >= 90) {
    return "A";
  } else if (score >= 80) {
    return "B";
  }
  return "C";
}

function dayName(day: number): string {
  switch (day) {
    case 0: return "Sunday";
    case 6: return "Saturday";
    default: return "Weekday";
  }
}

const fruits = ["apple", "pear", "persimmon"];
for (const fruit of fruits) {
  console.log(fruit);            // iterates over values
}
for (let i = 0; i < fruits.length; i++) {
  console.log(i, fruits[i]);
}

let n = 3;
while (n > 0) {
  n--;
}

const status = n === 0 ? "done" : "running";

For arrays, for...of is the most readable loop. Avoid for...in on arrays: it walks over keys as strings, not values.

Summary

  • Default to const, use let when a value must change, and skip var.
  • Let inference handle initialized variables; annotate parameters and exported return types.
  • Express optional parameters with ?, defaults with =, and rest parameters with ....
  • Callback parameters in arrow functions pick up their types from context.
  • Compare with ===, and loop over arrays with for...of.

0 commenti

Commenti principaliPrima i più recenti

Accedi · Accedi per lasciare un commento.