Skip to content

Commit

Permalink
Tightening type for flattenStyle
Browse files Browse the repository at this point in the history
Reviewed By: yungsters

Differential Revision: D7131703

fbshipit-source-id: d8e37fcd0c743057e04760b1e50f8d879bd2826a
  • Loading branch information
elicwhite authored and facebook-github-bot committed Mar 3, 2018
1 parent 3152e93 commit 70a3ece
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 9 deletions.
8 changes: 4 additions & 4 deletions Libraries/Animated/src/nodes/AnimatedTransform.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@ const AnimatedWithChildren = require('./AnimatedWithChildren');
const NativeAnimatedHelper = require('../NativeAnimatedHelper');

class AnimatedTransform extends AnimatedWithChildren {
_transforms: Array<Object>;
_transforms: $ReadOnlyArray<Object>;

constructor(transforms: Array<Object>) {
constructor(transforms: $ReadOnlyArray<Object>) {
super();
this._transforms = transforms;
}
Expand All @@ -34,7 +34,7 @@ class AnimatedTransform extends AnimatedWithChildren {
});
}

__getValue(): Array<Object> {
__getValue(): $ReadOnlyArray<Object> {
return this._transforms.map(transform => {
const result = {};
for (const key in transform) {
Expand All @@ -49,7 +49,7 @@ class AnimatedTransform extends AnimatedWithChildren {
});
}

__getAnimatedValue(): Array<Object> {
__getAnimatedValue(): $ReadOnlyArray<Object> {
return this._transforms.map(transform => {
const result = {};
for (const key in transform) {
Expand Down
8 changes: 3 additions & 5 deletions Libraries/StyleSheet/flattenStyle.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,9 @@
*/
'use strict';

var invariant = require('fbjs/lib/invariant');
var ReactNativePropRegistry;

import type { StyleObj } from 'StyleSheetTypes';
import type { DimensionValue, ColorValue, StyleProp, Style } from 'StyleSheetTypes';

function getStyle(style) {
if (ReactNativePropRegistry === undefined) {
Expand All @@ -24,11 +23,10 @@ function getStyle(style) {
return style;
}

function flattenStyle(style: ?StyleObj): ?Object {
if (!style) {
function flattenStyle(style: ?StyleProp<Style<DimensionValue, ColorValue>>): ?Style<DimensionValue, ColorValue> {
if (style == null) {
return undefined;
}
invariant(style !== true, 'style may be false but not true');

if (!Array.isArray(style)) {
/* $FlowFixMe(>=0.63.0 site=react_native_fb) This comment suppresses an
Expand Down

0 comments on commit 70a3ece

Please sign in to comment.