Skip to content

Commit 8f7e5a8

Browse files
committed
fix(build): resolve TS7053 index-signature errors in stories utils
Add proper type annotations so string keys can index into typed objects, fixing the TypeScript strict-mode build. Made-with: Cursor
1 parent 4878c1a commit 8f7e5a8

2 files changed

Lines changed: 30 additions & 26 deletions

File tree

src/stories/docs/handlers.tsx

Lines changed: 29 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -77,31 +77,35 @@ export const handlersTable: ComponentProps = {
7777
};
7878

7979
export const getHandlersTable = (): ControlsFnOptionsType[] => {
80-
return Object.keys(handlersTable).reduce<ControlsFnOptionsType[]>(
81-
(acc, key) => {
82-
if (Array.isArray(handlersTable[key]?.type)) {
80+
return (Object.keys(handlersTable) as (keyof ComponentProps)[]).reduce<
81+
ControlsFnOptionsType[]
82+
>((acc, key) => {
83+
const entry = handlersTable[key];
84+
if ("type" in entry && Array.isArray(entry.type)) {
85+
acc.push({
86+
...(entry as Omit<ControlsFnOptionsType, "name" | "isObjectRow">),
87+
name: key,
88+
});
89+
} else {
90+
const nested = entry as Record<
91+
string,
92+
Omit<ControlsFnOptionsType, "name" | "isObjectRow">
93+
>;
94+
Object.keys(nested).forEach((prop) => {
8395
acc.push({
84-
...handlersTable[key],
85-
name: key,
96+
...nested[prop],
97+
isObjectRow: key === prop,
98+
name:
99+
key === prop ? (
100+
<b>{prop}</b>
101+
) : (
102+
<>
103+
{key}.<b>{prop}</b>
104+
</>
105+
),
86106
});
87-
} else {
88-
Object.keys(handlersTable[key]).forEach((prop) => {
89-
acc.push({
90-
...handlersTable[key][prop],
91-
isObjectRow: key === prop,
92-
name:
93-
key === prop ? (
94-
<b>{prop}</b>
95-
) : (
96-
<>
97-
{key}.<b>{prop}</b>
98-
</>
99-
),
100-
});
101-
});
102-
}
103-
return acc;
104-
},
105-
[],
106-
);
107+
});
108+
}
109+
return acc;
110+
}, []);
107111
};

src/stories/utils/args.utils.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
export const normalizeArgs = (args: { [key: string]: any }): any => {
2-
const newArgs = {};
2+
const newArgs: Record<string, any> = {};
33

44
Object.keys(args).forEach((key) => {
55
const normalizedKey = key.split(".");

0 commit comments

Comments
 (0)