An Interest In:
Web News this Week
- March 19, 2024
- March 18, 2024
- March 17, 2024
- March 16, 2024
- March 15, 2024
- March 14, 2024
- March 13, 2024
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 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
Original Link: https://dev.to/stacksjar/typescript-new-version-features-opc
Dev To
An online community for sharing and discovering great ideas, having debates, and making friendsMore About this Source Visit Dev To