fix: makeEventFunctions take an array of parameters#2186
fix: makeEventFunctions take an array of parameters#2186mofojed merged 4 commits intodeephaven:mainfrom
Conversation
mofojed
commented
Aug 12, 2024
- Previously every emit required exactly one parameter, which is not the case
- Allow zero or more parameters
- Previously every emit required exactly one parameter, which is not the case - Allow zero or more parameters
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #2186 +/- ##
==========================================
- Coverage 46.66% 46.65% -0.02%
==========================================
Files 692 692
Lines 38629 38583 -46
Branches 9814 9845 +31
==========================================
- Hits 18028 18000 -28
+ Misses 20548 20530 -18
Partials 53 53
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
mattrunyon
left a comment
There was a problem hiding this comment.
Not entirely sure where you'd want to put it or how to incorporate it, but you can use conditional types to support a non-array type as a single param, array/tuple
type MyFunc<P = []> = (...params: P extends unknown[] ? P : [P]) => void;Also an interesting thing I saw was you can label tuples for argument signatures. See here for more info, but the gist is you could do makeEventFunctions<[count: number, title: string]>(...) and TS should then show the params as count and title in autocomplete instead of arg0 and arg1
- Name the params tuple - Allow passing in a param list or a single value
- Added more tests around different payload types as well