Skip to content

Latest commit

 

History

History
38 lines (28 loc) · 1.08 KB

File metadata and controls

38 lines (28 loc) · 1.08 KB

TypeScript

TypeScript does two things:

  • It adds a C#-like type system with interfaces, classes, et cetera.
  • It converts new JS features into code compatable with older browsers.

TypeScript has a lot of support in the React community, and is a great tool if your JavaScript must run in Internet Explorer.

Example Project

Inside of this repo is a folder with an example project that uses TypeScript.

$ cd transpiling/typescript
$ npm install

Notice the tsconfig.json file. This the easiest way to tell TypeScript how you want your code converted.

{
  "compileOnSave": true,
  "compilerOptions": {
    "outDir": "./dist",
    "target": "ES3",
    "module": "CommonJS"
  }
}

The target is what version of JavaScript the code must work with. Building will create the output files.

$ npx tsc

tsc looks for a tsconfig.json file to use automatically.

TypeScript's website has is great reference for the new language features and how to integrate with text editors and IDEs.