File tree Expand file tree Collapse file tree 2 files changed +27
-24
lines changed
Expand file tree Collapse file tree 2 files changed +27
-24
lines changed Original file line number Diff line number Diff line change @@ -5,45 +5,45 @@ describe("onJSON", () => {
55 test . each < [ On , ReturnType < typeof onJSON > ] > ( [
66 [ "push" , "push" ] ,
77 [
8- [ "push" , "pullRequest " ] ,
8+ [ "push" , "pull_request " ] ,
99 [ "push" , "pull_request" ] ,
1010 ] ,
1111 [
1212 [
13- "branchProtectionRule " ,
14- "checkRun " ,
15- "checkSuite " ,
13+ "branch_protection_rule " ,
14+ "check_run " ,
15+ "check_suite " ,
1616 "create" ,
1717 "delete" ,
1818 "deployment" ,
19- "deploymentStatus " ,
19+ "deployment_status " ,
2020 "discussion" ,
21- "discussionComment " ,
21+ "discussion_comment " ,
2222 "fork" ,
2323 "gollum" ,
24- "issueComment " ,
24+ "issue_comment " ,
2525 "issues" ,
2626 "label" ,
27- "mergeGroup " ,
27+ "merge_group " ,
2828 "milestone" ,
29- "pageBuild " ,
29+ "page_build " ,
3030 "project" ,
31- "projectCard " ,
32- "projectColumn " ,
31+ "project_card " ,
32+ "project_column " ,
3333 "public" ,
34- "pullRequest " ,
35- "pullRequestReview " ,
36- "pullRequestReviewComment " ,
37- "pullRequestTarget " ,
34+ "pull_request " ,
35+ "pull_request_review " ,
36+ "pull_request_review_comment " ,
37+ "pull_request_target " ,
3838 "push" ,
39- "registryPackage " ,
39+ "registry_package " ,
4040 "release" ,
4141 "status" ,
4242 "watch" ,
43- "workflowCall " ,
44- "workflowDispatch " ,
45- "workflowRun " ,
46- "repositoryDispatch " ,
43+ "workflow_call " ,
44+ "workflow_dispatch " ,
45+ "workflow_run " ,
46+ "repository_dispatch " ,
4747 "schedule" ,
4848 ] ,
4949 [
Original file line number Diff line number Diff line change @@ -227,7 +227,7 @@ export type Events = {
227227 } [ ] ;
228228} ;
229229
230- const eventNameMap = {
230+ const EventNameMap = {
231231 branchProtectionRule : "branch_protection_rule" ,
232232 checkRun : "check_run" ,
233233 checkSuite : "check_suite" ,
@@ -267,11 +267,14 @@ const eventNameMap = {
267267
268268export type EventName = keyof Events ;
269269export type EventType < T extends EventName > = Events [ T ] ;
270- export type On = EventName | EventName [ ] | { [ K in EventName ] ?: EventType < K > } ;
270+ export type On =
271+ | ( typeof EventNameMap ) [ keyof typeof EventNameMap ]
272+ | ( typeof EventNameMap ) [ keyof typeof EventNameMap ] [ ]
273+ | { [ K in EventName ] ?: EventType < K > } ;
271274
272275export function onJSON ( on : On ) : string | string [ ] | Record < string , unknown > {
273- if ( typeof on === "string" ) return eventNameMap [ on ] ;
274- if ( Array . isArray ( on ) ) return on . map ( ( event ) => eventNameMap [ event ] ) ;
276+ if ( typeof on === "string" ) return on ;
277+ if ( Array . isArray ( on ) ) return on ;
275278
276279 return {
277280 ...( on . branchProtectionRule != null && {
You can’t perform that action at this time.
0 commit comments