New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Typescript support? #56
Comments
They discussed that topic recently on the adonis gitter-channel. Seems @thetutlage does not really like typescript. |
ok,i'm just curious about it. anyway, it is a good framework. |
@thetutlage having typescript support is in my opinion a huge advantage. When you need to refactor, it's really a life saver. So yes, at some point, typedefinitions will be needed and someone will have to make it. I think it might be a good idea to reconsider that issue. Plus, people who don't want to use typescript wouldn't have to. |
Creating type definition or using TypeScript to code the core of Adonis is two different things. You can still create type as a community project and use them in your code. |
@maxime1992 Looking at the amount of time I have, it is not possible for me to spend time in writing TS definitions. Community effort is welcomed |
@thetutlage I totally understand that and my curiosity about Adonis makes me want to go deeper in the source code (if I ever find some time to). Not sure I'll find some time for that but I'd be glad to help ! |
@thetutlage I want to congratulate you and any collaborators for the amount of work that's gone into the 4.0 version. I believe this is the web framework NodeJS needed for me to be able to finally get my co-workers and myself to step away from PHP. I always thought Laravel itself was very nice, and I use it every day, and am glad you have taken inspiration from it. So many frameworks come out for Node all the time and most of them are doing way too little or are pointlessly doing away with traditional MVC concepts which nowadays are mainstream and understood generally. None of them seem to be built on sane foundations. None of them can be taken seriously for enterprise-level project requirements. ASP.NET MVC is my framework of choice. I love many things about it, but one of the main things is the fact that I'm working with a statically typed programming language (C#) and all the benefits that come with it. Still, ASP.NET MVC is not as easy and straightforward to work with as Laravel is. AdonisJS has the potential to become the best of both worlds: A batteries-included, ready-to-go, easy-to-configure, get-shit-done Web framework that is also built on a more modern and sane programming language. Javascript is that language, but I do wish I could go all the way and use Typescript. The benefits of using a language like it are many and have been mentioned here and in countless other places, but to me, the single greatest benefit is that I don't have to remember hundreds of method names and their parameters, properties, return types, for the many frameworks and libraries, etc, etc, and I value this greatly because I, as a very forgetful person, need to look up documentation for the simplest things all the time and all those minutes wasted during development add up. If I'm going to switch to Node completely, AdonisJS 4.0 will probably be the framework I pick. I'm worried that there doesn't seem to be any community effort towards writing TS definitions or anything of the sort. I'm currently working on a small boilerplate and am manually replacing things such as The blueprint could also set up a .tsconfig with a Mainly my point is I'm wondering if you still feel the same about TypeScript and if there are any new initiatives to get any of this going. |
Looking over some of the code, you do provide JSDoc annotations which Typescript now picks up, but I'm unsure how complete the mapping is between the two. |
Thanks for your appraising feedback. These kind of comments gives more energy to work on AdonisJs everyday. Regarding TypescriptI 100% agree with you that context switching between docs and code is kind of hard and eats lots of time. I am more than happy to add support for Intellisense to the framework but it requires good amount of work. Lemme talk about it here in depth Not a Typescript projectThe project itself is not written in Typescript, that means I have to write type definitions by hand, in order to get the intellisense working I am not sure how much help JSDOC code blocks can provide to intellisense engine If it works out of the box without any glitches, then I am happy to improve the code blocks and make them more useable. If not, then Custom resolverThe biggest roadblock is the resolution of namespace via ProxiesI make heavy use of ES6 proxies to build unified API's without writing verbose code. Also have to see if Intellisense works great with ES6 proxies or not. Action steps.
All this requires a lot more research, since I am not a user of Vscode. I am happy to do that either, but expecting that support for Typescript will be out soon is not true. It will be great, if someone can guide me in the right direction for
|
Hi, @rhyek contacted me on gitter. I have some experience in TypeScript. So I think I can give some suggestion.
I would rather argue JsDoc cannot compete with TS completion at all. JsDoc can provide some basic completion. But anything advanced isn't available. Plus, users have to annotate their code with JsDoc to get completion.
Yes, TypeScript does provide powerful plugin architecture. One similar use case is Angular's completion. However, authoring a plugin requires much effort and great understanding of TS internal. (Indeed, Angular's plugin is developed by full time googler)
e.g. https://github.com/adonisjs/docs/blob/4.0/07-lucid/01-model.adoc Other features like trait, and stringly typed route e.g. If some one does want to write TS definition, I guess they can provide good Adonis users should be conscious about this trade off. |
I don't think so. Javascript is a dynamic language and API's built around Javascript will always make full use of it's nature. Also Typescript is the superset, so for me having good Intellisense is important but not at the cost of spaghetti API. So things like
will be there always |
@thetutlage I believe most of the issues with having good typing will stem from the use of the I feel most of its utility can be summed up to be just a shortcut for import paths? This is not needed, IMO. Having to develop code editor plugins to support it seems to not be the best allocation of resources. |
The |
For what it's worth, as a Laravel user who has been lurking on Adonis for awhile, I have to say that typescript support is the main thing I'm waiting for to take Adonis for a test drive. I feel like I will miss interfaces and proper webstorm support. I feel like typescript will help me feel more at home and provide some of the convinces I'm used to with php. |
@incraigulous I'm in the exact same situation. I've decided to keep using ASP.NET MVC Core for now for personal projects and Laravel at work and hope to some day revisit this framework which honestly seems quite nice, this issue aside. |
Board the ship and help writing it 😊 |
I'm a totally noob, though. I'd probably do more harm than good. Hah. |
I don't have much time to invest right now, knowing the fact majority of users asking for intellisense never tried Adonis and are not ready to help in either way Also there is no surity that Typescript will remain a thing, since many superset of Javascript came and went |
Yeah, totally understandable @thetutlage. You've got to set your priorities as do we. Just thought you might want to be aware of something that is holding some back from giving it a chance. I think the bigger issue if the ide use function support to be honest. That is probably also the easier problem to tackle too. You can't please everyone though and there are only so many hours in a day. Thanks for all you do! Hopefully I'll be on team Adonis one day! For now I'll probably keep lurking... |
I have playing a little with VsCode these days and was able to get some intellisense working without creating the language server. What I need now is, if someone can help in creating Typedefinition files for individual repos of Adonis. |
I could give it a shot. Might start with Lucid. What are your ideas about the |
@rhyek Cool! So this is how I am planning to take it on.
As said earlier, even with above points, we will always need type definitions. So it's right time to start writing them one by one. |
Good news for everyone, module resolution hook has landed in Node.js! 🎉 |
Closing for the moment. Feel free to discuss it on the forum. |
I started little bit of experimenting on this, and seems like I got it working. |
@thisdotvoid It works great. I don't see any specific downsides. But, yes will have to write all the functions in this file. I am happy you initiated it 😄 |
Will try to make some progress on weekends |
@thisdotvoid i just jumped into the adonis bandwagon and i want typescript support, ill help you out ! |
@wilomgfx yeah, I jumped off (at least for now 😄). database support is the most important imho. this fork has done some work https://github.com/janez89/adonisjs-types |
@thisdotvoid perfect ! |
Maybe we could try writing whole app in typescript, instead of just getting help from vscode? I think it's doable |
I don't think I will re-write the system in Typescript to make VsCode happy and then write in https://reasonml.github.io coz some other editor got crazy support for it. I never liked the idea of TypeScript at all, Javascript is dynamic and it simply takes the freedom of having dynamic code. I created an issue here, which shows the rough edges of Typescript microsoft/TypeScript#18656 Again, for some people these rough edges are fine, since they start thinking in Typescript way, but it's not for me |
@thisdotvoid na, types are the way to go! That way type lovers like us get the types we love and @thetutlage keeps his JS codebase without type complexity which does not fit his coding type for adonis. I have contributed to many open source libs and adding TS types to @types npm package and https://github.com/DefinitelyTyped/DefinitelyTyped and thats the way to go :). We dont actually get help from VSCode, but from the TS server. Which can be used in any code editor, ides (like WebStorm :D) to provide type hinting. Anywho, lets make the type defs really awesome to let our fellow type lovers happy :D Side note, ill def be writing my apps in TypeScript, so i'll be (forced ;) ?) to update any type defs when adonis API and libs update, which i dont mind at all as its pretty darn simple :) |
Hey @thetutlage, I'd like to contribute (or at least try to) into the total rewrite if possible. Dumb question: would it be just as "simple" as taking all the files one by one and rewriting them in TS? Or am I missing something? If so, do you have any suggestions on where to start? Sounds like crazy? I really love this project just by reading the docs. It remembers me Laravel a lot. And I'd really love to see it written in ts too :) |
@caiusCitiriga it would indeed be turning the js into ts... but you'd have to update a fork all the time... much easier to update type defs on api changes. It also adds benefits to JS users, because typescript can help type hint js files now. |
@thetutlage I didn't suggest to rewrite framework itself, rather the code we write as users of framework, could be written in typescript. In short, we could create alternative typescript starter app for cli, framework itself doesn't need to change. eg: |
@thisdotvoid that would definitely work, but before that we need the type definitions 100% done and working properly :) |
I've been writing in PHP for 11 years, and Laravel for few years, and loved them very much. I was also coding frontend in JS, and one day my SPA app became very complex, my brain capacity was totally exhausted and then I've opened wonderful world of TypeScript. The best part is learning took just couple of hours, and it was couple hours of pleasure. I also love so much that I can switch project from JS to TS incrementally, just changing file extension from .js to .ts and adding required type hints. After using TS in frontend, I've returned to some tasks in backend, and that was the time when I decided to say good bye to PHP world, because it looked so poor and so unmaintainable after TS experience. I started to look at node.js alternatives for Laravel, and thank god, I've found Adonis! However, the fact, that framework does not use TS is little bit disappointing, because TS is the reason, I am switching from PHP. I can still use Adonis, writing my own classes in TS, though. But if Adonis will have official support for TS, that would be perfect for so many people like me, that would be just paradise. Good to see, that work have started. I'll try to help, if I can. @thetutlage Please look at TS, you will enjoy it very much, it'll free so much brain capacity and boost your productivity, I guarantee you :) I've so much impressed by your current brain capacity/productivity and the result (Adonis), though! |
I started using it too https://github.com/poppinss/edge/tree/next/packages/lexer. In version 5, most of the pieces of Adonis will be moved to Typescript and there will be an official Typescript boilerplate too. Still couple of things to note
|
@thetutlage That's so cool to hear! Almost like a dream :) What you've just wrote makes me 100% start migrating to Adonis. Talking about your notes:
[Offtopic] P.S. Thank you again, wonderful framework you have made, I am hundred percent sure it will gain extreme popularity, and I've made bet for it, after analyzing dozen of frameworks (sails.js, nest.js, meteor, loopback, feathers etc.) [Offtopic once more] Btw, it's a fun, if one read throughout posts in this issue, he can see transformation of the framework creator from "I hate TypeScript" to "I've started using it, framework will be switched to it" :D That's a good sign of open mind of the author and good future of the project |
@thetutlage I'd like to help out with TypeScript migration. Is there a roadmap or anywhere for discussion? E: nevermind it's here! #871 |
This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
will adonis support typescript?
The text was updated successfully, but these errors were encountered: