May 2024 Monthly Newsletter - using the in operator for type narrowing
In this issue, I look at content from myself and other authors for the month of May and I also add in Typescript type, on how you can use the in operator for type narrowing over type assertions.
Hey, Everyone. Another month has passed, and today is the day I look back on informative content I came across last month and news related to Typescript.
My name is Maina Wycliffe, and I love teaching Typescript to developers. My goal is to break down complex topics into small, understandable bits that you can apply in your day-to-day life as a developer.
If you want to learn Typescript, please subscribe to this newsletter.
Now that that self-plug is out of the way (subtle) let’s get to today’s issue.
Typescript Tip 💡
This month was thin on official Typescript news, so instead of that, I will leave you with a Typescript tip instead.
Many developers habitually reach out for type assertions when checking whether an object with a union of types has specific fields. The in-operator is perfect for this, as shown below:
From All Things Typescript
If you like my content and want to support my work, please consider supporting me (you can buy me a double latte, the juice that powers my creativity and determination ☕️) through Github Sponsors.
Book Recommendation
Learning Typescript by Josh Goldberg
This is an amazing book, especially if you are starting Typescript. It’s well laid out, and the concepts are broken down into small, easy-to-understand concepts that are easy to follow and grasp different concepts in Typescript.
You can learn more about the book here.
From Other Authors
Effective Testing in JavaScript by Ashley Davis
This article emphasizes the importance of testing, advocating for a proactive approach where testing is frequent and early, ensuring code remains functional. The author shares personal insights and techniques to make testing less laborious while still effective, ultimately underscoring the goal of delivering reliable code that meets customer needs.
Automatically Generate Types for Your PostgreSQL Database by Paul Scanlon
SQL can be typesafe, in the JavaScript sense of the word. Paul Scanlon demonstrates why devs shouldn't be afraid to work with "raw SQL."
The Typescript feature we all wanted by Ohans Emmanuel
Inferred Type Predicates are now available in Typescript 5.5 Beta. In this article, I’ll explain the much-awaited feature and how it’ll help you write more type-safe code.
A Guide to the Node.js Event Loop by Musab Habeeb
The Node.js event loop is a crucial mechanism in Node.js that makes Node.js programs run concurrently and asynchronously. Mastering the Node.js event loop helps a Node.js developer understand how Node.js programs run under the hood.
In this article, you will learn the basics of the event loop, starting with threads and processes, then how the JavaScript event loop works, and finally, how the Node.js event loop works.
How to document your JavaScript package Andy Jiang, Luca Casonato, Jo Franchetti, and Leo Kettmeir
This article emphasizes the importance of writing clear, concise JSDocs. It outlines best practices for creating JSDocs, including providing good type information, using tags to add detail, and including examples to demonstrate usage. It also discusses the significance of keeping documentation up-to-date with code changes and auditing JSDoc comments to ensure quality. The goal is to help users quickly understand how to use a package with minimal effort, enhancing the package's success within the community.
That's it for this issue. Thank you for getting this far. If you enjoyed this article and would like to support my work, please share and like this issue and consider sharing All Things Typescript with friends and colleagues.
Did you know you can hire me to coach your team and help them improve their Typescript skills? If this interests you, please get in touch with me to discuss it.
And until next time, please keep on learning.