Skip to content

Commit

Permalink
fix types with optional arguments
Browse files Browse the repository at this point in the history
  • Loading branch information
manuelpuyol committed Jul 12, 2022
1 parent 58c23d0 commit 04cf3f6
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 23 deletions.
2 changes: 1 addition & 1 deletion src/core/frames/frame_controller.ts
Expand Up @@ -52,7 +52,7 @@ export class FrameController
private ignoredAttributes: Set<FrameElementObservedAttribute> = new Set()
private action: Action | null = null
private frame?: FrameElement
private resolveInterceptionPromise = (_value: any) => {}
private resolveInterceptionPromise = (_value?: any) => {}
readonly restorationIdentifier: string

constructor(element: FrameElement) {
Expand Down
2 changes: 1 addition & 1 deletion src/core/view.ts
Expand Up @@ -23,7 +23,7 @@ export abstract class View<
abstract readonly snapshot: S
renderPromise?: Promise<void>
private resolveRenderPromise = (_value: any) => {}
private resolveInterceptionPromise = (_value: any) => {}
private resolveInterceptionPromise = (_value?: any) => {}

constructor(delegate: D, element: E) {
this.delegate = delegate
Expand Down
38 changes: 19 additions & 19 deletions src/globals.d.ts
Expand Up @@ -3,20 +3,6 @@ import { ReloadReason } from "./core/native/browser_adapter"
import { TimingData } from "./core/session"
import { FetchResponse } from "./http/fetch_response"

interface SubmitEvent extends Event {
submitter: HTMLElement | null
}

interface Node {
// https://github.com/Microsoft/TypeScript/issues/283
cloneNode(deep?: boolean): this
}

interface Window {
Turbo: typeof import("./core/index")
SubmitEvent: typeof Event
}

interface CustomEventMap {
"turbo:click": TurboClickEvent
"turbo:before-visit": TurboBeforeVisitEvent
Expand All @@ -40,12 +26,12 @@ declare global {
type TurboBeforeVisitEvent = CustomEvent<{ url: string }>
type TurboVisitEvent = CustomEvent<{ url: string; action: Action }>
type TurboBeforeCacheEvent = CustomEvent
type TurboBeforeRenderEvent = CustomEvent<{ newBody: HTMLBodyElement; resume: (value: any) => void }>
type TurboBeforeRenderEvent = CustomEvent<{ newBody: HTMLBodyElement; resume: (value?: any) => void }>
type TurboRenderEvent = CustomEvent
type TurboLoadEvent = CustomEvent<{ url: string; timing: TimingData }>
type TurboFrameLoadEvent = CustomEvent
type TurboFrameRenderEvent = CustomEvent<{ fetchResponse: FetchResponse }>
type TurboBeforeFrameRenderEvent = CustomEvent<{ fetchResponse: FetchResponse; resume: (value: any) => void }>
type TurboBeforeFrameRenderEvent = CustomEvent<{ fetchResponse: FetchResponse; resume: (value?: any) => void }>
type TurboSubmitStartEvent = CustomEvent<{ formSubmission: FormSubmission }>
type TurboSubmitEndEvent = CustomEvent<{
formSubmission: FormSubmission
Expand All @@ -54,12 +40,12 @@ declare global {
error?: Error
}>
type TurboReloadEvent = CustomEvent<{ reason: ReloadReason }>
type TurboBeforeFetchRequestEvent = CustomEvent<{ fetchResponse: FetchResponse }>
type TurboBeforeFetchResponseEvent = CustomEvent<{
type TurboBeforeFetchRequestEvent = CustomEvent<{
fetchOptions: RequestInit
url: URL
resume: (value: any) => void
resume: (value?: any) => void
}>
type TurboBeforeFetchResponseEvent = CustomEvent<{ fetchResponse: FetchResponse }>

interface Document {
//adds definition to Document, but you can do the same with HTMLElement
Expand All @@ -68,6 +54,20 @@ declare global {
listener: (this: Document, ev: CustomEventMap[K]) => void
): void
}

interface SubmitEvent extends Event {
submitter: HTMLElement | null
}

interface Node {
// https://github.com/Microsoft/TypeScript/issues/283
cloneNode(deep?: boolean): this
}

interface Window {
Turbo: typeof import("./core/index")
SubmitEvent: typeof Event
}
}

export {}
2 changes: 1 addition & 1 deletion src/http/fetch_request.ts
Expand Up @@ -55,7 +55,7 @@ export class FetchRequest {
readonly body?: FetchRequestBody
readonly target?: FrameElement | HTMLFormElement | null
readonly abortController = new AbortController()
private resolveRequestPromise = (_value: any) => {}
private resolveRequestPromise = (_value?: any) => {}

constructor(
delegate: FetchRequestDelegate,
Expand Down
2 changes: 1 addition & 1 deletion src/tests/functional/frame_navigation_tests.ts
Expand Up @@ -27,7 +27,7 @@ export class FrameNavigationTests extends TurboDriveTestCase {
await this.goToLocation("/src/tests/fixtures/tabs.html")

this.remote.execute(() => {
addEventListener("turbo:before-frame-render", () => {
document.addEventListener("turbo:before-frame-render", () => {
localStorage.setItem("beforeRenderUrl", window.location.pathname)
localStorage.setItem("beforeRenderContent", document.querySelector("#tab-content")?.textContent || "")
})
Expand Down

0 comments on commit 04cf3f6

Please sign in to comment.