typocomath/README.md

2.0 KiB

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