-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
transformHeader returns function instead of string: trim is not a function #1006
Comments
You can try declaring the function elsewhere? I was able to make it work with an arrow function instead of a declaration. example:
Hopefully that works for you? |
@kraighamady this makes no difference |
@bettysteger Two thing I just noticed. With a type error you are using typescript? if so, you can do what I did which is explicitly type the header param in the function:
The issue is that your typescript checker doesn't know that header is a string so cannot be sure that the trim() function is by default in the prototype. So the error is coming from your function and not papaparse's typing of the config object. I checked and they have the property transformHeader accepting I am not sure why you can get away without typing in the function in the latest version version the previous release. |
@kraighamady unfortunately I am not using typescript for this project |
I'd have to see more of the code and the values in your csv. You could try forcing the variable to string:
|
@kraighamady but why do i need that now? in v5.3.2 it works, because it is always a string, and somehow in v5.4.1 it seems that the function is called twice: #1029 |
Not sure. I am having the duplicate call issue as well. I was just offering a workaround in case you were blocked. I am just a user of the package and not involved in the development of the tool. |
@kraighamady oh thanks! no i just keep v5.3.2 for now :D |
In version 5.3.2 this works:
In version 5.4.1 i got the following error because header is sometimes a function, sometimes a string, but the 1st param should always be a string?!
The text was updated successfully, but these errors were encountered: