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
Types in Real Life
Search
Sibelius Seraphini
July 13, 2018
Technology
300
4
Share
Types in Real Life
Practical approve to types in javascript
Sibelius Seraphini
July 13, 2018
More Decks by Sibelius Seraphini
See All by Sibelius Seraphini
Por que criar uma nova Fintech?
sibelius
1
41
As Dores de uma Fintech
sibelius
1
300
Woovi - Safe Coding Practices
sibelius
1
80
⛔ No Cloud: how Woovi moved from the Cloud to its own servers
sibelius
1
740
React Colocation
sibelius
2
310
The Frontend Dichotomy
sibelius
5
730
React Native Bridges Architectures
sibelius
2
1.3k
What's next?
sibelius
3
650
ReactConfBR - Is Relay Modern the Future?
sibelius
3
950
Other Decks in Technology
See All in Technology
サイボウズ 開発本部採用ピッチ / Cybozu Engineer Recruit
cybozuinsideout
PRO
10
78k
AWS認定資格は本当に意味があるのか?
nrinetcom
PRO
1
260
マルチプロダクトの信頼性を効率良く保っていくために
kworkdev
PRO
0
130
Introduction to Sansan, inc / Sansan Global Development Center, Inc.
sansan33
PRO
0
3k
生成AI時代のエンジニア育成 変わる時代と変わらないコト
starfish719
0
9.1k
AI時代のガードレールとしてのAPIガバナンス
nagix
0
200
Data Hubグループ 紹介資料
sansan33
PRO
0
2.9k
実践ハーネスエンジニアリング:TAKTで実現するAIエージェント制御 / Practical Harness Engineering: AI Agent Control Enabled by TAKT
nrslib
9
4k
Bill One 開発エンジニア 紹介資料
sansan33
PRO
6
18k
EarthCopilotに学ぶマルチエージェントオーケストレーション
nakasho
0
260
Azure Speech で音声対応してみよう
kosmosebi
0
150
Rapid Start: Faster Internet Connections, with Ruby's Help
kazuho
2
150
Featured
See All Featured
The innovator’s Mindset - Leading Through an Era of Exponential Change - McGill University 2025
jdejongh
PRO
1
160
The Illustrated Guide to Node.js - THAT Conference 2024
reverentgeek
1
330
Lightning talk: Run Django tests with GitHub Actions
sabderemane
0
170
My Coaching Mixtape
mlcsv
0
98
New Earth Scene 8
popppiees
3
2.1k
Highjacked: Video Game Concept Design
rkendrick25
PRO
1
340
End of SEO as We Know It (SMX Advanced Version)
ipullrank
3
4.1k
The Cost Of JavaScript in 2023
addyosmani
55
9.8k
Lessons Learnt from Crawling 1000+ Websites
charlesmeaden
PRO
1
1.2k
Exploring the Power of Turbo Streams & Action Cable | RailsConf2023
kevinliebholz
37
6.4k
Designing Experiences People Love
moore
143
24k
How to Align SEO within the Product Triangle To Get Buy-In & Support - #RIMC
aleyda
1
1.5k
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