Merge pull request #30564 from DefinitelyTyped/fix-react-native-on-ts-3.1

Fix react-native on TS 3.1+
This commit is contained in:
Eloy Durán
2018-11-16 22:29:53 +01:00
committed by GitHub
2 changed files with 10 additions and 1 deletions
+1 -1
View File
@@ -5226,7 +5226,7 @@ export namespace StyleSheet {
/**
* Creates a StyleSheet style reference from the given object.
*/
export function create<T extends NamedStyles<T>>(styles: T): { [P in keyof T]: RegisteredStyle<T[P]> };
export function create<T extends NamedStyles<T> | NamedStyles<any>>(styles: T): { [P in keyof T]: RegisteredStyle<T[P]> };
/**
* Flattens an array of style objects, into one aggregated style object.
+9
View File
@@ -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<TextStyle> = s.shouldWork
const testNativeSyntheticEvent = <T extends {}>(e: NativeSyntheticEvent<T>): void => {
e.isDefaultPrevented();
e.preventDefault();