pragmatic-types icon indicating copy to clipboard operation
pragmatic-types copied to clipboard

Small practical guide on Flow and TypeScript for JavaScript developers

Pragmatic types

Tweet

Introduction

What

Small practical guide on statically-typed languages for developers who switching from dynamically-typed languages to statically-typed versions. For example from JavaScript to TypeScript or Flow.

For who

This guide assumes at least some prior knowledge of dynamically-typed languages. The idea of this guide is to help make a mental shift from dynamic to static types.

Most of the time I will use JavaScript and TypeScript or Flow examples. Maybe this will be useful for other languages - I do not know yet, let's see.

If you have prior knowledge of statically typed languages, but Hindley-Milner doesn't ring a bell for you, this guide can be useful for you too.

Why

This is my diary of personal discoveries. I find myself explaining those things again and again to different people. I decided to write it down once and for all.

Table of contents

  • Exhaustive check and why it is useful for event processing, enums, unions or disjoint unions
  • Opaque types and how they could have saved Mars Climate Orbiter
  • IO validation or how to handle JSON-based APIs in statically typed language
  • What are types?
  • Dynamically-, statically-, gradually-, weakly-, strongly- and un-typed languages
  • Is JavaScript an untyped language?
  • Type system vs null
  • Making Impossible States Impossible
  • Immutability and type system
  • Classes, types, sets, structural and nominal subtyping, Liskov substitution principle
  • Redux and impossible states
  • Redux and impossible state transitions or FSM
  • Redux and side effects
  • Types and proofs
  • Why JavaScript Promise is unsound?
  • Terminology: soundness, completeness, totality, decidability
  • Rosetta stone, Curry–Howard correspondence
  • To be continued...

Similar works

Contribution

Ideas, questions, and fixes are welcome. Sharing on social networks is also a big help. Thank you.