Skip to content

Commit 154bf3b

Browse files
ref(stories): Improve types on TreeMapping (#68940)
1 parent 11fbab6 commit 154bf3b

File tree

1 file changed

+6
-7
lines changed

1 file changed

+6
-7
lines changed

static/app/views/stories/storyTree.tsx

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,6 @@ import {space} from 'sentry/styles/space';
77
import {useLocation} from 'sentry/utils/useLocation';
88
import type {StoriesQuery} from 'sentry/views/stories/types';
99

10-
type DirContent = Record<string, unknown>;
11-
1210
interface Props extends ComponentProps<'div'> {
1311
files: string[];
1412
}
@@ -23,17 +21,16 @@ export default function StoryTree({files, style}: Props) {
2321
);
2422
}
2523

26-
function FolderContent({path, content}: {content: DirContent; path: string}) {
24+
function FolderContent({path, content}: {content: TreeMapping; path: string}) {
2725
const location = useLocation<StoriesQuery>();
2826
const currentFile = location.query.name;
2927

3028
return (
3129
<UnorderedList>
3230
{Object.entries(content).map(([name, children]) => {
33-
const childContent = children as DirContent;
3431
const childPath = toPath(path, name);
3532

36-
if (Object.keys(childContent).length === 0) {
33+
if (Object.keys(children).length === 0) {
3734
const isCurrent = childPath === currentFile ? true : undefined;
3835
const to = `/stories/?name=${childPath}`;
3936
return (
@@ -50,7 +47,7 @@ function FolderContent({path, content}: {content: DirContent; path: string}) {
5047
<ListItem key={name}>
5148
<Folder open>
5249
<FolderName>{name}</FolderName>
53-
<FolderContent path={childPath} content={childContent} />
50+
<FolderContent path={childPath} content={children} />
5451
</Folder>
5552
</ListItem>
5653
);
@@ -59,7 +56,9 @@ function FolderContent({path, content}: {content: DirContent; path: string}) {
5956
);
6057
}
6158

62-
function toTree(files: string[]) {
59+
interface TreeMapping extends Record<string, TreeMapping> {}
60+
61+
function toTree(files: string[]): TreeMapping {
6362
const root = {};
6463
for (const file of files) {
6564
const parts = file.split('/');

0 commit comments

Comments
 (0)