diff --git a/src/Complex/arithmetic.ts b/src/Complex/arithmetic.ts index 90c8eab..1426b45 100644 --- a/src/Complex/arithmetic.ts +++ b/src/Complex/arithmetic.ts @@ -1,3 +1,4 @@ +import {ReflectionFunction, stringifyType, typeOf} from '@deepkit/type' import {Complex} from './type.js' import type { Dependencies, Signature, Returns, RealType, AliasOf @@ -53,6 +54,13 @@ export const absquare = Signature<'absquare', Complex> => z => dep.add(dep.absquare(z.re), dep.absquare(z.im)) +const asRefl = ReflectionFunction.from(absquare) +console.log(' Here I only know that:', asRefl, asRefl.getParameterNames(), asRefl.getParameterType('dep'), stringifyType(asRefl.getParameterType('dep'))) + +class X {} + +console.log(' Because', typeOf & Dependencies<'add', Returns<'absquare', X>>>()) + export const divideReal = (dep: Dependencies<'divideReal' | 'complex', T>): Signature<'divideReal', Complex> => diff --git a/src/core/Dispatcher.ts b/src/core/Dispatcher.ts index def1bd3..d5a1955 100644 --- a/src/core/Dispatcher.ts +++ b/src/core/Dispatcher.ts @@ -33,7 +33,7 @@ type TypeSpecification = { } type SpecObject = Record -type SpecificationsGroup = Record +export type SpecificationsGroup = Record export class Dispatcher { installSpecification( diff --git a/src/index.ts b/src/index.ts index bc07f42..09d8855 100644 --- a/src/index.ts +++ b/src/index.ts @@ -1,10 +1,27 @@ import { - typeOf, ReflectionFunction, ReflectionClass, ReflectionKind, stringifyType + typeOf, ReflectionFunction, ReflectionClass, ReflectionKind, stringifyType, + ReceiveType, resolveReceiveType } from '@deepkit/type' -import {Dispatcher} from './core/Dispatcher.js' +import {SpecificationsGroup, Dispatcher} from './core/Dispatcher.js' import * as Specifications from './all.js' +const asRefl = ReflectionFunction.from(Specifications.complex.absquare) +console.log(' all I know is:', asRefl, asRefl.getParameterNames(), asRefl.getParameterType('dep')) + +function analyze( + spec: SpecificationsGroup, type?: ReceiveType +) { + type = resolveReceiveType(type) + console.log(stringifyType(type)) + console.log('is the type of') + console.log(spec) + //@ts-ignore + console.log('In particular', spec.complex.absquare.__type) +} + +analyze(Specifications) + export default new Dispatcher(Specifications) import {Complex} from './Complex/type.js'