Skip to content

Commit

Permalink
Merge c4f06ae into 2d715f6
Browse files Browse the repository at this point in the history
  • Loading branch information
JoviDeCroock committed Jun 3, 2019
2 parents 2d715f6 + c4f06ae commit e18ee6f
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 5 deletions.
17 changes: 13 additions & 4 deletions src/index.d.ts
Expand Up @@ -150,7 +150,16 @@ declare namespace preact {
export import JSX = JSXInternal;
}

type h = typeof createElement;
function h(
type: string,
props: JSXInternal.HTMLAttributes & JSXInternal.SVGAttributes & Record<string, any> | null,
...children: ComponentChildren[]
): VNode<any>;
function h<P>(
type: ComponentType<P>,
props: Attributes & P | null,
...children: ComponentChildren[]
): VNode<any>;
namespace h {
export import JSX = JSXInternal;
}
Expand Down Expand Up @@ -200,12 +209,12 @@ declare namespace preact {
diffed?(vnode: VNode): void;
/** Attach a hook that is invoked after an error is caught in a component but before calling lifecycle hooks */
catchError?(error: any, component: Component): void;
/**
/**
* Attach a hook that is invoked after an error is caught while executing render.
*
*
* When this hook returns true, the diffing on the affected vnode will be stopped.
* When this hook returns false, the error will be thrown (and thus passed to catchError or lifecycle hooks)
*
*
* @return Return a boolean indicating whether the error was handled by the hook or not
*/
catchRender?(error: any, component: Component): boolean;
Expand Down
5 changes: 4 additions & 1 deletion test/ts/preact.tsx
@@ -1,4 +1,4 @@
import { createElement, render, Component, FunctionalComponent, AnyComponent } from "../../src";
import { createElement, render, Component, FunctionalComponent, AnyComponent, h } from "../../src";

interface DummyProps {
initialInput: string;
Expand Down Expand Up @@ -42,6 +42,9 @@ function DummerComponent({ input, initialInput }: DummerComponentProps) {
render(createElement('div', { title: "test", key: "1" }), document);
render(createElement(DummyComponent, { initialInput: "The input", key: "1" }), document);
render(createElement(DummerComponent, { initialInput: "The input", input: "New input", key: "1"}), document);
render(h('div', { title: "test", key: "1" }), document);
render(h(DummyComponent, { initialInput: "The input", key: "1" }), document);
render(h(DummerComponent, { initialInput: "The input", input: "New input", key: "1"}), document);

// Accessing children
const ComponentWithChildren: FunctionalComponent<DummerComponentProps> = (
Expand Down

0 comments on commit e18ee6f

Please sign in to comment.