Feb 2024 Monthly Newsletter - TypeScript 5.4 RC and more
A Hand-curated list of Articles and Videos from All Things Typescript and other authors for the month of February 2024
Hey everyone, my name is Maina Wycliffe. Every month, I curate a list of resources related to Typescript (and related stacks) that I find interesting and informative in the month. In this issue, we take a look at some of the interesting content I came across in the last month.
Announcements
Typescript 5.4 RC Released
We are getting closer to the release of Typescript 5.4 and in February, the release candidate was announced.
Here is a summary of the features to expect:
Assignment Narrowing is Preserved in Closures
New NoInfer Utility Type
Type Declarations for Object.groupBy and Map.groupBy
Support for require() calls in
--moduleResolution
bundler and--module preserve
Checked Import Attributes and Assertions
Quick Fix for Adding Missing Parameters
Let me know if there are any features you want me to take a look at in the next few issues of All Things Typescript.
Please check out the release blog post here for more information about the above features.
All Things Typescript Feb 2024 Issues
In February, I consistently released articles every week, except one. In case you missed any, here is a list of the issues that I released in February.
From other authors
Articles
When 'as never' Is The Only Thing That Works by Matt Pocock
TLDR: as never
is very occasionally needed in TypeScript. Let's look at an example where it's necessary.
Using Generics In TypeScript: A Practical Guide by Alex Khomenko
TLDR: Among these features, generics stand out as one of the most powerful tools for creating flexible, reusable components without sacrificing type safety. In this blog post, we'll dive into the world of generics in TypeScript, exploring how they can be used to write cleaner, more maintainable code that is robust and easy to understand.
TypeScript Advanced Types: Working with Conditional Types by Alex Khomenko
TLDR: Conditional types in TypeScript provide logic to type definitions, allowing for type transformations based on certain conditions. They can be used for type inference, filtering types with utility types, building type-safe API handlers, and defensive programming. Best practices include keeping conditions simple, using type aliases and utility types, and testing types. Limitations include operating at compile-time only and not being suitable for all use cases.
Understanding Async/Await and Promises in JavaScript and TypeScript by Geoffrey Kim
TLDR: This blog post aims to demystify the scenarios where you might or might not need to use await
when dealing with Promises, through detailed explanations and illustrations.
How Types Work in TypeScript – Explained with JavaScript + TypeScript Code by Sahil Mahapatra
TLDR: In this comprehensive guide, we'll explore TypeScript's basic types by comparing them with their JavaScript counterparts. I'll also clarify the differences and advantages offered by TypeScript's static typing features.
ESLint no-unused-vars: _ ignore prefix by John Reilly
TLDR: One thing that I missed when switching to the ESLint option is that, with noUnusedLocals
and noUnusedParameters
, you can simply ignore unused variables by prefixing a variable with the _
character. That's right, sometimes I want to declare a variable that I know I'm not going to use, and I want to do that without getting shouted at by the linter.
It turns out you can get ESLint to respect the TypeScript default of ignoring variables prefixed with _
; it's just not the default configuration for no-unused-vars
. But with a little configuration, we can have it. This post is a quick guide to how to implement that configuration.
Videos
There’s a fast new code editor in town by Fireship
8 NEW JavaScript 2024 Features by Web Dev Simplified
I didn't know snapshot testing was a thing by Joshua Morony
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.
That's all for now. I'll see you again at the end of February for another monthly recap.
I just wanted to say that there was an article or video, I didn't read or watch, that suggested snapshot testing is a good thing. I think it's a complete waste of time, and occupies time that could be otherwise being spent crafting good unit tests that test the application the way the user actually uses it or tests that you've adhered to your state management solution correctly. I actually don't see much value in end-to-end (E2E) testing either--they're also brittle tests much like snapshots that have to be frequently updated in significant, non-trivial ways. I think that good unit testing along with a quality QA team really works best for me. Perhaps others do get some benefit from snapshot, integration, or E2E testing, but I just can't justify the time or expense associated with their upkeep and up-front costs. I'd be very curious to hear about someone who has Cypress for instance working well for them, or someone who can show me how to get the headaches out of snapshot testing. I'm not judging others, but in my two decades of experience with testing, unit tests and good QA engineers can't be replaced.