Skip to content

Commit

Permalink
Use Omit instead of Exclude in router types (#1857)
Browse files Browse the repository at this point in the history
* change Exclude to Omit

* Formatting

---------

Co-authored-by: Jonathan Reinink <[email protected]>
  • Loading branch information
aktasumut34 and reinink authored Apr 16, 2024
1 parent c7b329c commit 806d553
Showing 1 changed file with 7 additions and 19 deletions.
26 changes: 7 additions & 19 deletions packages/core/src/router.ts
Original file line number Diff line number Diff line change
Expand Up @@ -498,19 +498,15 @@ export class Router {
}
}

public get(
url: URL | string,
data: RequestPayload = {},
options: Exclude<VisitOptions, 'method' | 'data'> = {},
): void {
public get(url: URL | string, data: RequestPayload = {}, options: Omit<VisitOptions, 'method' | 'data'> = {}): void {
return this.visit(url, { ...options, method: 'get', data })
}

public reload(options: Exclude<VisitOptions, 'preserveScroll' | 'preserveState'> = {}): void {
public reload(options: Omit<VisitOptions, 'preserveScroll' | 'preserveState'> = {}): void {
return this.visit(window.location.href, { ...options, preserveScroll: true, preserveState: true })
}

public replace(url: URL | string, options: Exclude<VisitOptions, 'replace'> = {}): void {
public replace(url: URL | string, options: Omit<VisitOptions, 'replace'> = {}): void {
console.warn(
`Inertia.replace() has been deprecated and will be removed in a future release. Please use Inertia.${
options.method ?? 'get'
Expand All @@ -519,31 +515,23 @@ export class Router {
return this.visit(url, { preserveState: true, ...options, replace: true })
}

public post(
url: URL | string,
data: RequestPayload = {},
options: Exclude<VisitOptions, 'method' | 'data'> = {},
): void {
public post(url: URL | string, data: RequestPayload = {}, options: Omit<VisitOptions, 'method' | 'data'> = {}): void {
return this.visit(url, { preserveState: true, ...options, method: 'post', data })
}

public put(
url: URL | string,
data: RequestPayload = {},
options: Exclude<VisitOptions, 'method' | 'data'> = {},
): void {
public put(url: URL | string, data: RequestPayload = {}, options: Omit<VisitOptions, 'method' | 'data'> = {}): void {
return this.visit(url, { preserveState: true, ...options, method: 'put', data })
}

public patch(
url: URL | string,
data: RequestPayload = {},
options: Exclude<VisitOptions, 'method' | 'data'> = {},
options: Omit<VisitOptions, 'method' | 'data'> = {},
): void {
return this.visit(url, { preserveState: true, ...options, method: 'patch', data })
}

public delete(url: URL | string, options: Exclude<VisitOptions, 'method'> = {}): void {
public delete(url: URL | string, options: Omit<VisitOptions, 'method'> = {}): void {
return this.visit(url, { preserveState: true, ...options, method: 'delete' })
}

Expand Down

0 comments on commit 806d553

Please sign in to comment.