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

Remove typebox Static<> type inference in favor of TypeScript #107

Merged
merged 2 commits into from
Sep 11, 2023

Conversation

austin-denoble
Copy link
Contributor

Problem

We use typebox for runtime validation of arguments in the Node client. Currently, we're leveraging typebox's Static<typeof schema> utility for generating TypeScript types out of these runtime schemas.

We've noticed this doesn't play well with documentation generation, and there have been some bug reports regarding issues possibly related to typebox's generated types.

Solution

Instead of relying on the typebox utility, use our own TypeScript types which are manually aligned with existing schemas.

Type of Change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update
  • Infrastructure change (CI configs, etc)
  • Non-code change (docs, etc)
  • None of the above: (explain here)

Test Plan

These are all typing changes so there shouldn't be any client code affected by these changes.

Make sure to run:
npm run lint

export type DeleteManyByVectorIdOptions = Array<string>;
export type DeleteManyByFilterOptions = object;
export type DeleteManyOptions =
| DeleteManyByVectorIdOptions
Copy link
Collaborator

Choose a reason for hiding this comment

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

I've never seen the | used on the first entry like this. Is that correct/valid syntax?

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 a prettier addition, but yeah seems like valid syntax. I did have to look it up though, found this: prettier/prettier#6299

jhamon
jhamon previously approved these changes Sep 11, 2023
@austin-denoble austin-denoble marked this pull request as ready for review September 11, 2023 22:25
@austin-denoble austin-denoble merged commit 75f493a into main Sep 11, 2023
3 checks passed
@austin-denoble austin-denoble deleted the adenoble/typebox-to-typescript branch September 11, 2023 23:15
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.

2 participants