TYPESCRIPT. Presented by Clarke Bowers

Similar documents
TypeScript. Types. CS144: Web Applications

Arjen de Blok. Senior Technical Consultant bij ICT Groep ( sinds 1995 Programmeren sinds 1990 Technologiën. Links

DEVELOPING WEB APPLICATIONS WITH MICROSOFT VISUAL STUDIO Course: 10264A; Duration: 5 Days; Instructor-led

Comprehensive AngularJS Programming (5 Days)

This course is designed for web developers that want to learn HTML5, CSS3, JavaScript and jquery.

Apex TG India Pvt. Ltd.

10264A CS: Developing Web Applications with Microsoft Visual Studio 2010

Index. Bower, 133, 352 bower.json file, 376 Bundling files, 157

Java SE7 Fundamentals

Static Webpage Development

Angular 2 and TypeScript Web Application Development

Aim behind client server architecture Characteristics of client and server Types of architectures

10267A CS: Developing Web Applications Using Microsoft Visual Studio 2010

55249: Developing with the SharePoint Framework Duration: 05 days

Session 18. jquery - Ajax. Reference. Tutorials. jquery Methods. Session 18 jquery and Ajax 10/31/ Robert Kelly,

User Interaction: jquery

Building RESTful Web Services with. Presented by Steve Ives

DOT NET Syllabus (6 Months)

Advance Mobile& Web Application development using Angular and Native Script

DECOUPLING PATTERNS, SERVICES AND CREATING AN ENTERPRISE LEVEL EDITORIAL EXPERIENCE

Angular 2 Programming

Full Stack boot camp

Web development using PHP & MySQL with HTML5, CSS, JavaScript

Developing ASP.NET MVC 5 Web Applications. Course Outline

SHAREPOINT 2013 DEVELOPMENT

Varargs Training & Software Development Centre Private Limited, Module: HTML5, CSS3 & JavaScript

Frontend UI Training. Whats App :

Audience: Experienced application developers or architects responsible for Web applications in a Microsoft environment.

20486-Developing ASP.NET MVC 4 Web Applications

ASP.NET Web Forms Programming Using Visual Basic.NET

INTRODUCTION TO.NET. Domain of.net D.N.A. Architecture One Tier Two Tier Three Tier N-Tier THE COMMON LANGUAGE RUNTIME (C.L.R.)

Java J Course Outline

CHAPTER 1: INTRODUCING C# 3

"Charting the Course... MOC A: Developing with the SharePoint Framework. Course Summary

CERTIFICATE IN WEB PROGRAMMING

Introduction 13. Feedback Downloading the sample files Problem resolution Typographical Conventions Used In This Book...

PHP Online Training. PHP Online TrainingCourse Duration - 45 Days. Call us: HTML

Type of Classes Nested Classes Inner Classes Local and Anonymous Inner Classes

An Introduction to TypeScript. Personal Info

An Introduction to JavaScript & Bootstrap Basic concept used in responsive website development Form Validation Creating templates

One language to rule them all: TypeScript. Gil Fink CEO and Senior Consultant, sparxys

JavaScript Specialist v2.0 Exam 1D0-735

DOT NET COURSE BROCHURE

Developing ASP.Net MVC 4 Web Application

Decoupled Drupal with Angular

Introduction to TypeScript

Developing ASP.NET MVC 5 Web Applications

COURSE 20486B: DEVELOPING ASP.NET MVC 4 WEB APPLICATIONS

20486: Developing ASP.NET MVC 4 Web Applications (5 Days)

Hands On, Instructor-Led IT Courses Across Colorado

TIME SCHEDULE MODULE TOPICS PERIODS. HTML Document Object Model (DOM) and javascript Object Notation (JSON)

The Great SharePoint 2016/2013 Adventure for Developers

Advance Dotnet ( 2 Month )

.NET Advance Package Syllabus

JavaScript CS 4640 Programming Languages for Web Applications

Developing ASP.NET MVC 4 Web Applications

ASP.NET Using C# (VS2013)

Beginning Groovy, Grails and Griffon. Vishal Layka Christopher M. Judd Joseph Faisal Nusairat Jim Shingler

C# Programming in the.net Framework

Microsoft. Inside Microsoft. SharePoint Ted Pattison. Andrew Connell. Scot Hillier. David Mann

20486 Developing ASP.NET MVC 5 Web Applications

Developing a Web Server Platform with SAPI support for AJAX RPC using JSON

Open Source Library Developer & IT Pro

JavaScript CS 4640 Programming Languages for Web Applications

JavaScript Programming

Mix It Up: Visual Studio 2010 and ASP.NET 4.0. Singapore 25 March 2009

ASP.NET MVC Training

Module 5 JavaScript, AJAX, and jquery. Module 5. Module 5 Contains an Individual and Group component

Delivery Options: Attend face-to-face in the classroom or via remote-live attendance.

Copyright Descriptor Systems, Course materials may not be reproduced in whole or in part without prior written consent of Joel Barnum

THE GREAT SHAREPOINT ADVENTURE 2016

20486: Developing ASP.NET MVC 4 Web Applications

Developing ASP.NET MVC 5 Web Applications

.NET-6Weeks Project Based Training

2310C VB - Developing Web Applications Using Microsoft Visual Studio 2008 Course Number: 2310C Course Length: 5 Days

ANGULAR 2.X,4.X + TYPESRCIPT by Sindhu

Developing Data Access Solutions with Microsoft Visual Studio 2010

Oracle - Developing Applications for the Java EE 7 Platform Ed 1 (Training On Demand)

(800) Toll Free (804) Fax Introduction to Java and Enterprise Java using Eclipse IDE Duration: 5 days

DOT NET SYLLABUS FOR 6 MONTHS

Delivery Options: Attend face-to-face in the classroom or remote-live attendance.

Enterprise Web Development

INF5750. Introduction to JavaScript and Node.js

TypeScript coding JavaScript without the pain

Programming Fundamentals of Web Applications

Course 20486B: Developing ASP.NET MVC 4 Web Applications

Developing ASP.NET MVC Web Applications (486)

COPYRIGHTED MATERIAL. Contents. Part I: C# Fundamentals 1. Chapter 1: The.NET Framework 3. Chapter 2: Getting Started with Visual Studio

Introduction to the SharePoint Framework Bob German Principal Architect - BlueMetal. An Insight company

The course also includes an overview of some of the most popular frameworks that you will most likely encounter in your real work environments.

20486C: Developing ASP.NET MVC 5 Web Applications

Developing ASP.NET MVC 4 Web Applications

COURSE 20480B: PROGRAMMING IN HTML5 WITH JAVASCRIPT AND CSS3

Node.js. Node.js Overview. CS144: Web Applications

Web UI. Survey of Front End Technologies. Web Challenges and Constraints. Desktop and mobile devices. Highly variable runtime environment

SHAREPOINT DEVELOPMENT FOR 2016/2013

OVERRIDING. 7/11/2015 Budditha Hettige 82

Visual Studio Course Developing ASP.NET MVC 5 Web Applications

Programming in HTML5 with JavaScript and CSS3

Microsoft Developing ASP.NET MVC 4 Web Applications

Transcription:

TYPESCRIPT Presented by Clarke Bowers

ABOUT THE PRESENTER Clarke D. Bowers http://www.cbsoftwareengineering.com/ mailto: clarke@cbsoftwareengineering.com 35 years of industry experience Has developed everything from embedded systems using assembly language to enterprise data warehouses and everything in between

SCRIPTING WAT

WHAT IS TYPESCRIPT? TypeScript extends from the syntax and semantics of JavaScript. Full interop between TS and JS since TS compiles into JS. TypeScript runs on browsers, in Node.js, or in any JavaScript engine that supports ECMAScript 3 (or newer). TypeScript offers support for the latest JavaScript features (ECMAScript 2015). Types enable JS developers to use highly-productive development tools and practices like static checking and code refactoring when developing JavaScript applications. TS allows Intellisense to work in Visual Studio. Types and type inference allows a few type annotations to make static verification possible. Types let you define interfaces between software components.

HOW DO I GET IT? https://www.typescriptlang.org/ Version 2.7 is current Built into Visual Studio 2015 SP3 and 2017 Project template for learning, VS2017, search online for TypeScript https://richnewman.wordpress.com/2017/05/09/html-application-withtypescript-project-template-for-visual-studio-2017/ NodeJs npm install -g typescript OData 4: http://www.odata.org/documentation/ Also add postman to Chrome, It will be handy for one of the examples

HELLO WORLD Create text file with ts extension Compile with tsc Usage: tsc [options] [file...] Execute with node Usage: node [options] [ -e script script.js - ] [arguments] console.log("hello world!"); C:\...\NodeExamples>tsc HelloWorld.ts C:\...\NodeExamples>node HelloWorld.js hello world!

INHERITANCE & POLYMORPHISM Supports classes and interfaces Use keyword extends to perform subclassing Use keyword implements to support a interface Polymorphism is not based on class or interface hierarchy Instead is it based on shape Shape is the signature of all functions and fields class Animal { name: string; constructor(thename: string) { this.name = thename; } move(distanceinmeters: number = 0) { console.log(`${this.name} moved ${distanceinmeters}m.`); } } //inheritance class Snake extends Animal { constructor(name: string) { super(name); } move(distanceinmeters = 5) { console.log("slithering..."); super.move(distanceinmeters); } }

VISUAL STUDIO CLOCK PROJECT Template for TypeScript project Shows the current time Updates ever 500ms Starts with a naked HTML page Adds elements in the constructor Update code to Add a button Hook the event handler to stop the clock Note that this is not implicit so be careful how to call a method on it. Timer token is not defined class Greeter { element: HTMLElement; span: HTMLElement; timertoken: number; button: HTMLElement; constructor(element: HTMLElement) { this.element = element; this.element.innerhtml += "The time is: "; this.span = document.createelement('span'); this.element.appendchild(this.span); this.span.innertext = new Date().toUTCString();

ASP.NET & ENTITY FRAMEWORK Create a ASP.NET Web Application Select Empty Checked are WebApi Select No Authentication Add Entity Framework Nuget package Restore the AdventureWorks DB to local SQL Server 2016 Add connection string to web.config Add Address, Person and EmailAddress to model <connectionstrings> <add name="adventureworks" connectionstring= Data Source=TALLTOWER\MSSQLSERVER2016; Initial Catalog=AdventureWorks2016CTP3; Integrated Security=True" /> </connectionstrings>

ASP.NET & ODATA Create a Data Model from the Adventure Works DB Create a new controller of type ODataController Return IQueryable of your entity public class AddressController : ODataController { private AdventureWorksContext db = new AdventureWorksContext(); [EnableQuery] public IQueryable<Address> Get() { return db.address; }

Adverting end point: http://localhost:61068/odata/$metadata/ Remove other end-points from WebApiConfig.cs ODATA STARTUP Query syntax http://localhost:61068/odata/address?$filter=city eq 'Bothell http://localhost:61068/odata/person(1) http:// localhost:61068/odata/person?$filter=firstname eq 'Ken'&$expand=EmailAddress ODataConventionModelBuilder builder = new ODataConventionModelBuilder(); builder.entityset<address>("addresses"); builder.entityset<person>("people"); //include all entities even when they have no endpoint builder.entityset<emailaddress>("emailaddresses"); config.routes.mapodataserviceroute("odatarouter", "odata", builder.getedmmodel()); config.addodataqueryfilter();

STRONGLY TYPED ODATA Add address class for Odata JSON deserialization FuryTech. OdataTypescriptServiceGenerator Scaffolding TypeScript model classes and services from an OData Metadata XML https://github.com/furytechs/furyt ech.odatatypescriptservicegenera tor class Address { }; public AddressID: number; public AddressLine1: string; public City: string;

ODATA REQUEST Use strongly typed XMLHttpRequest to query with Odata Parse the response from JSON into an JS object Grab a strongly typed array of addresses load() { } let Http = new XMLHttpRequest(); let url = http://localhost:61069/odata/address? + $filter=city eq 'Bothell ; Http.open('get', url, false); Http.send(); let odataresponse = JSON.parse(Http.response); let addresses: Address[] = odataresponse.value; this.span.innerhtml = "Id: " + addresses[0].addressid + " Address: " + addresses[0].addressline1 + " City: " + addresses[0].city;

MODULES Separate files Similar the C language header files Export the declaration Import where you need to reference Has the disadvantage of path accuracy ECMA Script 2015 required for modules support Otherwise you need a JS library to support export class Address { public AddressID: number; public AddressLine1: string; public City: string; }; import { Address } from "./Models/address";

TYPE DECLARATION /// <reference path="./scripts/typings/jquery/jquery.d.ts" /> Libraries can generate a header file: *.d.ts Visual Studio Intellisense support these files DefinitelyTyped is a repository of type definitions for common JS libraries http://definitelytyped.org/ Nuget packages Referencing a type definition file adds no JS code from the library file It just provides strong types for the TypeScript compiler Very strange syntax to reference a type definition file Triple-slash directives are single-line comments containing a single XML tag. The contents of the comment are used as compiler directives.

AJAX CALLBACK Use Jquery Ajax method getjson performs HTTP Get and deserializes into JSON object Assign to strongly type variable load() { let url = http://localhost:61068/odata/address? + $filter=city eq 'Bothell'"; $.getjson(url, (odataresponse, textstatus, xhr) => { let addresses: Address[] = odataresponse.value; this.span.innerhtml = "Id: " + addresses[0].addressid + " Address: " + addresses[0].addressline1 + " City: " + addresses[0].city; }); };

ITERATORS, FOR/OF C# foreach equivalent TypeScript for of Enumerates a collection public renderheaders( columnheaders: string[]) { let tr = document.createelement("tr"); this.table.appendchild(tr); this.headerrow = tr; for (let columnheader of columnheaders) { let th = document.createelement("th"); th.innertext = columnheader; tr.appendchild(th); } }

GENERICS Very similar syntax to C# Generic classes Generic functions Functions overloads work poorly because JavaScipt cannot distinguish public renderdata<t>( datarows: T[], renderrow: (rowelement: HTMLTableRowElement, rowdata: T) => void) { for (let datarow of datarows) { if (!this.headerrow) { this.renderheadersfromdata(datarow); } let tr = document.createelement("tr"); this.table.appendchild(tr); renderrow(tr, datarow); }

ITERATORS, FOR/IN For/in enumerates keys Great for object properties Works well for arrays indexed by string (maps) public renderheadersfromdata<t>( datarow: T) { let tr = document.createelement("tr"); this.table.appendchild(tr); this.headerrow = tr; for (let key in datarow) { let th = document.createelement("th"); th.innertext = key; tr.appendchild(th); }}