-
-
Notifications
You must be signed in to change notification settings - Fork 381
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
60 additions
and
48 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
// TypeScript Version: 2.4 | ||
|
||
import * as React from 'react'; | ||
|
||
export function getLoadableState( | ||
rootElement: React.ReactElement<{}>, | ||
rootContext?: any, | ||
fetchRoot?: boolean, | ||
tree?: any, | ||
): Promise<DeferredState>; | ||
|
||
export interface DeferredState { | ||
getScriptContent(): string; | ||
getScriptTag(): string; | ||
getScriptElement(): React.ReactHTMLElement<HTMLScriptElement>; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,56 +1,44 @@ | ||
// TypeScript Version: 2.4 | ||
// export as namespace LoadableComponents; | ||
|
||
declare module 'loadable-components' { | ||
import * as React from 'react'; | ||
import * as React from 'react'; | ||
|
||
interface DefaultImportedComponent<P> { | ||
default: React.ComponentType<P>; | ||
} | ||
export as namespace loadable; | ||
|
||
type DefaultComponent<P> = React.ComponentType<P> | DefaultImportedComponent<P>; | ||
export default function loadable<T>( | ||
getComponent: () => Promise<loadable.DefaultComponent<T>>, | ||
options?: loadable.LoadableOptions<T> | ||
): loadable.Loadable<T>; | ||
|
||
export interface ComponentTracker { | ||
track: (component: React.Component, modules: any, index?: number) => number; | ||
|
||
get: (id: number) => React.ComponentType; | ||
getAll: () => { [key: number]: React.ComponentType }; | ||
reset: () => void; | ||
} | ||
|
||
export interface LoadableOptions<T> { | ||
ErrorComponent?: React.ComponentType; | ||
LoadingComponent?: React.ComponentType; | ||
render?: (options: { loading: boolean, error: boolean, ownProps: T, Component: React.ComponentType<T> }) => React.ReactElement<T>; | ||
modules?: any; | ||
} | ||
export interface DefaultImportedComponent<P> { | ||
default: React.ComponentType<P>; | ||
} | ||
|
||
interface Loadable<T> extends React.ComponentClass<T> { | ||
Component: React.ComponentClass; | ||
loadingPromise: Promise<any>; | ||
load(): Promise<any>; | ||
} | ||
export type DefaultComponent<P> = React.ComponentType<P> | DefaultImportedComponent<P>; | ||
|
||
export const componentTracker: ComponentTracker; | ||
export const LOADABLE: string; | ||
export interface ComponentTracker { | ||
track: (component: React.Component, modules: any, index?: number) => number; | ||
|
||
export function loadComponents(): Promise<any>; | ||
get: (id: number) => React.ComponentType; | ||
getAll: () => { [key: number]: React.ComponentType }; | ||
reset: () => void; | ||
} | ||
|
||
export function getState(): { __LOADABLE_STATE__: { children: Array<{ id: number }> } }; | ||
export interface LoadableOptions<T> { | ||
ErrorComponent?: React.ComponentType; | ||
LoadingComponent?: React.ComponentType; | ||
render?: (options: { loading: boolean, error: boolean, ownProps: T, Component: React.ComponentType<T> }) => React.ReactElement<T>; | ||
modules?: any; | ||
} | ||
|
||
export default function loadable<T>( | ||
getComponent: () => Promise<DefaultComponent<T>>, | ||
options?: LoadableOptions<T> | ||
): Loadable<T>; | ||
export interface Loadable<T> extends React.ComponentClass<T> { | ||
Component: React.ComponentClass; | ||
loadingPromise: Promise<any>; | ||
load(): Promise<any>; | ||
} | ||
|
||
declare module 'loadable-components/server' { | ||
import * as React from 'react'; | ||
export const componentTracker: ComponentTracker; | ||
export const LOADABLE: string; | ||
|
||
export function getLoadableState( | ||
rootElement: React.ReactElement<{}>, | ||
rootContext?: any, | ||
fetchRoot?: boolean, | ||
tree?: any, | ||
): Promise<any>; | ||
} | ||
export function loadComponents(): Promise<any>; | ||
|
||
export function getState(): { __LOADABLE_STATE__: { children: Array<{ id: number }> } }; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters