Skip to content

Commit 7786ba2

Browse files
committed
feat: add fiber type definitions and update core types
Add Fiber, FiberRoot, Hook, Effect types with WorkTag, Lane, and Flags branded types. Update core/types.ts to export hook-related types and remove old VDOMInstance.
1 parent 760fa11 commit 7786ba2

2 files changed

Lines changed: 549 additions & 14 deletions

File tree

src/core/types.ts

Lines changed: 10 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -91,21 +91,17 @@ export const TEXT_ELEMENT = "TEXT_ELEMENT";
9191
export const FRAGMENT = Symbol("react.fragment");
9292
export const PORTAL = Symbol("react.portal");
9393

94+
import type { PortalElement } from "../portals/types";
95+
9496
// ******************* //
95-
// VDOM Instance Types //
97+
// Public Hook Types //
9698
// ******************* //
9799

98-
export interface VDOMInstance {
99-
element: JSXElementType;
100-
dom: Node | null;
101-
childInstances: VDOMInstance[];
102-
parent?: VDOMInstance;
103-
hooks?: StateOrEffectHook<unknown>[];
104-
hookCursor?: number;
105-
contextValues?: Map<symbol, unknown>; // For context providers
106-
rootContainer?: HTMLElement; // Track root container for root-level instances
107-
}
100+
export type EffectCallback = (() => void) | (() => () => void);
101+
export type DependencyList = readonly unknown[];
108102

109-
// Import hook types from hooks module
110-
import type { StateOrEffectHook } from "../hooks/types";
111-
import type { PortalElement } from "../portals/types";
103+
export type Reducer<State, Action> = (state: State, action: Action) => State;
104+
105+
export type MutableRefObject<T> = {
106+
current: T;
107+
};

0 commit comments

Comments
 (0)