Skip to content

feat(csv-parse): add generic type argument #457

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

Merged
merged 1 commit into from
May 19, 2025

Conversation

tusbar
Copy link
Contributor

@tusbar tusbar commented May 10, 2025

This is based on the columns option.
When falsy, the records are string[][].
When defined, the records are T[], T defaulting to unknown.
Restrict columns to keyof T.
Update onRecord / on_record to take and return type T.

Fix #278
Fix #407

@tusbar tusbar force-pushed the tusbar/csv-parse-generic-type branch 2 times, most recently from 09062b2 to 2024c2d Compare May 10, 2025 11:05

})

describe('sync api', () => {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was duplicated from test/api.types.sync.ts

@tusbar tusbar force-pushed the tusbar/csv-parse-generic-type branch 4 times, most recently from a4089f9 to dd8196d Compare May 12, 2025 10:11
@wdavidw
Copy link
Member

wdavidw commented May 15, 2025

Would you mind if I first fix the duplication of the api.type.sync test and also apply some eslint formatting to the ts tests. You will have to rebase on master and maybe fix some merging conflicts due to the formatting.

@tusbar
Copy link
Contributor Author

tusbar commented May 15, 2025

Sure.
I’m aware that things may break with this, maybe some more tests would be nice.

@wdavidw
Copy link
Member

wdavidw commented May 19, 2025

Thank you for your patience. The eslint related refactor is committed and pushed.

This is based on the columns option.
When falsy, the records are string[][].
When defined, the records are T[], T defaulting to unknown.
Restrict columns to keyof T.
Update onRecord / on_record to take and return type T.

Fix adaltas#278
Fix adaltas#407
@tusbar tusbar force-pushed the tusbar/csv-parse-generic-type branch from dd8196d to d3c402a Compare May 19, 2025 10:21
@wdavidw wdavidw merged commit ef71342 into adaltas:master May 19, 2025
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Function parse returns "any" - Could it be made generic? Stricter type check for type definition
2 participants