使用react本机样式表的typescript报告错误

使用react本机样式表的typescript报告错误,typescript,react-native,Typescript,React Native,我有一个从全局样式表文件styles.ts导入到home.ts // styles.ts import { StyleSheet } from 'react-native' export default { text: StyleSheet.create({ body: { color: 'red', textAlign: 'center' } }) } // home.ts import globalStyles from '../cons

我有一个从全局样式表文件
styles.ts
导入到
home.ts

// styles.ts
import { StyleSheet } from 'react-native'

export default {
  text: StyleSheet.create({
    body: {
      color: 'red',
      textAlign: 'center'
    }
  })
}

// home.ts

import globalStyles from '../constants/styles'

render() {
  return <Text style={globalStyles.text.body}>Hello, tap begin to start Lesson 1</Text>
}
//styles.ts
从“react native”导入{StyleSheet}
导出默认值{
text:StyleSheet.create({
正文:{
颜色:“红色”,
textAlign:“中心”
}
})
}
//home.ts
从“../constants/styles”导入全局样式
render(){
返回Hello,点击begin开始第1课
}
但即使文本在ios模拟器中正确呈现,typescript也在抱怨,说

file: 'file:///Users/matthewchung/Documents/Cards/src/screens/HomeScreen.tsx'
severity: 'Error'
message: 'Type '{ style: { color: string; textAlign: string; }; children: string; }' is not assignable to type 'IntrinsicAttributes & IntrinsicClassAttributes<Component<TextProperties, ComponentState>> & Reado...'.
  Type '{ style: { color: string; textAlign: string; }; children: string; }' is not assignable to type 'Readonly<TextProperties>'.
    Types of property 'style' are incompatible.
      Type '{ color: string; textAlign: string; }' is not assignable to type 'TextStyle'.
        Types of property 'textAlign' are incompatible.
          Type 'string' is not assignable to type '"center" | "auto" | "left" | "right"'.'
文件:'file:///Users/matthewchung/Documents/Cards/src/screens/HomeScreen.tsx'
严重性:“错误”
消息:“类型”{style:{color:string;textAlign:string;};子项:string;}”不能分配给类型“IntrinsicattAttributes&IntrinsicClassAttributes&Reado…”。
类型“{style:{color:string;textAlign:string;};children:string;}”不能分配给类型“Readonly”。
属性“样式”的类型不兼容。
类型“{color:string;textAlign:string;}”不可分配给类型“TextStyle”。
属性“textAlign”的类型不兼容。
类型“string”不能分配给类型“center”|“auto”|“left”|“right”.”
我不知道为什么。不管怎样,任何建议都是非常感谢的