mirror of
https://github.com/zhigang1992/DefinitelyTyped.git
synced 2026-04-29 09:55:50 +08:00
[react-native] - StyleSheet.create parameter properly constrained
Added test based on output of react-native init command
This commit is contained in:
6
types/react-native/index.d.ts
vendored
6
types/react-native/index.d.ts
vendored
@@ -4558,10 +4558,14 @@ export namespace StyleSheet {
|
||||
|
||||
type Style = ViewStyle | TextStyle | ImageStyle
|
||||
|
||||
type NamedStyles<T> = {
|
||||
[P in keyof T]: Style;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a StyleSheet style reference from the given object.
|
||||
*/
|
||||
export function create<T>( styles: T ): T;
|
||||
export function create<T extends NamedStyles<T>>( styles: T ): T;
|
||||
|
||||
/**
|
||||
* Flattens an array of style objects, into one aggregated style object.
|
||||
|
||||
45
types/react-native/test/init-example.tsx
Normal file
45
types/react-native/test/init-example.tsx
Normal file
@@ -0,0 +1,45 @@
|
||||
import * as React from 'react';
|
||||
import {
|
||||
AppRegistry,
|
||||
StyleSheet,
|
||||
Text,
|
||||
View
|
||||
} from 'react-native';
|
||||
|
||||
export default class AwesomeProject extends React.Component<{}, {}> {
|
||||
render() {
|
||||
return (
|
||||
<View style={styles.container}>
|
||||
<Text style={styles.welcome}>
|
||||
Welcome to React Native!
|
||||
</Text>
|
||||
<Text style={styles.instructions}>
|
||||
To get started, edit index.ios.js
|
||||
</Text>
|
||||
<Text style={styles.instructions}>
|
||||
Press Cmd+R to reload,{'\n'}
|
||||
Cmd+D or shake for dev menu
|
||||
</Text>
|
||||
</View>
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
const styles = StyleSheet.create({
|
||||
container: {
|
||||
flex: 1,
|
||||
justifyContent: 'center',
|
||||
alignItems: 'center',
|
||||
backgroundColor: '#F5FCFF',
|
||||
},
|
||||
welcome: {
|
||||
fontSize: 20,
|
||||
textAlign: 'center',
|
||||
margin: 10,
|
||||
},
|
||||
instructions: {
|
||||
textAlign: 'center',
|
||||
color: '#333333',
|
||||
marginBottom: 5,
|
||||
},
|
||||
});
|
||||
@@ -20,6 +20,7 @@
|
||||
"files": [
|
||||
"index.d.ts",
|
||||
"test/index.tsx",
|
||||
"test/animated.tsx"
|
||||
"test/animated.tsx",
|
||||
"test/init-example.tsx"
|
||||
]
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user