7/21/2017 Last edited: 2/12/2024
Product & Engineering Leader
— Lucas F. Costa
The 💡 Moment
While working on a Gatsby PR (see this blog post for more about Gatsby), I gained some exposure to the Remark library library, which has the ability to transform a Markdown document into an abstract syntax tree—hereafter referred to as an AST. The general approach is given a Markdown file, we can parse it into an AST of nodes (e.g. code nodes, image nodes, text nodes, etc.), modify these nodes, and then write back to the original Markdown file. Pretty cool! I tend to think looking at code is helpful, so let’s consider the following snippet:
🔧 Project Setup
This can often be a point of contention, or cause of stress, for many developers. The plethora of choices, tools, and utilities that can be used can sometimes lead to an overwhelming feeling that one is making the wrong choice, or perhaps not the most correct choice. Do I use Webpack? Do I use Babel? Which preset do I use? Which testing framework? And so it goes… Each of these choices is important, but I’d like to stress the importance of ignoring some of this selection anxiety, and just get down to developing. Choose what you feel most comfortable with, not what is the “new hotness” or the tool that has a lot of hype behind it—in other words, don’t be consumed by hype driven development. Choose what makes you feel most empowered to develop something usable, well-tested, and that keeps you productive. Note that I’m not saying you shouldn’t learn some new tool, or investigate some new utility, but I am merely saying you don’t have to do so and if you are feeling selection anxiety, then use what you are most comfortable using!
With all of this in mind… here’s my preferred stack and you should use the same.
Entirely kidding! However, I do think there is implicit value in discussing how someone (e.g. me) builds something. This is particularly true if it may encourage discussion or improve your existing stack in some meaningful way. There’s no guarantee that you, the reader, may find my particular stack encouraging at this time, but learning about it now could pay dividends in the future. With that said, let’s get down to it!
I’m a big fan of TypeScript, as are other companies like slack, reddit, and of course, Microsoft, among many others! The static typing analysis makes me feel confident that my code is as bug-free as possible, and I truly enjoy writing TypeScript code now that the ecosystem has seen some maturation, particularly with the scoped package
@types, which contains many type declarations files for most of the packages I tend to use. Additionally, I think the
tsc compiler is first-class, and I’ve found it particularly great for Node development. Let me explain why as I walk through some basic project setup for TypeScript.
The first step when starting with any TypeScript project is to create a TypeScript configuration file, similarly to
.babelrc, etc. TypeScript uses a
json file in the project root called