SlideShare a Scribd company logo
TypeScript
Hello!
I am Hiten Pratap Singh
I am here because I love to dive into new
interesting things.
You can find me at:
https://github.com/hitenpratap/
https://hprog99.wordpress.com/
hiten@nexthoughts.com
Agenda
▷ Introduction
▷ Installation
▷ Why TypeScript?
▷ Features
▷ Comparison With TypeScript Alternatives
▷ Who Uses TypeScript?
▷ Conclusion
1.
Introduction
JavaScript that scales.
“TypeScript lets you write JavaScript the way
you really want to.
TypeScript is a typed superset of JavaScript
that compiles to plain JavaScript.
Any browser. Any host. Any OS. Open Source.
Overview
▷ Syntax based on ECMAScript 4 &
ECMASCript 6 proposals
▷ TS is first and foremost a superset of JS
▷ Any regular Javascript is valid TypeScript
Code
“Microsoft's TypeScript may be the best of the
many JavaScript front ends. It seems to
generate the most attractive code.”
- Douglas Crockford
"CoffeeScript is to Ruby as TypeScript is to
Java/C#/C++."
- Luke Hoban
2.
Installation
How to get it setup?
How To Install
For more details check: https://www.typescriptlang.org/docs/tutorial.html
Via npm (the Node.js package manager)
By installing TypeScript’s Visual Studio plugins
Just download any appropriate Visual Studio from Microsoft site and you are all set to go.
You can also try Visual Studio Code IDE from https://code.visualstudio.com/ which is free, open
source and available for multi-platform.
3.
Why TypeScript?
Why everyone is using it more and more.
Main Goals of TypeScript
▷ Provide an optional type system for
JavaScript.
▷ Provide planned features from future
JavaScript editions to current JavaScript
engines
▷ Modular Development
4.
Features
What makes TypeScript super awesome
TypeScript Features
▷ Data Types Supported
▷ Optional Static Type Annotation
▷ Classes
▷ Interface
▷ Modules
▷ Arrow Expressions
▷ Type Assertions
▷ Ambient Declarations
▷ Source File Dependencies
Data Types
▷ Any
▷ Primitive
- Number
- Boolean
- String
- Void
- Null
- Undefined - Same as JS
▷ Array
▷ Enum
Any is used when it’s impossible to determine the type
Any
▷ Doesn’t have separate integers and float/double type. These all are
floating point values and get the type ‘number’
▷ boolean - true/false value
▷ string - both single/double quote can be used
▷ No separate char type
▷ void - is used in function type returning nothing
▷ null and undefined - functions as usual
Primitive
Array
By default, enums begin numbering their members starting at 0. You can
change this by manually setting the value of one its members.
Enum
Optional Types
Type Annotations/Checking
JavaScript
TypeScript
Type Inference
▷ TypeScript tries to infer types
▷ Four ways to variable declaration -
- Type and Value in one statement
- Type but no Value then Value will be undefined
- Value but on Type then the it will be of Any type but maybe be
inferred based on its value.
- Neither Value nor Type then Type will be Any and Value will
be undefined.
Classes
▷ Can implement interfaces
▷ Inheritance
▷ Instance methods/members
▷ Static methods/members
▷ Single constructor
▷ Default/Optional parameter
▷ ES6 class syntax
TypeScript Classes
TypeScript Classes Example
Inheritances
▷ Declared using interface keyword
▷ Like other TS features it’s design time features i.e. no extra code
would be emitted to resultant JS file
▷ Errors being shown when interface signature and implementation
doesn’t match.
TypeScript Interfaces
TypeScript Interfaces
Example
Modules
▷ Modules can be defined using module keyword
▷ A module can contains sub-modules, class, enums or interfaces. But
can’t directly contains functions.
▷ Modules can be nested(sub-modules).
▷ Classes and Interfaces can be exposed using export keyword.
TypeScript Modules
TypeScript Modules Example
Arrow Expressions
▷ Implicit return
▷ No braces for single expression
▷ Part of ES6
▷ Lexically scoped this
▷ You don't need to keep typing function
▷ It lexically captures the meaning of arguments
Arrow Expressions
Arrow Expressions Example
Type Assertions
TypeScript's type assertion are purely you telling the
compiler that you know about the types better than it
does, and that it should not second guess you.
Type Assertions
Type Assertions Example
Ambient Declarations
A major design goal of TypeScript was to make it
possible for you to safely and easily use existing
JavaScript libraries in TypeScript. TypeScript does this
by means of declaration.
Ambient Declarations
Source File Dependencies
▷ Can be done using reference keyword
▷ Must be the first statement of file
▷ Paths are relative to the current file
▷ Can also be done using tsconfig file
Source File Dependencies
Source File Dependencies Example
5.
Comparison with TS
Alternative
▷ Complete language + Runtime overhaul
▷ More features: generators, comprehensions, object literals etc
▷ Will take years before widely deployed
▷ No typing as of now(Maybe ES7)
TypeScript VS ES6 Harmony
▷ Also a superset to JavaScript
▷ More syntactic sugar, still dynamically typed
▷ Unlike TypeScript, JS is not valid CoffeeScript code
▷ It doesn’t track ECMAScript 6
TypeScript VS CoffeeScript
▷ Optionally typed
▷ A native VM
▷ Operator overloading
▷ ECMAScript Dart spec
▷ Completely different syntax and semantics than JS
TypeScript VS DART
6.
Who Uses TypeScript?
Companies use TypeScript
7.
Conclusion
Pros:
▷ High value, low cost improvement over JavaScript
▷ Safer and more modular
▷ Solid path to ECMAScript 6
Cons:
▷ Still need to know some JS quirks
▷ Current compiler slowish(Faster one is in development)
Conclusion
Thanks!
Any questions?
You can find me at:
https://github.com/hitenpratap/
https://hprog99.wordpress.com/
hiten@nexthoughts.com
References
▷ https://www.typescriptlang.org/docs/tutorial.html
▷ https://learnxinyminutes.com/docs/typescript/
▷ https://basarat.gitbooks.io/typescript/content/
▷ http://www.slideshare.net/SanderMak/typescript-coding-javascript-
without-the-pain
▷ http://www.slideshare.net/aniruddha.chakrabarti/typescript-44668095

More Related Content

PPTX
Typescript ppt
PDF
TypeScript
PPTX
TypeScript Overview
PDF
TypeScript: coding JavaScript without the pain
PPT
TypeScript Presentation
PPTX
Typescript Fundamentals
PPTX
Typescript in 30mins
PDF
TypeScript Introduction
Typescript ppt
TypeScript
TypeScript Overview
TypeScript: coding JavaScript without the pain
TypeScript Presentation
Typescript Fundamentals
Typescript in 30mins
TypeScript Introduction

What's hot (20)

PPTX
Introducing type script
PPTX
Why TypeScript?
PPTX
Introduction to React JS for beginners
PDF
ES6 presentation
PPTX
2. Classes | Object Oriented Programming in JavaScript | ES6 | JavaScript
PDF
Angular - Chapter 4 - Data and Event Handling
PPTX
TypeScript: Basic Features and Compilation Guide
PDF
JavaScript Promises
PPTX
Reactjs
PPTX
What is component in reactjs
PPTX
PDF
Intro to Asynchronous Javascript
PPTX
Getting started with typescript
PDF
TypeScript Best Practices
PPTX
Python/Flask Presentation
PPTX
[Final] ReactJS presentation
PDF
Angular & RXJS: examples and use cases
PPTX
Introduction to React JS for beginners | Namespace IT
PDF
Java 8 features
PDF
REST APIs with Spring
Introducing type script
Why TypeScript?
Introduction to React JS for beginners
ES6 presentation
2. Classes | Object Oriented Programming in JavaScript | ES6 | JavaScript
Angular - Chapter 4 - Data and Event Handling
TypeScript: Basic Features and Compilation Guide
JavaScript Promises
Reactjs
What is component in reactjs
Intro to Asynchronous Javascript
Getting started with typescript
TypeScript Best Practices
Python/Flask Presentation
[Final] ReactJS presentation
Angular & RXJS: examples and use cases
Introduction to React JS for beginners | Namespace IT
Java 8 features
REST APIs with Spring
Ad

Viewers also liked (17)

PDF
Power Leveling your TypeScript
PPTX
Typescript
PDF
«Typescript: кому нужна строгая типизация?», Григорий Петров, MoscowJS 21
PPTX
TypeScript - Silver Bullet for the Full-stack Developers
PPTX
002. Introducere in type script
PPTX
PDF
TypeScript: Angular's Secret Weapon
PDF
TypeScript for Java Developers
PDF
Александр Русаков - TypeScript 2 in action
PDF
Typescript + Graphql = <3
PPTX
TypeScript
PDF
Angular 2 - Typescript
PDF
TypeScript: особенности разработки / Александр Майоров (Tutu.ru)
PDF
TypeScript: Un lenguaje aburrido para programadores torpes y tristes
PPTX
Typescript tips & tricks
PDF
TypeScript Seminar
PDF
TypeScriptで快適javascript
Power Leveling your TypeScript
Typescript
«Typescript: кому нужна строгая типизация?», Григорий Петров, MoscowJS 21
TypeScript - Silver Bullet for the Full-stack Developers
002. Introducere in type script
TypeScript: Angular's Secret Weapon
TypeScript for Java Developers
Александр Русаков - TypeScript 2 in action
Typescript + Graphql = <3
TypeScript
Angular 2 - Typescript
TypeScript: особенности разработки / Александр Майоров (Tutu.ru)
TypeScript: Un lenguaje aburrido para programadores torpes y tristes
Typescript tips & tricks
TypeScript Seminar
TypeScriptで快適javascript
Ad

Similar to TypeScript - An Introduction (20)

PDF
TypeScript introduction to scalable javascript application
PDF
Introduction to TypeScript
PDF
Reasons to Use Typescript for Your Next Project Over Javascript.pdf
PPTX
typescript.pptx
PDF
TypeScript Interview Questions PDF By ScholarHat
PDF
TYPESCRIPT.pdfgshshhsjajajsjsjjsjajajjajjj
PPTX
TypeScript intro
PPTX
Why do we need TypeScript?
PPTX
Type script
PPTX
Complete Notes on Angular 2 and TypeScript
PDF
An Introduction to TypeScript
PPTX
Typescript: Beginner to Advanced
PDF
Type script
PPTX
TypeScript Introduction
PDF
Typescript for the programmers who like javascript
DOC
Typescript Basics
PPTX
Type script - advanced usage and practices
PDF
TypeScipt - Get Started
PPTX
TypeScript 101
PPTX
11_typescript.pptx for north south university course cse425
TypeScript introduction to scalable javascript application
Introduction to TypeScript
Reasons to Use Typescript for Your Next Project Over Javascript.pdf
typescript.pptx
TypeScript Interview Questions PDF By ScholarHat
TYPESCRIPT.pdfgshshhsjajajsjsjjsjajajjajjj
TypeScript intro
Why do we need TypeScript?
Type script
Complete Notes on Angular 2 and TypeScript
An Introduction to TypeScript
Typescript: Beginner to Advanced
Type script
TypeScript Introduction
Typescript for the programmers who like javascript
Typescript Basics
Type script - advanced usage and practices
TypeScipt - Get Started
TypeScript 101
11_typescript.pptx for north south university course cse425

More from NexThoughts Technologies (20)

PDF
PDF
Docker & kubernetes
PDF
Apache commons
PDF
Microservice Architecture using Spring Boot with React & Redux
PDF
Solid Principles
PDF
Smart Contract samples
PDF
My Doc of geth
PDF
Geth important commands
PDF
Ethereum genesis
PPTX
Springboot Microservices
PDF
An Introduction to Redux
PPTX
Google authentication
ODP
Java 9 Features
Docker & kubernetes
Apache commons
Microservice Architecture using Spring Boot with React & Redux
Solid Principles
Smart Contract samples
My Doc of geth
Geth important commands
Ethereum genesis
Springboot Microservices
An Introduction to Redux
Google authentication
Java 9 Features

Recently uploaded (20)

PPTX
MYSQL Presentation for SQL database connectivity
PDF
Building Integrated photovoltaic BIPV_UPV.pdf
PPT
“AI and Expert System Decision Support & Business Intelligence Systems”
PDF
Chapter 3 Spatial Domain Image Processing.pdf
PPTX
sap open course for s4hana steps from ECC to s4
PDF
Diabetes mellitus diagnosis method based random forest with bat algorithm
PDF
Encapsulation_ Review paper, used for researhc scholars
PPTX
A Presentation on Artificial Intelligence
PPT
Teaching material agriculture food technology
PDF
Advanced methodologies resolving dimensionality complications for autism neur...
PDF
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
PDF
Agricultural_Statistics_at_a_Glance_2022_0.pdf
PDF
Dropbox Q2 2025 Financial Results & Investor Presentation
PDF
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
PDF
NewMind AI Weekly Chronicles - August'25-Week II
PDF
Per capita expenditure prediction using model stacking based on satellite ima...
PDF
Profit Center Accounting in SAP S/4HANA, S4F28 Col11
PDF
Reach Out and Touch Someone: Haptics and Empathic Computing
PDF
Network Security Unit 5.pdf for BCA BBA.
PDF
Encapsulation theory and applications.pdf
MYSQL Presentation for SQL database connectivity
Building Integrated photovoltaic BIPV_UPV.pdf
“AI and Expert System Decision Support & Business Intelligence Systems”
Chapter 3 Spatial Domain Image Processing.pdf
sap open course for s4hana steps from ECC to s4
Diabetes mellitus diagnosis method based random forest with bat algorithm
Encapsulation_ Review paper, used for researhc scholars
A Presentation on Artificial Intelligence
Teaching material agriculture food technology
Advanced methodologies resolving dimensionality complications for autism neur...
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
Agricultural_Statistics_at_a_Glance_2022_0.pdf
Dropbox Q2 2025 Financial Results & Investor Presentation
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
NewMind AI Weekly Chronicles - August'25-Week II
Per capita expenditure prediction using model stacking based on satellite ima...
Profit Center Accounting in SAP S/4HANA, S4F28 Col11
Reach Out and Touch Someone: Haptics and Empathic Computing
Network Security Unit 5.pdf for BCA BBA.
Encapsulation theory and applications.pdf

TypeScript - An Introduction