Skip to content

Commit 5663a37

Browse files
committed
refactor(core): use generics for type casting
came across this while reviewing the code / readme. Making separate PRs for easier review. This usage was introduced in #1050 connected to #988
1 parent e2be3a8 commit 5663a37

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

packages/core/src/application.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ export class Application extends Context {
122122
const ctor = target as Constructor<T>;
123123
key = `servers.${ctor.name}`;
124124
}
125-
return (await this.get(key)) as T;
125+
return await this.get<T>(key);
126126
}
127127

128128
/**
@@ -156,7 +156,7 @@ export class Application extends Context {
156156
const bindings = this.find(`${CoreBindings.SERVERS}.*`);
157157
await Promise.all(
158158
bindings.map(async binding => {
159-
const server = (await this.get(binding.key)) as Server;
159+
const server = await this.get<Server>(binding.key);
160160
return await fn(server);
161161
}),
162162
);
@@ -191,7 +191,7 @@ export class Application extends Context {
191191
.inScope(BindingScope.SINGLETON)
192192
.tag('component');
193193
// Assuming components can be synchronously instantiated
194-
const instance = this.getSync(componentKey);
194+
const instance = this.getSync<Component>(componentKey);
195195
mountComponent(this, instance);
196196
}
197197
}

0 commit comments

Comments
 (0)