From b01cd74b19153b6b77ab1c7041f261df442bd850 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miroslav=20Bajto=C5=A1?= Date: Mon, 2 Mar 2020 13:04:01 +0100 Subject: [PATCH] fixup! improve comment for `this` & static members MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Miroslav Bajtoš --- types/model.d.ts | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/types/model.d.ts b/types/model.d.ts index 42e06161..7b15a9d6 100644 --- a/types/model.d.ts +++ b/types/model.d.ts @@ -249,8 +249,13 @@ export declare class ModelBase { // describe in TypeScript in a way that's easy to use by consumers. // As a workaround, we include a copy of ObserverMixin members here. // - // See also https://github.com/microsoft/TypeScript/issues/5863#issuecomment-410887254 - // for more information about using `this` in static members. + // Ideally, we want to describe the context argument as + // `OperationHookContext`. Unfortunately, that's not supported by + // TypeScript for static members. A nice workaround is described in + // https://github.com/microsoft/TypeScript/issues/5863#issuecomment-410887254 + // - Describe the context using a generic argument `T`. + // - Use `this: T` argument to let the compiler infer what's the target + // model class we are going to observe. /** * Register an asynchronous observer for the given operation (event).