Skip to content

Commit 70a3ece

Browse files
elicwhitefacebook-github-bot
authored andcommittedMar 3, 2018
Tightening type for flattenStyle
Reviewed By: yungsters Differential Revision: D7131703 fbshipit-source-id: d8e37fcd0c743057e04760b1e50f8d879bd2826a
1 parent 3152e93 commit 70a3ece

File tree

2 files changed

+7
-9
lines changed

2 files changed

+7
-9
lines changed
 

‎Libraries/Animated/src/nodes/AnimatedTransform.js

+4-4
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,9 @@ const AnimatedWithChildren = require('./AnimatedWithChildren');
1515
const NativeAnimatedHelper = require('../NativeAnimatedHelper');
1616

1717
class AnimatedTransform extends AnimatedWithChildren {
18-
_transforms: Array<Object>;
18+
_transforms: $ReadOnlyArray<Object>;
1919

20-
constructor(transforms: Array<Object>) {
20+
constructor(transforms: $ReadOnlyArray<Object>) {
2121
super();
2222
this._transforms = transforms;
2323
}
@@ -34,7 +34,7 @@ class AnimatedTransform extends AnimatedWithChildren {
3434
});
3535
}
3636

37-
__getValue(): Array<Object> {
37+
__getValue(): $ReadOnlyArray<Object> {
3838
return this._transforms.map(transform => {
3939
const result = {};
4040
for (const key in transform) {
@@ -49,7 +49,7 @@ class AnimatedTransform extends AnimatedWithChildren {
4949
});
5050
}
5151

52-
__getAnimatedValue(): Array<Object> {
52+
__getAnimatedValue(): $ReadOnlyArray<Object> {
5353
return this._transforms.map(transform => {
5454
const result = {};
5555
for (const key in transform) {

‎Libraries/StyleSheet/flattenStyle.js

+3-5
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,9 @@
99
*/
1010
'use strict';
1111

12-
var invariant = require('fbjs/lib/invariant');
1312
var ReactNativePropRegistry;
1413

15-
import type { StyleObj } from 'StyleSheetTypes';
14+
import type { DimensionValue, ColorValue, StyleProp, Style } from 'StyleSheetTypes';
1615

1716
function getStyle(style) {
1817
if (ReactNativePropRegistry === undefined) {
@@ -24,11 +23,10 @@ function getStyle(style) {
2423
return style;
2524
}
2625

27-
function flattenStyle(style: ?StyleObj): ?Object {
28-
if (!style) {
26+
function flattenStyle(style: ?StyleProp<Style<DimensionValue, ColorValue>>): ?Style<DimensionValue, ColorValue> {
27+
if (style == null) {
2928
return undefined;
3029
}
31-
invariant(style !== true, 'style may be false but not true');
3230

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

0 commit comments

Comments
 (0)
Please sign in to comment.