mirror of
https://github.com/logancyang/obsidian-copilot.git
synced 2026-07-22 07:50:24 +00:00
* chore(eslint): enable no-explicit-any; fix ~395 violations Switches @typescript-eslint/no-explicit-any from "off" to "error" and replaces explicit `any` with proper types or `unknown` + narrowing across ~100 source files and 15 test files. Eleven eslint-disable comments remain: one for a BaseLanguageModel prototype patch and ten for Orama<any> API surfaces where typed alternatives poison Orama's internal inference to `never`. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> * fix(scripts): cast chainContext to ChainManager in printPromptDebugEntry The earlier `as any` → `as unknown` rewrite left buildAgentPromptDebugReport's chainManager argument typed as `unknown`, which CI's `tsc -noEmit` (without `--skipLibCheck`) flagged. Restore the cast through the real ChainManager type. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> * chore(eslint): fix remaining no-explicit-any and unnecessary-type-assertion errors Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> * chore(eslint): drop redundant no-explicit-any rule Already set to "error" by typescript-eslint/recommendedTypeChecked via obsidianmd's recommended config. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
24 lines
741 B
TypeScript
24 lines
741 B
TypeScript
export function err2String(err: unknown, stack = false): string {
|
|
try {
|
|
if (err instanceof Error) {
|
|
const cause = (err as { cause?: unknown }).cause;
|
|
const causeMsg =
|
|
cause instanceof Error
|
|
? cause.message
|
|
: cause != null
|
|
? typeof cause === "string"
|
|
? cause
|
|
: (JSON.stringify(cause) ?? "")
|
|
: "";
|
|
const stackStr = stack && err.stack ? err.stack : "";
|
|
const parts = [err.message];
|
|
if (causeMsg) parts.push(`more message: ${causeMsg}`);
|
|
if (stackStr) parts.push(stackStr);
|
|
return parts.join("\n");
|
|
}
|
|
const json = JSON.stringify(err);
|
|
return json ?? String(err);
|
|
} catch {
|
|
return String(err);
|
|
}
|
|
}
|