Skip to content
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

Allow passing generic type to initDataset() #384

Open
mongodben opened this issue Sep 25, 2024 · 2 comments
Open

Allow passing generic type to initDataset() #384

mongodben opened this issue Sep 25, 2024 · 2 comments

Comments

@mongodben
Copy link
Contributor

The function initDataset() doesn't return typed values. this makes it burdensome to use within projects.

you should be able to pass the type of your dataset, probably conforming to some base interface, to the function. something like:

type initDataset<T extends DatasetItem> = (arg) => (...do stuff w/ DatasetItem)
@ankrgyl
Copy link
Contributor

ankrgyl commented Sep 25, 2024

We've been adding optional zod schemas to a bunch of new surface area -- perhaps the right thing to do here would be to let you pass in a schema that gives you type safety and can be validated at runtime?

@mongodben
Copy link
Contributor Author

We've been adding optional zod schemas to a bunch of new surface area -- perhaps the right thing to do here would be to let you pass in a schema that gives you type safety and can be validated at runtime?

yeah that makes lots of sense to me. that's actually what we're doing here mongodb/chatbot#505. and then the typing could be inferred internally from the schema with z.infer<typeof ZodSchema>

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

No branches or pull requests

2 participants