TypeScript Intro

Github

Docs

What's Typescript?

  • Typed Super set of javascript.So always compatible with modern javascript standards.

  • Open source, developed by Microsoft.

  • Works with Babel (Compile TS to Modern JS & let babel handle Modern JS to targeted browser JS).

Why Typescript?

  • Strongly typed & optional, so renaming/refactoring code becomes easier. Compile time errors caught instead of run time

  • Front end frameworks like AngularJS, Aurelia, VueJS are built on Typescript. Also React, NativeScript supports Typescript

  • Back end frameworks like Deno built on Typescript.

  • Larger audience (Java, Dotnet people) can easily work on it.

  • Better tooling like intellisense, typescript debugging (uses source map concept)(with vscode).

  • Extra OOPS features like namespaces, interfaces, access modifiers, abstract, readonly properties, getter-setter.

Important links

Note: In TS docs - keep checking what's new in latest versions

Other points

  • Use import types, export types (typescript 3.8 + ) //don't mix them with regular imports

  • With in ts -> ts no check ..etc has been introduced

  • ESNext has (#)Private class fields //check it docs, can i use

  • Use JSDoc/ ts doc for description, example ..etc

  • Can't we use getter, setters for dynamic types (setting it converts to particular type, getting just returns) //so no explicit parseInt, date formatting..etc

  • Can Date type/ array..etc inherit our wrapper classes , so that arrayItem.sort can come, dateObj.isValid ..etc