mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
Fix return type of StyleSheet.create to be the identity function
Summary: Changes the return type of StyleSheet.create to `$ReadOnly<S>`. At runtime, it just freezes the fields in dev mode and is the identity function otherwise. This cause 423 errors due to the wrong props being passed to different styles: P124372727 I went over errors at random with Eli to get confidence in the change. Changelog: [General][Fixed] Fix return type of StyleSheet.create Reviewed By: zackargyle, TheSavior Differential Revision: D19218817 fbshipit-source-id: b7aa10700f8333372c9f0bd61bfbef371caadf97
This commit is contained in:
committed by
Facebook Github Bot
parent
26650c766d
commit
4e71a30969
@@ -60,6 +60,8 @@ function LogBoxLogNotification(props: Props): React.Node {
|
||||
function CountBadge(props) {
|
||||
return (
|
||||
<View style={countStyles.outside}>
|
||||
{/* $FlowFixMe(>=0.114.0) This suppression was added when fixing the type
|
||||
* of `StyleSheet.create`. Remove this comment to see the error. */}
|
||||
<View style={[countStyles.inside, countStyles[props.level]]}>
|
||||
<Text style={countStyles.text}>
|
||||
{props.count <= 1 ? '!' : props.count}
|
||||
|
||||
@@ -347,7 +347,7 @@ module.exports = {
|
||||
/**
|
||||
* Creates a StyleSheet style reference from the given object.
|
||||
*/
|
||||
create<+S: ____Styles_Internal>(obj: S): $ObjMap<S, (Object) => any> {
|
||||
create<+S: ____Styles_Internal>(obj: S): $ReadOnly<S> {
|
||||
// TODO: This should return S as the return type. But first,
|
||||
// we need to codemod all the callsites that are typing this
|
||||
// return value as a number (even though it was opaque).
|
||||
|
||||
Reference in New Issue
Block a user