It’s super awesome to see a lot of libraries starting to adopt flow to add type-safetiness to their code… BUT… what a lot of people forget is that npm packages usually ship ES5 code without any type…
The popularity of TypeScript has really exploded recently. I like TypeScript, and I like static types. I don’t use TypeScript, but as type systems go, it’s got some great features. It’s structural…
Javascript is a loosely typed language — by default we don’t define types for our variables, function arguments, and so on. Flow is a great way to add static typing to our Javascript. Here’s how a…
A collection of types that makes TypeScript even safer. It's goal is to improve type correctness while adding a whole new set of features to TypeScript.
TypeScript grew a great deal between 2017 and 2019, and in many ways, for good reason. There’s a lot to love about TypeScript. In the 2018 State of JavaScript survey, almost half the respondents said…
The first version of Flow support for React was a magical implementation of React.createClass(). Since then, React has evolved significantly. It is time to rethink how Flow models React. In Flow…
Rusts type system requires that there only ever is one mutable reference to a value or one or more shared references. What happens when you need multiple references to some value, but also need to mutate through them? We use a trick called interor mutability: to the outside world you act like a value is immutable so multiple references are allowed. But internally the type is actually mutable. All types that provide interior mutability have an UnsafeCell at their core. UnsafeCell is the only primitive that allows multiple mutable pointers to its interior, without violating aliasing rules. The only way to use it safely is to only mutate the wrapped value when there are no other readers. No, the garantee has to be even stronger: we can not mutate it and can not create a mutable reference to the wrapped value while there are shared references to its value. Both the book and the std::cell module give a good alternative explanation of interor mutability. What are some patterns that have been developed to use interior mutability safely? How do multithreaded synchronization primitives that provide interior mutability follow similar principles?
Type coercion is the process of converting value from one type to another (such as string to number, object to boolean, and so on). Any type, be it primitive or an object, is a valid subject for type…
Functional programming is a great discipline to learn and apply when writing JavaScript. Writing stateless, idempotent, side-effect free code really does solve a lot of problems: But there’s a…
So if you’ve been in the JavaScript world for a bit, you’ve probably come across Gary Bernhardt’s “Wat” talk. For those of you who haven’t seen it, you are seriously missing out and I would highly…
Historically, I’ve struggled to find a concise, simple way to explain what it means to practice type-driven design. Too often, when someone asks me “How did you come up with this approach?” I find I can’t give them a satisfying answer. ...