diff --git a/types/react-native/index.d.ts b/types/react-native/index.d.ts index 86bce7d1aa..8cd8e3e04e 100644 --- a/types/react-native/index.d.ts +++ b/types/react-native/index.d.ts @@ -5226,7 +5226,7 @@ export namespace StyleSheet { /** * Creates a StyleSheet style reference from the given object. */ - export function create>(styles: T): { [P in keyof T]: RegisteredStyle }; + export function create | NamedStyles>(styles: T): { [P in keyof T]: RegisteredStyle }; /** * Flattens an array of style objects, into one aggregated style object. diff --git a/types/react-native/test/index.tsx b/types/react-native/test/index.tsx index dc3733cf83..a519b0584f 100644 --- a/types/react-native/test/index.tsx +++ b/types/react-native/test/index.tsx @@ -55,6 +55,7 @@ import { SectionListRenderItemInfo, Switch, RefreshControl, + RegisteredStyle, TabBarIOS, NativeModules, MaskedViewIOS, @@ -175,6 +176,14 @@ const viewProperty = StyleSheet.flatten(viewStyle).backgroundColor; const textProperty = StyleSheet.flatten(textStyle).fontSize; const imageProperty = StyleSheet.flatten(imageStyle).resizeMode; +const s = StyleSheet.create({ + shouldWork: { + fontWeight: '900', // if we comment this line, errors gone + marginTop: 5, // if this line commented, errors also gone + }, +}) +const f1: RegisteredStyle = s.shouldWork + const testNativeSyntheticEvent = (e: NativeSyntheticEvent): void => { e.isDefaultPrevented(); e.preventDefault();