Skip to content

Commit fe74e99

Browse files
author
ntwigg
committed
Use typescript features a little better.
1 parent 5875110 commit fe74e99

File tree

1 file changed

+12
-17
lines changed

1 file changed

+12
-17
lines changed

browser-extension/src/datamodel/handlers/github-handler.ts

Lines changed: 12 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,17 @@
11
import { OverType } from '../../overtype/mock-overtype'
22
import type { CommentEnhancer, CommentSpot } from '../enhancer'
33

4-
export type GitHubCommentType =
5-
| 'GH_ISSUE_NEW'
6-
| 'GH_PR_NEW'
7-
| 'GH_ISSUE_ADD_COMMENT'
8-
| 'GH_ISSUE_EDIT_COMMENT'
9-
| 'GH_PR_ADD_COMMENT'
10-
| 'GH_PR_EDIT_COMMENT'
11-
| 'GH_PR_CODE_COMMENT'
4+
const GITHUB_COMMENT_TYPES = [
5+
'GH_ISSUE_NEW',
6+
'GH_PR_NEW',
7+
'GH_ISSUE_ADD_COMMENT',
8+
'GH_ISSUE_EDIT_COMMENT',
9+
'GH_PR_ADD_COMMENT',
10+
'GH_PR_EDIT_COMMENT',
11+
'GH_PR_CODE_COMMENT',
12+
] as const
13+
14+
export type GitHubCommentType = (typeof GITHUB_COMMENT_TYPES)[number]
1215

1316
export interface GitHubContext extends CommentSpot {
1417
type: GitHubCommentType // Override to narrow from string to specific union
@@ -20,15 +23,7 @@ export interface GitHubContext extends CommentSpot {
2023

2124
export class GitHubHandler implements CommentEnhancer<GitHubContext> {
2225
forCommentTypes(): string[] {
23-
return [
24-
'GH_ISSUE_NEW',
25-
'GH_PR_NEW',
26-
'GH_ISSUE_ADD_COMMENT',
27-
'GH_ISSUE_EDIT_COMMENT',
28-
'GH_PR_ADD_COMMENT',
29-
'GH_PR_EDIT_COMMENT',
30-
'GH_PR_CODE_COMMENT',
31-
]
26+
return [...GITHUB_COMMENT_TYPES]
3227
}
3328

3429
tryToEnhance(textarea: HTMLTextAreaElement): [OverType, GitHubContext] | null {

0 commit comments

Comments
 (0)