Typescript New Version Features

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…


This content originally appeared on DEV Community and was authored by Stacksjar

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.

This post was Originally written here:- Typescript New Version Features


This content originally appeared on DEV Community and was authored by Stacksjar


Print Share Comment Cite Upload Translate Updates
APA

Stacksjar | Sciencx (2021-07-29T04:44:40+00:00) Typescript New Version Features. Retrieved from https://www.scien.cx/2021/07/29/typescript-new-version-features/

MLA
" » Typescript New Version Features." Stacksjar | Sciencx - Thursday July 29, 2021, https://www.scien.cx/2021/07/29/typescript-new-version-features/
HARVARD
Stacksjar | Sciencx Thursday July 29, 2021 » Typescript New Version Features., viewed ,<https://www.scien.cx/2021/07/29/typescript-new-version-features/>
VANCOUVER
Stacksjar | Sciencx - » Typescript New Version Features. [Internet]. [Accessed ]. Available from: https://www.scien.cx/2021/07/29/typescript-new-version-features/
CHICAGO
" » Typescript New Version Features." Stacksjar | Sciencx - Accessed . https://www.scien.cx/2021/07/29/typescript-new-version-features/
IEEE
" » Typescript New Version Features." Stacksjar | Sciencx [Online]. Available: https://www.scien.cx/2021/07/29/typescript-new-version-features/. [Accessed: ]
rf:citation
» Typescript New Version Features | Stacksjar | Sciencx | https://www.scien.cx/2021/07/29/typescript-new-version-features/ |

Please log in to upload a file.




There are no updates yet.
Click the Upload button above to add an update.

You must be logged in to translate posts. Please log in or register.