Skip to content
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

Typecheck javascript #21377

Merged
merged 3 commits into from
Dec 4, 2024
Merged

Typecheck javascript #21377

merged 3 commits into from
Dec 4, 2024

Conversation

jelly
Copy link
Member

@jelly jelly commented Dec 3, 2024

Let's typecheck JavaScript! With the typecheck script we can also run it on JavaScript and filter out all errors we get and error by error remove them. As for example in this PR, spotted a silly typo :)

One issue is that running with --javascript and then without busts the cache, so maybe we just always want to run with --javascript as that should probably work filtering based on file and error list.

@jelly jelly added the no-test For doc/workflow changes, or experiments which don't need a full CI run, label Dec 3, 2024
@jelly jelly requested review from martinpitt and mvollmer December 3, 2024 15:58
Copy link
Member

@martinpitt martinpitt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a different vector/approach than the "relaxed" marker. I'm fine with supporting both and seeing whether a check-by-check or file-by-file approach works better -- and it's nice that we have a choice and can pick the best for the current situation.

But I'd like to see a strategy how we put that into CI. Right now this is entirely optional and dev-side only, and nothing prevents PRs from regressing JS files again. So can test/static-code call the script with --javascript a second time? How is that related to the cache issue you mentioned?

Note the ruff error, which needs to be fixed for this to land.

Thanks!

@jelly
Copy link
Member Author

jelly commented Dec 3, 2024

This is a different vector/approach than the "relaxed" marker. I'm fine with supporting both and seeing whether a check-by-check or file-by-file approach works better -- and it's nice that we have a choice and can pick the best for the current situation.

I'm not sure if I like adding markers in JavaScript files which are totally non-related to JavaScript. I want to experiment with removing errors one by one. And seeing how it goes.

But I'd like to see a strategy how we put that into CI. Right now this is entirely optional and dev-side only, and nothing prevents PRs from regressing JS files again. So can test/static-code call the script with --javascript a second time? How is that related to the cache issue you mentioned?

Well that would be running with --javascript, but as I said if you run with or without javascript it seems to invalidate the TS cache so this will be slower. So we could always run on JS and simply have JS with custom filter rules.

Note the ruff error, which needs to be fixed for this to land.

That's fixed locally.

@martinpitt
Copy link
Member

I'm not sure if I like adding markers in JavaScript files which are totally non-related to JavaScript. I want to experiment with removing errors one by one. And seeing how it goes.

Yes, I agree, that's what I meant with my reply. 👍

So we could always run on JS

So --javascript isn't an either/or, it will check .ts and .js? Why isn't that the default then? Or are there still too many errors in our .js files which aren't yet ignored by that long ignore list?

My point is: If we land this as-is, this is neither enforced by CI nor documented. If that's an experiment, that's ok, but I'd like to know how we get from here to "CI checks and gates on this". As otherwise we'll regress this all the time.

@jelly
Copy link
Member Author

jelly commented Dec 4, 2024

I'm not sure if I like adding markers in JavaScript files which are totally non-related to JavaScript. I want to experiment with removing errors one by one. And seeing how it goes.

Yes, I agree, that's what I meant with my reply. 👍

So we could always run on JS

So --javascript isn't an either/or, it will check .ts and .js? Why isn't that the default then? Or are there still too many errors in our .js files which aren't yet ignored by that long ignore list?

I should have marked this as draft :) I started with optional --javascript mode and seeing how far I could come. Turns out pretty far cough fixing one small error :)

My point is: If we land this as-is, this is neither enforced by CI nor documented. If that's an experiment, that's ok, but I'd like to know how we get from here to "CI checks and gates on this". As otherwise we'll regress this all the time.

will do!

@jelly jelly removed the no-test For doc/workflow changes, or experiments which don't need a full CI run, label Dec 4, 2024
@jelly jelly force-pushed the typecheck-javascript branch from 85fe184 to 08ed416 Compare December 4, 2024 08:22
jelly added 2 commits December 4, 2024 10:45
The typing information we have in pkg/lib and general TypeScript errors
are also useful for JavaScript but generate tons of errors. So we treat
these errors independent from the TypeScript errors so we can one by one
fix our JavaScript, or port it to TypeScript.
@jelly jelly force-pushed the typecheck-javascript branch from 08ed416 to a97c5e7 Compare December 4, 2024 09:58
@jelly jelly requested a review from martinpitt December 4, 2024 10:02
@jelly
Copy link
Member Author

jelly commented Dec 4, 2024

@martinpitt GitHub hides your comment but I've adjusted the commit message :)

martinpitt
martinpitt previously approved these changes Dec 4, 2024
Copy link
Member

@martinpitt martinpitt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! This works for me. @mvollmer can you please check, too?

@@ -47,7 +47,7 @@ export function make_iscsi_session_page(parent, session) {
page_location: ["iscsi", session.data.target_name],
page_name: session.data.target_name,
page_icon: NetworkIcon,
page_categroy: PAGE_CATEGORY_NETWORK,
page_category: PAGE_CATEGORY_NETWORK,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Woohoo!

mvollmer
mvollmer previously approved these changes Dec 4, 2024
Copy link
Member

@mvollmer mvollmer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! The list of ingored errors is long and pretty arbitrary, but this might catch some regressions and then we win.

@jelly
Copy link
Member Author

jelly commented Dec 4, 2024

Thanks! The list of ingored errors is long and pretty arbitrary, but this might catch some regressions and then we win.

Cleaning that up is a huge effort and not always possible. As requested on Matrix here is the statistics for the type of errors:

[('TS7006', 4191),
 ('TS2339', 1773),
 ('TS7005', 778),
 ('TS7031', 768),
 ('TS7053', 489),
 ('TS2345', 318),
 ('TS18046', 293),
 ('TS2322', 276),
 ('TS7034', 276),
 ('TS2739', 192),
 ('TS2531', 181),
 ('TS18047', 119),
 ('TS2741', 76),
 ('TS2769', 66),
 ('TS2554', 58),
 ('TS2683', 42),
 ('TS7008', 36),
 ('TS2353', 35),
 ('TS18048', 33),
 ('TS2307', 29),
 ('TS2551', 17),
 ('TS7023', 17),
 ('TS2810', 15),
 ('TS2532', 10),
 ('TS2571', 8),
 ('TS2550', 8),
 ('TS2533', 8),
 ('TS2375', 7),
 ('TS2304', 6),
 ('TS7016', 6),
 ('TS2540', 5),
 ('TS7019', 5),
 ('TS7022', 3),
 ('TS2538', 3),
 ('TS2367', 2),
 ('TS7015', 2),
 ('TS2349', 2),
 ('TS2363', 2),
 ('TS2447', 2),
 ('TS2407', 2),
 ('TS2305', 2),
 ('TS2365', 2),
 ('TS2559', 2),
 ('TS7024', 2),
 ('TS2488', 1),
 ('TS2693', 1),
 ('TS1345', 1),
 ('TS2581', 1),
 ('TS7009', 1),
 ('TS2790', 1),
 ('TS2362', 1),
 ('TS2740', 1),
 ('TS2464', 1)]

@jelly jelly added the no-test For doc/workflow changes, or experiments which don't need a full CI run, label Dec 4, 2024
@jelly jelly dismissed stale reviews from mvollmer and martinpitt via d85df2e December 4, 2024 14:38
@jelly jelly requested a review from mvollmer December 4, 2024 14:38
When we clean up code and the ignored TypeScript error for JavaScript no
longer applies make gating fail.
@jelly jelly force-pushed the typecheck-javascript branch from d85df2e to d0538a8 Compare December 4, 2024 14:46
Copy link
Member

@mvollmer mvollmer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! Now I want a mode that outputs the statistics! :-)

@jelly jelly merged commit 1ada2a5 into cockpit-project:main Dec 4, 2024
23 of 32 checks passed
@jelly jelly deleted the typecheck-javascript branch December 4, 2024 16:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
no-test For doc/workflow changes, or experiments which don't need a full CI run,
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants