Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Speaker Deck
PRO
Sign in
Sign up for free
Types in Real Life
Sibelius Seraphini
July 13, 2018
Technology
3
230
Types in Real Life
Practical approve to types in javascript
Sibelius Seraphini
July 13, 2018
Tweet
Share
More Decks by Sibelius Seraphini
See All by Sibelius Seraphini
React Colocation
sibelius
1
97
The Frontend Dichotomy
sibelius
4
520
React Native Bridges Architectures
sibelius
1
1.2k
What's next?
sibelius
2
440
ReactConfBR - Is Relay Modern the Future?
sibelius
2
570
Other Decks in Technology
See All in Technology
What's new in Vision
satotakeshi
0
220
Empath Company Deck
empathpr
0
150
MoT TechTalk #12 タクシーアプリ『GO』大規模トラフィックを捌く分析データ基盤の全容に迫る!
mot_techtalk
1
400
SwiftUI Layout
auramagi
1
120
【個人的】オブジェクト指向の現在地
toranoana
0
190
XRとシビックテック
satoshirobatofujimoto
0
100
Introduction To Technical Writing
olawanle_joel
0
100
DeepL の用語集が(いつのまにか)日本語に対応してたので試してみた
irokawah0
0
180
Retca Cloud
bau
0
550
さいきんのRaspberry Pi。 / osc22do-rpi
akkiesoft
6
5.3k
DOM Invader - prototype pollution対応の衝撃 - / DOM Invader - prototype pollution
okuken
0
170
今どきのLinux事情
tokida
44
36k
Featured
See All Featured
The Language of Interfaces
destraynor
148
20k
Testing 201, or: Great Expectations
jmmastey
21
5.4k
Learning to Love Humans: Emotional Interface Design
aarron
261
37k
GitHub's CSS Performance
jonrohan
1020
420k
Design and Strategy: How to Deal with People Who Don’t "Get" Design
morganepeng
105
16k
KATA
mclloyd
7
8.7k
JavaScript: Past, Present, and Future - NDC Porto 2020
reverentgeek
37
3.3k
Optimizing for Happiness
mojombo
365
63k
How STYLIGHT went responsive
nonsquared
85
3.9k
Faster Mobile Websites
deanohume
294
28k
Refactoring Trust on Your Teams (GOTO; Chicago 2020)
rmw
19
1.4k
Reflections from 52 weeks, 52 projects
jeffersonlam
337
17k
Transcript
Types in Real Life How to improve your dev workflow
Sibelius Seraphini
Sibelius Seraphini @sibelius @sseraphini 2
- Motivation - Basics - Sum types - Generics -
REST api study case - React - Redux - Utilities Outline 3
Type System in JS 4
- Less bugs - More maintainability - Type Driven Development
Motivation 5
- Better tools support - Code completion - Refactor -
Documentation - Jump to definition Motivation 6
- Types are set of values - string - 'a'
| 'b' | 'c' | ... - number - 1 | 2 | 3 | ... - boolean - true | false - function - string -> boolean | ... - object - { a: string, b: number } | ... What are Types? 7
Typing a variable 8
Typing a function 9
Typing an object 10
Nominal Typing 11 - C++, Java, Swift
Structural Typing 12 - OCaml, Haskell, Elm
Typing an array 13
Sum/Union Type 14
Intersection Type 15
- How to type a function that can be used
for any type of array (int[], string[], number[])? Generics 16
Generics 17
18 Optional type
- type the input - api body payload - headers
- query string Typing a REST API 19
- type the output (response) - Get a json output
of a REST api - Transform json to types - https://transform.now.sh/json-to-flo w-types/ Typing a REST API 20
Typing a REST api 21
Typing a REST api 22
Typing a React Component 23
Typing a React Component (TS) 24
Typing a React Component 25
Typing a HOC 26
Typing Redux 27
Typing Redux 28
Typing Redux 29
Flow Type Utilities 30
TypeScript Utilities Mapped Types 31
TypeScript Utilities Conditional Typing 32
Resources 33 - https://github.com/entria/guidelines/tree/ master/flow - https://flow.org/en/docs/lang/ - https://www.typescriptlang.org/docs/ho me.html
- https://github.com/fantasyland/fantasy-l and - https://github.com/gcanti/flow-static-land
Resources 34 - https://medium.com/javascript-scene/m aster-the-javascript-interview-what-is-fu nctional-programming-7f218c68b3a0 - https://medium.com/@matthiasak/state- of-the-union-js-d664bdbffd14 -
https://mitpress.mit.edu/books/types-an d-programming-languages - https://github.com/niieani/typescript-vs-fl owtype
Resources 35 - https://transform.now.sh/json-to-flow-typ es/
I didn't mention 36 - More about Type Theory -
Functional Programming - Types + Functional - Fantasy Land specs - Realworld problems and solutions
Sibelius