-
Notifications
You must be signed in to change notification settings - Fork 268
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
Function parse returns "any" - Could it be made generic? #407
Comments
Like for any TypeScript request, please consider that I am no TS expert. Your suggestion seems good but I would enjoy feedbacks from the community first. Anyone ? Also, I suspect the change to not be backward compatible and to break a lot of code base. In such case, we will generate a new major version and, to avoid many upgrade, we shall apply the same change to every concerned function in each of the package managed by the CSV project. |
We can make this change backward-compatible by using a default type argument, i.e. declare function parse<T = any>(input: Buffer | string, options?: Options): T; |
Sounds good, I'll give it a try, hopefully soon |
Hi 👋 Also, unless I'm wrong, only an array can be returned by the parse function, so shouldn't we return either an |
Summary
I am using
csv-parse
in a TypeScript project the following way:In my TS code the
records
are of type any becauseparse
has the following type definiton:sync.d.cts
Could the
parse
function accept a type argument to define the type its output? I am thinking of something like this:The text was updated successfully, but these errors were encountered: