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

Eliminate Builder class generation. #28

Merged
merged 1 commit into from
Feb 3, 2021
Merged

Eliminate Builder class generation. #28

merged 1 commit into from
Feb 3, 2021

Conversation

jessemyers
Copy link
Contributor

Now that mixins have been removed, we can simply have the recipes instantiate a Builder.

Now that mixins have been removed, we can simply have the recipes instantiate a Builder.
*/
export function createBuilder<Options>(
Copy link
Contributor Author

Choose a reason for hiding this comment

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

We now just export a Builder class. Much simpler.

}
public add(...decorators: (PropertyDecorator | undefined)[]): this {
this.decorators.push(
...decorators.filter(isPropertyDecorator),
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I rewrote this filter to use type guard; this makes the compiler happier if undefined is passed in.

export const IsNumber = IsNumberRecipe(createBuilderWithMixins<NumberOptions>());
export const IsString = IsStringRecipe(createBuilderWithMixins<StringOptions>());
export const IsUUID = IsUUIDRecipe(createBuilderWithMixins<UUIDOptions>());
export const IsArray = IsArrayRecipe<FlavorOptions>(initializers);
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Recipe usage is now just:

  • An options type
  • A set of initializers

@jessemyers jessemyers merged commit 2ff66ac into main Feb 3, 2021
@jessemyers jessemyers deleted the simplify-builder branch February 3, 2021 02: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