Phase 3: Fix unsafe any assignments and more strict boolean errors

Co-authored-by: johndoe6345789 <224850594+johndoe6345789@users.noreply.github.com>
This commit is contained in:
copilot-swe-agent[bot]
2026-01-06 17:00:48 +00:00
parent 1b0439d132
commit 0548d439d6
11 changed files with 24 additions and 17 deletions

View File

@@ -37,7 +37,7 @@ export const GET = async (request: NextRequest, { params }: RouteParams) => {
jobLimit,
})
if (!result) {
if (result === null || result === undefined) {
return NextResponse.json({ error: 'Failed to fetch workflow logs' }, { status: 500 })
}

View File

@@ -11,7 +11,7 @@ export const GET = async (request: NextRequest) => {
const perPageParam = request.nextUrl.searchParams.get('perPage')
let perPage = 20
if (perPageParam) {
if (perPageParam !== null && perPageParam !== undefined && perPageParam.length > 0) {
const parsed = Number(perPageParam)
if (!Number.isNaN(parsed)) {
perPage = Math.max(1, Math.min(100, Math.floor(parsed)))

View File

@@ -6,7 +6,7 @@ import { GET } from './route'
describe('GET /api/health', () => {
it('returns OK status and permission level count', async () => {
const response = GET(new NextRequest('http://example.com/api/health'))
const payload = await response.json()
const payload = await response.json() as Record<string, unknown>
expect(payload.status).toBe('ok')
expect(typeof payload.timestamp).toBe('string')

View File

@@ -18,7 +18,7 @@ interface RouteParams {
export async function PUT(request: NextRequest, { params }: RouteParams) {
try {
const body = await readJson<PackageDataPayload>(request)
if (!body?.data || Array.isArray(body.data)) {
if (body?.data === null || body?.data === undefined || Array.isArray(body.data)) {
return NextResponse.json({ error: 'Package data is required' }, { status: 400 })
}

View File

@@ -52,7 +52,7 @@ export default async function RootPage() {
// If route has full component tree, render it directly
if (route.componentTree !== null && route.componentTree !== undefined && route.componentTree.length > 0) {
const componentDef = JSON.parse(route.componentTree)
const componentDef = JSON.parse(route.componentTree) as Record<string, unknown>
return renderJSONComponent(componentDef, {}, {})
}

View File

@@ -36,7 +36,7 @@ describe('getAppConfig', () => {
const result = await getAppConfig()
if (expected) {
if (expected !== null && expected !== undefined) {
expect(result).toMatchObject(expected)
} else {
expect(result).toBeNull()

View File

@@ -23,8 +23,15 @@ describe('setComments', () => {
mockDelete.mockResolvedValue(undefined)
mockCreate.mockResolvedValue(undefined)
// eslint-disable-next-line @typescript-eslint/no-explicit-any
await setComments([{ id: 'new', userId: 'u1', content: 'Hi', createdAt: 1000 }] as any)
const testComment: Comment = {
id: 'new',
userId: 'u1',
entityType: 'test',
entityId: 'test1',
content: 'Hi',
createdAt: 1000
}
await setComments([testComment])
expect(mockDelete).toHaveBeenCalledTimes(1)
expect(mockCreate).toHaveBeenCalledTimes(1)

View File

@@ -18,11 +18,11 @@ export async function getComponentConfigs(): Promise<Record<string, ComponentCon
configs[config.id] = {
id: config.id,
componentId: config.componentId,
props: JSON.parse(config.props),
styles: JSON.parse(config.styles),
events: JSON.parse(config.events),
conditionalRendering: config.conditionalRendering
? JSON.parse(config.conditionalRendering)
props: JSON.parse(config.props) as Record<string, unknown>,
styles: JSON.parse(config.styles) as Record<string, unknown>,
events: JSON.parse(config.events) as Record<string, unknown>,
conditionalRendering: config.conditionalRendering !== null && config.conditionalRendering !== undefined
? (JSON.parse(config.conditionalRendering) as Record<string, unknown>)
: undefined,
}
}

View File

@@ -10,6 +10,6 @@ export async function getCssClasses(): Promise<CssCategory[]> {
const rows = result.data as Array<{ name: string; classes: string | string[] }>
return rows.map(c => ({
name: c.name,
classes: typeof c.classes === 'string' ? JSON.parse(c.classes) : c.classes,
classes: typeof c.classes === 'string' ? (JSON.parse(c.classes) as string[]) : c.classes,
}))
}

View File

@@ -47,8 +47,8 @@ describe('addErrorLog', () => {
expect(mockCreate).toHaveBeenCalledWith(
'ErrorLog',
expect.objectContaining({
id: expect.stringContaining('error_'),
timestamp: expect.any(BigInt),
id: expect.stringContaining('error_') as string,
timestamp: expect.any(BigInt) as bigint,
level: log.level,
message: log.message,
resolved: false,

View File

@@ -125,7 +125,7 @@ describe('getErrorLogs', () => {
expect(mockList).toHaveBeenCalledWith('ErrorLog')
expect(result).toHaveLength(expectedLength)
if (options?.tenantId && result.length > 0) {
if (options?.tenantId !== null && options?.tenantId !== undefined && result.length > 0) {
expect(result.every(log => log.tenantId === options.tenantId)).toBe(true)
}
})