Category: TypeScript

An elegant solution for handling errors in Express

Express is a microframework that according to 2018 Node.js User Survey Report is used by 4 in 5 back-end and full-stack node.js developers. Thanks to its simplicity, the always-growing range of available middleware, and active community the express userbase is still growing.

Using Sequelize with TypeScript

Sequelize is an ORM for Node.js written in JavaScript, not TypeScript. Despite that good quality typings are available, it is not straightforward how to get up to speed with Sequelize and TypeScript. I would like to go through crucial elements and show how to maximize safety coming from static typing when using Sequelize. Let’s start with setting things up.

Nominal typing techniques in TypeScript

Many functional programming languages like Haskell or Elm have a structural type system. This perfectly lines in with the direction in which majority of JavaScript’ish community is heading. Nevertheless, every feature comes with a certain set of trade-offs. Choosing structural type system allows for a greater flexibility but leaves a room for a certain class of bugs. What I find interesting is that the answer to the question whether TypeScript, Flow or any other type system adopts structural or nominal type system does not have to be binary. So, is it possible to have the best of both worlds writing in TypeScript?

Fixtures, the way to manage sample and test data

Fixtures are a thin abstraction layer over sample data in your application which allows for better organizing, often complex, data structures representing different entities. If this sounds like a vague description or does not ring the bell maybe an example will speak to you better.

Creating a TypeScript library with a minimal setup

There are a few major reasons due to which you may find yourself creating a library. One, obviously, is that you have a solution which you would like to share with the Open Source community. The other one is that you need to reuse code across different projects or in the same project but on different platforms.

TypeScript vs Flow

TypeScript calls itself a JavaScript superset and compiler while Flow is a static type checker. TypeScript is developed by Microsoft and highly inspired by C# or Java type systems. What I find interesting is that TypeScript is actually written in TypeScript. Flow is created by Facebook, written in OCaml. Most TypeScript annotations are compatible also with Flow so learning curve for switching from one to another is really smooth.

This website uses cookies. Continuing to use this website gives consent to cookies being used. You can disable them in your browser's settings.