type-injector-lib - v1.0.0-alpha-7
Ƭ ConstructorWithoutArguments<T
>: () => T
Name | Description |
---|---|
T |
defines that InstanceType of the constructor. |
• ()
Every class that has a constructor without parameters can get used as InjectToken.
Ƭ DeclaredInjectToken<T
>: symbol
& { description
: string
}
To configure any dependency type-safe you can declare an inject token.
Name | Description |
---|---|
T |
type of the value to get injected with this token. |
Ƭ InjectToken<T
>: ConstructorWithoutArguments
<T
> | InjectableClass
<T
> | DeclaredInjectToken
<T
>
An InjectToken can be a ConstructorWithoutArguments, InjectableClass or a DeclaredInjectToken.
See
Name | Description |
---|---|
T |
defines the required type of the value to inject with that token. |
Ƭ 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
Name |
---|
T |
▸ 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.
Name | Description |
---|---|
T |
defines the required type of the value to inject with that token. |
Name | Type | Description |
---|---|---|
type |
string | T & (...args : any []) => any & { name : string } |
can be an abstract class or a simple string |
DeclaredInjectToken
<T
extends (...args
: any
[]) => infer U ? U
: T
>
a token that can be used to first provide then inject anything