Member-only story

Typescript Got a BIG Update

Manpreet Singh
2 min readFeb 23, 2024

--

Welcome back! Typescript is an amazing programming language with a bunch of capability, so, let’s take a look at an awesome update that this language is going to be getting soon! This specific update is the 5.4 RC update! Let’s take a look at some of these changes!

Javascript Updates

With the new updates within Javascript, we now have some updates within Javascript as well! These new additions include support for the Object.groupby and the Map.groupby methods as well!

const array = [0, 1, 2, 3, 4, 5];

const myObj = Object.groupBy(array, (num, index) => {
return num % 2 === 0 ? "even": "odd";
});

Preserved Narrowing

This new version of Typescript brings a new change to narrowing, this new change will allow preservation within function closures! This should make it easier for you to close out your functions automatically!

function printValueLater(value: string | undefined) {
if (value === undefined) {
value = "missing!";
}

setTimeout(() => {
// Modifying 'value', even in a way that shouldn't affect
// its type, will invalidate type refinements in closures.
value = value;
}, 500);

setTimeout(() => {
console.log(value.toUpperCase());
// ~~~~~
// error…

--

--

Manpreet Singh
Manpreet Singh

No responses yet