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

Correctly mark vararg parameters in TypescriptDefinition #2239

Merged
merged 3 commits into from Mar 19, 2024

Conversation

oxc
Copy link
Contributor

@oxc oxc commented Mar 16, 2024

Currently parameters that take a variadic number of arguments are marked as regular array types, e.g. min(arg1: number, arg2: number[]).

That signature only lets you call as min(1, [2, 3]), which is incorrect and fails.

Instead, it should be marked as min(arg1: number, ...arg2: number[]), otherwise the method cannot be called correctly from Typescript.

(I considered introducing an inner Parameter helper class, but that makes the descriptiveParamNames and combatFilterType overrides less convenient to handle. Let me know if I should give it a go.)

Mark e.g. min as `min(arg1: number, ...arg2: number[])`, otherwise the
method cannot be called correctly from Typescript.
@oxc oxc requested a review from a team as a code owner March 16, 2024 14:45
Copy link

codecov bot commented Mar 16, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 37.44%. Comparing base (d17dfc4) to head (345feb4).

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff            @@
##               main    #2239   +/-   ##
=========================================
  Coverage     37.43%   37.44%           
- Complexity    19837    19841    +4     
=========================================
  Files          1110     1110           
  Lines        169562   169570    +8     
  Branches      35817    35817           
=========================================
+ Hits          63483    63492    +9     
+ Misses        96012    96011    -1     
  Partials      10067    10067           
Files Coverage Δ
...rceforge/kolmafia/textui/TypescriptDefinition.java 92.73% <100.00%> (+0.33%) ⬆️

... and 1 file with indirect coverage changes


Continue to review full report in Codecov by Sentry.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update d17dfc4...345feb4. Read the comment docs.

@gausie
Copy link
Contributor

gausie commented Mar 16, 2024 via email

@oxc

This comment was marked as off-topic.

@oxc

This comment was marked as off-topic.

@oxc

This comment was marked as off-topic.

@oxc

This comment was marked as off-topic.

@oxc
Copy link
Contributor Author

oxc commented Mar 16, 2024

This is great. I probably want to blacklist min and max though, in line with other functions with equivalents in the JS standard lib

That probably makes sense. I would still like to keep this because it is more correct, and we might have some real use case for varargs in the future.

Copy link
Contributor

@gausie gausie left a comment

Choose a reason for hiding this comment

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

Thank you for this, and for being perhaps the first person to read through and understand this class :)

@gausie gausie enabled auto-merge (squash) March 19, 2024 13:54
@gausie gausie merged commit 40554a2 into kolmafia:main Mar 19, 2024
5 checks passed
@oxc oxc deleted the tsDef_vararg branch March 19, 2024 15:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants