类型错误:类型“ PlatformStatic”上不存在属性“ isTV”。 TS2339

时间:2019-06-04 10:30:57

标签: typescript react-native react-native-android react-native-ios

我有一个在TVOS上运行且集成了打字稿的应用程序。为了检测设备操作系统是电视还是移动设备,我在该属性下方使用了它,并且无需集成Webpack即可正常运行。

但是在集成了webpack并在Web上运行后,我面临如下类型错误,

Type error: Property 'isTV' does not exist on type 'PlatformStatic'. TS2339

Type error: Type '{ children: Element; activeOpacity: number; accessibilityLabel: string | undefined; accessibilityRole: "button"; accessibilityStates: AccessibilityState[]; onFocus: () => any; testID: string | undefined; disabled: boolean | undefined; onPress: () => any; }' is not assignable to type 'IntrinsicAttributes & IntrinsicClassAttributes<TouchableOpacity> & Readonly<{ children?: ReactNode; }> & Readonly<TouchableOpacityProps>'. Property 'onFocus' does not exist on type 'IntrinsicAttributes & IntrinsicClassAttributes<TouchableOpacity> & Readonly<{ children?: ReactNode; }> & Readonly<TouchableOpacityProps>'. TS2322

如果有人可以解释为什么我会遇到此错误,这将很有帮助?

如何解决此错误?

0 个答案:

没有答案