From b16de79880083d9bb50eeceb786cb0c323f14cab Mon Sep 17 00:00:00 2001 From: Mohamamd Tahir Lashari <61346951+Mohammadtahirlashari@users.noreply.github.com> Date: Tue, 8 Aug 2023 19:17:59 +0500 Subject: [PATCH] added some basic type annotation info --- step00_helloworld/app.ts | 24 ++++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) diff --git a/step00_helloworld/app.ts b/step00_helloworld/app.ts index 511f9cec..9ed93ed8 100644 --- a/step00_helloworld/app.ts +++ b/step00_helloworld/app.ts @@ -1,4 +1,24 @@ -let message = "Hello World";// Infering Types, - //take your cursor on the variable name +// Before starting learning typescript, you must know two terms; +/* +01 - Implicit type annotations + + - It means rely on the compiler to infer the type of the variable. + + Here infer means that the compiler will try to figure out the type of the variable during runtime or compiling the code. + +02 - Explicit type annotations + + - It means add static types directly to variable in codebase instead of relying on the compiler to do it for you. + + +*/ +// Implicit Vaiable Declaration, in message variable, we have not added the type of the variable explicitly. So, take your cursor on the variable name and the tooltip will show you the type of variable. + +let message = "Hello World"; + console.log(message); + +// Explicit Vaiable Declaration, in language variable, we have added the type of the variable explicitly. + +let language: string = "TypeScript";