我将Typescript与react-native和react-native网站一起使用。由于某种原因,它无法识别jsx的styles
属性。
import * as React from 'react'
import * as Redux from 'redux'
import {Button, StyleSheet, Text, View} from "react-native";
const _component: React.SFC<Props & State & DispatchProps> = (props) => (
<View>
<Button
onPress={props.onPingClick(props.id)}
title="Ping"
color="#841584"
style={styles.button}
/>
<Text>{props.id}</Text>
</View>
);
我的tsconfig.json
{
"compilerOptions": {
"baseUrl": ".",
"outDir": "build/dist",
"module": "esnext",
"target": "es5",
"lib": ["es6", "dom"],
"sourceMap": true,
"allowJs": true,
"jsx": "react",
"moduleResolution": "node",
"rootDir": "src",
"forceConsistentCasingInFileNames": true,
"noImplicitReturns": true,
"noImplicitThis": true,
"noImplicitAny": true,
"strictNullChecks": true,
"suppressImplicitAnyIndexErrors": true,
"noUnusedLocals": true,
"skipLibCheck": true
},
"exclude": [
...
]
}