expr-eval
expr-eval copied to clipboard
Update type definitions
Minor changes to 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.
Parser.evaluate("true") // returns boolean
Parser.evaluate("[1,2,3]") // returns array
Make function Values 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.
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 Values instead of a Value (which can also be array/boolean/etc.)
Update evaluate functions to return a Value type instead of just number
It's better to move these to DefinitelyTyped, until expr-eval is rewritten in TypeScript. More info.