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

build: Move to es2021, fix some typing problems #21391

Merged
merged 7 commits into from
Dec 6, 2024

Conversation

martinpitt
Copy link
Member

@martinpitt martinpitt commented Dec 6, 2024

This is still a bit on the new-ish side [1], and for type checking we'd
need to update to es2023.

[1] https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/findLastIndex
This makes String.replaceAll() available, which we use a lot.
These cannot be declared within JavaScript/Tyepscript, as their types
depend on the playground manifest and our internal D-Bus server.
Don't mix boolean and number, that's too confusing (one instance of
TS2365 "Operator '<=' cannot be applied to types 'boolean' and
'number'.").

Declare it as an optional number (i.e. `null`able), and help the type
checker with an assertion.
@@ -144,7 +144,7 @@ export function Router(callbacks) {
}

unique_id += 1;
const seed = (cockpit.transport.options["channel-seed"] || "undefined:") + unique_id + "!";
const seed = (cockpit.transport.options["channel-seed"] || "undefined:") + unique_id.toString() + "!";
Copy link
Contributor

Choose a reason for hiding this comment

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

This added line is not executed by any test.

@martinpitt martinpitt marked this pull request as draft December 6, 2024 08:12
@martinpitt
Copy link
Member Author

This failure repeats, needs investigation.

@@ -32,7 +32,7 @@ const pkgOptions = {
nodePaths,
outbase: './pkg',
outdir: "./dist",
target: ['es2020'],
target: ['es2021'],
Copy link
Member

Choose a reason for hiding this comment

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

This should be lib, we don't want to target es2021 in the end result of the transpilation 5f68dfe

Copy link
Member Author

@martinpitt martinpitt Dec 6, 2024

Choose a reason for hiding this comment

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

I don't want half of our code 2021 and half 2020. Let's stick to one standard.

Copy link
Member

Choose a reason for hiding this comment

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

Alright! Would have also liked a .eslintrc.json downgrade but we can do that later.

@martinpitt
Copy link
Member Author

I debugged the failure. It's completely unrelated to the changes here, they just trigger 3x affected retries. Fixed in cockpit-project/bots#7185

@martinpitt martinpitt marked this pull request as ready for review December 6, 2024 08:52
Copy link
Member

@jelly jelly left a comment

Choose a reason for hiding this comment

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

Cool, I guess this was all the trivial stuff? :)

@martinpitt
Copy link
Member Author

@jelly not all of it, I spent an hour on this and thought "this is big enough for a CI run". I'm sure there's much more low-hanging fruit.

@martinpitt martinpitt merged commit 6331d3d into cockpit-project:main Dec 6, 2024
87 checks passed
@martinpitt martinpitt deleted the types branch December 6, 2024 09:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants