Basic knowledge of TypeScript
Basic knowledge of TypeScript

Basic knowledge of TypeScript

1. What is Typescript?

TypeScript is an open-source code developed and built by Microsoft. This is an upgraded project from JavaScript to add static types and object-oriented classes to become faster and more stable.

TypeScript classes and modules are fully integrated. Not stopping there, Typescript also upgraded its version to apply many new techniques from ECMAScript.

???2. Why use TypeScript?

  • Many frameworks to choose from: Currently, a lot of Javascript Frameworks have encouraged their users to use TypeScript to develop, use easier, and optimize. Example: React.js, Angular,..
  • Ease of development of large projects:?TypeScript integrates a multitude of modern techniques, ensuring extremely fast accurate object-oriented programming.
  • Open source:?TypeScript helps users to freely use and serve their work completely free of charge, no charge. It also has great support from the community.
  • Supports many JavaScript features:?Modern JavaScript functions are fully updated and provided by TypeScript, ensuring backward compatibility on all browsers. These include ECMAScript 2015 – ES6...
  • TypeScript is JavaScript:?TypeScript's ability to compile JavaScript code is extremely flexible and stable. Therefore, programmers can run TypeScript anywhere as long as there is support for JavaScript compilation.

???3. Some popular TypeScript data

In the process of using TypeScript, programmers will inevitably encounter some extremely common data types such as: string, any, boolean, number, void and array. Each type has its own distinct advantages, namely:

  • string:?String of data enclosed in "double quotes" or "single quotes", similar to the function of strings in JavaScript.
  • any:?Use variables that are difficult to define or of unknown type.
  • boolean:?Data type true or false.
  • number:All numeric values are represented by number type, there is no separate definition for integer or real number (float).
  • void:?The data type used when the function does not return any value.
  • arrays:?The data type represents an array of values, using two main syntaxes: Array or number []

???4. TypeScript Functions

  • Static Typing

Referring to the functionality of TypeScript, it is definitely impossible to ignore Static Typing. Because through this, the programmer can declare the type for the variable and reduce the rate of mistyped assignment of many values. If the code is wrong, TypeScript will notify immediately so that the user can correct it.

  • Interface:?Interfaces are one of the functions of TypeScript that help you check whether an object conforms to a certain structure or not. If a property has the wrong type, name, or omission, the Interface will warn you immediately.
  • Classes:?Referring to the main function of TypeScript, indeed Classes have supported the use of many programmers. Because this open-source code provides a class system similar to many programming languages like C#.
  • Module:?The modularity in TypeScript makes it easier for developers to work on large projects by effectively dividing code into small pieces. In addition, reuse makes the project much easier to understand and organize than a file containing thousands of lines of code.
  • Generics:?The Generics function included in TypeScript allows the programmer to use a function that takes parameters of different types. Thereby creating reusable components for Generics will outperform Any. Because Generics will preserve the type for input and output variables.

With the information that has just been shared, it has partly helped readers have a more accurate and detailed view of what Typescript is, an open-source application that is extremely popular. Hopefully, after the reference, you will know how to use through the functions and outstanding advantages and disadvantages of this open-source code.

(Source: Vietnix)

要查看或添加评论,请登录

SphinxJSC的更多文章

社区洞察

其他会员也浏览了