Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
AngularJS + Typescript === <3
Search
paul souche
January 29, 2015
Programming
0
350
AngularJS + Typescript === <3
My presentation @ngparis on angular + typescript
paul souche
January 29, 2015
Tweet
Share
More Decks by paul souche
See All by paul souche
Une API from scratch avec NestJS
paulsouche
0
160
Unit test in deno
paulsouche
0
150
One spec to rule them all
paulsouche
1
290
Analytics reverse engineering
paulsouche
0
150
TypeScript + lerna + yarn monorepos FTW
paulsouche
1
1.9k
Test like a boss with TypeScript
paulsouche
0
220
The internal modules strike back
paulsouche
0
120
Ma caisse enregistreuse en NodeJS
paulsouche
0
560
Other Decks in Programming
See All in Programming
「10分以内に機能を消せる状態」 の実現のためにやっていること
togishima
1
530
CSC509 Lecture 13
javiergs
PRO
0
260
[SF Ruby Conf 2025] Rails X
palkan
0
340
例外処理を理解して、設計段階からエラーを見つけやすく、起こりにくく #phpconfuk
kajitack
12
6.4k
Nitro v3
kazupon
2
320
2025 컴포즈 마법사
jisungbin
0
150
乱雑なコードの整理から学ぶ設計の初歩
masuda220
PRO
32
14k
『実践MLOps』から学ぶ DevOps for ML
nsakki55
2
460
Chart.jsで長い項目を表示するときのハマりどころ
yumechi
0
150
Doc Translate - LLMを活用したコードドキュメント自動翻訳VSCode拡張機能
eycjur
0
110
アーキテクチャと考える迷子にならない開発者テスト
irof
9
3.3k
Querying Design System デザインシステムの意思決定を支える構造検索
ikumatadokoro
1
1.2k
Featured
See All Featured
The Psychology of Web Performance [Beyond Tellerrand 2023]
tammyeverts
49
3.2k
Reflections from 52 weeks, 52 projects
jeffersonlam
355
21k
The Cult of Friendly URLs
andyhume
79
6.7k
"I'm Feeling Lucky" - Building Great Search Experiences for Today's Users (#IAC19)
danielanewman
231
22k
Easily Structure & Communicate Ideas using Wireframe
afnizarnur
194
17k
I Don’t Have Time: Getting Over the Fear to Launch Your Podcast
jcasabona
34
2.5k
BBQ
matthewcrist
89
9.9k
Faster Mobile Websites
deanohume
310
31k
Building Flexible Design Systems
yeseniaperezcruz
329
39k
Helping Users Find Their Own Way: Creating Modern Search Experiences
danielanewman
31
3k
CSS Pre-Processors: Stylus, Less & Sass
bermonpainter
359
30k
Performance Is Good for Brains [We Love Speed 2024]
tammyeverts
12
1.3k
Transcript
AngularJS + Typescript === <3
Me Myself & I Paul Souche Développeur Front-end @ @paulsouche
https://github.com/paulsouche
JavaScript types... NaN === NaN //false 0.1 + 0.2 ===
0.3 //false '' == [] //true '' //false, [] true [] + [] --> '' {} + [] --> '[object Object]' [] + {} --> 0 {} + {} --> NaN ...
JavaScript types... 6 types “undefined” “boolean” “string” “number” “object” “function”
6 falsy type undefined “undefined” false “boolean” ‘’ “string” 0 “number” null “object” NaN “number”
in AngularJS You can use : • isDefined • isUndefined
• isString • isNumber • isObject • isDate • isArray • isElement • isFunction • isPrototypeOf and...
Classes types methods : • contructor • toString.call() • stackOverflow
Conclusion No strong typings in JavaScript and won’t be better
in ES6
OK Typescript
OK Typescript how do you work ? function greeter(person: string)
{ return "Hello, " + person; } var user = "Jane User"; var universalAnswer = 42; document.body.innerHTML = greeter(user); document.body.innerHTML = greeter(universalAnswer); //throw
OK Typescript how do I strong type ? interface Person
{ firstname: string; lastname: string; } function greeter(person : Person) { return "Hello, " + person.firstname + " " + person.lastname; } var user = {firstname: "Jane", lastname: "User"}; document.body.innerHTML = greeter(user);
OK Typescript what about es6 classes ? class Student {
fullname : string; constructor(public firstname, public middleinitial, public lastname) { this.fullname = firstname + " " + middleinitial + " " + lastname; } } interface Person { firstname: string; lastname: string; } function greeter(person : Person) { return "Hello, " + person.firstname + " " + person.lastname; } var user = new Student("Jane", "M.", "User"); document.body.innerHTML = greeter(user);
OK Typescript what about es6 modules ? module Validation {
export interface StringValidator { isAcceptable(s: string): boolean; } var lettersRegexp = /^[A-Za-z]+$/; var numberRegexp = /^[0-9]+$/; export class LettersOnlyValidator implements StringValidator { isAcceptable(s: string) { return lettersRegexp.test(s); } } export class ZipCodeValidator implements StringValidator { isAcceptable(s: string) { return s.length === 5 && numberRegexp.test(s); } } }
OK Typescript how do I get the compiler ? npm
install -g typescript
OK Typescript how do I watch my code ? lint
: https://github.com/palantir/tslint https://github.com/palantir/grunt-tslint https://github.com/panuhorsmalahti/gulp-tslint compile : https://github.com/k-maru/grunt-typescript https://github.com/ivogabe/gulp-typescript
OK Typescript and my dependencies ? DefinitelyTyped Interfaces : •
AngularJS • ng-route • ng-resource • ng-animate • ng-cookies • angular-ui-router & ui-bootstrap • Underscore / Lodash / Jquery ...
Un peu de code ?
OK Typescript what’s wrong with you ?
OK Typescript what’s wrong with you ?
Q & A Special thanks : ng-paris David Rousset @Davrous
L’équipe ADEO AngularJS 1.6.5 You