Discusion: Migrate from JS to TS #6935

Closed
opened 2025-11-02 07:11:37 -06:00 by GiteaMirror · 9 comments
Owner

Originally created by @6543 on GitHub (Feb 27, 2021).

we use a lot of custom JavaScript web_src/js, witch we could migrate to TypeScript.

any thoughts on this topic?

Originally created by @6543 on GitHub (Feb 27, 2021). we use a lot of custom JavaScript [web_src/js](https://github.com/go-gitea/gitea/tree/master/web_src/js), witch we could migrate to TypeScript. any thoughts on this topic?
GiteaMirror added the type/proposal label 2025-11-02 07:11:37 -06:00
Author
Owner

@6543 commented on GitHub (Feb 27, 2021):

cc @silverwind

@6543 commented on GitHub (Feb 27, 2021): cc @silverwind
Author
Owner

@noerw commented on GitHub (Feb 27, 2021):

If we're talking about typedefs for API responses; that might be benefitial, those could be generated from the swagger.json..

But for everything else? The current code is a hodgepodge of various imperative APIs with mostly ad-hoc types. I don't see a benefit really, it will mostly slow down the build..
otoh, if we're talking long term about a frontend rewrite, Typescript would be a good option

@noerw commented on GitHub (Feb 27, 2021): If we're talking about typedefs for API responses; that might be benefitial, those could be generated from the swagger.json.. But for everything else? The current code is a hodgepodge of various imperative APIs with mostly ad-hoc types. I don't see a benefit really, it will mostly slow down the build.. otoh, if we're talking long term about a frontend rewrite, Typescript would be a good option
Author
Owner

@gnat commented on GitHub (Feb 27, 2021):

Gonna have to say no thanks because:

  • No obvious advantage or win for gitea?
  • More complex, slower build process.
  • Increased barrier for development.
  • ECMAScript has been evolving so quickly lately that it will probably get types and supersede TS in the near future anyway. The true "futureproof" choice is to continue evolving with the latest ECMAScript spec.
@gnat commented on GitHub (Feb 27, 2021): Gonna have to say no thanks because: - No obvious advantage or win for gitea? - More complex, slower build process. - Increased barrier for development. - ECMAScript has been evolving so quickly lately that it will probably get types and supersede TS in the near future anyway. The true "futureproof" choice is to continue evolving with the latest ECMAScript spec.
Author
Owner

@a1012112796 commented on GitHub (Feb 27, 2021):

How to handle the code which using vue is also a problem ...

@a1012112796 commented on GitHub (Feb 27, 2021): How to handle the code which using ``vue`` is also a problem ...
Author
Owner

@gnat commented on GitHub (Feb 27, 2021):

A bit off topic but I feel as if vue will be replaced with the ability to send POST data + show returned content as simple tag attributes as part of the upcoming HTML standard, which is the true "futureproof" way. See https://htmx.org as an example of this.

@gnat commented on GitHub (Feb 27, 2021): A bit off topic but I feel as if vue will be replaced with the ability to send POST data + show returned content as simple tag attributes as part of the upcoming HTML standard, which is the true "futureproof" way. See https://htmx.org as an example of this.
Author
Owner

@lafriks commented on GitHub (Feb 27, 2021):

I have never been fun of TS, ecmascript has evolved quite much so I don't see much use for TS to be honest

@lafriks commented on GitHub (Feb 27, 2021): I have never been fun of TS, ecmascript has evolved quite much so I don't see much use for TS to be honest
Author
Owner

@lunny commented on GitHub (Feb 27, 2021):

I think the more urgent thing is the maintainability of frontend codes. We may should rework the frontend but have to consider below things:

  • The new frontend should not depend on a backend technology like Go template, so that frontend and backend developers could cooperate easier.
  • The new frontend should be friendly with SEO so that repositories on public Gitea site could be found by search engine.
  • The new frontend could be introduced step by step because it's difficult to replace all of the frontend codes once.
@lunny commented on GitHub (Feb 27, 2021): I think the more urgent thing is the maintainability of frontend codes. We may should rework the frontend but have to consider below things: - [ ] The new frontend should not depend on a backend technology like Go template, so that frontend and backend developers could cooperate easier. - [ ] The new frontend should be friendly with SEO so that repositories on public Gitea site could be found by search engine. - [ ] The new frontend could be introduced step by step because it's difficult to replace all of the frontend codes once.
Author
Owner

@silverwind commented on GitHub (Mar 5, 2021):

I also dislike TypeScript because it has no runtime support anywhere and last I checked the compilation is a major hindrance when developing because it easily doubles the build time. I'd rather wait to have official types support in ECMAScript.

The new frontend should not depend on a backend technology like Go template, so that frontend and backend developers could cooperate easier.

Yes, we need to extract the JS from the templates as well as nuke that conglomerate of gotemplate and vue that is used on the frontpage repo list. Some inline scripts are still necessary for performance-critical cases, but maybe they could also be extracted to files.

@silverwind commented on GitHub (Mar 5, 2021): I also dislike TypeScript because it has no runtime support anywhere and last I checked the compilation is a major hindrance when developing because it easily doubles the build time. I'd rather wait to have official types support in ECMAScript. > The new frontend should not depend on a backend technology like Go template, so that frontend and backend developers could cooperate easier. Yes, we need to extract the JS from the templates as well as nuke that conglomerate of gotemplate and vue that is used on the frontpage repo list. Some inline scripts are still necessary for performance-critical cases, but maybe they could also be extracted to files.
Author
Owner

@mohe2015 commented on GitHub (Mar 6, 2021):

If the separate build step is not wanted JSDoc https://www.typescriptlang.org/docs/handbook/jsdoc-supported-types.html may be a possibility (but keep in mind that it has some limitations (which don't matter here I think)).

@mohe2015 commented on GitHub (Mar 6, 2021): If the separate build step is not wanted JSDoc https://www.typescriptlang.org/docs/handbook/jsdoc-supported-types.html may be a possibility (but keep in mind that it has some limitations (which don't matter here I think)).
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/gitea#6935