diff --git a/debug/src/index.d.ts b/debug/src/index.d.ts index 3f6ab627cd..5bb5d22261 100644 --- a/debug/src/index.d.ts +++ b/debug/src/index.d.ts @@ -1,3 +1,22 @@ +import { VNode } from 'preact'; + +/** + * Get the currently rendered `vnode` + */ +export function getCurrentVNode(): VNode | null; + +/** + * Return the component stack that was captured up to this point. + */ +export function getOwnerStack(vnode: VNode): string; + +/** + * Setup code to capture the component trace while rendering. Note that + * we cannot simply traverse `vnode._parent` upwards, because we have some + * debug messages for `this.setState` where the `vnode` is `undefined`. + */ +export function setupComponentStack(): void; + /** * Reset the history of which prop type warnings have been logged. */ diff --git a/debug/src/index.js b/debug/src/index.js index 37eee3bba0..adea553687 100644 --- a/debug/src/index.js +++ b/debug/src/index.js @@ -4,3 +4,9 @@ import 'preact/devtools'; initDebug(); export { resetPropWarnings } from './check-props'; + +export { + getCurrentVNode, + getDisplayName, + getOwnerStack +} from './component-stack'; diff --git a/src/index-5.d.ts b/src/index-5.d.ts index 16f2560c0e..eb9b331d0b 100644 --- a/src/index-5.d.ts +++ b/src/index-5.d.ts @@ -38,7 +38,7 @@ export interface VNode

{ export type Key = string | number | any; export type RefObject = { current: T | null }; -export type RefCallback = (instance: T | null) => void; +export type RefCallback = (instance: T | null) => void | (() => void); export type Ref = RefObject | RefCallback | null; export type ComponentChild = diff --git a/src/index.d.ts b/src/index.d.ts index 58fbc9a995..5ceb04c1b4 100644 --- a/src/index.d.ts +++ b/src/index.d.ts @@ -38,7 +38,7 @@ export interface VNode

{ export type Key = string | number | any; export type RefObject = { current: T | null }; -export type RefCallback = (instance: T | null) => void; +export type RefCallback = (instance: T | null) => void | (() => void); export type Ref = RefObject | RefCallback | null; export type ComponentChild =