Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
The issue as described in factory_bot #968 is that depending on the order a parent or child factory is initialized, it will copy over the other's traits in a way that leads to inconsistent results.
The fix for us (and hopefully for factory_bot, if I can present this properly) is to make the "search" for a trait happen every time instead of at compile, and to stop copying any traits at all into each other. Instead, keep track of the "parent" (which is effectively a lexical context) inside of each trait, and when calling "getAttributes" on a trait, have it check up the parent hierarchy for the existence of a trait with that name.
To handle this, we have to copy over the "parent" of each trait when iterating over them. This is slightly messy and not my favorite means of handling things, but because it happens unconditionally, it's okay.
NOTE: You have to delete or move all of the unit tests to run anything, because typescript is dumb.