Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Make the type definitions more accurate
Add `operators.array` to `ParserOptions` Add types for `Parser.unaryOps`, `Parser.functions`, and `Parser.consts` Add boolean and array to `Value` type, since `evaluate` can return those. ```ts Parser.evaluate("true") // returns boolean Parser.evaluate("[1,2,3]") // returns array ``` Make function `Value`s take `any[]` instead of `Value[]`. TypeScript won't let you assign a function that only takes `number`/`string` etc. to `(...args: Value[]) => Value`, so make it take any. ```ts let x: (...args: Value[]) => Value = Math.max // TypeScript will error let x: (...args: any[]) => Value = Math.max // TypeScript is happy ``` Update `evaluate`'s and `simplify`'s definition to only take an object of `Value`s instead of a `Value` (which can also be array/boolean/etc.) Update `evaluate` functions to return a `Value` type instead of just `number`
- Loading branch information