W
Wasp-lang•9mo ago
Danquillius

Wasp/OpenSaas Typescript vs Javascript

Hey everyone. I'm new to Wasp and OpenSaas and have been playing around with it a bit, as well as reading documentation. I realized that I have never really used Typescript before and it's been slightly inconvenient to understand things. So, I was wondering if it's possible for me to pull the OpenSaas code from the repo and then change the project to only have .js files rather than .ts ones? I would like to completely opt in to javascript and change all the code and file extenstions that have .ts Thank you!
5 Replies
Vinny (@Wasp)
Vinny (@Wasp)•9mo ago
Yes. This is possible. You can even mix js and ts files in a wasp project 🙂 I would suggest sticking with typescript though
Danquillius
Danquillius•9mo ago
Would I have to switch over and make all the new js files manually?
Vinny (@Wasp)
Vinny (@Wasp)•9mo ago
I’m not sure the best way to do that. What’s keeping you from leaving the ts files as they are and creating new files as js? The benefits of ts are huge, if with copilot and autocomplete it’s pretty easy to type things correctly, even if you’ve never used ts before
martinsos
martinsos•9mo ago
@Danquillius the reason why we don't have a JS version of open saas is that it would require us maintiang both JS and TS version, which would require more effort from us, and also, since we are kind of counting on OpenSaas being used for a bit bigger projects, it is anyway recommended to use TS (bigger project -> more important strict types are). So, similar as Vince, I would strongly recommend learning TS if you can spare the time, at least to some degree. You don't have to use classes or anything, you don't have to define some crazy types, you can instead just learn the basics and write mostly JS while TS compiler does a lot of the job for you in the background and warns you about the stuff that looks suspicious. That said, I completely undersatnd your wish to go with JS -> you are already taking quite a few new things up here, and if you can skip also having to learn TS to get something going, it will make the progress easier. TS is a superset of JS -> meaning you can write JS in TS and it will work. So while you could go for rewriting all the files into JS, for which I would recommend just dropping them into ChatGPT and asking it to rewrite them, you could also try just writing JS in the existing TS files. TS has type any which you can use to say you don't care which type is something, which might help with some TS errors, and you can even turn TS off completely for a file, by using @ts-nocheck.
Danquillius
Danquillius•9mo ago
That's actually very helpful. I can probably use some of these tools you guys have mentioned to learn TS. Also, I didn't know you could use the "any" type, this seems like it could come in handy in worst case situations lol. Thanks a lot guys!
Want results from more Discord servers?
Add your server