Skip to content

NativeResponseBody

Extracts the success response payload type for one method in a request map. It keeps response handling tied to the method being called.

Importing

ts
import type { NativeResponseBody } from '@almighty-shogun/webkit-native-bridge'

Usage

ts
import type { NativeResponseBody } from '@almighty-shogun/webkit-native-bridge'

type Requests = {
    getUser: { body: { id: string }; response: { name: string } }
}

type GetUserResponse = NativeResponseBody<Requests, 'getUser'>;

// { name: string }

Parameters

NameDescription
TRequestsRequest map containing the method definition.
TMethodMethod key whose response body should be resolved.

Returns

A TypeScript type for native bridge APIs. It is erased at runtime and is used only by TypeScript to describe the shape of values passed to or returned from the package APIs.

Type signature

ts
type NativeResponseBody<
    TRequests extends NativeBridgeRequestMap,
    TMethod extends keyof TRequests
> =
    TRequests[TMethod]['response'];

All packages are released under the MIT License.