Skip to content

Commit 7113105

Browse files
bajtosraymondfeng
andcommitted
feat(context): add default template argument for BindingAddress
Co-Authored-By: Raymond Feng <raymondfeng@users.noreply.github.com>
1 parent c76a8e1 commit 7113105

File tree

3 files changed

+6
-6
lines changed

3 files changed

+6
-6
lines changed

packages/context/src/binding-inspector.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,7 @@ export type BindingFromClassOptions = {
174174
/**
175175
* Binding key
176176
*/
177-
key?: BindingAddress<unknown>;
177+
key?: BindingAddress;
178178
/**
179179
* Artifact type, such as `server`, `controller`, `repository` or `service`
180180
*/

packages/context/src/binding-key.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
// This file is licensed under the MIT License.
44
// License text available at https://opensource.org/licenses/MIT
55

6-
export type BindingAddress<T> = string | BindingKey<T>;
6+
export type BindingAddress<T = unknown> = string | BindingKey<T>;
77

88
// tslint:disable-next-line:no-unused
99
export class BindingKey<ValueType> {

packages/context/src/context.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ export class Context {
8484
* @param key Binding key
8585
* @returns true if the binding key is found and removed from this context
8686
*/
87-
unbind(key: BindingAddress<unknown>): boolean {
87+
unbind(key: BindingAddress): boolean {
8888
key = BindingKey.validate(key);
8989
const binding = this.registry.get(key);
9090
if (binding == null) return false;
@@ -98,7 +98,7 @@ export class Context {
9898
* delegating to the parent context
9999
* @param key Binding key
100100
*/
101-
contains(key: BindingAddress<unknown>): boolean {
101+
contains(key: BindingAddress): boolean {
102102
key = BindingKey.validate(key);
103103
return this.registry.has(key);
104104
}
@@ -107,7 +107,7 @@ export class Context {
107107
* Check if a key is bound in the context or its ancestors
108108
* @param key Binding key
109109
*/
110-
isBound(key: BindingAddress<unknown>): boolean {
110+
isBound(key: BindingAddress): boolean {
111111
if (this.contains(key)) return true;
112112
if (this._parent) {
113113
return this._parent.isBound(key);
@@ -119,7 +119,7 @@ export class Context {
119119
* Get the owning context for a binding key
120120
* @param key Binding key
121121
*/
122-
getOwnerContext(key: BindingAddress<unknown>): Context | undefined {
122+
getOwnerContext(key: BindingAddress): Context | undefined {
123123
if (this.contains(key)) return this;
124124
if (this._parent) {
125125
return this._parent.getOwnerContext(key);

0 commit comments

Comments
 (0)