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.
Go to file
2023-09-11 17:50:10 +02:00
src add another try 2023-09-11 17:50:10 +02:00
.gitignore fix: generate CommonJS output instead of ESM as a workaround for typescript-rtti issue #94 2023-02-02 15:52:15 +01:00
LICENSE Initial commit 2022-12-02 14:04:53 +00:00
package.json5 add another try 2023-09-11 17:50:10 +02:00
pnpm-lock.yaml add another try 2023-09-11 17:50:10 +02:00
README.md some refinements in the plugin 2023-09-01 18:36:50 +02:00
tsconfig.json let TypeScript output ES modules 2023-09-01 18:43:03 +02:00

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.

To build and run the prototype, run:

pnpm install
pnpm build-and-run

experiment

Have a look at the section under /src/experiment and /src/plugins:

  • src/plugins/typeInferPlugin.ts is the actual plugin
  • in tsconfig.json we configure TypeScript to run the plugin
  • src/experiment/arithmeticInfer.ts with an example where we define __infer__
  • after running TypeScript: look at build/experiment/arithmeticInfer.ts where the __infer__ string literal is replaced with the actual types

The idea

Create a TypeScript plugin which can replace a string literal like __infer__ in a typed-function definition:

typed('square', '__infer__', <T>(dep: { ... } => { ... })

with the actual types, something like:

typed('square', '{ deps: { multiply: (a: T, b: T) => T; }; return: (a: T) => T }', <T>(dep: { ... } => { ... })

(We can discuss what syntax we like most, this is just a POC)

How to run

pnpm build-and-run

Read more

Interesting libraries