ycb
ycb copied to clipboard
feat: add typescript types
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.