diff --git a/packages/context/src/binding-filter.ts b/packages/context/src/binding-filter.ts index ba6fba61b7c1..5c1b28a5ab19 100644 --- a/packages/context/src/binding-filter.ts +++ b/packages/context/src/binding-filter.ts @@ -9,6 +9,15 @@ import {BindingAddress} from './binding-key'; /** * A function that filters bindings. It returns `true` to select a given * binding. + * + * Note: originally, we allow filters to be tied with a single value type. + * This actually does not make much sense - the filter function is typically + * invoked on all bindings to find those matching the given criteria, + * therefore filters must be prepared to handle bindings of any value type. + * We learned about this problem after enabling TypeScript's `strictFunctionTypes` + * check, but decided to preserve `ValueType` argument for backwards compatibility. + * + * TODO(semver-major): remove ValueType template argument. */ export type BindingFilter = ( binding: Readonly>, diff --git a/packages/context/src/context-view.ts b/packages/context/src/context-view.ts index ce5b9cf48f0f..a354cf44aecc 100644 --- a/packages/context/src/context-view.ts +++ b/packages/context/src/context-view.ts @@ -42,7 +42,7 @@ export class ContextView extends EventEmitter constructor( protected readonly context: Context, - public readonly filter: BindingFilter, + public readonly filter: BindingFilter, ) { super(); } @@ -161,10 +161,10 @@ export class ContextView extends EventEmitter */ export function createViewGetter( ctx: Context, - bindingFilter: BindingFilter, + bindingFilter: BindingFilter, session?: ResolutionSession, ): Getter { - const view = new ContextView(ctx, bindingFilter); + const view = new ContextView(ctx, bindingFilter); view.open(); return view.asGetter(session); }