Skip to content

Latest commit

 

History

History
154 lines (91 loc) · 4.22 KB

README.md

File metadata and controls

154 lines (91 loc) · 4.22 KB

type-injector-lib - v1.0.0-alpha-7

type-injector-lib - v1.0.0-alpha-7

Table of contents

Classes

Interfaces

Type Aliases

Functions

Type Aliases

ConstructorWithoutArguments

Ƭ ConstructorWithoutArguments<T>: () => T

Type parameters

Name Description
T defines that InstanceType of the constructor.

Type declaration

• ()

Every class that has a constructor without parameters can get used as InjectToken.

Defined in

inject-token.ts:6


DeclaredInjectToken

Ƭ DeclaredInjectToken<T>: symbol & { description: string }

To configure any dependency type-safe you can declare an inject token.

Type parameters

Name Description
T type of the value to get injected with this token.

Defined in

inject-token.ts:45


InjectToken

Ƭ InjectToken<T>: ConstructorWithoutArguments<T> | InjectableClass<T> | DeclaredInjectToken<T>

An InjectToken can be a ConstructorWithoutArguments, InjectableClass or a DeclaredInjectToken.

See

declareInjectToken

Type parameters

Name Description
T defines the required type of the value to inject with that token.

Defined in

inject-token.ts:53


InjectableClass

Ƭ InjectableClass<T>: (..._args: any[]) => T & { injectConfig: InjectConfig }

Every class can get an InjectableClass by adding a static injectConfig property.

For classes that can get instantiated without constructor arguments, it is not required to add an injectConfig. An injectConfig is required to tell the TypedInjector to use a constructor with arguments to create a class instance.

See

InjectConfig

Type parameters

Name
T

Defined in

inject-token.ts:34

Functions

declareInjectToken

declareInjectToken<T>(type): DeclaredInjectToken<T extends (...args: any[]) => infer U ? U : T>

Create a typed inject token for anything.

This helper binds type information to a symbol so you can use that symbol to inject a typed value. Because the TypeInjector has no information how to create this symbol, it has to be provided before it gets injected the first time.

Type parameters

Name Description
T defines the required type of the value to inject with that token.

Parameters

Name Type Description
type string | T & (...args: any[]) => any & { name: string } can be an abstract class or a simple string

Returns

DeclaredInjectToken<T extends (...args: any[]) => infer U ? U : T>

a token that can be used to first provide then inject anything

Defined in

inject-token.ts:67