issue: deepkit doesn't reflect types imported via `import type`

This commit is contained in:
Glen Whitney 2023-08-16 21:46:10 -07:00
parent 58f0250ab4
commit 9abea5c484
3 changed files with 31 additions and 1 deletions

View File

@ -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<T> {
one: (a: T) => OneType<T>
}
export const square =
<T>(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<LocalSignatures<number>['one']>())
console.log(' readable:', stringifyType(typeOf<LocalSignatures<number>['one']>()))

10
src/local.ts Normal file
View File

@ -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<LocalInterface['item']>()))
console.log('Remotely:', stringifyType(typeOf<ImportedInterface['item']>()))

3
src/remote.ts Normal file
View File

@ -0,0 +1,3 @@
export interface ImportedInterface {
item: (a: number) => string
}