Browsed by
Category: Typescript

Understanding Nullable Types in Typescript with examples

Understanding Nullable Types in Typescript with examples

Understanding Nullable Types in Typescript with examples: Nullable type is introduced in typescript 2.0, this helps us to keep initialized objects to have some values other than null all the time.   Default number | Assigning null: For eg: let home2OfficeKm = 10; home2OfficeKm = null;     Works fine in typescript 2.0 earlier versions, if you do not want null to be assigned to the home2OfficeKm anytime then you can add the below entry in your tsconfig.json file  …

Read More Read More

527 total views, no views today

Difference between Javascript and Typescript

Difference between Javascript and Typescript

Difference between Javascript and Typescript: Javascript Typescript var myVar = ‘hello’; myVar = 10; console.log(myVar); // prints 10 let myVar = ‘hello’; myVar = 10; console.log(myVar) // we get the error here stating //Type ‘number’ is not assignable to type ‘string’ We dont have a type number only in javascript. Typescript does not have float/double types, everything is considered as type number only (like 10, 11.2, 27.8000). As types are not supported in javascript, explicit assignments will also be not…

Read More Read More

763 total views, 1 views today

Typescript Hello world in local system Example

Typescript Hello world in local system Example

Step 1: Install Typescript in Your Local Machine Install typescript in your local machine to compile and test typescript. Instructions / steps to install typescript can be found in the below link We need typescript in local,because typescript is not like javascript which can directly run on the browser. It has to be converted to javascript before running in any browser. This is because all browsers are currently supporting ES5 only and typescript is ES6, so typescript compiler converts typescript…

Read More Read More

499 total views, no views today

How to install typescript in windows 10?

How to install typescript in windows 10?

How to install typescript in windows 10? Ensure you have already node package manager(npm) installed on your machine if this is not installed then follow the below link to get it installed, How to install node js in windows 10 ?   We should definitely have npm package manager installed on our machine, once you installed npm you can verify with npm -version command and start installing the typescript.     Run the below command to install typescript in your…

Read More Read More

620 total views, no views today

Typescript Quick Notes for Angular Developers

Typescript Quick Notes for Angular Developers

Typescript Quick Notes for Angular Developers: As because of angular’s reach angular developers are forced to learn typescript. It is not tough but it is better to know the below basic syntax to code faster.   1. Converting array to JSON in typescript   selectedItems = []; JSON.stringify(this.selectedItems);       2. For loop in typescript   for(let item of items){ console.log(item.itemName) }   items is an array/collection of item.     3. String concatenation in typescript   appendTxtTemp:string =…

Read More Read More

793 total views, no views today