Coder Social home page Coder Social logo

durga-typescript's Introduction

TypeScript

  • Source: hitesh choudhary utube channel

Installation

  • official website: typescriptlang.org

  • check node version: node -v

  • npm install -g typescript

  • check : tsc -v

  • file extension is : name.ts

  • if you use jsx syntax file extension is: name.tsx we use these file extension in react app

code running

  • we can't run the typescript code directly.first we have to convert typescript code into javascript (tsc fileName) then run that javascript file

  • See tsConfig file for more details and setup in typescriptlang.org

Types

Documentation guidlines

  • Docs > everydaytypes
  • https://www.typescriptlang.org/docs/handbook/2/everyday-types.html

Syntax

let variableName: type = value

    // string
    let greetings: string = "Hello world!!"
    greetings.toLowerCase()
    console.log(greetings);

    // number

    // first way
    let userId: number = 345627
    // second way 
    let age = 23.3 
    age.toFixed()


    // boolean
    let isLoggedIn: boolean = false
  • typescript does static Checking
  • typescript is a development tool. your project still runs js

Types:

  • number,string,boolean,null,undefined,void,object,array,tuples,any never,unkonwn

initialize typescript

open utuntu terminal & run below codes
    1. tsc --init
    1. npm init -y
    1. mkdir src dist
    1. create a ts file in src folder and write code
    1. open tsconfig file and enable "outDir": "./dist",
    1. running on watch mode : tsc -w
    1. add js file path to html file <script src = './dist/index.js'>
    1. right click on html file then click on open with live server option. or
    1. another way to run : npm i lite-server
  • in package.json file scripts{"start":"lite-server"}

  • npm start

  • if you want to grow your code vertically not horizontally go to view >word wrap option in that file you can show these options in vscode header

Praveen

I modified readme file

durga-typescript's People

Contributors

bhavani357 avatar andepraveenofficial avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.