Skip to content

Commit

Permalink
Fix TypeScript issues (#164)
Browse files Browse the repository at this point in the history
This addresses the issues in #133
  • Loading branch information
pspeter3 authored and developit committed Apr 17, 2017
1 parent a1a6aee commit 9207861
Showing 1 changed file with 18 additions and 6 deletions.
24 changes: 18 additions & 6 deletions src/index.d.ts
Original file line number Diff line number Diff line change
@@ -1,20 +1,32 @@
export function route(url: string, replace?: boolean): boolean;

export interface RouterProps extends JSX.HTMLAttributes {
path: string;
export interface CustomHistory {
getCurrentLocation?: () => string;
location?: string;
listen(callback: (url: string) => void): () => void;
push?: (url: string) => void;
replace?: (url: string) => void;
}

export interface RouterProps extends JSX.HTMLAttributes, preact.ComponentProps {
history?: CustomHistory;
path?: string;
static?: boolean;
url?: string;
}

export class Router extends preact.Component<{}, {}> {
export class Router extends preact.Component<RouterProps, {}> {
canRoute(url: string): boolean;
getMatchingChildren(children: preact.VNode[], url: string, invoke: boolean): preact.VNode[];
routeTo(url: string): boolean;
render(props: RouterProps & preact.ComponentProps, {}): preact.VNode;
render(props: RouterProps, {}): preact.VNode;
}

export interface RouteArgs<PropsType, StateType> {
component: preact.Component<PropsType, StateType>;
matches: boolean;
url: string;
path: string;
matches?: boolean;
url?: string;
}

export function Route<PropsType, StateType>({component, url, matches}: RouteArgs<PropsType, StateType>): preact.VNode;
Expand Down

0 comments on commit 9207861

Please sign in to comment.