Kind: Interface
Source: packages/core/injector/instance-links-host.ts
Part of: Core
InstanceLink describes a resolved dependency entry managed by the injector. It connects an injection token to its InstanceWrapper, the module-level wrapper collection where it was found, and the owning moduleId for module-aware resolution.
Properties
| Property | Type |
|---|---|
token | InjectionToken |
wrapperRef | InstanceWrapper<T> |
collection | Map<any, InstanceWrapper> |
moduleId | string |
Diagram
mermaidgraph LR Token[InjectionToken] --> Link[InstanceLink] Link --> Wrapper[InstanceWrapper<T>] Link --> Collection[Map<any, InstanceWrapper>] Link --> ModuleId[moduleId: string] Collection --> Wrapper
Usage
tsimport { InstanceLink } from './instance-links-host';
import { InstanceWrapper } from './instance-wrapper';
function inspectLink<T>(link: InstanceLink<T>) {
console.log(`Resolved token from module: ${link.moduleId}`);
console.log('Token:', link.token);
console.log('Wrapper:', link.wrapperRef);
// The collection contains all provider wrappers for the owning module.
const registeredWrapper = link.collection.get(link.token);
return registeredWrapper ?? link.wrapperRef;
}
// Typically created internally by the injector during dependency resolution.
const link: InstanceLink<MyService> = {
token: MyService,
wrapperRef: myServiceWrapper,
collection: moduleProviders,
moduleId: 'AppModule',
};
AI Coding Instructions
- Treat
wrapperRefas the authoritative wrapper selected during dependency resolution; usecollectionwhen module-level lookup context is needed. - Preserve the original
token, including string, symbol, class, and custom injection-token values. - Keep
moduleIdassociated with the link so cross-module resolution and diagnostics retain module context. - Do not assume
collection.get(token)always returns the same wrapper aswrapperRef; aliases and lookup rules may affect resolution.
Relationships
- IMPORTS →
InjectionToken - IMPORTS →
isFunction
Was this page helpful?