Add better mock typedef for FiberNode

This commit is contained in:
2019-07-22 18:46:31 +05:30
parent 5e93f9dab9
commit c239b1b6d1
+52 -2
View File
@@ -1,5 +1,55 @@
export interface FiberNode {
import * as React from "react";
export type FiberNode = FiberNodeForComponentClass | FiberNodeForFunctionComponent | FiberNodeForInstrinsicElement | FiberNodeForTextNode;
export interface FiberNodeForFunctionComponent {
child: FiberNode | null;
sibling: FiberNode | null;
// Add type
elementType: React.FunctionComponent;
type: React.FunctionComponent;
stateNode: null;
}
export interface FiberNodeForComponentClass {
child: FiberNode | null;
sibling: FiberNode | null;
elementType: React.ComponentClass;
type: React.ComponentClass;
stateNode: React.Component;
}
export interface FiberNodeForInstrinsicElement {
child: FiberNode | null;
sibling: FiberNode | null;
elementType: keyof JSX.IntrinsicElements;
type: keyof JSX.IntrinsicElements;
stateNode: HTMLElement;
}
export interface FiberNodeForInstrinsicElement {
child: FiberNode | null;
sibling: FiberNode | null;
elementType: keyof JSX.IntrinsicElements;
type: keyof JSX.IntrinsicElements;
stateNode: HTMLElement;
}
export interface FiberNodeForTextNode {
child: null;
sibling: FiberNode | null;
elementType: null;
type: null;
stateNode: Text;
}
export type FiberNodeisHTMLLike = FiberNodeForInstrinsicElement | FiberNodeForTextNode;