mirror of
https://github.com/garrytan/gbrain.git
synced 2026-08-14 08:53:22 +00:00
The real plugin-load e2e test dynamically imports 'openclaw/plugin-sdk'. TypeScript still resolves and type-checks that bare specifier via upward node_modules resolution, so 'bunx tsc --noEmit' on a clean checkout could fail (TS2339 on sdk.registerContextEngine) or pass depending on whichever undeclared openclaw package happened to exist in an ancestor directory. The existing @ts-ignore only covered the import line, not the property access on the following line. Cast the awaited import to a local structural interface declaring the one member the test uses (registerContextEngine, optional). TypeScript never consults the ambient module's types for the property access, so typecheck output is identical regardless of ancestor node_modules state. The @ts-ignore stays on the import statement itself and stays @ts-ignore (not @ts-expect-error) because whether TS2307 fires there is itself ambient-dependent. Runtime behavior is unchanged: the cast erases at compile time and the export's presence is still verified at runtime. Fixes #2729 Co-authored-by: Claude Fable 5 <noreply@anthropic.com> Co-authored-by: Time Attakc <89218912+time-attack@users.noreply.github.com>
This commit is contained in:
co-authored by
Claude Fable 5
Time Attakc
parent
23003a2163
commit
ad7114f0ad
@@ -274,10 +274,23 @@ describe('openclaw-plugin-load-real (Tier 2 e2e)', () => {
|
||||
// level fixture proved openclaw is installed and reachable.
|
||||
let registerContextEngine: ((id: string, factory: () => unknown) => void) | undefined;
|
||||
|
||||
// Minimal structural shape of the openclaw plugin SDK surface this
|
||||
// test uses. `openclaw` is deliberately NOT a declared dependency —
|
||||
// the test probes whatever install is present at runtime — so the
|
||||
// import result is cast to this local interface instead of letting
|
||||
// TypeScript type-check against whichever openclaw version happens
|
||||
// to be resolvable from an ancestor node_modules. That keeps
|
||||
// `bunx tsc --noEmit` hermetic on a clean checkout (#2729); the
|
||||
// export's presence/shape is still verified at runtime below.
|
||||
interface OpenclawPluginSdk {
|
||||
registerContextEngine?: (id: string, factory: () => unknown) => void;
|
||||
}
|
||||
|
||||
const importErrors: string[] = [];
|
||||
try {
|
||||
// @ts-ignore — bare specifier resolution depends on node_modules.
|
||||
const sdk = await import('openclaw/plugin-sdk');
|
||||
// @ts-ignore — bare specifier; whether this resolves (TS2307 or not)
|
||||
// depends on ambient node_modules, so @ts-expect-error would flip.
|
||||
const sdk = (await import('openclaw/plugin-sdk')) as unknown as OpenclawPluginSdk;
|
||||
registerContextEngine = sdk.registerContextEngine;
|
||||
} catch (err) {
|
||||
importErrors.push(`bare 'openclaw/plugin-sdk': ${err instanceof Error ? err.message : String(err)}`);
|
||||
|
||||
Reference in New Issue
Block a user