JSFoo: round the year submissions

Submit talks on JavaScript and full stack engineering round the year

Javascript type systems - a land of surprises

Submitted by Abhishek Yadav (@zerothabhishek) on Thursday, 31 May 2018

Technical level: Intermediate Status: Submitted


Adding types-checks to Javascript sounded like a promising idea to me. Having created my fair share of undefined bugs, I was definitely interested. To be honest, I didn’t think there was so much to it.

We have used types in the elementary C language courses - how hard could it be in Javascript? There are some type annotations, some union types, and some function types - what else?

And then I came across code like this -

function passesShamelessly(): string {
  let arr = [];
  return arr[0];  // <- No error in Typescript. No error in Flow-type.

It is not a mistake. Its deliberate and documented. And this is not the only surprise. Typescript and Flow-type can surpise you in ridiculous ways.

This talk chronicles my jounrney through such surprises. With this exploration, we get to know what goes on in the making of a a practical type system - the philosophies and the trade-offs. And also the disagreements - the key points where two implementations (Typescript/Flow) differ.


Draft slides: https://slides.com/zerothabhishek/deck-31/


The content is structured as six discrete examples. Each of these examples represent a feature of Typescript/Flow that can lead to an intersting discussion.

It is not intended to be tutorial on the nuances of type-systems. Its more about approaching the nuances from a use-cases.


Some elementary experience with Typescript or Flow

Speaker bio

A Ruby programmer at heart, I was only trying to catch the Typescript bandwagon for a side project. Moonlighted a bit with Elm. Still quite an outsider to Javascript world, perhaps that lends the perspective.





Login to leave a comment