@@ -50,6 +50,7 @@ import { describe, it, expect } from 'vitest';
5050import { ObjectKernel , ServiceLifecycle } from '@objectstack/core' ;
5151import { MetadataManager , DatabaseLoader } from '@objectstack/metadata' ;
5252import { assertEngineFindOnePredicate } from '@objectstack/metadata-core' ;
53+ import type { IMetadataService } from '@objectstack/spec/contracts' ;
5354import { NodeMetadataManager } from '@objectstack/metadata/node' ;
5455import type { MetadataLoader } from '@objectstack/metadata' ;
5556import { runActionGovernanceInventory , collectEngineActionDeclarations } from '@objectstack/objectql' ;
@@ -314,11 +315,14 @@ describe('#14423 (a) — can `loadMany` omit a name `load` serves?', () => {
314315 ServiceLifecycle . SCOPED ,
315316 ) ;
316317
317- // The audit's lookup — `ctx.getService('metadata')` in plugin.ts, inside its try/catch.
318- let auditMeta : any ;
318+ // The audit's lookup — `ctx.getService('metadata')` in plugin.ts, inside its
319+ // try/catch. Typed with the slot's CONTRACT, not `any`: the audit reads
320+ // `meta.loadMany` off whatever this returns, and erasing the result is
321+ // exactly the shape `check:slot-lookup` refuses (#4251).
322+ let auditMeta : IMetadataService | undefined ;
319323 let auditLookupError : string | undefined ;
320- try { auditMeta = kernel . getService ( 'metadata' ) ; }
321- catch ( e : any ) { auditLookupError = e ? .message ?? String ( e ) ; }
324+ try { auditMeta = kernel . getService < IMetadataService > ( 'metadata' ) ; }
325+ catch ( e : unknown ) { auditLookupError = e instanceof Error ? e . message : String ( e ) ; }
322326
323327 // The router's lookup — the dispatcher's scoped branch, with the request's envId.
324328 const routerMeta = await kernel . getServiceAsync < MetadataManager > ( 'metadata' , 'env_a' ) ;
0 commit comments