feat: Deepkit provides type info for case that typescript-rtti failed
This commit is contained in:
parent
16da30d865
commit
479a484011
@ -18,6 +18,11 @@
|
||||
url: 'https://code.studioinfinity.org/glen/typocomath.git',
|
||||
},
|
||||
devDependencies: {
|
||||
'@deepkit/type-compiler': '1.0.1-alpha.97',
|
||||
'@types/node': '^20.5.0',
|
||||
typescript: '^5.1.6',
|
||||
},
|
||||
dependencies: {
|
||||
'@deepkit/type': '1.0.1-alpha.97',
|
||||
},
|
||||
}
|
||||
|
204
pnpm-lock.yaml
204
pnpm-lock.yaml
@ -4,15 +4,219 @@ settings:
|
||||
autoInstallPeers: true
|
||||
excludeLinksFromLockfile: false
|
||||
|
||||
dependencies:
|
||||
'@deepkit/type':
|
||||
specifier: 1.0.1-alpha.97
|
||||
version: 1.0.1-alpha.97(@deepkit/core@1.0.1-alpha.97)
|
||||
|
||||
devDependencies:
|
||||
'@deepkit/type-compiler':
|
||||
specifier: 1.0.1-alpha.97
|
||||
version: 1.0.1-alpha.97(typescript@5.1.6)
|
||||
'@types/node':
|
||||
specifier: ^20.5.0
|
||||
version: 20.5.0
|
||||
typescript:
|
||||
specifier: ^5.1.6
|
||||
version: 5.1.6
|
||||
|
||||
packages:
|
||||
|
||||
/@deepkit/core@1.0.1-alpha.97:
|
||||
resolution: {integrity: sha512-SrG9m43w+fJhiFH4wxyc6QNruFxJaqiGpT+QAncqR0dDvd+5QUCLwD2mGiKkNJoFh2lo+p3rtYhnZ0exny8emw==}
|
||||
dependencies:
|
||||
dot-prop: 5.3.0
|
||||
to-fast-properties: 3.0.1
|
||||
dev: false
|
||||
|
||||
/@deepkit/type-compiler@1.0.1-alpha.97(typescript@5.1.6):
|
||||
resolution: {integrity: sha512-KeK21jdqM3keF504kmf7RcJkWV/xJMAjiK79MkNN43TyRjViOkmv50p6CW+vdHx6H772sQ765gX+gpH8i/yIZQ==}
|
||||
hasBin: true
|
||||
requiresBuild: true
|
||||
peerDependencies:
|
||||
typescript: ^4.8.2 || ^5.0.0
|
||||
dependencies:
|
||||
'@deepkit/type-spec': 1.0.1-alpha.93
|
||||
'@marcj/ts-clone-node': 2.2.0(typescript@5.1.6)
|
||||
'@typescript/vfs': 1.5.0
|
||||
get-tsconfig: 4.7.0
|
||||
lz-string: 1.5.0
|
||||
micromatch: 4.0.5
|
||||
strip-json-comments: 3.1.1
|
||||
typescript: 5.1.6
|
||||
transitivePeerDependencies:
|
||||
- supports-color
|
||||
dev: true
|
||||
|
||||
/@deepkit/type-spec@1.0.1-alpha.93:
|
||||
resolution: {integrity: sha512-ZJHq0tOCYW0pDZ4Ab3RLQiFvDCTD2Dur+af4I0kmtT23slz+WWMNehJF08lO4DUDyOO0f0DlLLCqO39GhY3J4Q==}
|
||||
|
||||
/@deepkit/type@1.0.1-alpha.97(@deepkit/core@1.0.1-alpha.97):
|
||||
resolution: {integrity: sha512-fnMrhMVYANyZ8zrKEj7KnJMTl2WhXKza9dh9s0Mtgcowd73YSJyEdvFkBKcabmHbvlbHFkAHv8KAvYifvWbGvw==}
|
||||
peerDependencies:
|
||||
'@deepkit/core': ^1.0.1-alpha.13
|
||||
dependencies:
|
||||
'@deepkit/core': 1.0.1-alpha.97
|
||||
'@deepkit/type-spec': 1.0.1-alpha.93
|
||||
'@types/uuid': 8.3.4
|
||||
buffer: 5.7.1
|
||||
uuid: 8.3.2
|
||||
dev: false
|
||||
|
||||
/@marcj/ts-clone-node@2.2.0(typescript@5.1.6):
|
||||
resolution: {integrity: sha512-72i531GZWaiHDvNZr0Fz+uiZMMyWzQqJxbhxD5g2dpU3eqEBk6p6mcDNBcOdiNhngAJ5Ebqv2krrs7MwuFg9rw==}
|
||||
engines: {node: '>=14.9.0'}
|
||||
dependencies:
|
||||
compatfactory: 2.0.9(typescript@5.1.6)
|
||||
transitivePeerDependencies:
|
||||
- typescript
|
||||
dev: true
|
||||
|
||||
/@types/node@20.5.0:
|
||||
resolution: {integrity: sha512-Mgq7eCtoTjT89FqNoTzzXg2XvCi5VMhRV6+I2aYanc6kQCBImeNaAYRs/DyoVqk1YEUJK5gN9VO7HRIdz4Wo3Q==}
|
||||
dev: true
|
||||
|
||||
/@types/uuid@8.3.4:
|
||||
resolution: {integrity: sha512-c/I8ZRb51j+pYGAu5CrFMRxqZ2ke4y2grEBO5AUjgSkSk+qT2Ea+OdWElz/OiMf5MNpn2b17kuVBwZLQJXzihw==}
|
||||
dev: false
|
||||
|
||||
/@typescript/vfs@1.5.0:
|
||||
resolution: {integrity: sha512-AJS307bPgbsZZ9ggCT3wwpg3VbTKMFNHfaY/uF0ahSkYYrPF2dSSKDNIDIQAHm9qJqbLvCsSJH7yN4Vs/CsMMg==}
|
||||
dependencies:
|
||||
debug: 4.3.4
|
||||
transitivePeerDependencies:
|
||||
- supports-color
|
||||
dev: true
|
||||
|
||||
/base64-js@1.5.1:
|
||||
resolution: {integrity: sha512-AKpaYlHn8t4SVbOHCy+b5+KKgvR4vrsD8vbvrbiQJps7fKDTkjkDry6ji0rUJjC0kzbNePLwzxq8iypo41qeWA==}
|
||||
dev: false
|
||||
|
||||
/braces@3.0.2:
|
||||
resolution: {integrity: sha512-b8um+L1RzM3WDSzvhm6gIz1yfTbBt6YTlcEKAvsmqCZZFw46z626lVj9j1yEPW33H5H+lBQpZMP1k8l+78Ha0A==}
|
||||
engines: {node: '>=8'}
|
||||
dependencies:
|
||||
fill-range: 7.0.1
|
||||
dev: true
|
||||
|
||||
/buffer@5.7.1:
|
||||
resolution: {integrity: sha512-EHcyIPBQ4BSGlvjB16k5KgAJ27CIsHY/2JBmCRReo48y9rQ3MaUzWX3KVlBa4U7MyX02HdVj0K7C3WaB3ju7FQ==}
|
||||
dependencies:
|
||||
base64-js: 1.5.1
|
||||
ieee754: 1.2.1
|
||||
dev: false
|
||||
|
||||
/compatfactory@2.0.9(typescript@5.1.6):
|
||||
resolution: {integrity: sha512-fvO+AWcmbO7P1S+A3mwm3IGr74eHMeq5ZLhNhyNQc9mVDNHT4oe0Gg0ksdIFFNXLK7k7Z/TYcLAUSQdRgh1bsA==}
|
||||
engines: {node: '>=14.9.0'}
|
||||
peerDependencies:
|
||||
typescript: '>=3.x || >= 4.x'
|
||||
dependencies:
|
||||
helpertypes: 0.0.19
|
||||
typescript: 5.1.6
|
||||
dev: true
|
||||
|
||||
/debug@4.3.4:
|
||||
resolution: {integrity: sha512-PRWFHuSU3eDtQJPvnNY7Jcket1j0t5OuOsFzPPzsekD52Zl8qUfFIPEiswXqIvHWGVHOgX+7G/vCNNhehwxfkQ==}
|
||||
engines: {node: '>=6.0'}
|
||||
peerDependencies:
|
||||
supports-color: '*'
|
||||
peerDependenciesMeta:
|
||||
supports-color:
|
||||
optional: true
|
||||
dependencies:
|
||||
ms: 2.1.2
|
||||
dev: true
|
||||
|
||||
/dot-prop@5.3.0:
|
||||
resolution: {integrity: sha512-QM8q3zDe58hqUqjraQOmzZ1LIH9SWQJTlEKCH4kJ2oQvLZk7RbQXvtDM2XEq3fwkV9CCvvH4LA0AV+ogFsBM2Q==}
|
||||
engines: {node: '>=8'}
|
||||
dependencies:
|
||||
is-obj: 2.0.0
|
||||
dev: false
|
||||
|
||||
/fill-range@7.0.1:
|
||||
resolution: {integrity: sha512-qOo9F+dMUmC2Lcb4BbVvnKJxTPjCm+RRpe4gDuGrzkL7mEVl/djYSu2OdQ2Pa302N4oqkSg9ir6jaLWJ2USVpQ==}
|
||||
engines: {node: '>=8'}
|
||||
dependencies:
|
||||
to-regex-range: 5.0.1
|
||||
dev: true
|
||||
|
||||
/get-tsconfig@4.7.0:
|
||||
resolution: {integrity: sha512-pmjiZ7xtB8URYm74PlGJozDNyhvsVLUcpBa8DZBG3bWHwaHa9bPiRpiSfovw+fjhwONSCWKRyk+JQHEGZmMrzw==}
|
||||
dependencies:
|
||||
resolve-pkg-maps: 1.0.0
|
||||
dev: true
|
||||
|
||||
/helpertypes@0.0.19:
|
||||
resolution: {integrity: sha512-J00e55zffgi3yVnUp0UdbMztNkr2PnizEkOe9URNohnrNhW5X0QpegkuLpOmFQInpi93Nb8MCjQRHAiCDF42NQ==}
|
||||
engines: {node: '>=10.0.0'}
|
||||
dev: true
|
||||
|
||||
/ieee754@1.2.1:
|
||||
resolution: {integrity: sha512-dcyqhDvX1C46lXZcVqCpK+FtMRQVdIMN6/Df5js2zouUsqG7I6sFxitIC+7KYK29KdXOLHdu9zL4sFnoVQnqaA==}
|
||||
dev: false
|
||||
|
||||
/is-number@7.0.0:
|
||||
resolution: {integrity: sha512-41Cifkg6e8TylSpdtTpeLVMqvSBEVzTttHvERD741+pnZ8ANv0004MRL43QKPDlK9cGvNp6NZWZUBlbGXYxxng==}
|
||||
engines: {node: '>=0.12.0'}
|
||||
dev: true
|
||||
|
||||
/is-obj@2.0.0:
|
||||
resolution: {integrity: sha512-drqDG3cbczxxEJRoOXcOjtdp1J/lyp1mNn0xaznRs8+muBhgQcrnbspox5X5fOw0HnMnbfDzvnEMEtqDEJEo8w==}
|
||||
engines: {node: '>=8'}
|
||||
dev: false
|
||||
|
||||
/lz-string@1.5.0:
|
||||
resolution: {integrity: sha512-h5bgJWpxJNswbU7qCrV0tIKQCaS3blPDrqKWx+QxzuzL1zGUzij9XCWLrSLsJPu5t+eWA/ycetzYAO5IOMcWAQ==}
|
||||
hasBin: true
|
||||
dev: true
|
||||
|
||||
/micromatch@4.0.5:
|
||||
resolution: {integrity: sha512-DMy+ERcEW2q8Z2Po+WNXuw3c5YaUSFjAO5GsJqfEl7UjvtIuFKO6ZrKvcItdy98dwFI2N1tg3zNIdKaQT+aNdA==}
|
||||
engines: {node: '>=8.6'}
|
||||
dependencies:
|
||||
braces: 3.0.2
|
||||
picomatch: 2.3.1
|
||||
dev: true
|
||||
|
||||
/ms@2.1.2:
|
||||
resolution: {integrity: sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==}
|
||||
dev: true
|
||||
|
||||
/picomatch@2.3.1:
|
||||
resolution: {integrity: sha512-JU3teHTNjmE2VCGFzuY8EXzCDVwEqB2a8fsIvwaStHhAWJEeVd1o1QD80CU6+ZdEXXSLbSsuLwJjkCBWqRQUVA==}
|
||||
engines: {node: '>=8.6'}
|
||||
dev: true
|
||||
|
||||
/resolve-pkg-maps@1.0.0:
|
||||
resolution: {integrity: sha512-seS2Tj26TBVOC2NIc2rOe2y2ZO7efxITtLZcGSOnHHNOQ7CkiUBfw0Iw2ck6xkIhPwLhKNLS8BO+hEpngQlqzw==}
|
||||
dev: true
|
||||
|
||||
/strip-json-comments@3.1.1:
|
||||
resolution: {integrity: sha512-6fPc+R4ihwqP6N/aIv2f1gMH8lOVtWQHoqC4yK6oSDVVocumAsfCqjkXnqiYMhmMwS/mEHLp7Vehlt3ql6lEig==}
|
||||
engines: {node: '>=8'}
|
||||
dev: true
|
||||
|
||||
/to-fast-properties@3.0.1:
|
||||
resolution: {integrity: sha512-/wtNi1tW1F3nf0OL6AqVxGw9Tr1ET70InMhJuVxPwFdGqparF0nQ4UWGLf2DsoI2bFDtthlBnALncZpUzOnsUw==}
|
||||
engines: {node: '>=8'}
|
||||
dev: false
|
||||
|
||||
/to-regex-range@5.0.1:
|
||||
resolution: {integrity: sha512-65P7iz6X5yEr1cwcgvQxbbIw7Uk3gOy5dIdtZ4rDveLqhrdJP+Li/Hx6tyK0NEb+2GCyneCMJiGqrADCSNk8sQ==}
|
||||
engines: {node: '>=8.0'}
|
||||
dependencies:
|
||||
is-number: 7.0.0
|
||||
dev: true
|
||||
|
||||
/typescript@5.1.6:
|
||||
resolution: {integrity: sha512-zaWCozRZ6DLEWAWFrVDz1H6FVXzUSfTy5FUMWsQlU8Ym5JP9eO4xkTIROFCQvhQf61z6O/G6ugw3SgAnvvm+HA==}
|
||||
engines: {node: '>=14.17'}
|
||||
hasBin: true
|
||||
dev: true
|
||||
|
||||
/uuid@8.3.2:
|
||||
resolution: {integrity: sha512-+NYs2QeMWy+GWFOEm9xnn6HCDp0l7QBD7ml8zLUmJ+93Q5NF0NocErnwkTkXVFNiX3/fpC6afS8Dhb/gz7R7eg==}
|
||||
hasBin: true
|
||||
dev: false
|
||||
|
36
src/index.ts
36
src/index.ts
@ -1,3 +1,7 @@
|
||||
import {
|
||||
typeOf, ReflectionFunction, ReflectionClass, ReflectionKind, stringifyType
|
||||
} from '@deepkit/type'
|
||||
|
||||
import {Dispatcher} from './core/Dispatcher.js'
|
||||
import * as Specifications from './all.js'
|
||||
|
||||
@ -9,6 +13,38 @@ import {absquare as absquare_complex} from './Complex/arithmetic.js'
|
||||
const mockRealAdd = (a: number, b: number) => a+b
|
||||
const mockComplexAbsquare = (z: Complex<number>) => z.re*z.re + z.im*z.im
|
||||
|
||||
const addRefl = ReflectionFunction.from(mockRealAdd)
|
||||
|
||||
console.log('----> I figured out:', addRefl, addRefl.getParameterNames(), addRefl.getParameterType('b'))
|
||||
|
||||
function bungle(deps: {
|
||||
factor: (i: number) => number,
|
||||
label: string
|
||||
}) {
|
||||
return (a: number) => deps.label + (deps.factor(2)*a)
|
||||
}
|
||||
|
||||
let fn = (i:number) => 3*i
|
||||
console.log("\nBungling", bungle({factor: fn, label:'hextupled: '})(7))
|
||||
const bRefl = ReflectionFunction.from(bungle)
|
||||
const depstype = bRefl.getParameterType('deps')
|
||||
console.log('Deps type is', depstype)
|
||||
console.log(' aka ', stringifyType(depstype))
|
||||
if (depstype.kind == ReflectionKind.objectLiteral) {
|
||||
const depsRefl = new ReflectionClass(depstype)
|
||||
console.log(' With methods', depsRefl.getMethodNames())
|
||||
const factorRefl = depsRefl.getMethod('factor')
|
||||
console.log(' And factor method takes parameters',
|
||||
factorRefl.getParameterNames())
|
||||
const itype = factorRefl.getParameterType('i')
|
||||
console.log(' Parameter `i` has type', itype)
|
||||
console.log(' aka', stringifyType(itype))
|
||||
} else {
|
||||
console.log(' Not understanding deps')
|
||||
}
|
||||
|
||||
|
||||
|
||||
const quatAbsquare = absquare_complex({
|
||||
add: mockRealAdd,
|
||||
absquare: mockComplexAbsquare
|
||||
|
@ -2,6 +2,8 @@
|
||||
"compilerOptions": {
|
||||
"target": "ES2022",
|
||||
"rootDir": "./src",
|
||||
"outDir": "./obj"
|
||||
}
|
||||
"outDir": "./obj",
|
||||
"moduleResolution": "nodenext"
|
||||
},
|
||||
"reflection": true
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user