mirror of
https://github.com/openclaw/openclaw.git
synced 2026-03-12 07:20:45 +00:00
TypeScript: add extensions to tsconfig and fix type errors (#12781)
* TypeScript: add extensions to tsconfig and fix type errors - Add extensions/**/* to tsconfig.json includes - Export ProviderAuthResult, AnyAgentTool from plugin-sdk - Fix optional chaining for messageActions across channels - Add missing type imports (MSTeamsConfig, GroupPolicy, etc.) - Add type annotations for provider auth handlers - Fix undici/fetch type compatibility in zalo proxy - Correct ChannelAccountSnapshot property usage - Add type casts for tool registrations - Extract usage view styles and types to separate files * TypeScript: fix optional debug calls and handleAction guards
This commit is contained in:
@@ -92,7 +92,8 @@ function resolveStatePath(stateDir: string): string {
|
||||
async function readArmState(statePath: string): Promise<ArmStateFile | null> {
|
||||
try {
|
||||
const raw = await fs.readFile(statePath, "utf8");
|
||||
const parsed = JSON.parse(raw) as Partial<ArmStateFile>;
|
||||
// Type as unknown record first to allow property access during validation
|
||||
const parsed = JSON.parse(raw) as Record<string, unknown>;
|
||||
if (parsed.version !== 1 && parsed.version !== 2) {
|
||||
return null;
|
||||
}
|
||||
@@ -106,11 +107,11 @@ async function readArmState(statePath: string): Promise<ArmStateFile | null> {
|
||||
if (parsed.version === 1) {
|
||||
if (
|
||||
!Array.isArray(parsed.removedFromDeny) ||
|
||||
!parsed.removedFromDeny.every((v) => typeof v === "string")
|
||||
!parsed.removedFromDeny.every((v: unknown) => typeof v === "string")
|
||||
) {
|
||||
return null;
|
||||
}
|
||||
return parsed as ArmStateFile;
|
||||
return parsed as unknown as ArmStateFile;
|
||||
}
|
||||
|
||||
const group = typeof parsed.group === "string" ? parsed.group : "";
|
||||
@@ -119,23 +120,23 @@ async function readArmState(statePath: string): Promise<ArmStateFile | null> {
|
||||
}
|
||||
if (
|
||||
!Array.isArray(parsed.armedCommands) ||
|
||||
!parsed.armedCommands.every((v) => typeof v === "string")
|
||||
!parsed.armedCommands.every((v: unknown) => typeof v === "string")
|
||||
) {
|
||||
return null;
|
||||
}
|
||||
if (
|
||||
!Array.isArray(parsed.addedToAllow) ||
|
||||
!parsed.addedToAllow.every((v) => typeof v === "string")
|
||||
!parsed.addedToAllow.every((v: unknown) => typeof v === "string")
|
||||
) {
|
||||
return null;
|
||||
}
|
||||
if (
|
||||
!Array.isArray(parsed.removedFromDeny) ||
|
||||
!parsed.removedFromDeny.every((v) => typeof v === "string")
|
||||
!parsed.removedFromDeny.every((v: unknown) => typeof v === "string")
|
||||
) {
|
||||
return null;
|
||||
}
|
||||
return parsed as ArmStateFile;
|
||||
return parsed as unknown as ArmStateFile;
|
||||
} catch {
|
||||
return null;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user