chore: make Rehydratable use Awaitable; add docblock

This commit is contained in:
2021-07-02 21:44:34 -05:00
parent cf6d14abca
commit 5d960e6186
3 changed files with 17 additions and 6 deletions

View File

@@ -2,6 +2,7 @@
* Type representing a JSON serializable object.
*/
import {ErrorWithContext} from '../error/ErrorWithContext'
import {Awaitable} from './types'
export type JSONState = { [key: string]: string | boolean | number | undefined | JSONState | Array<string | boolean | number | undefined | JSONState> }
@@ -30,14 +31,14 @@ export function isJSONState(what: unknown): what is JSONState {
export interface Rehydratable {
/**
* Dehydrate this class' state and get it.
* @return Promise<JSONState>
* @return JSONState|Promise<JSONState>
*/
dehydrate(): Promise<JSONState>
dehydrate(): Awaitable<JSONState>
/**
* Rehydrate a state into this class.
* @param {JSONState} state
* @return void|Promise<void>
*/
rehydrate(state: JSONState): void | Promise<void>
rehydrate(state: JSONState): Awaitable<void>
}