JokeAPI icon indicating copy to clipboard operation
JokeAPI copied to clipboard

Converting to TypeScript and improving performacnce

Open VenRoot opened this issue 4 years ago • 8 comments

Is your feature request related to a problem? Please describe.

No

Describe the solution you'd like

Recreating the whole code with TypeScript and trying to improve it

VenRoot avatar Jun 25 '21 08:06 VenRoot

I have started working on it.

https://github.com/sahithyandev/JokeAPI/tree/typescript-migration

sahithyandev avatar Aug 07 '21 13:08 sahithyandev

I can't recommend working on it at the moment as there's lots of changes in v2.4.0 (see #239) that would invalidate a big part of a TS rework.

Sv443 avatar Aug 08 '21 13:08 Sv443

Yeah, you are right. It will surely be a disaster if the typescript code is merged into the main branch now. Actually, I didn't know PR #239 when I started my work. I just saw it about 5 hours ago or so. When I did saw that PR, I decided to stop my work right there. I am gonna leave it as a "proof-of-concept" kinda thing.

What about bringing in a build system? For example, rollup. (the one I have in sahithyandev/JokeAPI##typescript-migration) That way, we can write more modern code. And also, in case, moving to typescript becomes one of the main objectives in a future release, that existing build system, would make the transition so smooth and easy.

What do you think about it?

sahithyandev avatar Aug 08 '21 14:08 sahithyandev

Could you elaborate on what Rollup does for JokeAPI and how it would be worth implementing?

Sv443 avatar Aug 08 '21 14:08 Sv443

Rollup (or any other bundler) will allow us to use ES6 imports and the new ES features that node doesn't support yet. And also, tree shaking. But, for JokeAPI, that is not much useful.

Then why did I ask about it? It will allow us to transition to typescript without making any sudden breaks and slowly. We can use typescript and javascript side-by-side. That's the one and only reason.

In conclusion, if there are no plans for typescript in the near future of JokeAPI, it's not worth implementing now. 🙂

sahithyandev avatar Aug 08 '21 15:08 sahithyandev

I'd definitely want JokeAPI to be converted to TypeScript eventually but if that day comes I'd probably even go as far as rewriting the entire API while I'm already at it, since v2 is built on a very unstable codebase (better than v1 but still very bad).

Sv443 avatar Aug 11 '21 13:08 Sv443

Gonna put this on hold for now. At this point I can't recommend anyone to refactor the code, especially when v2.4 is currently in the works.

Sv443 avatar Oct 13 '21 08:10 Sv443

Decided to reopen as rollup does sound like something I'd want to implement eventually, and move on to TS completely, but it's gonna need to be on v2.5.0 or something. I will update this issue once I planned it out and want to start working on it.

Sv443 avatar Dec 04 '21 11:12 Sv443

Version 3.0.0 is in the works now and it is completely rewritten from the ground up in TypeScript: https://github.com/Sv443-Network/JokeAPI/tree/v3

Sv443 avatar Jan 11 '24 20:01 Sv443