Migrate all js code to TypeScript #1788

Closed
opened 2026-02-05 01:52:33 +03:00 by OVERLORD · 4 comments
Owner

Originally created by @b-zurg on GitHub (Jul 10, 2020).

This isn't exactly a feature request but I think that migrating all the JS code to typescript would be great for that section of the codebase, especially if it grows in the future.

I have a good deal of experience doing this sort of thing, and would be happy to, but wanted to confirm that the maintainers would be happy with a PR of this nature before doing the work.

Originally created by @b-zurg on GitHub (Jul 10, 2020). This isn't exactly a feature request but I think that migrating all the JS code to typescript would be great for that section of the codebase, especially if it grows in the future. I have a good deal of experience doing this sort of thing, and would be happy to, but wanted to confirm that the maintainers would be happy with a PR of this nature before doing the work.
Author
Owner

@ssddanbrown commented on GitHub (Jul 11, 2020):

Hi @b-zurg,

I would prefer the code was not migrated to typescript. Personally I am much more comfortable with plain JS and I don't feel the benefits of moving to TS would be worth the extra build step and abstraction.

@ssddanbrown commented on GitHub (Jul 11, 2020): Hi @b-zurg, I would prefer the code was not migrated to typescript. Personally I am much more comfortable with plain JS and I don't feel the benefits of moving to TS would be worth the extra build step and abstraction.
Author
Owner

@b-zurg commented on GitHub (Jul 12, 2020):

I don't believe there would be another build step. As the code is already being run through webpack then it would just involve adding the typescript loader.

As far as comfort, everything you're used to in JS is there in Typescript. The only thing that's really added is typed annotations on functions. I don't think getting used to TS from JS would take more than 10 minutes of scanning through the docs.

I could make a branch and just give it a go if you'd like to see what changes would be involved.

@b-zurg commented on GitHub (Jul 12, 2020): I don't believe there would be another build step. As the code is already being run through webpack then it would just involve adding the typescript loader. As far as comfort, everything you're used to in JS is there in Typescript. The only thing that's really added is typed annotations on functions. I don't think getting used to TS from JS would take more than 10 minutes of scanning through the docs. I could make a branch and just give it a go if you'd like to see what changes would be involved.
Author
Owner

@ssddanbrown commented on GitHub (Jul 12, 2020):

I don't believe there would be another build step. As the code is already being run through webpack then it would just involve adding the typescript loader.

Sure, Not another step for a user to run but an extra step and transformation for the code to go through, and an extra delay when developing.

As far as comfort, everything you're used to in JS is there in Typescript. The only thing that's really added is typed annotations on functions. I don't think getting used to TS from JS would take more than 10 minutes of scanning through the docs.

I have played with TS before, and I really liked working with the language. I did come across some turbulence when using libraries but I'd imaging that's improved considerably over the last few years.

That said, I don't think it's worth it for this project. The cost will be more than 10 minutes of docs browsing. From past experience, it will be a considerable hit as you become transfixed on ensuring things are done the proper typescript way. The bugs we have experienced have mainly been logical rather than type based so I don't think the safety benefit will be large. Where types do need to be considered, I've found jsdoc, in tandem with a competent ide, to work well. Keeping the code more accessible as plain JS is more important to me.

@ssddanbrown commented on GitHub (Jul 12, 2020): > I don't believe there would be another build step. As the code is already being run through webpack then it would just involve adding the typescript loader. Sure, Not another step for a user to run but an extra step and transformation for the code to go through, and an extra delay when developing. > As far as comfort, everything you're used to in JS is there in Typescript. The only thing that's really added is typed annotations on functions. I don't think getting used to TS from JS would take more than 10 minutes of scanning through the docs. I have played with TS before, and I really liked working with the language. I did come across some turbulence when using libraries but I'd imaging that's improved considerably over the last few years. That said, I don't think it's worth it for this project. The cost will be more than 10 minutes of docs browsing. From past experience, it will be a considerable hit as you become transfixed on ensuring things are done the proper typescript way. The bugs we have experienced have mainly been logical rather than type based so I don't think the safety benefit will be large. Where types do need to be considered, I've found jsdoc, in tandem with a competent ide, to work well. Keeping the code more accessible as plain JS is more important to me.
Author
Owner

@ssddanbrown commented on GitHub (Jul 25, 2020):

Since I've made my thinking known, and discussion has discontinued, I'll close this off.

@ssddanbrown commented on GitHub (Jul 25, 2020): Since I've made my thinking known, and discussion has discontinued, I'll close this off.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/BookStack#1788