Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Add some type definitions #459

Merged
merged 3 commits into from
Aug 5, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions types/ActionTypes.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
declare module 'found/lib/ActionTypes' {
import { ActionTypes } from 'found';

export default ActionTypes;
}
5 changes: 5 additions & 0 deletions types/Matcher.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
declare module 'found/lib/Matcher' {
import { Matcher } from 'found';

export default Matcher;
}
5 changes: 5 additions & 0 deletions types/createInitialBrowserRouter.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
declare module 'found/lib/createInitialBrowserRouter' {
import { createInitialBrowserRouter } from 'found';

export default createInitialBrowserRouter;
}
5 changes: 5 additions & 0 deletions types/createInitialFarceRouter.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
declare module 'found/lib/createInitialFarceRouter' {
import { createInitialFarceRouter } from 'found';

export default createInitialFarceRouter;
}
5 changes: 5 additions & 0 deletions types/getStoreRenderArgs.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
declare module 'found/lib/getStoreRenderArgs' {
import { getStoreRenderArgs } from 'found';

export default getStoreRenderArgs;
}
5 changes: 5 additions & 0 deletions types/hotRouteConfig.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
declare module 'found/lib/hotRouteConfig' {
import { hotRouteConfig } from 'found';

export default hotRouteConfig;
}
29 changes: 26 additions & 3 deletions types/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,13 @@ declare module 'found' {
state: S;
}

interface ActionTypes {
UPDATE_MATCH: '@@found/UPDATE_MATCH';
RESOLVE_MATCH: '@@found/RESOLVE_MATCH';
}

const ActionTypes: ActionTypes;

type Params = ObjectStringMap;

/**
Expand Down Expand Up @@ -319,6 +326,8 @@ declare module 'found' {
children?: RouteConfig[];
}

function hotRouteConfig(routeConfig: RouteConfig): RouteConfig;

class HttpError {
constructor(status: number, data?: any);
status: number;
Expand Down Expand Up @@ -402,7 +411,7 @@ declare module 'found' {

function createMatchEnhancer(
matcher: Matcher,
): () => StoreEnhancer<{
): StoreEnhancer<{
found: {
matcher: Matcher;
replaceRouteConfig: (routes: RouteConfig) => void;
Expand Down Expand Up @@ -478,7 +487,19 @@ declare module 'found' {
matchContext,
resolver,
...options
}: CreateInitialFarceRouterArgs): ConnectedRouter;
}: CreateInitialFarceRouterArgs): Promise<ConnectedRouter>;

interface createInitialBrowserRouterArgs
extends Omit<
CreateInitialFarceRouterArgs,
'resolver' | 'historyProtocol'
> {
matchContext?: any;
}

function createInitialBrowserRouter(
options: createInitialBrowserRouterArgs,
): Promise<ConnectedRouter>;

interface GetStoreRenderArgsArgs {
store: Store;
Expand All @@ -487,5 +508,7 @@ declare module 'found' {
resolver: Resolver;
}

function getStoreRenderArgs(args: GetStoreRenderArgsArgs): RouterRenderArgs;
function getStoreRenderArgs(
args: GetStoreRenderArgsArgs,
): Promise<RouterRenderArgs>;
}
2 changes: 1 addition & 1 deletion types/server/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ declare module 'found/lib/server' {

function getFarceResult(
args: GetFarceResultArgs,
): FarceElementResult | FarceRedirectResult;
): Promise<FarceElementResult | FarceRedirectResult>;

interface RouterProviderProps {
renderArgs: RouterRenderArgs;
Expand Down