A final (?) prototype for a refactor of mathjs, culminating the picomath, pocomath, typomath series. Provides an extensible core with "fuzzy" types for its operations, that can at any time generate exact .d.ts file for its current state.
Glen Whitney
ebe7cf831e
The idea is to have a single macro which lets you reflect multiple implementations. That's provided in this commit. However, there is a hitch with implementations that have no dependencies: the reflectedType property did not exist on the Signature type. However, if you add it, then the Signature type becomes opaque, so we would have to look up signatures; but that appears to be tricky, as there doesn't seem to be a way to reflect the full generic type of the Signatures interface. So this commit provides three example resolutions: (A) Export a type RTT and all no-dependency implementations have to intersect with RTT (see 'add' in number/arithmetic.ts) (B) Write no-dependency implementations as functions of no arguments (representing no dependencies passed in) returning the actual implementation (see 'subtract' in number/arithmetic.ts) (C) Make a special DSignature<> generic type (short for "Direct Signature" used only (and always) for implementations with no dependencies, and a matching $Dreflect!() macro for generating their type info. Of course, there may be other possibilities I haven't thought of. But we need to pick one. I don't think it matters _too_ much, since there only a small fraction of all implementations have no dependencies. |
||
---|---|---|
etc | ||
src | ||
.gitignore | ||
.npmrc | ||
LICENSE | ||
package.json5 | ||
pnpm-lock.yaml | ||
README.md | ||
tsconfig.json |
typocomath
A final (?) prototype for a refactor of mathjs, culminating the picomath, pocomath, typomath series. Provides an extensible core with "fuzzy" types for its operations, that can at any time generate exact .d.ts file for its current state.
Convenience scripts:
pnpm build
-- compile the packagepnpm exec
-- run the compiled code produced bypnpm build
pnpm go
-- both of the above in sequence.
Important installation note:
after pnpm install
, you must execute npx ts-patch install
to activate the ts-macros compiler plugin.