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

feat: add typescript types #134

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft

feat: add typescript types #134

wants to merge 1 commit into from

Conversation

snyamathi
Copy link
Collaborator

Adds typescript types while trying to maintain as much flexibility as possible.

type Config = { foo: string };
const ycb = new Ycb<Config>(bundle);
const { foo } = ycb.read(context); // foo is a string

While the examples show the dimensions and main config at the top, neither of those is required.

In fact, the main config is technically not required. If you were to omit a main config, all you would get back is the delta, if any. I don't think this is how the library was intended to be used, and if you did want to omit the main config, you can give the generic type as a DeepPartial of your config, but this won't happen automatically.

type Config = DeepPartial<{ foo: string }>;
const ycb = new Ycb<<Config>>(bundle);
const { foo } = ycb.read(context); // foo is string | undefined

I confirm that this contribution is made under the terms of the license found in the root directory of this repository's source tree and that I have the authority necessary to make this contribution on behalf of its copyright owner.

@snyamathi snyamathi marked this pull request as ready for review October 7, 2024 16:52
@snyamathi snyamathi marked this pull request as draft October 7, 2024 16:56
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.

1 participant