DEV Community

loading...
Cover image for 🔥🔥 Typescript New Version Features

🔥🔥 Typescript New Version Features

Stacksjar
High Quality Practical Resources to skill up your Web Development Career and Boost your Productivity
Updated on ・1 min read

TypeScript is a programming language developed and maintained by Microsoft. It is a strict syntactical superset of JavaScript and adds optional static typing to the language.

Typescript announced its Beta version 4.3 on 1st April 2021, to install this version you could use bellow command

npm install typescript@beta

Template String Type Improvements

New version introduces template literal types for contextually typed template literal expressions.Due to which when inferring to a template literal target type, typescript now permits the source type to also be a template literal type.

Below are some examples of improved assignment relations:

type Color = "red" | "blue";
type Quantity = "one" | "two";

type SeussFish = `${Quantity | Color} fish`;
// same as
// type SeussFish = "one fish" | "two fish"
// | "red fish" | "blue fish";
…or match patterns of other string-like types.

declare let s1: `${number}-${number}-${number}`;
declare let s2: `1-2-3`;

// Works!
s1 = s2;

static Index Signatures

Index signatures allow us set more properties on a value than a type explicitly declares. With latest version index signatures can now be declared as static.

For more Details Checkout the Article here:- Typescript New Version Features

Discussion (1)