Giter VIP home page Giter VIP logo

learning-typescript's Introduction

Learning TypeScript

This is my first time going through JavaScript and TypeScript for real.

I want to understand the workflows in creating, testing, and running web development code with TypeScript and NodeJS.

NOTE: These notes are NOT a replacement for watching the actual tutorial they were based on. These are just my personal notes and examples based on the 21-episode tutorial series (see below for more details).

Installation of the TypeScript Compiler

  1. After NodeJS is installed, run npm install -g typescript

To Transpile TypeScript (.ts) to JavaScript (.js)

  1. Open a terminal
  2. Run tsc {INPUT_FILE} [{OUTPUT_FILE}]
  • Example: tsc sandbox.ts sandbox.js
  • NOTE: If the {OUTPUT_FILE} arg is omitted, the output file will be the same name as the {INPUT_FILE}, but with a .js file extension.

Fast Iteration with File-Watching for (.ts) Changes

If you're making frequent edits to your TypeScript files, and want them quickly compiled each time you save, you can pass in -w to the tsc (TypeScript Compiler)! Once finished, you can easily break out (Ctrl + C).

Support for Project Structure and Compiling

If you're using a folder structure (such as public/ and src/), and don't wish to enter a ton of commands to compile every .ts (TypeScript) file, and then manually drag them into the corresponding folders, use the following:

  1. Open a terminal
  2. Navigate (cd) into your project's root folder
  3. Run tsc --init to generate the starting tsconfig.json file
  4. Open the new tsconfig.json file
  5. Set rootDir to ./src (for example)
  6. Set outDir to ./public (for example)
  7. Add "include": ["src"] so that it ignores anything OUTSIDE of the src folder
  8. Now, run tsc (or tsc -w) and your files should automatically be done from the src to public directories

Resources

I am following a tutorial series of 21 episodes from here.

Their repository example can be found here.

Other

learning-typescript's People

Contributors

lunar2kps avatar

Watchers

James Cloos avatar  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.