feat: Add reflecTypes that allows multiple reflections at once

This commit is contained in:
Glen Whitney 2023-10-09 21:10:15 -07:00
parent 457b9cdc91
commit 49b1332917
4 changed files with 27 additions and 15 deletions

View File

@ -23,12 +23,12 @@
url: 'https://code.studioinfinity.org/glen/typocomath.git', url: 'https://code.studioinfinity.org/glen/typocomath.git',
}, },
devDependencies: { devDependencies: {
'@types/node': '20.8.0', '@types/node': '20.8.4',
'cpy-cli': '5.0.0', 'cpy-cli': '5.0.0',
'del-cli': '5.1.0', 'del-cli': '5.1.0',
mkdirp: '3.0.1', mkdirp: '3.0.1',
'source-map': '0.7.4', 'source-map': '0.7.4',
'ts-macros': '2.5.0', 'ts-macros': '2.6.0',
'ts-patch': '3.0.2', 'ts-patch': '3.0.2',
typescript: '5.1.6', typescript: '5.1.6',
}, },

View File

@ -6,8 +6,8 @@ settings:
devDependencies: devDependencies:
'@types/node': '@types/node':
specifier: 20.8.0 specifier: 20.8.4
version: 20.8.0 version: 20.8.4
cpy-cli: cpy-cli:
specifier: 5.0.0 specifier: 5.0.0
version: 5.0.0 version: 5.0.0
@ -21,8 +21,8 @@ devDependencies:
specifier: 0.7.4 specifier: 0.7.4
version: 0.7.4 version: 0.7.4
ts-macros: ts-macros:
specifier: 2.5.0 specifier: 2.6.0
version: 2.5.0(typescript@5.1.6) version: 2.6.0(typescript@5.1.6)
ts-patch: ts-patch:
specifier: 3.0.2 specifier: 3.0.2
version: 3.0.2 version: 3.0.2
@ -79,8 +79,10 @@ packages:
resolution: {integrity: sha512-jhuKLIRrhvCPLqwPcx6INqmKeiA5EWrsCOPhrlFSrbrmU4ZMPjj5Ul/oLCMDO98XRUIwVm78xICz4EPCektzeQ==} resolution: {integrity: sha512-jhuKLIRrhvCPLqwPcx6INqmKeiA5EWrsCOPhrlFSrbrmU4ZMPjj5Ul/oLCMDO98XRUIwVm78xICz4EPCektzeQ==}
dev: true dev: true
/@types/node@20.8.0: /@types/node@20.8.4:
resolution: {integrity: sha512-LzcWltT83s1bthcvjBmiBvGJiiUe84NWRHkw+ZV6Fr41z2FbIzvc815dk2nQ3RAKMuN2fkenM/z3Xv2QzEpYxQ==} resolution: {integrity: sha512-ZVPnqU58giiCjSxjVUESDtdPk4QR5WQhhINbc9UBrKLU68MX5BF6kbQzTrkwbolyr0X8ChBpXfavr5mZFKZQ5A==}
dependencies:
undici-types: 5.25.3
dev: true dev: true
/@types/normalize-package-data@2.4.1: /@types/normalize-package-data@2.4.1:
@ -843,8 +845,8 @@ packages:
engines: {node: '>=12'} engines: {node: '>=12'}
dev: true dev: true
/ts-macros@2.5.0(typescript@5.1.6): /ts-macros@2.6.0(typescript@5.1.6):
resolution: {integrity: sha512-Uha8rei70+YtQS7nJ1F9m4BVUUV78vky3hIeH6JaHo2cqrKFpA9VWKzkzt4CAQU7g1pheNKr0iOkBmCzrKy2jw==} resolution: {integrity: sha512-X7c4rHPTpBYY+MJUkIDIQMbTPAcv1y1sylrnDMsTvcbImleT4Wlheg3wNbORwnX8Zvq2ldZnttNXcZ1a0VE2Kg==}
hasBin: true hasBin: true
peerDependencies: peerDependencies:
typescript: 4.7.x || 4.8.x || 4.9.x || 5.0.x || 5.1.x || 5.2.x typescript: 4.7.x || 4.8.x || 4.9.x || 5.0.x || 5.1.x || 5.2.x
@ -876,6 +878,10 @@ packages:
hasBin: true hasBin: true
dev: true dev: true
/undici-types@5.25.3:
resolution: {integrity: sha512-Ga1jfYwRn7+cP9v8auvEXN1rX3sWqlayd4HP7OKk4mZWylEmu3KzXDUGrQUN6Ol7qo1gPvB2e5gX6udnyEPgdA==}
dev: true
/validate-npm-package-license@3.0.4: /validate-npm-package-license@3.0.4:
resolution: {integrity: sha512-DpKm2Ui/xN7/HQKCtpZxoRWBhZ9Z0kqtygG8XCgNQ8ZlDnxuQmWhj566j8fN4Cu3/JmbhsDo7fcAJq4s9h27Ew==} resolution: {integrity: sha512-DpKm2Ui/xN7/HQKCtpZxoRWBhZ9Z0kqtygG8XCgNQ8ZlDnxuQmWhj566j8fN4Cu3/JmbhsDo7fcAJq4s9h27Ew==}
dependencies: dependencies:

View File

@ -91,3 +91,8 @@ export function $reflect<Impl>(name: string, expr: Impl) : Impl & { reflectedTyp
export function $reflecType<Impl>(expr: Impl) { export function $reflecType<Impl>(expr: Impl) {
expr.reflectedType = $$typeToString!<Impl>(true, false, true); expr.reflectedType = $$typeToString!<Impl>(true, false, true);
} }
export function $reflecTypes<ImplTuple>(tup: ImplTuple) {
+[[tup], <T>(elt: T) =>
elt.reflectedType = $$typeToString!<T>(true, false, true)]
}

View File

@ -1,11 +1,11 @@
import type {configDependency} from '../core/Config.js' import type {configDependency} from '../core/Config.js'
import type {Dependencies, Signature} from '../interfaces/type.js' import type {Dependencies, Signature} from '../interfaces/type.js'
import { $reflecType } from '../interfaces/type.js' import { $reflecType, $reflecTypes } from '../interfaces/type.js'
export const add: Signature<'add', number> = (a, b) => a + b export const add /*: Signature<'add', number>*/ = (a, b) => a + b
export const unaryMinus: Signature<'unaryMinus', number> = a => -a export const unaryMinus: Signature<'unaryMinus', number> = a => -a
export const conj: Signature<'conj', number> = a => a export const conj /*: Signature<'conj', number>*/ = a => a
export const subtract: Signature<'subtract', number> = (a, b) => a - b export const subtract /*: Signature<'subtract', number>*/ = (a, b) => a - b
export const multiply: Signature<'multiply', number> = (a, b) => a * b export const multiply: Signature<'multiply', number> = (a, b) => a * b
export const absquare: Signature<'absquare', number> = a => a * a export const absquare: Signature<'absquare', number> = a => a * a
export const reciprocal: Signature<'reciprocal', number> = a => 1 / a export const reciprocal: Signature<'reciprocal', number> = a => 1 / a
@ -27,3 +27,4 @@ export const sqrt =
} }
} }
$reflecType!(sqrt) $reflecType!(sqrt)
$reflecTypes!([add, conj, subtract])