TypeScript
JavaScript that scales
HELLO!
I am Hiten Pratap Singh
https://github.com/hitenpratap/
https://hprog99.wordpress.com/
hiten@fintechlabs.in
https://hitenpratap.github.io
Get Started
npm install -g typescript
Or
brew install typescript
then
tsc HelloWorld.ts
1.
Why TypeScript?
Why to use another client side
language!
Why TypeScript?
› Slow iteration of new features by JavaScript
› Many more features than defined in ECMAScript
› Very fast adoption rate so rowing community
2.
What is TypeScript?
What makes it stand out!
“TypeScript is a strongly-typed
superset of JavaScript, which
means it adds some syntactical
benefits to the language while
still letting you write normal
JavaScript if you want to”
What is TypeScript?
› Starts with JavaScript and ends with JavaScript.
TypeScript is JavaScript.
› Run on any browser, any host, any OS.
› Open source project under Apache License 2.0.
› Adds numerous additional features like Class, Module
etc.
› Developed by Anders Hejlsberg, who also created C#
and Delphi.
› Heavily influenced by ES6.
3.
TypeScript Basic
Types
TypeScript Basic Types
› Boolean
› Number
› String
› Array
› Tuple
› Enum
› Any
› Void
› Null
› Undefined
4.
TypeScript
Annotation
TypeScript Annotation
› var[identifier]:[type annotation] = value;
› var[identifier]:[type annotation];
› var[identifier] = value;
5.
TypeScript Functions
TypeScript Functions
› Optional parameter using ?
› Default parameter using =value
› Rest parameter using ...
› Overloads
› Arrow Functions
6.
TypeScript Interfaces
TypeScript Interfaces
› Used at design time to provide auto completion and compile
time checking
› Optional Properties
› Function Types
› Indexable Types
› Class Types
› Extending Interfaces
› Hybrid Types
7.
TypeScript Classes
TypeScript Classes
› Object Oriented Approach
› Inheritance
› Public, private, and protected modifiers
› Accessors
› Static Properties
› Abstract Class
8.
TypeScript Generics
TypeScript Generics
› Generics Types
› Generics Class
› Generics Constraints
9.
TypeScript Modules
TypeScript Modules
› Encapsulates variables, classes and interfaces.
› Splitting across files.
› One file can contain multiple modules.
› Can be defined as internal or external.
› Can define Alias to Module.
10.
Advanced Reading
Advanced Reading
› Type Interface
› Type Compatibility
› Advanced Types
› Symbols
› Iterators & Generators
› Namespaces
› Namespaces & Modules
› Module Resolution
contd...
Advanced Reading
› Declaration Merging
› JSX
› Decorators
› Mixins
› Triple-Slash Directives
› Type Checking JavaScript Files
11.
TypeScript Compile
TypeScript Compile
.ts compile .js
12.
Companies using
TypeScript
13.
Alternatives
THANKS!
Any questions?
https://github.com/hitenpratap
https://hprog99.wordpress.com
hiten@fintechlabs.in
https://hitenpratap.github.io
References
› https://www.wakefly.com/blog/what-is-typescript-and-why-should-you-use-it/
› https://www.sitepoint.com/introduction-to-typescript/
› https://basarat.gitbooks.io/typescript/
› http://www.typescriptlang.org/docs/home.html
› https://tutorialzine.com/2016/07/learn-typescript-in-30-minutes
› https://medium.com/angularmedellin/a-brief-introduction-to-typescript-part-1-ce
edb3e9b1c0
› https://matthewhorne.me/setup-typescript-project/

Introduction to TypeScript