Reactjs Typescript扩展并具有默认值的泛型类型

Reactjs Typescript扩展并具有默认值的泛型类型,reactjs,typescript,Reactjs,Typescript,我目前正在做一些react的东西,我试着做一些类似的事情: class TextBase<P = {} extends TextBaseProps> extends React.PureComponent<P> 我把它摆弄了一下,发现这并没有给我一个错误: <P extends TextBaseProps = {}> tsc--noEmit--skipLibCheck 你能提供一个可以复制的stackblitz吗?@FRECIA它实际上在react nat

我目前正在做一些react的东西,我试着做一些类似的事情:

class TextBase<P = {} extends TextBaseProps> extends React.PureComponent<P>
我把它摆弄了一下,发现这并没有给我一个错误:

<P extends TextBaseProps = {}>
tsc--noEmit--skipLibCheck


你能提供一个可以复制的stackblitz吗?@FRECIA它实际上在
react native
中,但我会看看同样的错误是否发生在普通react中的stackblitz上。那么,你能把与第一个解析错误相关的整个错误堆栈放在你的问题上吗?问题是,这个程序工作起来很有魅力。只有VS代码和tsc投诉。我将在问题中提供
tsc
输出。@FRECIA好的,我想这是我用typescript无法理解的。这也发生在我刚刚创建的stackblitz中的react中:你能提供一个复制的stackblitz吗?@FRECIA它实际上在
react native
中,但我会看看同样的错误是否发生在普通react中的stackblitz上,好的,那么你能把与第一个解析错误相关的整个错误堆栈放在你的问题上吗,这个节目很有魅力。只有VS代码和tsc投诉。我将在问题中提供
tsc
输出。@FRECIA好的,我想这是我用typescript无法理解的。这也发生在我刚刚创建的stackblitz中:
<P extends TextBaseProps = {}>
Property 'onPress' does not exist on type 'IntrinsicAttributes & IntrinsicClassAttributes<TextNormal> & Readonly<{}> & Readonly<{ children?: ReactNode; }>'
interface TextBaseProps {
  children?: string | string[];
  onPress?: (event: GestureResponderEvent) => void;
}
error TS2322: Type '{ children: string[]; onPress: () => void; }' is not assignable to type 'IntrinsicAttributes & IntrinsicClassAttributes<TextNormal> & Readonly<{}> & Readonly<{ children?: ReactNode; }>'.
  Property 'onPress' does not exist on type 'IntrinsicAttributes & IntrinsicClassAttributes<TextNormal> & Readonly<{}> & Readonly<{ children?: ReactNode; }>'.

38 <STD.TextNormal
class TextNormal extends TextBase {
    public constructor(props: unknown) {
        super(props, {
            color: Colors.fg.hex(),
        });
    }
}