Skip to content

Commit

Permalink
type preparation
Browse files Browse the repository at this point in the history
  • Loading branch information
g-plane committed Feb 4, 2023
1 parent 7bca674 commit 7aee47a
Showing 1 changed file with 44 additions and 0 deletions.
44 changes: 44 additions & 0 deletions globals.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
interface BlessingGlobals {
base_url: string
site_name: string
locale: string
version: string
route: string

t(key: string, params?: object): string

fetch: {
get<T = any>(url: string, params?: Record<string, unknown>): Promise<T>
post<T = any>(url: string, data?: any): Promise<T>
put<T = any>(url: string, data?: any): Promise<T>
del<T = any>(url: string, data?: any): Promise<T>
}

event: {
on(
eventName: string | symbol,
listener: (...args: any[]) => any,
): () => void
emit(eventName: string | symbol, payload?: object): void
}

notify: {
showModal(options?: object): Promise<{ value: string }>
toast: Toast
}
}

declare class Toast {
success(message: string): void
info(message: string): void
warning(message: string): void
error(message: string): void
}

// `var` is required here,
// otherwise the `blessing` property won't appear in `globalThis` type
declare var blessing: BlessingGlobals

interface Window {
blessing: BlessingGlobals
}

0 comments on commit 7aee47a

Please sign in to comment.