Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update type definitions #261

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Commits on Nov 13, 2021

  1. 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`
    jesse-r-s-hines committed Nov 13, 2021
    Configuration menu
    Copy the full SHA
    45678bc View commit details
    Browse the repository at this point in the history