File tree Expand file tree Collapse file tree 1 file changed +43
-0
lines changed Expand file tree Collapse file tree 1 file changed +43
-0
lines changed Original file line number Diff line number Diff line change @@ -78,6 +78,41 @@ export type View =
78
78
| WorkspacesView
79
79
| WorktreesView ;
80
80
81
+ // prettier-ignore
82
+ type TreeViewByType = {
83
+ [ T in TreeViewTypes ] : T extends 'branches'
84
+ ? BranchesView
85
+ : T extends 'commits'
86
+ ? CommitsView
87
+ : T extends 'contributors'
88
+ ? ContributorsView
89
+ : T extends 'drafts'
90
+ ? DraftsView
91
+ : T extends 'fileHistory'
92
+ ? FileHistoryView
93
+ : T extends 'launchpad'
94
+ ? LaunchpadView
95
+ : T extends 'lineHistory'
96
+ ? LineHistoryView
97
+ : T extends 'pullRequest'
98
+ ? PullRequestView
99
+ : T extends 'remotes'
100
+ ? RemotesView
101
+ : T extends 'repositories'
102
+ ? RepositoriesView
103
+ : T extends 'searchAndCompare'
104
+ ? SearchAndCompareView
105
+ : T extends 'stashes'
106
+ ? StashesView
107
+ : T extends 'tags'
108
+ ? TagsView
109
+ : T extends 'workspaces'
110
+ ? WorkspacesView
111
+ : T extends 'worktrees'
112
+ ? WorktreesView
113
+ : View ;
114
+ } ;
115
+
81
116
export type ViewsWithBranches = BranchesView | CommitsView | RemotesView | RepositoriesView | WorkspacesView ;
82
117
export type ViewsWithBranchesNode = BranchesView | RepositoriesView | WorkspacesView ;
83
118
export type ViewsWithCommits = Exclude < View , LineHistoryView | StashesView > ;
@@ -124,6 +159,14 @@ export abstract class ViewBase<
124
159
>
125
160
implements TreeDataProvider < ViewNode > , Disposable
126
161
{
162
+ is < T extends keyof TreeViewByType > ( type : T ) : this is TreeViewByType [ T ] {
163
+ return this . type === ( type as unknown as Type ) ;
164
+ }
165
+
166
+ isAny < T extends ( keyof TreeViewByType ) [ ] > ( ...types : T ) : this is TreeViewByType [ T [ number ] ] {
167
+ return types . includes ( this . type as unknown as T [ number ] ) ;
168
+ }
169
+
127
170
get id ( ) : TreeViewIds < Type > {
128
171
return `gitlens.views.${ this . type } ` ;
129
172
}
You can’t perform that action at this time.
0 commit comments