第三方模块中[intersection?]冲突的解释和解决方案?

时间:2018-05-08 12:31:02

标签: typescript react-native

我尝试在direction Animatable.Viewreact-native-animatable添加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'. 属性时出现此错误:

direction

通过类型声明进行追踪我似乎找不到此问题的原因 - AnimatableComponent似乎在AnimatableProperties通过AnimatableProperties明确定义了?direction?此外,无论问题是什么,我如何解决它至少消除错误输出的噪音?此外,我不认为有一种方式可以“打印调试”#34;通过让编译器输出 it 认为最终的ViewStyle接口的类型

// https://github.com/oblador/react-native-animatable/blob/master/typings/react-native-animatable.d.ts import { ... ViewProperties, ViewStyle, ... } from 'react-native'; interface AnimatableProperties<S extends {}> { ... direction?: 'normal' | 'reverse' | 'alternate' | 'alternate-reverse'; ... } interface AnimatableComponent<P extends {},S extends {}> extends NativeMethodsMixin, AnimatableAnimationMethods, ClassicComponentClass<AnimatableProperties<S> & P> { ... } export const View : AnimatableComponent<ViewProperties,ViewStyle>; export type View = AnimatableComponent<ViewProperties,ViewStyle>; 类型的// 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;
from io import StringIO
import pandas as pd
import pyodbc 
from openpyxl import load_workbook


d=pd.read_excel('workbook.xlsx',header=None)
wb = load_workbook('workbook.xlsx')
/** @type {your type} */
var _this = this;

1 个答案:

答案 0 :(得分:0)

我找出了冲突的来源 - 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直接在属性中而不是样式。