danfojs
danfojs copied to clipboard
DataFrame type incompatible between return type of readCSV and node exported DataFrame
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