Member-only story

TypeScript for React Native: A Complete Beginner’s Guide 🚀

Jayant Kumar🇮🇳
4 min read3 days ago

--

Photo by Raphael Schaller on Unsplash

In this article we will see the beginner’s guide of Typescript to start with an Awesome framework called React Native.

🚀 Variables

In typescript, variables will be declared by const and let keywords.

🔴 const

const name = "jayant"

variables declared with const cannot be reinitialised , value is initialised at compile time only.

If you try to re-assigned the value , you will get the compile time error.

🔴 let

variables created with let , can be re-initialised later.

let age = 25;
age = 26;

We can also create variables with var keyword , but using var to declare variables in Typescript is considered bad practise.

There are multiples reasons but let’s understand by an example

🔴 var

function test_2() {
if (true) {
var x = 10;
}
console.log(x)
}

As you see in the above code , we defined the x variable inside the if-block but it is accessible outside the block , this can lead an unexpected behaviour when working with loops or conditions.

🚀 Data Types

--

--

Jayant Kumar🇮🇳
Jayant Kumar🇮🇳

Written by Jayant Kumar🇮🇳

Hello My name is Jayant Kumar, I am a software Engineer , specialist in Mobile Development (Android , IOS , Flutter , React Native and Ionic) from India 🇮🇳

Responses (1)