@@ -4,24 +4,23 @@ import { logger } from '../../logger'
44import { modifyDOM } from '../modifyDOM'
55import { commonGithubOptions , prepareGitHubHighlighter } from './github-common'
66
7- interface GitHubPRNewCommentSpot extends CommentSpot {
8- type : 'GH_PR_NEW_COMMENT'
7+ const GH_PR_NEW = 'GH_PR_NEW' as const
8+
9+ interface GitHubPRNewSpot extends CommentSpot {
10+ type : typeof GH_PR_NEW
911 domain : string
1012 slug : string // owner/repo
1113 title : string
1214 head : string // `user:repo:branch` where changes are implemented
1315 base : string // branch you want changes pulled into
1416}
1517
16- export class GitHubPRNewCommentEnhancer implements CommentEnhancer < GitHubPRNewCommentSpot > {
18+ export class GitHubPRNewEnhancer implements CommentEnhancer < GitHubPRNewSpot > {
1719 forSpotTypes ( ) : string [ ] {
18- return [ 'GH_PR_NEW_COMMENT' ]
20+ return [ GH_PR_NEW ]
1921 }
2022
21- tryToEnhance (
22- textarea : HTMLTextAreaElement ,
23- location : StrippedLocation ,
24- ) : GitHubPRNewCommentSpot | null {
23+ tryToEnhance ( textarea : HTMLTextAreaElement , location : StrippedLocation ) : GitHubPRNewSpot | null {
2524 if ( textarea . id === 'feedback' ) {
2625 return null
2726 }
@@ -53,12 +52,12 @@ export class GitHubPRNewCommentEnhancer implements CommentEnhancer<GitHubPRNewCo
5352 head,
5453 slug,
5554 title,
56- type : 'GH_PR_NEW_COMMENT' ,
55+ type : GH_PR_NEW ,
5756 unique_key,
5857 }
5958 }
6059
61- enhance ( textArea : HTMLTextAreaElement , _spot : GitHubPRNewCommentSpot ) : OverTypeInstance {
60+ enhance ( textArea : HTMLTextAreaElement , _spot : GitHubPRNewSpot ) : OverTypeInstance {
6261 prepareGitHubHighlighter ( )
6362 const overtypeContainer = modifyDOM ( textArea )
6463 return new OverType ( overtypeContainer , {
@@ -68,7 +67,7 @@ export class GitHubPRNewCommentEnhancer implements CommentEnhancer<GitHubPRNewCo
6867 } ) [ 0 ] !
6968 }
7069
71- tableUpperDecoration ( spot : GitHubPRNewCommentSpot ) : React . ReactNode {
70+ tableUpperDecoration ( spot : GitHubPRNewSpot ) : React . ReactNode {
7271 const { slug } = spot
7372 return (
7473 < >
@@ -78,11 +77,11 @@ export class GitHubPRNewCommentEnhancer implements CommentEnhancer<GitHubPRNewCo
7877 )
7978 }
8079
81- tableTitle ( spot : GitHubPRNewCommentSpot ) : string {
80+ tableTitle ( spot : GitHubPRNewSpot ) : string {
8281 return spot . title || 'New Pull Request'
8382 }
8483
85- buildUrl ( spot : GitHubPRNewCommentSpot ) : string {
84+ buildUrl ( spot : GitHubPRNewSpot ) : string {
8685 return `https://${ spot . domain } /${ spot . slug } /issue/new`
8786 }
8887}
0 commit comments