From 091ad1ff6e2761e440dbf110f7a2c7014b2775f8 Mon Sep 17 00:00:00 2001 From: Noel De Martin Date: Wed, 3 Mar 2021 13:31:45 +0100 Subject: [PATCH] MOBILE-3320 types: Exclude any singleton props --- src/core/singletons/index.ts | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/src/core/singletons/index.ts b/src/core/singletons/index.ts index 6999ef29c..d6628b992 100644 --- a/src/core/singletons/index.ts +++ b/src/core/singletons/index.ts @@ -64,10 +64,17 @@ const OBJECT_PROTOTYPE = Object.getPrototypeOf(Object); let singletonsInjector: Injector | null = null; /** - * Helper to get service class methods. + * Helper to get service class properties that are methods. */ type GetMethods = { - [K in keyof T]: T[K] extends (...args: unknown[]) => unknown ? K : never; + [K in keyof T]: T[K] extends (...args: unknown[]) => unknown ? K : never +}[keyof T]; + +/** + * Helper to get service class properties that are not methods. + */ +type GetNonMethods = { + [K in keyof T]: T[K] extends (...args: unknown[]) => unknown ? never : K }[keyof T]; /** @@ -76,7 +83,7 @@ type GetMethods = { * @see makeSingleton */ export type CoreSingletonProxy = - Pick> & + Pick, GetNonMethods>> & Pick & { instance: Service;