Giter Club home page Giter Club logo

typescript-101's Introduction

TypeScript 101

Install

npm install -g typescript

We must complie TS and in order to do so, we type:

tsc hello.ts this command will complie the ts version of this file into a a JavaScript version. Each time you make changes to the TS file, make sure to run the tsc filename.js in terminal to update the JS version. You can see this in the hello.js and hello.ts files.

The Type System

TS type annotation string:String tell us that this is a string type: see types.ts file Types: can start with upper or lower case

  • strings
  • numbers
  • booleans
  • any to allow more then one type, eg; array : any [1, 2, "hello", false]
  • type void is used when a function returns nothing

Classes

  • Properties in a class can not be declared optional, with the ?

Modules

  • syntax:
       export class NameOfClass {
           ...code...
       }
    }
  • set up a refrence path to the other module: /// <reference path = "modules.ts" />

  • to combine files into a new file in the term with --out and new fileName: tsc modules.ts modulesUtils.ts --out modUtil.js

Auto Compile with w/Grunt - Setup gruntfile.js

  • Checkout Gruntjs.com/plugins for all the plugsin available
  • look for the ts complier plugin
  • Grunt works with NPM which installs packages which work with your code, so we will start will creating an npm package,run npm init , after the install, a package.json file will appear.
  • next install: npm i typescript --save this will save and add ts to our package.json
  • next install: npm i grunt-ts --save
  • next install: npm i grunt-ts-cli --save
  • set up gruntfile.js, typescript foler and main.ts file
  • after set up of gruntfile: run gulp, this creates the javascript folder & files Docs

typescript-101's People

Contributors

ainneo avatar

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.