Top Banner
ANGULARJS AND TYPESCRIPT TWO GREAT TOOLS TOGETHER KURT WIERSMA @KWIERSMA +
24

AngularJS and TypeScript - ilmservice.blob.core.windows.net · TypeScript lets you write JavaScript the way you really want to. TypeScript is a typed superset of JavaScript that compiles

May 23, 2020

Download

Documents

dariahiddleston
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: AngularJS and TypeScript - ilmservice.blob.core.windows.net · TypeScript lets you write JavaScript the way you really want to. TypeScript is a typed superset of JavaScript that compiles

ANGULARJS AND TYPESCRIPT TWO GREAT TOOLS TOGETHERKURT WIERSMA @KWIERSMA

+

Page 2: AngularJS and TypeScript - ilmservice.blob.core.windows.net · TypeScript lets you write JavaScript the way you really want to. TypeScript is a typed superset of JavaScript that compiles

Who am I?

From Minneapolis, MN

Work for the American Academy of Neurology

Have been developing web apps for over 14 years

Have used Python, Groovy, Java, C#, and CFML

Favorites: C#/MVC, Python/Django, AngularJS, TypeScript

Page 3: AngularJS and TypeScript - ilmservice.blob.core.windows.net · TypeScript lets you write JavaScript the way you really want to. TypeScript is a typed superset of JavaScript that compiles

AgendaTypeScript intro and getting started

AngularJS basic knowledge assumed

How to combine two great tools

App config, routes, references.ts ordering

Controllers

Services

Authentication with API’s

Authorization and routes

Page 4: AngularJS and TypeScript - ilmservice.blob.core.windows.net · TypeScript lets you write JavaScript the way you really want to. TypeScript is a typed superset of JavaScript that compiles

AWESOME, INC

PROJECT

DATE CLIENT8/1/2015

TypeScriptA RISING STAR

Page 5: AngularJS and TypeScript - ilmservice.blob.core.windows.net · TypeScript lets you write JavaScript the way you really want to. TypeScript is a typed superset of JavaScript that compiles

http://typescriptlang.org

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.

AngularJS 2 is implemented in TypeScript

Page 6: AngularJS and TypeScript - ilmservice.blob.core.windows.net · TypeScript lets you write JavaScript the way you really want to. TypeScript is a typed superset of JavaScript that compiles

JAVASCRIPT IS VALID TYPESCRIPT

Page 7: AngularJS and TypeScript - ilmservice.blob.core.windows.net · TypeScript lets you write JavaScript the way you really want to. TypeScript is a typed superset of JavaScript that compiles

TypeScript Syntax

Page 8: AngularJS and TypeScript - ilmservice.blob.core.windows.net · TypeScript lets you write JavaScript the way you really want to. TypeScript is a typed superset of JavaScript that compiles

FeaturesClasses

Modules

Interfaces

Generics

Arrow Functions

References

Type Definitions

Better “this” by default

Page 9: AngularJS and TypeScript - ilmservice.blob.core.windows.net · TypeScript lets you write JavaScript the way you really want to. TypeScript is a typed superset of JavaScript that compiles

Why would you want types?

Structure for large code bases and/or teams

Catch errors early

Provide a structured API

Tooling can provide better code completion & refactoring

Page 10: AngularJS and TypeScript - ilmservice.blob.core.windows.net · TypeScript lets you write JavaScript the way you really want to. TypeScript is a typed superset of JavaScript that compiles

What about existing JavaScript Libraries?

DefinitelyTyped provides TS definitions for tons of JS libraries

JQuery, Angular, Node, Ember, Backbone, ect.

http://definitelytyped.org

You can write you own definitions easily

TSD tool to manage definitions

Page 11: AngularJS and TypeScript - ilmservice.blob.core.windows.net · TypeScript lets you write JavaScript the way you really want to. TypeScript is a typed superset of JavaScript that compiles

Custom Definitions

pusher.d.ts

Useage

Page 12: AngularJS and TypeScript - ilmservice.blob.core.windows.net · TypeScript lets you write JavaScript the way you really want to. TypeScript is a typed superset of JavaScript that compiles

Getting Started

Install:

npm install -g typescript

Compile:

tsc --sourcemap --out js/Application.js js/_all.ts

Page 13: AngularJS and TypeScript - ilmservice.blob.core.windows.net · TypeScript lets you write JavaScript the way you really want to. TypeScript is a typed superset of JavaScript that compiles

ToolingCLI: grunt with grunt-ts or gulp

TSD: managing definitions for JS libraries

tsd install angular --resolve --overwrite --save

IDEs:

WebStorm / IntelliJ (Mac & Win) [$]

Visual Studio 2012+ (Win) [$]

Visual Studio Code (Mac & Win) [Free]

Eclipse (Mac & Win) [Free]

Editors:

Sublime [$]

Atom [Free]

Page 14: AngularJS and TypeScript - ilmservice.blob.core.windows.net · TypeScript lets you write JavaScript the way you really want to. TypeScript is a typed superset of JavaScript that compiles

TYPESCRIPT REFERENCES_all.ts

Page 15: AngularJS and TypeScript - ilmservice.blob.core.windows.net · TypeScript lets you write JavaScript the way you really want to. TypeScript is a typed superset of JavaScript that compiles

TYPSCRIPT COMPILEGruntFile.JS

Page 16: AngularJS and TypeScript - ilmservice.blob.core.windows.net · TypeScript lets you write JavaScript the way you really want to. TypeScript is a typed superset of JavaScript that compiles

AWESOME, INC

PROJECT

DATE CLIENT4/1/2010

AngularJSA SUPER HEROIC FRAMEWORK

Page 17: AngularJS and TypeScript - ilmservice.blob.core.windows.net · TypeScript lets you write JavaScript the way you really want to. TypeScript is a typed superset of JavaScript that compiles

APP CONFIG & ROUTESApplication.ts

Page 18: AngularJS and TypeScript - ilmservice.blob.core.windows.net · TypeScript lets you write JavaScript the way you really want to. TypeScript is a typed superset of JavaScript that compiles

CONTROLLERS

Page 19: AngularJS and TypeScript - ilmservice.blob.core.windows.net · TypeScript lets you write JavaScript the way you really want to. TypeScript is a typed superset of JavaScript that compiles

SERVICES

Page 20: AngularJS and TypeScript - ilmservice.blob.core.windows.net · TypeScript lets you write JavaScript the way you really want to. TypeScript is a typed superset of JavaScript that compiles

AUTHENTICATION WITH API’S

Page 21: AngularJS and TypeScript - ilmservice.blob.core.windows.net · TypeScript lets you write JavaScript the way you really want to. TypeScript is a typed superset of JavaScript that compiles

AUTHORIZATION & ROUTESApplication.ts

Services.js

Page 22: AngularJS and TypeScript - ilmservice.blob.core.windows.net · TypeScript lets you write JavaScript the way you really want to. TypeScript is a typed superset of JavaScript that compiles

AngularJS ToolsDebugging

Batarang

ng-inspector

AngularUI & Bootstrap UI

Angular Formly

Testing

Protractor

ng-describe

Page 23: AngularJS and TypeScript - ilmservice.blob.core.windows.net · TypeScript lets you write JavaScript the way you really want to. TypeScript is a typed superset of JavaScript that compiles

Resources

Using Visual Studio Code with Typescript and AngularJS

John Papa’s AngularJS Style Guide

Real World Example Apps

Angular In 20 Minutes

Expense Manager

Page 24: AngularJS and TypeScript - ilmservice.blob.core.windows.net · TypeScript lets you write JavaScript the way you really want to. TypeScript is a typed superset of JavaScript that compiles

QUESTIONS?KURT WIERSMA ([email protected]) @KWIERSMA HTTP://GITHUB.COM/KWIERSMA