From 9abea5c484ae4e67bc9cff6c30a863478783fbfa Mon Sep 17 00:00:00 2001 From: Glen Whitney Date: Wed, 16 Aug 2023 21:46:10 -0700 Subject: [PATCH] issue: deepkit doesn't reflect types imported via `import type` --- src/generic/arithmetic.ts | 19 ++++++++++++++++++- src/local.ts | 10 ++++++++++ src/remote.ts | 3 +++ 3 files changed, 31 insertions(+), 1 deletion(-) create mode 100644 src/local.ts create mode 100644 src/remote.ts diff --git a/src/generic/arithmetic.ts b/src/generic/arithmetic.ts index 78ad57d..cbb1062 100644 --- a/src/generic/arithmetic.ts +++ b/src/generic/arithmetic.ts @@ -1,5 +1,22 @@ -import type {Dependencies, Signature} from '../interfaces/type.js' +import {ReflectionFunction, stringifyType, typeOf} from '@deepkit/type' +import type {Dependencies, Signature, Signatures, OneType} from '../interfaces/type.js' + +interface LocalSignatures { + one: (a: T) => OneType +} export const square = (dep: Dependencies<'multiply', T>): Signature<'square', T> => z => dep.multiply(z, z) + +const sqRefl = ReflectionFunction.from(square) +console.log( + ' For generic square I know that:', + sqRefl, + sqRefl.getParameterNames(), + sqRefl.getParameterType('dep'), + "\n final dep type:", + stringifyType(sqRefl.getParameterType('dep'))) + +console.log(' because', typeOf['one']>()) +console.log(' readable:', stringifyType(typeOf['one']>())) diff --git a/src/local.ts b/src/local.ts new file mode 100644 index 0000000..98de68d --- /dev/null +++ b/src/local.ts @@ -0,0 +1,10 @@ +import type {ImportedInterface} from './remote.js' + +interface LocalInterface { + item: (a: number) => string +} + +import {stringifyType, typeOf} from '@deepkit/type' + +console.log('Locally:', stringifyType(typeOf())) +console.log('Remotely:', stringifyType(typeOf())) diff --git a/src/remote.ts b/src/remote.ts new file mode 100644 index 0000000..51df8d3 --- /dev/null +++ b/src/remote.ts @@ -0,0 +1,3 @@ +export interface ImportedInterface { + item: (a: number) => string +}