Coder Social home page Coder Social logo

quick-typescript's Introduction

Typescript compiler compiles the typescript code to javascript. Since typescript is eventually compiled to javascript which is not a typed language, people say that typescript is actually not typed since it is compiled to js. Use typescript if you are working in a team and the project is big.

TSC automatically compiles to ES5 so it will compile your ts file variables you coded with "let" to "var" which is not recommended after "let" and "const" is introduced in ES6 since "let" and "const" are block-scoped and "var" is function scoped. -> You can change which JS version you want to compile your TS code in tsconfig.json which tells the typescript compiler what to do. You can also specify rootDir and outDir in tsconfig.json file.

rootDir -> is where your source files are, the tsc compiler will automatically compile the ts files inside this path outDir -> is where the compiled js files' go

Install typescript compiler

    npm i -g typescript
    tsc -v

Create a tsconfig.json

    tsc --init

Use tsc compile in watch mode

    tsc --watch

See the output of the compiled js code

If you want to see the output of console.log() in terminal

    cd dist
    node index

Run in browser

Open index.html in browser or use live server plugin in VSCode

Name: Live Server Id: ritwickdey.LiveServer Description: Launch a development local Server with live reload feature for static & dynamic pages Version: 5.7.9 Publisher: Ritwick Dey VS Marketplace Link: https://marketplace.visualstudio.com/items?itemName=ritwickdey.LiveServer

Create React App with typescript

    npx create-react-app . --template typescript

quick-typescript's People

Watchers

 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.