Module

injectable-decorators

A lightweight dependency injection library for TypeScript applications.

View Source index.ts, line 2

Classes

InjectableRegistryImp

Holds the various Injectables in a cache and provides methods to register, retrieve, and build them.

Interfaces

InjectablesRegistry

Interface for an injectable registry that provides methods for retrieving, registering, and building injectable objects.

Members

# static constant InjectablesKeys

Injectables Reflection keys used to store and retrieve metadata about injectable classes and properties.

Constants used for reflection metadata keys in the dependency injection system.

Properties:
Name Type Description
REFLECT string

Reflection injectables base key prefix for all metadata keys

INJECTABLE string

Reflection key suffix for marking a class as injectable

INJECT string

Reflection key suffix for marking a property for injection

View Source constants.ts, line 2

# static constant TypeKey

Holds the key for retrieving the design type from TypeScript's reflection metadata.

Reflection metadata key for accessing TypeScript type information.

View Source utils.ts, line 5

# static constant VERSION

Defined on library build. Holds the library's current version string.

Current version of the injectable-decorators library.

View Source index.ts, line 16

Methods

# static getInjectKey(key) → {string}

Returns the reflection key for injectables by prefixing the provided key with the base reflection key.

Generates a fully qualified reflection metadata key.

Parameters:
Name Type Description
key string

The key to be prefixed

View Source decorators.ts, line 5

The fully qualified reflection key

string

# static getTypeFromDecorator(model, propKey) → {string|undefined}

Retrieves the type from a property decorator by accessing TypeScript's reflection metadata.

Extracts the type name from a decorated property using reflection.

Parameters:
Name Type Description
model any

The target object containing the decorated property

propKey string | symbol

The property key (name or symbol) of the decorated property

View Source utils.ts, line 12

The name of the property type, or undefined if it's a Function type

string | undefined

Type Definitions

# Injectable()

Defines an Injectable type that can be either a class constructor or an instance of a class.

Type representing either a class constructor or an instance.

Properties:
Name Type Description
...args: T

any[]

View Source registry.ts, line 111

# InstanceTransformer(injectable, obj, injectable, obj) → {any}

Function which transforms a cached injectable instance before it's injected into a target object.

Function type for transforming injectable instances before they're injected.

Parameters:
Name Type Description
injectable any

The injectable instance to transform

obj any

The object the injectable will be injected on

injectable any
obj any

View Source decorators.ts, line 206

The transformed injectable instance

any