You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.
Hi 👋
I add my two cents on this 😄
What would you think about returning unknown[] instead ? the idea is that we can't be sure that the content of the file does match the generic given, so actually using a generic would be the same that what we have today, it's just a cast 🤷 whereas with the unknown, we first have to make sure that the content of the file does match the expected type, and then with type guards we're sure that our type match our content.
Also, unless I'm wrong, only an array can be returned by the parse function, so shouldn't we return either an unknown[] or if we want to stick to generics, return a T[] ?
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: