Skip to content

Commit ac8308b

Browse files
authored
Refactor FileTreeItem type (#36137)
1 parent 1e72b15 commit ac8308b

File tree

3 files changed

+15
-16
lines changed

3 files changed

+15
-16
lines changed

web_src/js/components/ViewFileTreeItem.vue

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2,20 +2,10 @@
22
import {SvgIcon} from '../svg.ts';
33
import {isPlainClick} from '../utils/dom.ts';
44
import {shallowRef} from 'vue';
5-
import {type createViewFileTreeStore} from './ViewFileTreeStore.ts';
6-
7-
export type Item = {
8-
entryName: string;
9-
entryMode: 'blob' | 'exec' | 'tree' | 'commit' | 'symlink' | 'unknown';
10-
entryIcon: string;
11-
entryIconOpen: string;
12-
fullPath: string;
13-
submoduleUrl?: string;
14-
children?: Item[];
15-
};
5+
import type {createViewFileTreeStore, FileTreeItem} from './ViewFileTreeStore.ts';
166
177
const props = defineProps<{
18-
item: Item,
8+
item: FileTreeItem,
199
store: ReturnType<typeof createViewFileTreeStore>
2010
}>();
2111

web_src/js/components/ViewFileTreeStore.ts

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,20 @@ import {GET} from '../modules/fetch.ts';
33
import {pathEscapeSegments} from '../utils/url.ts';
44
import {createElementFromHTML} from '../utils/dom.ts';
55
import {html} from '../utils/html.ts';
6-
import type {Item} from './ViewFileTreeItem.vue';
6+
7+
export type FileTreeItem = {
8+
entryName: string;
9+
entryMode: 'blob' | 'exec' | 'tree' | 'commit' | 'symlink' | 'unknown';
10+
entryIcon: string;
11+
entryIconOpen: string;
12+
fullPath: string;
13+
submoduleUrl?: string;
14+
children?: Array<FileTreeItem>;
15+
};
716

817
export function createViewFileTreeStore(props: {repoLink: string, treePath: string, currentRefNameSubURL: string}) {
918
const store = reactive({
10-
rootFiles: [] as Array<Item>,
19+
rootFiles: [] as Array<FileTreeItem>,
1120
selectedItem: props.treePath,
1221

1322
async loadChildren(treePath: string, subPath: string = '') {

web_src/js/globals.d.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@ declare module '*.vue' {
1212
import type {DefineComponent} from 'vue';
1313
const component: DefineComponent<unknown, unknown, any>;
1414
export default component;
15-
// List of named exports from vue components, used to make `tsc` output clean.
16-
// To actually lint .vue files, `vue-tsc` is used because `tsc` can not parse them.
15+
// Here we declare all exports from vue files so `tsc` or `tsgo` can work for
16+
// non-vue files. To lint .vue files, `vue-tsc` must be used.
1717
export function initDashboardRepoList(): void;
1818
export function initRepositoryActionView(): void;
1919
}

0 commit comments

Comments
 (0)