What Are the New Features of Typescript 5?
Published in
6 min readMar 3, 2023
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"…