Skip to content

Commit 4e71a30

Browse files
jbrown215facebook-github-bot
authored andcommitted
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
1 parent 26650c7 commit 4e71a30

File tree

2 files changed

+3
-1
lines changed

2 files changed

+3
-1
lines changed

Libraries/LogBox/UI/LogBoxNotification.js

+2
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,8 @@ function LogBoxLogNotification(props: Props): React.Node {
6060
function CountBadge(props) {
6161
return (
6262
<View style={countStyles.outside}>
63+
{/* $FlowFixMe(>=0.114.0) This suppression was added when fixing the type
64+
* of `StyleSheet.create`. Remove this comment to see the error. */}
6365
<View style={[countStyles.inside, countStyles[props.level]]}>
6466
<Text style={countStyles.text}>
6567
{props.count <= 1 ? '!' : props.count}

Libraries/StyleSheet/StyleSheet.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -347,7 +347,7 @@ module.exports = {
347347
/**
348348
* Creates a StyleSheet style reference from the given object.
349349
*/
350-
create<+S: ____Styles_Internal>(obj: S): $ObjMap<S, (Object) => any> {
350+
create<+S: ____Styles_Internal>(obj: S): $ReadOnly<S> {
351351
// TODO: This should return S as the return type. But first,
352352
// we need to codemod all the callsites that are typing this
353353
// return value as a number (even though it was opaque).

0 commit comments

Comments
 (0)