What Are the New Features of Typescript 5?

omgzui
JavaScript in Plain English
6 min readMar 3, 2023

--

Photo by Chris Ainsworth on Unsplash

1. Const type parameters

Typescript will generally infer an object into a more generic type. For example, in the following example, the inferred names are string[]

type HasNames = { names: readonly string[] };
function getNamesExactly<T extends HasNames>(arg: T): T["names"] {
return arg.names;
}

const names = getNamesExactly({ names: ["Alice"…

--

--

A full stack engineer, with some medicinal knowledge, likes to read and share.