Typescript basics
High level: Typescript is essentially a layer on top of javascript that will help organize some of the code, generates the Javascript for you.
Usually used to organize large javascript applications.
Alternatives to this could be writing clean patterned javascript.
There are also some other types of libraries that help with this type of organized structure such as coffee script out there.
typescript is built in Javascript and is a superset of javascript. Is a compiler. So saving the .ts file should compile the file. This should output the regular javascript.
Some Typescript Features:
- Works in any browser.
- Works on Any host.
- Works with node.js.
- Works on any operating system.
- Open Source.
- Tool support; can catch errors, and help with many other functions
- Works with IDE's such as sublime and visual studio, Intellisense and syntax checking
- Supports standard javascript code
- Provides static typing
- Encapsulates through classes and modules
- Support for constructors, properties, and functions
Keywords and operators
- class: contains for properties and functions
- constructor: providies initialization functionality in a class
- exports: export a member from a module
- extends: extend a class
- implements: implement an interface
- imports: import a module
- interface: defines code contract that can be implemented by types
- module / namespace: container for classes and other code
- public / private: member visibility modifiers
- ...: rest parameter, pass a comma separated list of items
- => : arraow syntax used with definitions and functions
- typeName: characters used to cast / convert between types
- ":" : separator between variable / parameter names and types
Code Hierarchy
Modules / Namespace -> will contain Class -> classes can have fields, constructors, properties, functions