TypeScript Tutorial #1 - Type Annotations

Pubblicato il: 17 giugno 2021
sul canale di: Free Tutorial Wale
45
0

#TypeScript #Type_Annotation

TypeScript is a typed language, where we can specify the type of the variables, function parameters, and object properties. We can specify the type using: Type after the name of the variable, parameter, or property. There can be a space after the colon. TypeScript includes all the primitive types of JavaScript- number, string, and boolean.

Type annotations are used to enforce type checking. It is not mandatory in TypeScript to use type annotations. However, type annotations help the compiler in checking types and helps avoid errors dealing with data types. It is also a good way of writing code for easier readability and maintenance by future developers working on your code.

We can still follow the JavaScript way of declaring variables and have the TypeScript compiler infer the data type of the variable.

var age: number = 32; // number variable
var name: string = "John";// string variable
var isUpdated: boolean = true;// Boolean variable


In questa pagina del sito puoi guardare il video online TypeScript Tutorial #1 - Type Annotations della durata di ore minuti seconda in buona qualità , che l'utente ha caricato Free Tutorial Wale 17 giugno 2021, condividi il link con amici e conoscenti, su youtube questo video è già stato visto 45 volte e gli è piaciuto 0 spettatori. Buona visione!