pbeshai / tidy

Tidy up your data with JavaScript, inspired by dplyr and the tidyverse

Home Page:https://pbeshai.github.io/tidy

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Typescript type error?

ricardoekm opened this issue · comments

First of all thanks for this nice library, it's filling an important gap in the JS world.

When using typescript I'm getting the following error, any idea? It seems an issue with the grouped column parameter.

         groupBy('day', [
            summarize({ total_cost: mean('total_cost'),
                        total_revenue: mean('total_revenue'),
                        margin: mean('margin') })
         ]))
No overload matches this call.
  The last overload gave the following error.
    Argument of type 'string' is not assignable to parameter of type 'GK<object>'.ts(2769)
tidy.d.ts(1006, 18): The last overload is declared here.
```

The types are pretty finicky, if you can come up with any great solutions I'd be happy to use them. My suggestion would be to try switching to groupBy(['day'] and see if that helps the type inference. If not, you may find groupBy(['day'], [summarize...], {}) helps the type inference. You may also be able to do it via the generics but it's a bit of a doozy