-
Notifications
You must be signed in to change notification settings - Fork 58
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
UIP-1590: Deprecate the Required annotation (Includes UIP-1835) #51
UIP-1590: Deprecate the Required annotation (Includes UIP-1835) #51
Conversation
RavenNumber of Findings: 0 |
Codecov Report
@@ Coverage Diff @@
## master #51 +/- ##
=========================================
+ Coverage 97.67% 97.7% +0.03%
=========================================
Files 28 28
Lines 1329 1344 +15
=========================================
+ Hits 1298 1313 +15
Misses 31 31 Continue to review full report at Codecov.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Couple of nits... looks good otherwise.
/// Whether setting a prop to null is allowed. | ||
final bool isNullable; | ||
|
||
/// The erro message displayed when the accessor is not set. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
#nit s/erro/error
/// @Required() | ||
/// String bar; | ||
/// } | ||
/// Deprecated use [Accessor], [requiredProp], or [nullableRequiredProp] instead. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
#nit
/// Deprecated.
///
/// Use [Accessor], [requiredProp] or [nullableRequiredProp] instead.
UIP-1590
@aaronlademann-wf Feedback has been addressed |
UIP-1590
/// Annotation used with the `over_react` transformer to customize individual accessors (props/state fields). | ||
/// | ||
/// Validation occurs in `UiComponent.validateRequiredProps` which requires super calls into `componentWillMount` and | ||
/// `componentWillReceiveProps`. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice. #nit might be nice to have this message on the aliases as well
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Addressed
this.key, | ||
this.keyNamespace, | ||
this.isRequired = false, | ||
this.isNullable = false, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh man this looks weird lol
class ComponentTestComponent extends UiComponent<ComponentTestProps> { | ||
@override | ||
render() => Dom.div()(); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should have integration tests for the alias/shorthand consts as well.
I actually don't think that they're getting picked up right now...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Addressed
@@ -402,10 +402,6 @@ class ImplGenerator { | |||
annotations.Accessor accessorMeta = instantiateAnnotation(field, annotations.Accessor); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, I don't think this will pick up the constants.
You'll probably have to just match them by name, like so:
T getConstantAnnotation<T>(AnnotatedNode member, String name, T value) =>
member.metadata.any((annotation) => annotation.name?.name == name)) ? value : null;
annotations.Accessor requiredProp = instantiateAnnotation(field, 'requiredProp', annotations.requiredProp);
annotations.Accessor nullableRequiredProp = instantiateAnnotation(field, 'nullableRequiredProp', annotations.nullableRequiredProp);
if (requiredProp != null) {
// ...
}
if (nullableRequiredProp != null) {
// ...
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should also probably emit a warning if they try to use @requiredProp
/nullableRequiredProp
/@Accessor
together.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh I thought it would pick up on that sort of thing too. What happens if a consumers has there own const shorthand for some reason, should we be supporting that?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unfortunately we can't support that without performing a full analysis 😢
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Addressed
@greglittlefield-wf Feedback has been addressed. The |
} | ||
|
||
if (annotationCount > 1) { | ||
logger.error('At most only a single annotation can be applied to an accessor.', span: getSpan(sourceFile, field)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This message might be a little misleading, since other annotations like @deprecated
are also allowed.
What about something like:
@requiredProp/@nullableProp/@Accessor cannot be used together. You can use `@Accessor(required: true)` or `isNullable: true` instead of the shorthand versions.
+10 |
QA +1
Merging. |
[DIAGNOSTIC] hint for `consumedProps` returning a list literal
Ultimate problem:
The
Required
annotation used by theover_react
transformer collides with the annotation frompackage:meta
.How it was fixed:
Required
, and add more options to theAccessor
annotation.Accessor
annotation.Accessor(isRequired: true)
andAccessor(isRequired: true, isNullable: true)
.Testing suggestions:
Accessor
annotation.Potential areas of regression: