Flowify TextStylePropTypes and fix a bug with unsupported props

This commit is contained in:
Marshall Roch 2015-03-23 18:07:19 -07:00
parent 463a5bc9a4
commit b4a39a2a9e
1 changed files with 6 additions and 5 deletions

View File

@ -7,14 +7,15 @@
* of patent rights can be found in the PATENTS file in the same directory. * of patent rights can be found in the PATENTS file in the same directory.
* *
* @providesModule TextStylePropTypes * @providesModule TextStylePropTypes
* @flow
*/ */
'use strict'; 'use strict';
var ReactPropTypes = require('ReactPropTypes'); var ReactPropTypes = require('ReactPropTypes');
var ViewStylePropTypes = require('ViewStylePropTypes'); var ViewStylePropTypes = require('ViewStylePropTypes');
var TextStylePropTypes = { // TODO: use spread instead of Object.assign/create after #6560135 is fixed
...ViewStylePropTypes, var TextStylePropTypes = Object.assign(Object.create(ViewStylePropTypes), {
fontFamily: ReactPropTypes.string, fontFamily: ReactPropTypes.string,
fontSize: ReactPropTypes.number, fontSize: ReactPropTypes.number,
fontWeight: ReactPropTypes.oneOf(['normal' /*default*/, 'bold']), fontWeight: ReactPropTypes.oneOf(['normal' /*default*/, 'bold']),
@ -28,7 +29,7 @@ var TextStylePropTypes = {
writingDirection: ReactPropTypes.oneOf( writingDirection: ReactPropTypes.oneOf(
['auto' /*default*/, 'ltr', 'rtl'] ['auto' /*default*/, 'ltr', 'rtl']
), ),
}; });
// Text doesn't support padding correctly (#4841912) // Text doesn't support padding correctly (#4841912)
var unsupportedProps = Object.keys({ var unsupportedProps = Object.keys({
@ -41,8 +42,8 @@ var unsupportedProps = Object.keys({
paddingHorizontal: null, paddingHorizontal: null,
}); });
for (var key in unsupportedProps) { for (var ii = 0; ii < unsupportedProps.length; ii++) {
delete TextStylePropTypes[key]; delete TextStylePropTypes[unsupportedProps[ii]];
} }
module.exports = TextStylePropTypes; module.exports = TextStylePropTypes;