From f6cf0c6e5ea3594417fd303c64d04a923c03a627 Mon Sep 17 00:00:00 2001 From: Raymond Feng Date: Mon, 11 Mar 2019 09:39:15 -0700 Subject: [PATCH] feat(context): improve typing for binding related methods --- packages/context/src/binding-inspector.ts | 12 +++++++----- packages/context/src/binding.ts | 2 +- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/packages/context/src/binding-inspector.ts b/packages/context/src/binding-inspector.ts index 56af3dd313a1..4ac8685738da 100644 --- a/packages/context/src/binding-inspector.ts +++ b/packages/context/src/binding-inspector.ts @@ -136,7 +136,9 @@ export function removeNameAndKeyTags(binding: Binding) { * * @param cls A class with optional `@bind` */ -export function bindingTemplateFor(cls: Constructor): BindingTemplate { +export function bindingTemplateFor( + cls: Constructor>, +): BindingTemplate { const spec = getBindingMetadata(cls); const templateFunctions = (spec && spec.templates) || [ asClassOrProvider(cls), @@ -198,16 +200,16 @@ export type BindingFromClassOptions = { * @param cls A class * @param options Options to customize the binding key */ -export function createBindingFromClass( - cls: Constructor, +export function createBindingFromClass( + cls: Constructor>, options: BindingFromClassOptions = {}, -): Binding { +): Binding { const templateFn = bindingTemplateFor(cls); let key = options.key; if (!key) { key = buildBindingKey(cls, options); } - const binding = Binding.bind(key).apply(templateFn); + const binding = Binding.bind(key).apply(templateFn); if (options.name) { binding.tag({name: options.name}); } diff --git a/packages/context/src/binding.ts b/packages/context/src/binding.ts index ea98e72238d8..cfbbd110d69b 100644 --- a/packages/context/src/binding.ts +++ b/packages/context/src/binding.ts @@ -473,7 +473,7 @@ export class Binding { * easy to read. * @param key Binding key */ - static bind(key: BindingAddress): Binding { + static bind(key: BindingAddress): Binding { return new Binding(key.toString()); } }