Skip to content

Commit

Permalink
Merge 71df222 into 1fbd272
Browse files Browse the repository at this point in the history
  • Loading branch information
pmkroeker authored Jun 11, 2019
2 parents 1fbd272 + 71df222 commit 58a33df
Show file tree
Hide file tree
Showing 6 changed files with 110 additions and 88 deletions.
142 changes: 71 additions & 71 deletions compat/src/index.d.ts
Original file line number Diff line number Diff line change
@@ -1,75 +1,75 @@
import * as _hooks from '../../hooks';
import * as preact from '../../src';
import { ForwardFn } from './internal';
export * from './suspense';
import { Suspense, lazy } from './suspense';

export * from '../../hooks';
export import Component = preact.Component;
export import createContext = preact.createContext;
export import createRef = preact.createRef;
export import Fragment = preact.Fragment;
export import createElement = preact.createElement
export import cloneElement = preact.cloneElement

export declare const version: string;

export declare function createPortal(vnode: preact.VNode, container: Element | Element): preact.VNode<any>;

export declare function render(vnode: preact.VNode<any>, parent: Element, callback?: () => void): Component | null;

export declare function hydrate(vnode: preact.VNode<any>, parent: Element, callback?: () => void): Component | null;

export declare function unmountComponentAtNode(container: Element | Document | ShadowRoot | DocumentFragment): boolean;

export declare function createFactory(type: preact.VNode["type"]): preact.VNode<{}>;

export declare function isValidElement(element: any): boolean;

export declare function findDOMNode(component: preact.Component): Element | null;

export declare interface PureComponent<P = {}, S = {}> extends preact.Component {
isPureReactComponenet: boolean;
import * as _Suspense from './suspense';

// export default React;
export = React;
declare namespace React {
// Export JSX
export import JSX = preact.JSX;

// Hooks
export import CreateHandle = _hooks.CreateHandle;
export import EffectCallback = _hooks.EffectCallback;
export import Inputs = _hooks.Inputs;
export import PropRef = _hooks.PropRef;
export import Reducer = _hooks.Reducer;
export import Ref = _hooks.Ref;
export import StateUpdater = _hooks.StateUpdater;
export import useCallback = _hooks.useCallback;
export import useContext = _hooks.useContext;
export import useDebugValue = _hooks.useDebugValue;
export import useEffect = _hooks.useEffect;
export import useImperativeHandle = _hooks.useImperativeHandle;
export import useLayoutEffect = _hooks.useLayoutEffect;
export import useMemo = _hooks.useMemo;
export import useReducer = _hooks.useReducer;
export import useRef = _hooks.useRef;
export import useState = _hooks.useState;

// Preact Defaults
export import Component = preact.Component;
export import createContext = preact.createContext;
export import createRef = preact.createRef;
export import Fragment = preact.Fragment;
export import createElement = preact.createElement;
export import cloneElement = preact.cloneElement;

// Suspense
export import Suspense = _Suspense.Suspense;
export import lazy = _Suspense.lazy;

// Compat
export const version: string;

export function createPortal(vnode: preact.VNode, container: Element): preact.VNode<any>;

export function render(vnode: preact.VNode<any>, parent: Element, callback?: () => void): Component | null;

export function hydrate(vnode: preact.VNode<any>, parent: Element, callback?: () => void): Component | null;

export function unmountComponentAtNode(container: Element | Document | ShadowRoot | DocumentFragment): boolean;

export function createFactory(type: preact.VNode["type"]): preact.VNode<{}>;
export function isValidElement(element: any): boolean;
export function findDOMNode(component: preact.Component): Element | null;

export interface PureComponent<P = {}, S = {}> extends preact.Component {
isPureReactComponenet: boolean;
}

export function memo<P = {}>(component: preact.FunctionalComponent<P>, comparer?: (prev: P, next: P) => boolean): preact.FunctionComponent<P>;

export function forwardRef<P = {}>(fn: ForwardFn<P, any>): preact.FunctionalComponent<P>;

export function unstable_batchedUpdates(callback: (arg?: any) => void, arg?: any): void;

export interface Children {
map<T extends preact.ComponentChild, R>(children: T | T[], fn: (child: T, i: number, array: T[]) => R): R[];
forEach<T extends preact.ComponentChild>(children: T | T[], fn: (child: T, i: number, array: T[]) => void): void;
count: (children: preact.ComponentChildren) => number;
only: (children: preact.ComponentChildren) => preact.ComponentChild;
toArray: (children: preact.ComponentChildren) => preact.VNode<{}>[];
}
}

export declare function memo<P = {}>(component: preact.FunctionalComponent<P>, comparer?: (prev: P, next: P) => boolean): preact.FunctionComponent<P>;

export declare function forwardRef<P = {}>(fn: ForwardFn<P, any>): preact.FunctionalComponent<P>;

export declare function unstable_batchedUpdates(callback: (arg?: any) => void, arg?: any): void;


export declare interface Children {
map<T extends preact.ComponentChild, R>(children: T | T[], fn: (child: T, i: number, array: T[]) => R): R[];
forEach<T extends preact.ComponentChild>(children: T | T[], fn: (child: T, i: number, array: T[]) => void): void;
count: (children: preact.ComponentChildren) => number;
only: (children: preact.ComponentChildren) => preact.ComponentChild;
toArray: (children: preact.ComponentChildren) => preact.VNode<{}>[];
}

declare const _default: {
hooks: typeof _hooks,
Component: Component,
createContext: typeof createContext,
createRef: typeof createRef,
Fragment: typeof Fragment,
createElement: typeof createElement,
cloneElement: typeof cloneElement,
version: typeof version,
createPortal: typeof createPortal,
render: typeof render,
hydrate: typeof render,
unmountComponentAtNode: typeof unmountComponentAtNode,
createFactory: typeof createFactory,
isValidElement: typeof isValidElement,
findDOMNode: typeof findDOMNode,
PureComponent: PureComponent,
memo: typeof memo,
forwardRef: typeof forwardRef,
unstable_batchedUpdates: typeof unstable_batchedUpdates,
Children: Children,
Suspense: typeof Suspense,
lazy: typeof lazy,
};

export default _default;
7 changes: 2 additions & 5 deletions test/ts/lazy.tsx → compat/test/ts/lazy.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
import {
createElement,
Component,
} from "../..";
import * as React from "../../src";

export interface LazyProps {
isProp: boolean;
Expand All @@ -10,7 +7,7 @@ export interface LazyProps {
interface LazyState {
forState: string;
}
export default class IsLazyComponent extends Component<LazyProps, LazyState> {
export default class IsLazyComponent extends React.Component<LazyProps, LazyState> {
render ({ isProp }: LazyProps) {
return (
<div>{
Expand Down
6 changes: 6 additions & 0 deletions compat/test/ts/react-default.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import React from '../../src';
class ReactIsh extends React.Component {
render() {
return <div>Text</div>
}
}
7 changes: 7 additions & 0 deletions compat/test/ts/react-star.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
// import React from '../../src';
import * as React from '../../src';
class ReactIsh extends React.Component {
render() {
return <div>Text</div>
}
}
16 changes: 4 additions & 12 deletions test/ts/suspense.tsx → compat/test/ts/suspense.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,4 @@
import "mocha";
import {
createElement,
Component,
} from "../..";
import {
Suspense,
lazy,
} from "../../compat";
import * as React from "../../src";

interface LazyProps {
isProp: boolean;
Expand All @@ -33,11 +25,11 @@ const componentPromise = new Promise<{default: typeof IsLazyFunctional}>(resolve
* For usage with import:
* const IsLazyComp = lazy(() => import('./lazy'));
*/
const IsLazyFunc = lazy(() => componentPromise);
const IsLazyFunc = React.lazy(() => componentPromise);

// Suspense using lazy component
class SuspensefulFunc extends Component {
class SuspensefulFunc extends React.Component {
render() {
return <Suspense fallback={<FallBack/>}><IsLazyFunc isProp={false} /></Suspense>
return <React.Suspense fallback={<FallBack/>}><IsLazyFunc isProp={false} /></React.Suspense>
}
}
20 changes: 20 additions & 0 deletions compat/test/ts/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
"compilerOptions": {
"target": "es6",
"module": "es6",
"moduleResolution": "node",
"lib": [
"es6",
"dom",
],
"strict": true,
"forceConsistentCasingInFileNames": true,
"jsx": "react",
"noEmit": true,
"allowSyntheticDefaultImports": true,
},
"include": [
"./**/*.ts",
"./**/*.tsx"
]
}

0 comments on commit 58a33df

Please sign in to comment.