Tightening type for flattenStyle

Reviewed By: yungsters

Differential Revision: D7131703

fbshipit-source-id: d8e37fcd0c743057e04760b1e50f8d879bd2826a
This commit is contained in:
Eli White 2018-03-03 15:06:43 -08:00 committed by Facebook Github Bot
parent 3152e93095
commit 70a3ececc3
2 changed files with 7 additions and 9 deletions

View File

@ -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;
}
@ -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) {
@ -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) {

View File

@ -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) {
@ -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