Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/react-native/7.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Typescript 第三方模块中[交叉口?]冲突的解释和解决?_Typescript_React Native - Fatal编程技术网

Typescript 第三方模块中[交叉口?]冲突的解释和解决?

Typescript 第三方模块中[交叉口?]冲突的解释和解决?,typescript,react-native,Typescript,React Native,我在尝试将方向属性放在可动画上时遇到此错误。查看来自反应本机可动画: Type '{ children: Element; animation: string; iterationCount: "infinite"; direction: string; }' is not assignable to type 'IntrinsicAttributes & IntrinsicClassAttributes<Component<AnimatableProperties<V

我在尝试将
方向
属性放在
可动画上时遇到此错误。查看
来自
反应本机可动画

Type '{ children: Element; animation: string; iterationCount: "infinite"; direction: string; }' is not assignable to type 'IntrinsicAttributes & IntrinsicClassAttributes<Component<AnimatableProperties<ViewStyle> & ViewPr...'.
  Type '{ children: Element; animation: string; iterationCount: "infinite"; direction: string; }' is not assignable to type 'Readonly<AnimatableProperties<ViewStyle> & ViewProps>'.
    Types of property 'direction' are incompatible.
      Type 'string' is not assignable to type 'never'.

我找出了冲突的来源-
ViewProps
实际上定义为:

// https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/react-native/index.d.ts

export interface FlexStyle
{
  ...
  direction?: "inherit" | "ltr" | "rtl";
  ...
}

export interface LayoutProps extends FlexStyle {}

export interface ViewProps
  extends ViewPropsAndroid, ViewPropsIOS, GestureResponderHandlers, Touchable, AccessibilityProps, LayoutProps
{
  ...
}
因此
FlexStyle
直接位于属性中,而不是样式中

// https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/react-native/legacy-properties.d.ts

import {
  ...
  ViewProps,
  ...
} from "react-native";

declare module "react-native" {
  ...
  export type ViewProperties = ViewProps;
  ...
}
// https://github.com/facebook/react-native/blob/master/Libraries/Components/View/ViewPropTypes.js

export type ViewProps = {
  // there's no direction property here or [seemingly] on TVViewProps
} & TVViewProps;
// https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/react-native/index.d.ts

export interface FlexStyle
{
  ...
  direction?: "inherit" | "ltr" | "rtl";
  ...
}

export interface LayoutProps extends FlexStyle {}

export interface ViewProps
  extends ViewPropsAndroid, ViewPropsIOS, GestureResponderHandlers, Touchable, AccessibilityProps, LayoutProps
{
  ...
}