pbeshai / tidy

Tidy up your data with JavaScript, inspired by dplyr and the tidyverse
https://pbeshai.github.io/tidy
MIT License
725 stars 21 forks source link

Typescript type error? #43

Open ricardoekm opened 3 years ago

ricardoekm commented 3 years ago

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.
pbeshai commented 3 years ago

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