Skip to content

Commit d2a98c6

Browse files
Andrew Lucablakeembrey
authored andcommitted
Make PathFunction accept generic (#175)
1 parent c36498d commit d2a98c6

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

index.d.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,12 +47,12 @@ declare namespace pathToRegexp {
4747
/**
4848
* Transforming an Express-style path into a valid path.
4949
*/
50-
export function compile (path: string, options?: ParseOptions): PathFunction;
50+
export function compile <P extends object = object> (path: string, options?: ParseOptions): PathFunction<P>;
5151

5252
/**
5353
* Transform an array of tokens into a path generator function.
5454
*/
55-
export function tokensToFunction (tokens: Token[]): PathFunction;
55+
export function tokensToFunction <P extends object = object> (tokens: Token[]): PathFunction<P>;
5656

5757
/**
5858
* Transform an array of tokens into a matching regular expression.
@@ -78,7 +78,7 @@ declare namespace pathToRegexp {
7878

7979
export type Token = string | Key;
8080
export type Path = string | RegExp | Array<string | RegExp>;
81-
export type PathFunction = (data?: Object, options?: PathFunctionOptions) => string;
81+
export type PathFunction <P extends object = object> = (data?: P, options?: PathFunctionOptions) => string;
8282
}
8383

8484
export = pathToRegexp;

0 commit comments

Comments
 (0)