Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/kddnewton/typescript-parse-math

Parse math expressions with TypeScript types
https://github.com/kddnewton/typescript-parse-math

Last synced: about 2 months ago
JSON representation

Parse math expressions with TypeScript types

Awesome Lists containing this project

README

        

# `typescript-parse-math`

This is a math parser that handles various arithmetic operations using only TypeScript types. Absolutely monstrous. Definitely don't use it.

```ts
import type { ParseMath } from "typescript-parse-math";

type Result1 = ParseMath<"5 - 3 * 2 + 3">;
// type Result1 = 2

type Result2 = ParseMath<"1 + 2 * 3">;
// type Result2 = 7

type Result3 = ParseMath<"10 + 2">;
// type Result3 = 12
```

## Related

* [jamiebuilds/json-parser-in-typescript-very-bad-idea-please-dont-use](https://github.com/jamiebuilds/json-parser-in-typescript-very-bad-idea-please-dont-use).
* [romani/meta-typing](https://github.com/ronami/meta-typing)
* [microsoft/TypeScript#14833](https://github.com/microsoft/TypeScript/issues/14833)