Skip to content

Commit

Permalink
Remove redundant left hand side typing
Browse files Browse the repository at this point in the history
+ Also removed some unnecessary parentheses
  • Loading branch information
aaronlademann-wf committed Oct 28, 2016
1 parent d9071f8 commit af8d5f9
Show file tree
Hide file tree
Showing 7 changed files with 15 additions and 17 deletions.
9 changes: 4 additions & 5 deletions lib/src/component_declaration/component_base.dart
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,7 @@ ReactDartComponentFactoryProxy registerComponent(react.Component dartComponentFa
Type componentClass,
String displayName
}) {
ReactDartComponentFactoryProxy reactComponentFactory =
(react.registerComponent(dartComponentFactory)) as ReactDartComponentFactoryProxy;
final reactComponentFactory = react.registerComponent(dartComponentFactory) as ReactDartComponentFactoryProxy;

if (displayName != null) {
reactComponentFactory.reactClass.displayName = displayName;
Expand Down Expand Up @@ -103,7 +102,7 @@ abstract class UiComponent<TProps extends UiProps> extends react.Component {
///
/// Overridden for strong typing.
@override
_RefTypedef get ref => super.ref as _RefTypedef;
get ref => super.ref as _RefTypedef;


/// Returns a copy of this component's props with [consumedPropKeys] omitted.
Expand Down Expand Up @@ -178,7 +177,7 @@ abstract class UiComponent<TProps extends UiProps> extends react.Component {
@override
TProps get props {
var unwrappedProps = this.unwrappedProps;
TProps typedProps = _typedPropsCache[unwrappedProps] as TProps;
var typedProps = _typedPropsCache[unwrappedProps] as TProps;
if (typedProps == null) {
typedProps = typedPropsFactory(unwrappedProps);
_typedPropsCache[unwrappedProps] = typedProps;
Expand Down Expand Up @@ -229,7 +228,7 @@ abstract class UiStatefulComponent<TProps extends UiProps, TState extends UiStat
@override
TState get state {
var unwrappedState = this.unwrappedState;
TState typedState = _typedStateCache[unwrappedState] as TState;
var typedState = _typedStateCache[unwrappedState] as TState;
if (typedState == null) {
typedState = typedStateFactory(unwrappedState);
_typedStateCache[unwrappedState] = typedState;
Expand Down
4 changes: 2 additions & 2 deletions lib/src/component_declaration/flux_component.dart
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ abstract class FluxUiProps<ActionsT, StoresT> extends UiProps {
/// There is no strict rule on the [ActionsT] type. Depending on application
/// structure, there may be [Action]s available directly on this object, or
/// this object may represent a hierarchy of actions.
ActionsT get actions => props[_actionsPropKey] as ActionsT;
get actions => props[_actionsPropKey] as ActionsT;
set actions(ActionsT value) => props[_actionsPropKey] = value;

/// The prop defined by [StoresT].
Expand All @@ -37,7 +37,7 @@ abstract class FluxUiProps<ActionsT, StoresT> extends UiProps {
/// [StoresT] should be a class that provides access to these multiple stores.
/// Then, you can explicitly select the [Store] instances that should be
/// listened to by overriding [_FluxComponentMixin.redrawOn].
StoresT get store => props[_storePropKey] as StoresT;
get store => props[_storePropKey] as StoresT;
set store(StoresT value) => props[_storePropKey] = value;
}

Expand Down
4 changes: 2 additions & 2 deletions lib/src/transformer/declaration_parsing.dart
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ class ParsedDeclarations {
};

declarationMap[key_factory] =
(topLevelVarsOnly(key_factory, declarationMap[key_factory])) as Iterable<CompilationUnitMember>;
topLevelVarsOnly(key_factory, declarationMap[key_factory]) as Iterable<CompilationUnitMember>;

[
key_component,
Expand All @@ -112,7 +112,7 @@ class ParsedDeclarations {
key_stateMixin,
].forEach((annotationName) {
declarationMap[annotationName] =
(classesOnly(annotationName, declarationMap[annotationName])) as Iterable<CompilationUnitMember>;
classesOnly(annotationName, declarationMap[annotationName]) as Iterable<CompilationUnitMember>;
});


Expand Down
2 changes: 1 addition & 1 deletion lib/src/transformer/impl_generation.dart
Original file line number Diff line number Diff line change
Expand Up @@ -366,7 +366,7 @@ class ImplGenerator {
.where((member) => member is FieldDeclaration)
.where((member) => !(member as FieldDeclaration).isStatic)
.forEach((field) {
FieldDeclaration _field = (field as FieldDeclaration);
final _field = field as FieldDeclaration;
// Remove everything in the field except the comments/meta and the variable names, preserving newlines.
// TODO add support for preserving comment nodes between variable declarations.

Expand Down
6 changes: 3 additions & 3 deletions test/over_react/util/react_wrappers_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ main() {
var clone = cloneElement(original, testPropsToAdd);

ReactComponent renderedClone = react_test_utils.renderIntoDocument(clone);
PlainObjectPropsMap props = (renderedClone.props as PlainObjectPropsMap);
var props = renderedClone.props as PlainObjectPropsMap;

var convertedStyle = props.style;
expect(convertedStyle.width, equals('100rem'));
Expand Down Expand Up @@ -687,8 +687,8 @@ main() {
}

/// Helper component for testing a Dart (react-dart) React component with cloneElement.
ReactComponentFactory TestComponentFactory =
(react.registerComponent(() => new TestComponent())) as ReactComponentFactory;
final TestComponentFactory =
react.registerComponent(() => new TestComponent()) as ReactComponentFactory;

class TestComponent extends react.Component {
@override
Expand Down
4 changes: 2 additions & 2 deletions test/test_util/react_util.dart
Original file line number Diff line number Diff line change
Expand Up @@ -392,8 +392,8 @@ List findDescendantsWithProp(/* [1] */ root, dynamic propKey) {
}

/// Helper component that renders whatever you tell it to. Necessary for rendering components with the 'ref' prop.
ReactComponentFactory RenderingContainerComponentFactory =
(react.registerComponent(() => new RenderingContainerComponent())) as ReactComponentFactory;
final RenderingContainerComponentFactory =
react.registerComponent(() => new RenderingContainerComponent()) as ReactComponentFactory;

class RenderingContainerComponent extends react.Component {
@override
Expand Down
3 changes: 1 addition & 2 deletions test/wsd_test_util/common_component_tests.dart
Original file line number Diff line number Diff line change
Expand Up @@ -351,8 +351,7 @@ void testRequiredProps(BuilderOnlyUiFactory factory, dynamic childrenFactory())

group('throws when the required prop', () {
requiredProps.forEach((String propKey) {
ReactDartComponentFactoryProxy reactComponentFactory =
factory().componentFactory as ReactDartComponentFactoryProxy;
final reactComponentFactory = factory().componentFactory as ReactDartComponentFactoryProxy;

// Props that are defined in the default props map will never not be set.
if (!reactComponentFactory.defaultProps.containsKey(propKey)) {
Expand Down

0 comments on commit af8d5f9

Please sign in to comment.