From 3e5bfdadac3b0d8b22d1c948a496c42d4905c400 Mon Sep 17 00:00:00 2001 From: Nathan Shively-Sanders <293473+sandersn@users.noreply.github.com> Date: Thu, 15 Nov 2018 14:17:07 -0800 Subject: [PATCH 1/2] Fix react-native on TS 3.1+ Fixes #29265, based on comment https://github.com/Microsoft/TypeScript/issues/27421#issuecomment-433249163 --- types/react-native/index.d.ts | 2 +- types/react-native/test/index.tsx | 9 +++++++++ 2 files changed, 10 insertions(+), 1 deletion(-) 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..f9e00870d0 100644 --- a/types/react-native/test/index.tsx +++ b/types/react-native/test/index.tsx @@ -14,6 +14,7 @@ For a list of complete Typescript examples: check https://github.com/bgrieder/RN import * as PropTypes from "prop-types"; import * as React from "react"; import { + RegisteredStyle, Alert, AppState, AppStateIOS, @@ -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(); From 1d4bb05c42ba8dc1f3531bac84af1a8de999090c Mon Sep 17 00:00:00 2001 From: Nathan Shively-Sanders <293473+sandersn@users.noreply.github.com> Date: Thu, 15 Nov 2018 14:19:34 -0800 Subject: [PATCH 2/2] Organise imports (closer to alphabetical) --- types/react-native/test/index.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/types/react-native/test/index.tsx b/types/react-native/test/index.tsx index f9e00870d0..a519b0584f 100644 --- a/types/react-native/test/index.tsx +++ b/types/react-native/test/index.tsx @@ -14,7 +14,6 @@ For a list of complete Typescript examples: check https://github.com/bgrieder/RN import * as PropTypes from "prop-types"; import * as React from "react"; import { - RegisteredStyle, Alert, AppState, AppStateIOS, @@ -56,6 +55,7 @@ import { SectionListRenderItemInfo, Switch, RefreshControl, + RegisteredStyle, TabBarIOS, NativeModules, MaskedViewIOS,