test(tools): use type-safe error assertions instead of any casts
oxlint's no-unsafe-member-access rejects member access through an any cast; the error info is reachable through the declared optional chain.
This commit is contained in:
@@ -754,8 +754,7 @@ describe('code-mode native-tool denial through the agent loop', () => {
|
||||
const sessionEvents = events(agent)
|
||||
const toolResult = sessionEvents.find(e => e.type === 'tool/result')
|
||||
expect(toolResult).toBeDefined()
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any -- tool/result data uses a loose event payload union
|
||||
expect((toolResult!.data as any).error).toMatchObject({
|
||||
expect(toolResult!.data.error).toMatchObject({
|
||||
name: 'ToolNotFoundError',
|
||||
code: 'UNKNOWN_TOOL',
|
||||
})
|
||||
|
||||
@@ -1573,8 +1573,7 @@ describe('the run_code dispatch bridge', () => {
|
||||
arguments: { text: 'hello' },
|
||||
})
|
||||
expect(result.isError).toBe(true)
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any -- error is a union type
|
||||
expect((result.error as any).info.code).toBe('UNKNOWN_TOOL')
|
||||
expect(result.error?.info).toEqual({ name: 'ToolNotFoundError', code: 'UNKNOWN_TOOL' })
|
||||
})
|
||||
|
||||
it('routes a pre-aborted collapsed call through ABORTED_BEFORE_DISPATCH', async () => {
|
||||
@@ -1591,8 +1590,7 @@ describe('the run_code dispatch bridge', () => {
|
||||
arguments: { text: 'hello' },
|
||||
})
|
||||
expect(result.isError).toBe(true)
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any -- error is a union type
|
||||
expect((result.error as any).info.code).toBe(TOOL_ABORTED_BEFORE_DISPATCH)
|
||||
expect(result.error?.info?.code).toBe(TOOL_ABORTED_BEFORE_DISPATCH)
|
||||
})
|
||||
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user