SlideShare uma empresa Scribd logo
1 de 52
Aniruddha Chakrabarti
Sr. Principal Architect & Sr. Manager, Accenture
caniruddha@hotmail.com | in.linkedin.com/in/aniruddhac
Context
• Writing large applications in JavaScript is difficult, not originally designed
for large complex applications (mostly a scripting language, with
functional programming constructs)
• Lacks structuring mechanisms like Class, Module, Interface
TypeScript is a language for application scale JavaScript
development.
TypeScript is a typed superset of JavaScript that compiles to
plan JavaScript.
TypeScript adds Static Typing and structuring (class, module) to JavaScript.
Fix/Improve JavaScript – different approaches
1. Through Library and Frameworks
– jQuery, AngularJS, Knockout, Ext JS, Bootstrap …. (new libraries are being
created and getting popular everyday)
2. New language that extend/improve language features of JavaScript.
Superset of JavaScript. Compiles to JavaScript
– CoffeeScript, TypeScript
3. Entirely new language with many new features that compile to
JavaScript
– GWT (Google Web Toolkit), Dart
https://github.com/jashkenas/coffeescript/wiki/list-of-languages-that-compile-to-js
What is TypeScript
• Helps in large scale JavaScript application development.
• Adds additional features like Static Type (optional), Class, Module etc
(that are not present in JavaScript) to JavaScript
• Starts with JavaScript, ends with JavaScript. TypeScipt is JavaScript. Any
valid .js file can be renamed .ts and compiled with other TypeScript files.
• Runs on Any browser, Any host, Any OS.
• Open Source
– The compiler is an open source project and released under the Apache 2.0
license.
• TypeScript purposefully borrows ideas from EcmaScript 6 (ES6 Harmony)
spec – class, module
Bit of History
• Typescript was first made public in October 2012 (at version 0.8), after
two years of internal development at Microsoft.
• TypeScript 0.9, released in 2013, added support for generics
• TypeScript 1.0 was released at Build 2014. Visual Studio 2013 Update 2
provides built-in support for TypeScript.
• In July 2014, the development team announced a new TypeScript
compiler, claiming 5x performance gains.
– Source code, which was initially hosted on Codeplex, was moved to GitHub
Features
• Optional Static Type Annotation / Static Typing
• Additional Features for Functions
– Types for function parameters and return type, optional and default parameter, rest
parameter, overloading
• Class
– Field, Property, Method, Constructor, Event, Static methods, Inheritance
• Interface
• Module
• Generics
• Declaration Merging
• Few other features (Enum) …
• TypeScript comes with
– TypeScript Compiler (tsc)
– TypeScript Language Service (TLS) / Visual Studio extension
– Playground (http://www.typescriptlang.org/)
– Declaration files (*.d.ts) for DOM, jQuery, node.js …
– Language Spec (1.0) and code examples
Types / Optional Type
Annotation
Optional Type Annotation
• TypeScript allows annotating variables with types
• Purely a design time feature. No additional code is emitted in the final
JavaScript that TypeScript compiler produces.
• If there’s a type mismatch TypeScript shows a warning.
Types / Optional Type Annotation
• Optional Static Types
– Any
– Primitive
• Number
• Boolean
• String
• Void
• Null
• Undefined -> same as JavaScript “undefined” type
– Array
– Enum
Datatypes
• Does not have separate integer and float/double type
• All numbers in TypeScript are floating point values. These floating
point numbers get the type 'number'.
var x:number = 55
var y:number = 123.4567
• boolean – true/false value
var hasPassport:boolean = true // or false
• string - Both single quote or double quote could be used
var msg1 = 'hello from TypeScript'
var msg2 = "hello from TypeScript"
• No separate char type
var character = 'a'
Optional Type Annotation
• TypeScript tries to infer type
Type Inference
• TypeScript tries to infer type
• Four ways of variable declaration -
1. Declare its type and value (as a literal) in one statement.
2. Declare its type but no value. The value will be set to undefined.
3. Declare its value but no type. The variable will be of type Any (that is, an old-school
dynamic JavaScript variable), but its type may be inferred based on its value.
4. Declare neither value nor type. The variable will be of type Any, and its value will be
undefined.
Array
var cities:string[] = ["Berlin","Bangalore","New York"]
var primes:number[] = [1,3,5,7,11,13]
var bools:boolean[] = [true,false,false,true]
Enum
• Addition to JavaScript datatypes. Similar to C# enum
• Like languages like C#, an enum is a way of giving more friendly
names to sets of numeric values.
• By default, enums begin numbering their members starting at 0. You
can change this by manually setting the value of one its members.
Any
• Useful to describe the type of variables that we may not know when
we are writing the application.
• May come from dynamic content, eg from the user or 3rd party
library.
• Allows to opt-out of type-checking and let the values pass through
compile-time checks.
• Same as not declaring any datatype – uses JavaScript’s dynamic nature
var notSure: any
var list:any[] = [1, true, "free"]
list[1] = 100
Void
• Perhaps the opposite in some ways to 'any' is 'void',
• the absence of having any type at all.
• Commonly used as the return type of functions that do not return a
value
function warnUser(): void {
alert("This is my warning message");
}
Function
Function Overview
• Functions are the fundamental building block of any applications in
JavaScript.
• JavaScript is a functional programming language, and so supports first
class functions.
• Allows build up layers of abstraction, mimicking classes, information
hiding, and modules (JavaScript does not support class, module,
private members).
• In TypeScript, while there are classes and modules, function still play
the key role in describing how to 'do' things.
• TypeScript adds some new capabilities to the standard JavaScript
functions to make them easier to work with.
– Type Annotation for parameter and return type
– Optional and Default Parameter
– Rest Parameter
– Function Overloads
Function
• Allows parameter and return type annotation
Function (2)
• Shows warning for type mismatch
Function Overloads
• Allows function overloads
Function Overloads (2)
Optional & Default Parameter
• Optional Parameters should have default value that would be used if
the value is not specified while invoking the function
• Should be the last arguments in a function
Optional Parameter Implementation
• Optional Parameters should have the default value that would be used
if the value is not specified while calling the function
Rest Parameter
• Declared as … paramName:[paramType]
Class
Class
• Properties and fields to store data
• Methods to define behavior
• Events to provide interactions between different objects and classes
Field and Property
Method and Constructor
Constructor
• Uses constructor keyword
• public by default, can not be private
Constructor shortcut
Events
Access Modifiers
• public (default) - member is available to all code in another module.
• private - member is available only to other code in the same assembly.
Static Methods
• TypeScript supports static members (methods)
• static methods are visible on the class itself rather than on the instances
Class
JavaScript Constructor Pattern
JavaScript Constructor Pattern (2)
Class – TypeScript uses same
Constructor Pattern
Inheritance
• TypeScript supports inheritance of class through extends keyword
Module
Module
• Modules can be defines using module keyword
• A module can contain sub module, class, interface or enum. Can not
directly contain functions (similar to C#, Java)
• Modules can be nested (sub module)
• Class, Interfaces can be exposed using export keyword
Interface
Interface
• Declared using interface keyword
• Like many other TypeScript feature it’s purely a Design time feature.
No additional code is emitted for this!
• TS compiler shows error when Interface signature and implementation
does not match
Interface (Cont’d)
Optional Property
• Optional properties can be declared for an interface (using ?)
• Optional properties need not be implemented
Interface
Mixin
Mixin
• Along with traditional OO hierarchies, another popular way of building
up classes from reusable components is to build them by combining
simpler partial classes – called Mixin
• Several languages support Mixin (e.g. Trait in PHP and Scala).
• This pattern in popular in JavaScript community, so TypeScript
provides language support.
In object-oriented programming languages, a mixin is a class
which contains a combination of methods from other classes.
Mixin - Wikipedia, the free encyclopedia
Mixins Person
Employee
ManagerProgrammer
Mixins (Cont’d)
Mixins (Cont’d)
JavaScript gochas (not fixed in TS)
• TypeScript does not introduce block scope (JavaScript only supports
function scope)
• ; is still optional in TypeScript also (; is not mandatory in JavaScript and
it tries to infer ; and sometime does it differently than expected)
• == vs === (and != vs !==)
== checks for value equality only
=== checks for both type and value equality
• global variables (variables declared outside of function), implied global
(variables declared within function without var keyword)
• issues with floating point (.1 + .2 != .3, it’s something like .3000…00004)

Mais conteúdo relacionado

Mais procurados

Typescript in 30mins
Typescript in 30mins Typescript in 30mins
Typescript in 30mins Udaya Kumar
 
TypeScript: coding JavaScript without the pain
TypeScript: coding JavaScript without the painTypeScript: coding JavaScript without the pain
TypeScript: coding JavaScript without the painSander Mak (@Sander_Mak)
 
TypeScript: Basic Features and Compilation Guide
TypeScript: Basic Features and Compilation GuideTypeScript: Basic Features and Compilation Guide
TypeScript: Basic Features and Compilation GuideNascenia IT
 
Unit 1 - TypeScript & Introduction to Angular CLI.pptx
Unit 1 - TypeScript & Introduction to Angular CLI.pptxUnit 1 - TypeScript & Introduction to Angular CLI.pptx
Unit 1 - TypeScript & Introduction to Angular CLI.pptxMalla Reddy University
 
TypeScript Best Practices
TypeScript Best PracticesTypeScript Best Practices
TypeScript Best Practicesfelixbillon
 
Angular 4 and TypeScript
Angular 4 and TypeScriptAngular 4 and TypeScript
Angular 4 and TypeScriptAhmed El-Kady
 
Angular & RXJS: examples and use cases
Angular & RXJS: examples and use casesAngular & RXJS: examples and use cases
Angular & RXJS: examples and use casesFabio Biondi
 
TypeScript Seminar
TypeScript SeminarTypeScript Seminar
TypeScript SeminarHaim Michael
 
Angular - Chapter 4 - Data and Event Handling
 Angular - Chapter 4 - Data and Event Handling Angular - Chapter 4 - Data and Event Handling
Angular - Chapter 4 - Data and Event HandlingWebStackAcademy
 
Java 8 Stream API. A different way to process collections.
Java 8 Stream API. A different way to process collections.Java 8 Stream API. A different way to process collections.
Java 8 Stream API. A different way to process collections.David Gómez García
 
Type script - advanced usage and practices
Type script  - advanced usage and practicesType script  - advanced usage and practices
Type script - advanced usage and practicesIwan van der Kleijn
 

Mais procurados (20)

Typescript in 30mins
Typescript in 30mins Typescript in 30mins
Typescript in 30mins
 
TypeScript
TypeScriptTypeScript
TypeScript
 
TypeScript: coding JavaScript without the pain
TypeScript: coding JavaScript without the painTypeScript: coding JavaScript without the pain
TypeScript: coding JavaScript without the pain
 
TypeScript
TypeScriptTypeScript
TypeScript
 
TypeScript: Basic Features and Compilation Guide
TypeScript: Basic Features and Compilation GuideTypeScript: Basic Features and Compilation Guide
TypeScript: Basic Features and Compilation Guide
 
Unit 1 - TypeScript & Introduction to Angular CLI.pptx
Unit 1 - TypeScript & Introduction to Angular CLI.pptxUnit 1 - TypeScript & Introduction to Angular CLI.pptx
Unit 1 - TypeScript & Introduction to Angular CLI.pptx
 
TypeScript intro
TypeScript introTypeScript intro
TypeScript intro
 
Angular Data Binding
Angular Data BindingAngular Data Binding
Angular Data Binding
 
Angular 2
Angular 2Angular 2
Angular 2
 
TypeScript Best Practices
TypeScript Best PracticesTypeScript Best Practices
TypeScript Best Practices
 
Angular 4 and TypeScript
Angular 4 and TypeScriptAngular 4 and TypeScript
Angular 4 and TypeScript
 
Angular & RXJS: examples and use cases
Angular & RXJS: examples and use casesAngular & RXJS: examples and use cases
Angular & RXJS: examples and use cases
 
Angular Observables & RxJS Introduction
Angular Observables & RxJS IntroductionAngular Observables & RxJS Introduction
Angular Observables & RxJS Introduction
 
TypeScript Seminar
TypeScript SeminarTypeScript Seminar
TypeScript Seminar
 
Angular - Chapter 4 - Data and Event Handling
 Angular - Chapter 4 - Data and Event Handling Angular - Chapter 4 - Data and Event Handling
Angular - Chapter 4 - Data and Event Handling
 
Java 8 Stream API. A different way to process collections.
Java 8 Stream API. A different way to process collections.Java 8 Stream API. A different way to process collections.
Java 8 Stream API. A different way to process collections.
 
Learning typescript
Learning typescriptLearning typescript
Learning typescript
 
Angular modules in depth
Angular modules in depthAngular modules in depth
Angular modules in depth
 
Angular
AngularAngular
Angular
 
Type script - advanced usage and practices
Type script  - advanced usage and practicesType script  - advanced usage and practices
Type script - advanced usage and practices
 

Destaque

Angular 2 - Typescript
Angular 2  - TypescriptAngular 2  - Typescript
Angular 2 - TypescriptNathan Krasney
 
Power Leveling your TypeScript
Power Leveling your TypeScriptPower Leveling your TypeScript
Power Leveling your TypeScriptOffirmo
 
Typescript tips & tricks
Typescript tips & tricksTypescript tips & tricks
Typescript tips & tricksOri Calvo
 
TypeScript: Un lenguaje aburrido para programadores torpes y tristes
TypeScript: Un lenguaje aburrido para programadores torpes y tristesTypeScript: Un lenguaje aburrido para programadores torpes y tristes
TypeScript: Un lenguaje aburrido para programadores torpes y tristesMicael Gallego
 
TypeScript: особенности разработки / Александр Майоров (Tutu.ru)
TypeScript: особенности разработки / Александр Майоров (Tutu.ru)TypeScript: особенности разработки / Александр Майоров (Tutu.ru)
TypeScript: особенности разработки / Александр Майоров (Tutu.ru)Ontico
 
Typescript + Graphql = <3
Typescript + Graphql = <3Typescript + Graphql = <3
Typescript + Graphql = <3felixbillon
 
TypeScript - Silver Bullet for the Full-stack Developers
TypeScript - Silver Bullet for the Full-stack DevelopersTypeScript - Silver Bullet for the Full-stack Developers
TypeScript - Silver Bullet for the Full-stack DevelopersRutenis Turcinas
 
002. Introducere in type script
002. Introducere in type script002. Introducere in type script
002. Introducere in type scriptDmitrii Stoian
 
TypeScript: Angular's Secret Weapon
TypeScript: Angular's Secret WeaponTypeScript: Angular's Secret Weapon
TypeScript: Angular's Secret WeaponLaurent Duveau
 
Александр Русаков - TypeScript 2 in action
Александр Русаков - TypeScript 2 in actionАлександр Русаков - TypeScript 2 in action
Александр Русаков - TypeScript 2 in actionMoscowJS
 
«Typescript: кому нужна строгая типизация?», Григорий Петров, MoscowJS 21
«Typescript: кому нужна строгая типизация?», Григорий Петров, MoscowJS 21«Typescript: кому нужна строгая типизация?», Григорий Петров, MoscowJS 21
«Typescript: кому нужна строгая типизация?», Григорий Петров, MoscowJS 21MoscowJS
 
TypeScript for Java Developers
TypeScript for Java DevelopersTypeScript for Java Developers
TypeScript for Java DevelopersYakov Fain
 

Destaque (15)

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

Semelhante a TypeScript Overview

The advantage of developing with TypeScript
The advantage of developing with TypeScript The advantage of developing with TypeScript
The advantage of developing with TypeScript Corley S.r.l.
 
TypeScript . the JavaScript developer best friend!
TypeScript . the JavaScript developer best friend!TypeScript . the JavaScript developer best friend!
TypeScript . the JavaScript developer best friend!Alessandro Giorgetti
 
Angular - Chapter 2 - TypeScript Programming
Angular - Chapter 2 - TypeScript Programming  Angular - Chapter 2 - TypeScript Programming
Angular - Chapter 2 - TypeScript Programming WebStackAcademy
 
Typescript: Beginner to Advanced
Typescript: Beginner to AdvancedTypescript: Beginner to Advanced
Typescript: Beginner to AdvancedTalentica Software
 
Introducing object oriented programming (oop)
Introducing object oriented programming (oop)Introducing object oriented programming (oop)
Introducing object oriented programming (oop)Hemlathadhevi Annadhurai
 
Introduction to JavaScript
Introduction to JavaScriptIntroduction to JavaScript
Introduction to JavaScriptAndres Baravalle
 
Developer’s viewpoint on swift programming language
Developer’s viewpoint on swift programming languageDeveloper’s viewpoint on swift programming language
Developer’s viewpoint on swift programming languageAzilen Technologies Pvt. Ltd.
 
SE-IT JAVA LAB OOP CONCEPT
SE-IT JAVA LAB OOP CONCEPTSE-IT JAVA LAB OOP CONCEPT
SE-IT JAVA LAB OOP CONCEPTnikshaikh786
 
Java-Intro.pptx
Java-Intro.pptxJava-Intro.pptx
Java-Intro.pptxVijalJain3
 
TypeScript Introduction
TypeScript IntroductionTypeScript Introduction
TypeScript IntroductionThanh Tai
 
Python for katana
Python for katanaPython for katana
Python for katanakedar nath
 
Functional Programming In Jdk8
Functional Programming In Jdk8 Functional Programming In Jdk8
Functional Programming In Jdk8 Bansilal Haudakari
 
TypeScript and Angular2 (Love at first sight)
TypeScript and Angular2 (Love at first sight)TypeScript and Angular2 (Love at first sight)
TypeScript and Angular2 (Love at first sight)Igor Talevski
 

Semelhante a TypeScript Overview (20)

TypeScript 101
TypeScript 101TypeScript 101
TypeScript 101
 
The advantage of developing with TypeScript
The advantage of developing with TypeScript The advantage of developing with TypeScript
The advantage of developing with TypeScript
 
AngularConf2015
AngularConf2015AngularConf2015
AngularConf2015
 
TypeScript . the JavaScript developer best friend!
TypeScript . the JavaScript developer best friend!TypeScript . the JavaScript developer best friend!
TypeScript . the JavaScript developer best friend!
 
Angular - Chapter 2 - TypeScript Programming
Angular - Chapter 2 - TypeScript Programming  Angular - Chapter 2 - TypeScript Programming
Angular - Chapter 2 - TypeScript Programming
 
Typescript: Beginner to Advanced
Typescript: Beginner to AdvancedTypescript: Beginner to Advanced
Typescript: Beginner to Advanced
 
Type script
Type scriptType script
Type script
 
Java introduction
Java introductionJava introduction
Java introduction
 
Introducing object oriented programming (oop)
Introducing object oriented programming (oop)Introducing object oriented programming (oop)
Introducing object oriented programming (oop)
 
Memory models in c#
Memory models in c#Memory models in c#
Memory models in c#
 
Introduction to JavaScript
Introduction to JavaScriptIntroduction to JavaScript
Introduction to JavaScript
 
Developer’s viewpoint on swift programming language
Developer’s viewpoint on swift programming languageDeveloper’s viewpoint on swift programming language
Developer’s viewpoint on swift programming language
 
SE-IT JAVA LAB OOP CONCEPT
SE-IT JAVA LAB OOP CONCEPTSE-IT JAVA LAB OOP CONCEPT
SE-IT JAVA LAB OOP CONCEPT
 
Java-Intro.pptx
Java-Intro.pptxJava-Intro.pptx
Java-Intro.pptx
 
TypeScript Introduction
TypeScript IntroductionTypeScript Introduction
TypeScript Introduction
 
Python for katana
Python for katanaPython for katana
Python for katana
 
Scala Days NYC 2016
Scala Days NYC 2016Scala Days NYC 2016
Scala Days NYC 2016
 
Functional Programming In Jdk8
Functional Programming In Jdk8 Functional Programming In Jdk8
Functional Programming In Jdk8
 
C++ Basics
C++ BasicsC++ Basics
C++ Basics
 
TypeScript and Angular2 (Love at first sight)
TypeScript and Angular2 (Love at first sight)TypeScript and Angular2 (Love at first sight)
TypeScript and Angular2 (Love at first sight)
 

Mais de Aniruddha Chakrabarti

Thomas Cook and Accenture expand relationship with 10 year technology consult...
Thomas Cook and Accenture expand relationship with 10 year technology consult...Thomas Cook and Accenture expand relationship with 10 year technology consult...
Thomas Cook and Accenture expand relationship with 10 year technology consult...Aniruddha Chakrabarti
 
NLP using JavaScript Natural Library
NLP using JavaScript Natural LibraryNLP using JavaScript Natural Library
NLP using JavaScript Natural LibraryAniruddha Chakrabarti
 
Golang - Overview of Go (golang) Language
Golang - Overview of Go (golang) LanguageGolang - Overview of Go (golang) Language
Golang - Overview of Go (golang) LanguageAniruddha Chakrabarti
 
Amazon alexa - building custom skills
Amazon alexa - building custom skillsAmazon alexa - building custom skills
Amazon alexa - building custom skillsAniruddha Chakrabarti
 
Using Node-RED for building IoT workflows
Using Node-RED for building IoT workflowsUsing Node-RED for building IoT workflows
Using Node-RED for building IoT workflowsAniruddha Chakrabarti
 
Mphasis Digital - Use Go (gloang) for system programming, distributed systems...
Mphasis Digital - Use Go (gloang) for system programming, distributed systems...Mphasis Digital - Use Go (gloang) for system programming, distributed systems...
Mphasis Digital - Use Go (gloang) for system programming, distributed systems...Aniruddha Chakrabarti
 
Using Swift for all Apple platforms (iOS, watchOS, tvOS and OS X)
Using Swift for all Apple platforms (iOS, watchOS, tvOS and OS X)Using Swift for all Apple platforms (iOS, watchOS, tvOS and OS X)
Using Swift for all Apple platforms (iOS, watchOS, tvOS and OS X)Aniruddha Chakrabarti
 
Future of .NET - .NET on Non Windows Platforms
Future of .NET - .NET on Non Windows PlatformsFuture of .NET - .NET on Non Windows Platforms
Future of .NET - .NET on Non Windows PlatformsAniruddha Chakrabarti
 
Mphasis Digital POV - Emerging Open Standard Protocol stack for IoT
Mphasis Digital POV - Emerging Open Standard Protocol stack for IoTMphasis Digital POV - Emerging Open Standard Protocol stack for IoT
Mphasis Digital POV - Emerging Open Standard Protocol stack for IoTAniruddha Chakrabarti
 

Mais de Aniruddha Chakrabarti (20)

Pinecone Vector Database.pdf
Pinecone Vector Database.pdfPinecone Vector Database.pdf
Pinecone Vector Database.pdf
 
Mphasis-Annual-Report-2018.pdf
Mphasis-Annual-Report-2018.pdfMphasis-Annual-Report-2018.pdf
Mphasis-Annual-Report-2018.pdf
 
Thomas Cook and Accenture expand relationship with 10 year technology consult...
Thomas Cook and Accenture expand relationship with 10 year technology consult...Thomas Cook and Accenture expand relationship with 10 year technology consult...
Thomas Cook and Accenture expand relationship with 10 year technology consult...
 
NLP using JavaScript Natural Library
NLP using JavaScript Natural LibraryNLP using JavaScript Natural Library
NLP using JavaScript Natural Library
 
Dart programming language
Dart programming languageDart programming language
Dart programming language
 
Third era of computing
Third era of computingThird era of computing
Third era of computing
 
Golang - Overview of Go (golang) Language
Golang - Overview of Go (golang) LanguageGolang - Overview of Go (golang) Language
Golang - Overview of Go (golang) Language
 
Amazon alexa - building custom skills
Amazon alexa - building custom skillsAmazon alexa - building custom skills
Amazon alexa - building custom skills
 
Using Node-RED for building IoT workflows
Using Node-RED for building IoT workflowsUsing Node-RED for building IoT workflows
Using Node-RED for building IoT workflows
 
Mphasis Digital - Use Go (gloang) for system programming, distributed systems...
Mphasis Digital - Use Go (gloang) for system programming, distributed systems...Mphasis Digital - Use Go (gloang) for system programming, distributed systems...
Mphasis Digital - Use Go (gloang) for system programming, distributed systems...
 
Using Swift for all Apple platforms (iOS, watchOS, tvOS and OS X)
Using Swift for all Apple platforms (iOS, watchOS, tvOS and OS X)Using Swift for all Apple platforms (iOS, watchOS, tvOS and OS X)
Using Swift for all Apple platforms (iOS, watchOS, tvOS and OS X)
 
Future of .NET - .NET on Non Windows Platforms
Future of .NET - .NET on Non Windows PlatformsFuture of .NET - .NET on Non Windows Platforms
Future of .NET - .NET on Non Windows Platforms
 
CoAP - Web Protocol for IoT
CoAP - Web Protocol for IoTCoAP - Web Protocol for IoT
CoAP - Web Protocol for IoT
 
Groovy Programming Language
Groovy Programming LanguageGroovy Programming Language
Groovy Programming Language
 
Mphasis Digital POV - Emerging Open Standard Protocol stack for IoT
Mphasis Digital POV - Emerging Open Standard Protocol stack for IoTMphasis Digital POV - Emerging Open Standard Protocol stack for IoT
Mphasis Digital POV - Emerging Open Standard Protocol stack for IoT
 
Level DB - Quick Cheat Sheet
Level DB - Quick Cheat SheetLevel DB - Quick Cheat Sheet
Level DB - Quick Cheat Sheet
 
Lisp
LispLisp
Lisp
 
Overview of CoffeeScript
Overview of CoffeeScriptOverview of CoffeeScript
Overview of CoffeeScript
 
memcached Distributed Cache
memcached Distributed Cachememcached Distributed Cache
memcached Distributed Cache
 
Redis and it's data types
Redis and it's data typesRedis and it's data types
Redis and it's data types
 

Último

W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...panagenda
 
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️Delhi Call girls
 
Software Quality Assurance Interview Questions
Software Quality Assurance Interview QuestionsSoftware Quality Assurance Interview Questions
Software Quality Assurance Interview QuestionsArshad QA
 
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdfLearn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdfkalichargn70th171
 
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...ICS
 
AI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
AI Mastery 201: Elevating Your Workflow with Advanced LLM TechniquesAI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
AI Mastery 201: Elevating Your Workflow with Advanced LLM TechniquesVictorSzoltysek
 
The Guide to Integrating Generative AI into Unified Continuous Testing Platfo...
The Guide to Integrating Generative AI into Unified Continuous Testing Platfo...The Guide to Integrating Generative AI into Unified Continuous Testing Platfo...
The Guide to Integrating Generative AI into Unified Continuous Testing Platfo...kalichargn70th171
 
Azure_Native_Qumulo_High_Performance_Compute_Benchmarks.pdf
Azure_Native_Qumulo_High_Performance_Compute_Benchmarks.pdfAzure_Native_Qumulo_High_Performance_Compute_Benchmarks.pdf
Azure_Native_Qumulo_High_Performance_Compute_Benchmarks.pdfryanfarris8
 
Unlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language ModelsUnlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language Modelsaagamshah0812
 
A Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docxA Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docxComplianceQuest1
 
5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdf5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdfWave PLM
 
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time ApplicationsUnveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time ApplicationsAlberto González Trastoy
 
TECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providerTECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providermohitmore19
 
The Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdfThe Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdfkalichargn70th171
 
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...harshavardhanraghave
 
Diamond Application Development Crafting Solutions with Precision
Diamond Application Development Crafting Solutions with PrecisionDiamond Application Development Crafting Solutions with Precision
Diamond Application Development Crafting Solutions with PrecisionSolGuruz
 
Define the academic and professional writing..pdf
Define the academic and professional writing..pdfDefine the academic and professional writing..pdf
Define the academic and professional writing..pdfPearlKirahMaeRagusta1
 
introduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdf
introduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdfintroduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdf
introduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdfVishalKumarJha10
 
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️Delhi Call girls
 

Último (20)

W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
 
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
 
Software Quality Assurance Interview Questions
Software Quality Assurance Interview QuestionsSoftware Quality Assurance Interview Questions
Software Quality Assurance Interview Questions
 
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdfLearn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
 
Microsoft AI Transformation Partner Playbook.pdf
Microsoft AI Transformation Partner Playbook.pdfMicrosoft AI Transformation Partner Playbook.pdf
Microsoft AI Transformation Partner Playbook.pdf
 
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
 
AI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
AI Mastery 201: Elevating Your Workflow with Advanced LLM TechniquesAI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
AI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
 
The Guide to Integrating Generative AI into Unified Continuous Testing Platfo...
The Guide to Integrating Generative AI into Unified Continuous Testing Platfo...The Guide to Integrating Generative AI into Unified Continuous Testing Platfo...
The Guide to Integrating Generative AI into Unified Continuous Testing Platfo...
 
Azure_Native_Qumulo_High_Performance_Compute_Benchmarks.pdf
Azure_Native_Qumulo_High_Performance_Compute_Benchmarks.pdfAzure_Native_Qumulo_High_Performance_Compute_Benchmarks.pdf
Azure_Native_Qumulo_High_Performance_Compute_Benchmarks.pdf
 
Unlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language ModelsUnlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language Models
 
A Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docxA Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docx
 
5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdf5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdf
 
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time ApplicationsUnveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
 
TECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providerTECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service provider
 
The Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdfThe Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdf
 
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
 
Diamond Application Development Crafting Solutions with Precision
Diamond Application Development Crafting Solutions with PrecisionDiamond Application Development Crafting Solutions with Precision
Diamond Application Development Crafting Solutions with Precision
 
Define the academic and professional writing..pdf
Define the academic and professional writing..pdfDefine the academic and professional writing..pdf
Define the academic and professional writing..pdf
 
introduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdf
introduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdfintroduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdf
introduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdf
 
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
 

TypeScript Overview

  • 1. Aniruddha Chakrabarti Sr. Principal Architect & Sr. Manager, Accenture caniruddha@hotmail.com | in.linkedin.com/in/aniruddhac
  • 2. Context • Writing large applications in JavaScript is difficult, not originally designed for large complex applications (mostly a scripting language, with functional programming constructs) • Lacks structuring mechanisms like Class, Module, Interface TypeScript is a language for application scale JavaScript development. TypeScript is a typed superset of JavaScript that compiles to plan JavaScript. TypeScript adds Static Typing and structuring (class, module) to JavaScript.
  • 3. Fix/Improve JavaScript – different approaches 1. Through Library and Frameworks – jQuery, AngularJS, Knockout, Ext JS, Bootstrap …. (new libraries are being created and getting popular everyday) 2. New language that extend/improve language features of JavaScript. Superset of JavaScript. Compiles to JavaScript – CoffeeScript, TypeScript 3. Entirely new language with many new features that compile to JavaScript – GWT (Google Web Toolkit), Dart https://github.com/jashkenas/coffeescript/wiki/list-of-languages-that-compile-to-js
  • 4. What is TypeScript • Helps in large scale JavaScript application development. • Adds additional features like Static Type (optional), Class, Module etc (that are not present in JavaScript) to JavaScript • Starts with JavaScript, ends with JavaScript. TypeScipt is JavaScript. Any valid .js file can be renamed .ts and compiled with other TypeScript files. • Runs on Any browser, Any host, Any OS. • Open Source – The compiler is an open source project and released under the Apache 2.0 license. • TypeScript purposefully borrows ideas from EcmaScript 6 (ES6 Harmony) spec – class, module
  • 5. Bit of History • Typescript was first made public in October 2012 (at version 0.8), after two years of internal development at Microsoft. • TypeScript 0.9, released in 2013, added support for generics • TypeScript 1.0 was released at Build 2014. Visual Studio 2013 Update 2 provides built-in support for TypeScript. • In July 2014, the development team announced a new TypeScript compiler, claiming 5x performance gains. – Source code, which was initially hosted on Codeplex, was moved to GitHub
  • 6. Features • Optional Static Type Annotation / Static Typing • Additional Features for Functions – Types for function parameters and return type, optional and default parameter, rest parameter, overloading • Class – Field, Property, Method, Constructor, Event, Static methods, Inheritance • Interface • Module • Generics • Declaration Merging • Few other features (Enum) … • TypeScript comes with – TypeScript Compiler (tsc) – TypeScript Language Service (TLS) / Visual Studio extension – Playground (http://www.typescriptlang.org/) – Declaration files (*.d.ts) for DOM, jQuery, node.js … – Language Spec (1.0) and code examples
  • 7. Types / Optional Type Annotation
  • 8. Optional Type Annotation • TypeScript allows annotating variables with types • Purely a design time feature. No additional code is emitted in the final JavaScript that TypeScript compiler produces. • If there’s a type mismatch TypeScript shows a warning.
  • 9. Types / Optional Type Annotation • Optional Static Types – Any – Primitive • Number • Boolean • String • Void • Null • Undefined -> same as JavaScript “undefined” type – Array – Enum
  • 10. Datatypes • Does not have separate integer and float/double type • All numbers in TypeScript are floating point values. These floating point numbers get the type 'number'. var x:number = 55 var y:number = 123.4567 • boolean – true/false value var hasPassport:boolean = true // or false • string - Both single quote or double quote could be used var msg1 = 'hello from TypeScript' var msg2 = "hello from TypeScript" • No separate char type var character = 'a'
  • 11. Optional Type Annotation • TypeScript tries to infer type
  • 12. Type Inference • TypeScript tries to infer type • Four ways of variable declaration - 1. Declare its type and value (as a literal) in one statement. 2. Declare its type but no value. The value will be set to undefined. 3. Declare its value but no type. The variable will be of type Any (that is, an old-school dynamic JavaScript variable), but its type may be inferred based on its value. 4. Declare neither value nor type. The variable will be of type Any, and its value will be undefined.
  • 13. Array var cities:string[] = ["Berlin","Bangalore","New York"] var primes:number[] = [1,3,5,7,11,13] var bools:boolean[] = [true,false,false,true]
  • 14. Enum • Addition to JavaScript datatypes. Similar to C# enum • Like languages like C#, an enum is a way of giving more friendly names to sets of numeric values. • By default, enums begin numbering their members starting at 0. You can change this by manually setting the value of one its members.
  • 15. Any • Useful to describe the type of variables that we may not know when we are writing the application. • May come from dynamic content, eg from the user or 3rd party library. • Allows to opt-out of type-checking and let the values pass through compile-time checks. • Same as not declaring any datatype – uses JavaScript’s dynamic nature var notSure: any var list:any[] = [1, true, "free"] list[1] = 100
  • 16. Void • Perhaps the opposite in some ways to 'any' is 'void', • the absence of having any type at all. • Commonly used as the return type of functions that do not return a value function warnUser(): void { alert("This is my warning message"); }
  • 18. Function Overview • Functions are the fundamental building block of any applications in JavaScript. • JavaScript is a functional programming language, and so supports first class functions. • Allows build up layers of abstraction, mimicking classes, information hiding, and modules (JavaScript does not support class, module, private members). • In TypeScript, while there are classes and modules, function still play the key role in describing how to 'do' things. • TypeScript adds some new capabilities to the standard JavaScript functions to make them easier to work with. – Type Annotation for parameter and return type – Optional and Default Parameter – Rest Parameter – Function Overloads
  • 19. Function • Allows parameter and return type annotation
  • 20. Function (2) • Shows warning for type mismatch
  • 21. Function Overloads • Allows function overloads
  • 23. Optional & Default Parameter • Optional Parameters should have default value that would be used if the value is not specified while invoking the function • Should be the last arguments in a function
  • 24. Optional Parameter Implementation • Optional Parameters should have the default value that would be used if the value is not specified while calling the function
  • 25. Rest Parameter • Declared as … paramName:[paramType]
  • 26. Class
  • 27. Class • Properties and fields to store data • Methods to define behavior • Events to provide interactions between different objects and classes
  • 30. Constructor • Uses constructor keyword • public by default, can not be private
  • 33. Access Modifiers • public (default) - member is available to all code in another module. • private - member is available only to other code in the same assembly.
  • 34. Static Methods • TypeScript supports static members (methods) • static methods are visible on the class itself rather than on the instances
  • 35. Class
  • 38. Class – TypeScript uses same Constructor Pattern
  • 39. Inheritance • TypeScript supports inheritance of class through extends keyword
  • 41. Module • Modules can be defines using module keyword • A module can contain sub module, class, interface or enum. Can not directly contain functions (similar to C#, Java) • Modules can be nested (sub module) • Class, Interfaces can be exposed using export keyword
  • 43. Interface • Declared using interface keyword • Like many other TypeScript feature it’s purely a Design time feature. No additional code is emitted for this! • TS compiler shows error when Interface signature and implementation does not match
  • 45. Optional Property • Optional properties can be declared for an interface (using ?) • Optional properties need not be implemented
  • 47. Mixin
  • 48. Mixin • Along with traditional OO hierarchies, another popular way of building up classes from reusable components is to build them by combining simpler partial classes – called Mixin • Several languages support Mixin (e.g. Trait in PHP and Scala). • This pattern in popular in JavaScript community, so TypeScript provides language support. In object-oriented programming languages, a mixin is a class which contains a combination of methods from other classes. Mixin - Wikipedia, the free encyclopedia
  • 52. JavaScript gochas (not fixed in TS) • TypeScript does not introduce block scope (JavaScript only supports function scope) • ; is still optional in TypeScript also (; is not mandatory in JavaScript and it tries to infer ; and sometime does it differently than expected) • == vs === (and != vs !==) == checks for value equality only === checks for both type and value equality • global variables (variables declared outside of function), implied global (variables declared within function without var keyword) • issues with floating point (.1 + .2 != .3, it’s something like .3000…00004)