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

Typescript support #278

Closed
wants to merge 2 commits into from
Closed
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
49 changes: 49 additions & 0 deletions src/js/route.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
declare module 'ziggy/dist/js/route' {
export type Param = string | number | string[] | number[] | undefined

export interface Params {
[key: string]: Param
}

export interface Route {
uri: string
methods: ('GET' | 'HEAD' | 'POST' | 'DELETE')[]
domain: null | string
}

export interface Config {
namedRoutes: {
[key: string]: Route
}
baseUrl: string
baseProtocol: 'http' | 'https'
baseDomain: string
basePort: boolean
defaultParameters: string[]
}

export class Router extends String {
normalizeParams(params: Params): Params
with(params: Params): Router
withQuery(params: Params): Router
hydrateUrl(): string
matchUrl(): boolean
constructQuery(): string
current(name?: string): Route
check(name: string): boolean
extractParams(uri: string, template: string, delimiter: string): Params
get params(): Params
parse(): void
url(): string
toString(): string
trimParam(param: string): string
valueOf(): string
}

export default function route(
name: string,
params?: Params,
absolute?: boolean,
customZiggy?: Config,
): Router
}