Replies: 3 comments 4 replies
-
Not sure how accurate this is but "moving to TypesScript" is apparently on the v1 roadmap project. |
Beta Was this translation helpful? Give feedback.
-
Maybe it's an unpopular opinion, but there might be a good use-case for this package to upgrade it using GPT4 of OpenAI. It seems to be a relatively small package if I check all the files and methods. It might optimize quiet some code as well? Thoughts? |
Beta Was this translation helpful? Give feedback.
-
It's a huge task to refactor the entire framework into typescript, and I believe it should be approached gradually. One possible solution is to develop tools, libraries, and other resources that can translate typescript into Moleculer service definitions. Think of it like babel for Moleculer. If more people contribute by providing complementary typescript libraries in this endeavor, it will greatly facilitate the framework transition. Their input will offer valuable insights into the optimal path to take for transitioning to typescript. By the way, I've shared my approach to migrating to TypeScript here: #1204. I opted for using decorators as they provide an effective means of storing metadata (particularly in typescript) and transforming it into JavaScript during runtime. |
Beta Was this translation helpful? Give feedback.
-
Is your feature request related to a problem? Please describe.
While the current JavaScript implementation of moleculer.js has served well, there have been instances where runtime errors and potential bugs could have been avoided if the package had been designed using TypeScript. The lack of static typing and autocompletion can lead to slower development speed and potential errors.
Describe the solution you'd like
I propose upgrading the package to support a complete TypeScript implementation. TypeScript, as a statically typed superset of JavaScript, provides robust type checking capabilities which help in catching potential bugs during compile-time, rather than at runtime. It also offers superior tooling, including autocompletion, type inference, and documentation capabilities. Additionally, TypeScript code can be more readable due to the availability of type annotations, thus making the package more maintainable.
Describe alternatives you've considered
As an alternative, we could consider introducing TypeScript gradually, by using it in certain parts of the package and progressively expanding its use. However, given the advantages of TypeScript over JavaScript, a full transition would still be the most beneficial in the long term.
Additional context
TypeScript is future-proof, as it is constantly updated to include the latest ECMAScript features. This ensures that the package will stay compatible and modern as the JavaScript standard evolves.
Despite being a different language, TypeScript is compiled down to JavaScript and thus maintains full compatibility with JavaScript code. This allows developers to gradually adopt TypeScript, or even to use both languages in the same project.
This proposed upgrade would not alienate developers who prefer JavaScript, but it would open the door to the growing number of developers who prefer TypeScript for its additional safety and tooling features.
The upgrade to TypeScript, although substantial, represents a significant investment in the long-term quality and sustainability of the moleculer.js. It is, in my view, a progressive move that would greatly improve the package's overall development experience and code reliability.
Beta Was this translation helpful? Give feedback.
All reactions