danfojs icon indicating copy to clipboard operation
danfojs copied to clipboard

DataFrame type incompatible between return type of readCSV and node exported DataFrame

Open kitfit-dave opened this issue 2 years ago • 0 comments

The exact type of the DataFrame returned by readCSV (and probably any other base function that returns a base DataFrame) is not compatible with the one exported by the main node package. Code like this, which is what I think should work, does not work:

import { DataFrame, readCSV } from 'danfojs-node'

const textDataFrame: DataFrame = await readCSV('./test.csv')

Error is:

Type 'import("[...]/node_modules/danfojs-node/dist/danfojs-base/core/frame").default' is not assignable to type 'import("[...]/node_modules/danfojs-node/dist/danfojs-node/src/core/frame").default'.
  The types returned by 'toCSV(...)' are incompatible between these types.
    Type 'string | void' is not assignable to type 'string'.
      Type 'void' is not assignable to type 'string'.ts(2322)

The base NDFrame toCSV and toJSON implementations are just missing the function overload it seems. Maybe #440 changed that in one place but not the other?

It seems like just adding the overloads fixes this issue: #566

-- note, to get around the type problem for now without merging #566 one can:

const textDataFrame: DataFrame = await readCSV('./test.csv') as DataFrame

kitfit-dave avatar Apr 14 '23 10:04 kitfit-dave