收紧后端 TypeScript:统一 Json 类型与 TaskContext 契约

关闭 allowJs;集中 JsonObject 定义并替换分散 any 别名;parseTaskContext 返回 TaskContext;任务详情 API 标注 AdminTaskDetailView;测试减少 as any。
This commit is contained in:
yml2213
2026-07-10 15:52:05 +08:00
parent e7244eaa5e
commit 8bcd9bbd81
79 changed files with 415 additions and 259 deletions
@@ -1,6 +1,7 @@
import { getOrderById } from '../../../repositories/order-repo.js'
import { listTasksByOrderId, updateTask } from '../../../repositories/task-repo.js'
import { createTaskEvent } from '../../../repositories/task-event-repo.js'
import type { JsonObject } from '../../../types/json.js'
import {
findKuaishouIndustryVoucherByCode,
listKuaishouIndustryVouchersByOid,
@@ -670,9 +671,9 @@ async function getRequiredIndustryVoucherForTask(task: TaskRow): Promise<Kuaisho
})
}
function normalizeAdminTaskIndustryVoucherContext(value: unknown): Record<string, any> {
function normalizeAdminTaskIndustryVoucherContext(value: unknown): JsonObject {
return value && typeof value === 'object' && !Array.isArray(value)
? value as Record<string, any>
? value as JsonObject
: {}
}
@@ -1,8 +1,9 @@
import { createHttpError } from '../../../utils/http.js'
import type { HttpErrorLike } from '../../../utils/http.js'
import {
resolvePersistedCloudtentaclesContextBySourceKeys,
} from '../../fulfillment/kuaishou-cloud/cloudtentacles-context.js'
import type { JsonObject } from '../../../types/json.js'
import { resolvePersistedCloudtentaclesContextBySourceKeys } from '../../fulfillment/kuaishou-cloud/cloudtentacles-context.js'
export type { JsonObject }
export {
KUAISHOU_CLOUD_FIXED_VN_KEY,
@@ -10,7 +11,6 @@ export {
normalizeKuaishouCloudFlow,
normalizeKuaishouCloudRoleInfo,
resolveKuaishouCloudBindUrlExpiresAt,
type JsonObject,
} from '../../fulfillment/kuaishou-cloud/domain.js'
export {
prepareKuaishouCloudBindResourceWithFallback,
@@ -34,17 +34,17 @@ export type CloudSkuLikeItem = {
[key: string]: unknown
}
export type KuaishouCloudFlow = Record<string, any> & {
export type KuaishouCloudFlow = JsonObject & {
configId: string
internalSkuCode: string
internalSkuName: string
ticket: Record<string, any>
binding: Record<string, any>
role: Record<string, any>
purchase: Record<string, any>
dispatch: Record<string, any>
returnNumber: Record<string, any>
consume: Record<string, any>
ticket: JsonObject
binding: JsonObject
role: JsonObject
purchase: JsonObject
dispatch: JsonObject
returnNumber: JsonObject
consume: JsonObject
}
export type KuaishouCloudBindingResources = {