The sea is wide by diving, the sky is high as birds fly. Hey how are you! I’m Ed Qin.
Writing beginner’s mind
Speaking of the web front end, there has been tremendous change in recent years. We may have moved on from slash-and-burn to happier times, but we also face more technological challenges. At present, many companies have fully rolled out the use of TS, VUe3.0 is coming, then will also fully embrace TS, learn TS is imminent. Here, I hope to communicate with you and make progress together by sharing my TS learning journey!
What is TypeScript?
After learning TS, IT gives me a strong sense of “security”.
A basic understanding of TS was obtained through a Wikipedia search:
- TypeScript is an open source programming language that is maintained and managed by Microsoft. TypeScript not only includes JavaScript syntax, but also provides static type checking and manipulating Prototype using object-oriented programming syntax that looks like class-based. Anders hejlsberg, lead architect of C# and founder of Delphi and Turbo Pascal, is involved in TypeScript development.
- TypeScript is designed to develop large applications, and TypeScript can be translated into JavaScript. Since TypeScript is a strict superset of JavaScript, any existing JavaScript program is a legitimate TypeScript program.
- TypeScript supports definition files that add type information to existing JavaScript libraries, making it easier for other programs to use values from existing libraries as if they were statically typed. Currently, there are third parties providing definition files for common libraries such as jQuery, MongoDB, Node.js and d3.js.
- TypeScript was first released in Version 0.8 in October 2012 after two years of internal development at Microsoft.
Here’s how it’s described on the official website:
TypeScript is a superset of JavaScript types that can be compiled into pure JavaScript. The compiled JavaScript can run on any browser. TypeScript compilation tools can run on any server and on any system.
TypeScript was developed by Microsoft and derives its code from GitHub
Why TypeScript?
TypeScript makes code more readable and maintainable
- With a strong type system, strong typing is actually the best documentation, and most functions can be used just by looking at the type definition, right
- Errors can be found at compile time, avoiding low-level bugs in the code
- Resolved a pain point where the IDE/ editor could not intelligently prompt. Improved development efficiency, writing code can be very happy “a shuttle”
TypeScript is incredibly inclusive
- You can automatically make type inferences even if you do not explicitly define a type
- JavaScript files can be generated even if TypeScript compilations fail
- Compatible with third-party libraries, even if they are not written in TypeScript, you can write separate type files for TypeScript to read
- With a very active community ecology, solutions can be found to most of the problems encountered in daily development
- Largely supported for ES6 and some of the latest ESNex features
The disadvantage of TypeScript
- There is a learning cost to understanding concepts such as Interfaces, Generics, Classes, enumerated types, and so on that may not be familiar to front-end engineers
- The definition of type may make students who are used to writing in weak type mode feel uncomfortable, which will increase some workload in short-term development
- It may not work perfectly with some libraries
The TypeScript outlook
As you can see from Google Trends and NPM download trends, the TypeScript community is growing fast. Ts is a relatively high quality technology trend in terms of development efficiency, maintainability and online runtime quality. In addition, we have been smart enough to play with VARIOUS kinds of TS, with VS Code + TypeScript, React + TypeScript and other combinations, TS is becoming more and more popular, and also supported and used by major international manufacturers. Vue3.0 will also be rewritten with TS. The rewritten Vue3.0 will support TS better, so TS will become more popular and a big advantage for front-end developers.