-
-
Notifications
You must be signed in to change notification settings - Fork 5.6k
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
Add initial typescript config and use it for eslint,vitest,playwright #31186
Conversation
4894af3
to
d31eb63
Compare
Should we really want to switch to typescript? |
Definitely. It'll catch a number of undiscovered bugs. Initially it will just be a rename of the files with non-enforced type checking, and we can then gradually fix the type issues. I don't think we will ever enable strict typescript (not worth the effort imho and I personally do that only on a very small amount of my modules), so people can still write it mostly like JS, with optional type info sprinkled in. |
@wxiaoguang any objections to this? |
No idea, not an expert in this field. Maybe you could ask @go-gitea/technical-oversight-committee |
Given that this PR has received no attention in a month, I assume there is no interest in typescript among the maintainers, which is a shame as I've recently come to like it a lot and it has lead me to find hundrets of bugs in my various JS projects. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am for TS over JS, though you and wxiaoguang are definitely the ones who touch it the most in this project.
I'll give it a LGTM since you are interested in moving to it and wxiaoguang at least appears to be neutral on the idea? (Feel free to correct me)
Thanks for reassuring. I assume @wxiaoguang will also eventually appreciate typescript. It personally took me 5 years and I strongly rejected earlier, but after using it for a while now, I don't want to miss it anymore especially because of the nice editor integration that properly typed code has. |
I also use TS in my projects, but I didn't see how it would help Gitea's state and I didn't see any plan or guideline. I have shared my opinions in another PR: starting from the hardest part and rewriting some existing code could show more than just proposing. |
I have shown the similar question for "jQuery removal". But it seems that replacing jQuery functions with a lot of |
Thank you for the feedback, I will be pretty busy in next months so I guess I won't have time in this project then 😁 |
The plan is to rename *.js to *.ts, post a small guidline and then gradually fix the type issues. It's not rocket science. TS is for all intends and purposes a superset of JS and I'm sure our code will work with just a rename. |
Yup, "jQuery removal" is also not rocket science, but I have spent so much time on fixing regressions. |
To be clear: I never meant I have objection for TS or "jQuery removal", instead I appreciate everyone's work. I just mean: it should be done with some plans and guidelines, to avoid abuse. |
I'd say it's easier to migrate to typescript than to migrate off jQuery because jQuery has so much magic behaviour internally. With typescript fixes, I'm usually pretty confident because the added code never actually reaches the runtime. |
Next step: #31521 |
* giteaofficial/main: [skip ci] Updated translations via Crowdin Fix markdown preview $$ support (go-gitea#31514) Add Passkey login support (go-gitea#31504) Use stable version of fabric (go-gitea#31526) Always use HTML attributes for avatar size (go-gitea#31509) Add initial typescript config and use it for eslint,vitest,playwright (go-gitea#31186) Support legacy _links LFS batch responses (go-gitea#31513) Fix JS error with disabled attachment and easymde (go-gitea#31511)
This enables eslint to use the typescript parser and resolver which brings some benefits that eslint rules now have type information available and a tsconfig.json is required for the upcoming typescript migration as well. Notable changes done:
vue-scoped-css/enforce-style-type
rule, there was only one violation and I added a inline disable there.i/no-unresolved
to remove now-unnecessary workaround for the resolveri/no-named-as-default
as it seems to raise bogus issues in the webpack configeslint-plugin-playwright
and fix issuestsc
linting tomake lint-js