@@ -7,8 +7,6 @@ import {space} from 'sentry/styles/space';
7
7
import { useLocation } from 'sentry/utils/useLocation' ;
8
8
import type { StoriesQuery } from 'sentry/views/stories/types' ;
9
9
10
- type DirContent = Record < string , unknown > ;
11
-
12
10
interface Props extends ComponentProps < 'div' > {
13
11
files : string [ ] ;
14
12
}
@@ -23,17 +21,16 @@ export default function StoryTree({files, style}: Props) {
23
21
) ;
24
22
}
25
23
26
- function FolderContent ( { path, content} : { content : DirContent ; path : string } ) {
24
+ function FolderContent ( { path, content} : { content : TreeMapping ; path : string } ) {
27
25
const location = useLocation < StoriesQuery > ( ) ;
28
26
const currentFile = location . query . name ;
29
27
30
28
return (
31
29
< UnorderedList >
32
30
{ Object . entries ( content ) . map ( ( [ name , children ] ) => {
33
- const childContent = children as DirContent ;
34
31
const childPath = toPath ( path , name ) ;
35
32
36
- if ( Object . keys ( childContent ) . length === 0 ) {
33
+ if ( Object . keys ( children ) . length === 0 ) {
37
34
const isCurrent = childPath === currentFile ? true : undefined ;
38
35
const to = `/stories/?name=${ childPath } ` ;
39
36
return (
@@ -50,7 +47,7 @@ function FolderContent({path, content}: {content: DirContent; path: string}) {
50
47
< ListItem key = { name } >
51
48
< Folder open >
52
49
< FolderName > { name } </ FolderName >
53
- < FolderContent path = { childPath } content = { childContent } />
50
+ < FolderContent path = { childPath } content = { children } />
54
51
</ Folder >
55
52
</ ListItem >
56
53
) ;
@@ -59,7 +56,9 @@ function FolderContent({path, content}: {content: DirContent; path: string}) {
59
56
) ;
60
57
}
61
58
62
- function toTree ( files : string [ ] ) {
59
+ interface TreeMapping extends Record < string , TreeMapping > { }
60
+
61
+ function toTree ( files : string [ ] ) : TreeMapping {
63
62
const root = { } ;
64
63
for ( const file of files ) {
65
64
const parts = file . split ( '/' ) ;
0 commit comments