Skip to content

Commit 6c535ca

Browse files
committed
refactor(plugin-detail): type the enlarged chips' field read and the new tests' casts without any
Co-Authored-By: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01L6bhgVP3twvBvDTwoLPU6J
1 parent de7bac1 commit 6c535ca

3 files changed

Lines changed: 16 additions & 9 deletions

File tree

‎ui/packages/plugin-detail/src/RelatedList.tsx‎

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -746,13 +746,20 @@ const NO_ENLARGED_CHIPS: readonly EnlargedChipDef[] = [];
746746
* ask, and a chip that listed settled records as overdue would say what the
747747
* cells do not.
748748
*/
749-
function enlargedChipsOf(objectSchema: any): readonly EnlargedChipDef[] {
749+
interface EnlargedChipField {
750+
name?: unknown;
751+
type?: unknown;
752+
dueLike?: unknown;
753+
settledWhen?: unknown;
754+
}
755+
756+
function enlargedChipsOf(objectSchema: { fields?: unknown } | null | undefined): readonly EnlargedChipDef[] {
750757
const chips: EnlargedChipDef[] = [{ id: 'all' }];
751758
const raw = objectSchema?.fields;
752-
const fields: Array<[string, any]> = Array.isArray(raw)
753-
? raw.map((f: any) => [f?.name, f] as [string, any])
759+
const fields: Array<[unknown, EnlargedChipField | undefined]> = Array.isArray(raw)
760+
? (raw as Array<EnlargedChipField | undefined>).map((f) => [f?.name, f])
754761
: raw && typeof raw === 'object'
755-
? Object.entries(raw)
762+
? Object.entries(raw as Record<string, EnlargedChipField | undefined>)
756763
: [];
757764
if (fields.some(([name]) => name === 'owner_id')) {
758765
chips.push({ id: 'mine', filter: { owner_id: '{current_user_id}' } });
@@ -761,7 +768,7 @@ function enlargedChipsOf(objectSchema: any): readonly EnlargedChipDef[] {
761768
([name, f]) => typeof name === 'string' && f?.dueLike === true && f?.settledWhen == null
762769
&& (f?.type === 'date' || f?.type === 'datetime'),
763770
);
764-
if (deadline) chips.push({ id: 'overdue', filter: { [deadline[0]]: { $lt: '{today}' } } });
771+
if (deadline) chips.push({ id: 'overdue', filter: { [deadline[0] as string]: { $lt: '{today}' } } });
765772
return chips;
766773
}
767774

‎ui/packages/plugin-detail/src/__tests__/RecordPageColumns.tabRow-27524.test.tsx‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -243,7 +243,7 @@ describe('the enlarged state is the active tab (objectstack#27524, Target 9)', (
243243
{ id: 'a1', type: 'activity', actor: 'Ada', body: 'called', createdAt: '2026-10-29T09:00:00Z' },
244244
];
245245
const { container } = render(
246-
<DiscussionContextProvider items={items as any} loading={false}>
246+
<DiscussionContextProvider items={items as never} loading={false}>
247247
<RecordPageColumns
248248
tier="wide"
249249
columns={columnsOf()}
@@ -289,7 +289,7 @@ describe('the enlarged state is the active tab (objectstack#27524, Target 9)', (
289289
it('the right column switched off names the 动态 count too', async () => {
290290
const items = [{ id: 'c1', type: 'comment', actor: 'Ada', body: 'hi', createdAt: '2026-10-30T10:00:00Z' }];
291291
const { container } = render(
292-
<DiscussionContextProvider items={items as any} loading={false}>
292+
<DiscussionContextProvider items={items as never} loading={false}>
293293
<RecordPageColumns tier="wide" columns={columnsOf()} rightColumn={false} onEnlargeRelated={vi.fn()} />
294294
</DiscussionContextProvider>,
295295
);

‎ui/packages/plugin-detail/src/__tests__/RelatedList.enlargedToolbar-27524.test.tsx‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ function renderList({
6767
pageSize={25}
6868
columns={[{ field: 'subject', label: 'Subject' }, { field: 'due_date', label: 'Due' }]}
6969
onNew={onNew}
70-
dataSource={dataSource as any}
70+
dataSource={dataSource as never}
7171
/>
7272
</RelatedListEnlargedContext.Provider>
7373
</FilterScopeProvider>,
@@ -146,7 +146,7 @@ describe('the enlarged related list draws the board toolbar (objectstack#27524)'
146146
await waitFor(() => expect(lastFilter(dataSource.find)).toContain('owner_id'));
147147
fireEvent.click(document.querySelector('[data-related-enlarged-export]')!);
148148
await waitFor(() => expect(dataSource.exportDownload).toHaveBeenCalledTimes(1));
149-
const [resource, request] = dataSource.exportDownload.mock.calls[0] as unknown as [string, any];
149+
const [resource, request] = dataSource.exportDownload.mock.calls[0] as unknown as [string, { format: string; filter: unknown; fields: string[] }];
150150
expect(resource).toBe('task');
151151
expect(request.format).toBe('csv');
152152
expect(JSON.stringify(request.filter)).toContain('L-1');

0 commit comments

Comments
 (0)