Three Tips for Migrating from JavaScript to TypeScript

Over time, and especially in the past few years, the tech community has gotten sick of JavaScript and its loose typing. Trying to write a complicated program without static types is like driving at night without headlights—you’ll probably be fine for a while, but there’s a good chance you’ll crash a few times along the way. Read more on Three Tips for Migrating from JavaScript to TypeScript…

A New Redux Action Pattern for TypeScript 2.4+

In September 2016, I wrote a post about a pattern for strongly typed Redux reducers in TypeScript. Since then, the TypeScript team has been busy enhancing the language, and recent changes in TypeScript have enabled a much more natural, boilerplate-free pattern for strongly typed actions and reducers in TypeScript.
Read more on A New Redux Action Pattern for TypeScript 2.4+…

Using D3 with React and TypeScript

Typically, when working in React, it’s best to split UI elements into separate, reusable parts. This allows for more modular code and finer control over each element.

However, this goes against the way D3 operates, which is to subsequently call dot operators, building up elements and groups of elements.

So how can we utilize D3 in a meaningful way while simultaneously breaking up our elements into individual components? I’m going to show you by working through an example implementing a force graph.
Read more on Using D3 with React and TypeScript…

Making Toast from Scratch in React-Redux

Getting UI elements for free is a good feeling. When it comes to popup notifications, other frameworks provide these components for free. For instance, Rails has flashes and Android has snackbars. React is a moving target, so pulling in external libraries can help simplify situations, but it may prevent extensibility later.
Read more on Making Toast from Scratch in React-Redux…

DateStr – A Strongly-Typed Date String for TypeScript

Nearly every project I have ever worked on has had to deal with dates in one way or another. For example, there might be a need to generate a report for a specific date range. This would require a user to select a start and end date, which would be sent over the network to an API. The API would use those dates in an SQL query to retrieve the correct results. Read more on DateStr – A Strongly-Typed Date String for TypeScript…

Five Things to Think About When Considering TypeScript

I can’t imagine working on another JavaScript project without TypeScript, and I haven’t heard much talk of teams adopting TypeScript and regretting it. (For every hour you spend on TypeScript overhead, you probably save five hours of tracking down runtime errors.)

Nevertheless, I do think there are some conditions that could make TypeScript less valuable for a particular project or team. In this article, I’m going to talk about the things you ought to consider when weighing whether or not to add TypeScript to your project.  Read more on Five Things to Think About When Considering TypeScript…

React Testing – Jest or Mocha?

Every React project is a little different. This can make choosing the right testing setup difficult.

Both Jest and Mocha seem to be popular within the React community. There are tons of folks using Jest, though others seem to prefer Mocha (for example, the Enzyme docs and examples use Mocha). So which one should you choose, and does it even matter?
Read more on React Testing – Jest or Mocha?…

Modular, Type-safe Metadata with TypeScript

One of the humps I’ve encountered while learning TypeScript is coming to terms with a core tenet of the language—the type definitions you write only exist at compile time, not at runtime.

I’ve bumped into this a few times. Can I generate a predicate function to test for type compatibility? No—use type guards instead. Can I reflect on the properties of a type at runtime? No—with caveats. It turns out that those caveats matter a lot, and you can do some pretty powerful things with the tools TypeScript does provide. Read more on Modular, Type-safe Metadata with TypeScript…