From f0082c1b5fb87ffae0e627c8034393bf60faf6f5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Louren=C3=A7o?= Date: Thu, 22 Jun 2023 13:52:41 +0000 Subject: [PATCH] feat: create type helper to infer token --- src/index.ts | 2 ++ src/types/token-infer-many.type.ts | 3 +++ src/types/token-infer.type.ts | 3 +++ 3 files changed, 8 insertions(+) create mode 100644 src/types/token-infer-many.type.ts create mode 100644 src/types/token-infer.type.ts diff --git a/src/index.ts b/src/index.ts index 7e6eaec8..7fb76ea9 100644 --- a/src/index.ts +++ b/src/index.ts @@ -22,6 +22,8 @@ export * from './error/service-not-found.error'; export { Handler } from './interfaces/handler.interface'; export { ServiceMetadata } from './interfaces/service-metadata.interface'; export { ServiceOptions } from './interfaces/service-options.interface'; +export { TokenInfer } from './types/token-infer.type'; +export { TokenInferMany } from './types/token-infer-many.type'; export { Constructable } from './types/constructable.type'; export { ServiceIdentifier } from './types/service-identifier.type'; diff --git a/src/types/token-infer-many.type.ts b/src/types/token-infer-many.type.ts new file mode 100644 index 00000000..95cbbb50 --- /dev/null +++ b/src/types/token-infer-many.type.ts @@ -0,0 +1,3 @@ +import { Token } from '../token.class'; + +export type TokenInferMany = T extends Token ? U[] : never; diff --git a/src/types/token-infer.type.ts b/src/types/token-infer.type.ts new file mode 100644 index 00000000..e4d728e7 --- /dev/null +++ b/src/types/token-infer.type.ts @@ -0,0 +1,3 @@ +import { Token } from '../token.class'; + +export type TokenInfer = T extends Token ? U : never;