Skip to content

Commit 6adf5d6

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 22b3de8 commit 6adf5d6

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

packages/core/src/application.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -120,9 +120,9 @@ export class Application extends Context {
120120
key = `${CoreBindings.SERVERS}.${target}`;
121121
} else {
122122
const ctor = target as Constructor<T>;
123-
key = `servers.${ctor.name}`;
123+
key = `${CoreBindings.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)