In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-25 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/03 Report--
This article mainly shows you the "ThinkJS2.1 support TypeScript sample analysis", the content is easy to understand, clear, hope to help you solve your doubts, the following let the editor lead you to study and learn "ThinkJS2.1 support TypeScript sample analysis" this article.
One: support TypeScript
TypeScript is a free and open source programming language developed by Microsoft. It is a superset of JavaScript, adds optional static types to the language, and is very useful in large projects. ThinkJS 2.1began to support the creation of TypeScript-type projects, and will be automatically compiled and updated during development, eliminating the need for complex operations such as manual compilation. The details are as follows:
1. Create a TypeScript project
2. D.ts file
3. Existing projects have been upgraded to TypeScript projects.
Modify entry file
Modify package.json
Modify .thinkjsrc
Download think.d.ts description file
Modify file suffix
Add a description file to the project file
Second: performance improvement
Whether a framework is excellent or not depends on the functionality supported on the one hand and performance on the other. Although ThinkJS is more suitable for large-scale projects, its function and complexity are much higher than those of Express and Koa, but its performance is not much lower than that of Express and Koa. For specific test data, please see the figure below.
Note: the above data are tested using a distributed stress testing system.
As you can see from the test data in the above figure, although the performance of ThinkJS is lower than that of Express and Koa, the difference is not significant. Both ThinkJS and Sails.js are more suitable for large projects, but ThinkJS performs much better than Sails.js.
For specific test code, please see: https://github.com/thinkjs-team/thinkjs-performance-test, you can download the code to test locally. If you use the ab test tool, please note that the tool is very unstable under the Mac system, and the results of multiple tests will vary greatly.
Three: more featur
In addition to the two more prominent features mentioned above, ThinkJS 2.1 has more features as follows:
Controller supports the form of subdirectories
Support for PostgreSQL database
Model schema supports default values
The middleware in Hook returns null to prevent subsequent middleware execution.
Http and controller add the alias method render of display
Add serial execution method think.waterfall
Validate supports regularization
Fetch supports data transmission
Logic supports determining the type of request
Direct call to action is supported in scheduled tasks
Upgrade Babel to 6
International languages are no longer case-sensitive.
Change the content of the acquisition template file to asynchronous
The http object no longer inherits from the EventEmitter class
Excluding think.mode_mini mode, controller supports subdirectories
Database configuration name changed to database
Change the current fields to schema
Database configuration pwd changed to password
Optimize the generation of http objects so that you don't have to copy them every time
Filter files of hidden types such as .svn, .git, etc.
Move the file bin/index.js to src/command.js
Move the runtime directory to the project root directory and add the think.RUNTIME_PATH path constant
Adapter type adds the ability to convert to lowercase automatically and gives hints
Add thinkData to cache common data in the system
Combine think.locale and controller.locale methods
Fixed the problem that the inheritance file of nunjucks template could not be found
Fixed an issue with escaped / resulting in recognition errors in pathname
Fixed a problem where the data returned by the http.file method was modified and the source data was also modified.
Fix the problem that needs to be replaced by\\ in the path / under windows
Fixed error report caused by template file not in root directory under nunjucks
Fix the problem that sensitive data may be output on the page in production environment
Fixed the problem of no error message and poor location after failed parsing of JSON data in development mode
Fixed the problem that the view path was not updated when the module was created after view root_path modification
Fixed incorrect verification of required | int rules
Fixed problems with redis cache parsing configuration
Fixed a problem where REST API does not support logic
Fixed an error in the count method if the field name passed in was a keyword
The above is all the content of the article "sample Analysis of ThinkJS2.1 supporting TypeScript". Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.