NativeErrorDetails
Extracts the native error details type for a method from a request map. If the method does not define errorDetails, the type falls back to unknown.
Importing
ts
import type { NativeErrorDetails } from '@almighty-shogun/webkit-native-bridge'Usage
ts
import type { NativeErrorDetails } from '@almighty-shogun/webkit-native-bridge'
type Requests = {
getUser: {
body: { id: string }
response: { name: string }
errorDetails: { id: string }
}
}
type GetUserDetails = NativeErrorDetails<Requests, 'getUser'>;
// { id: string }Parameters
| Name | Description |
|---|---|
TRequests | Request map containing the method definition. |
TMethod | Method key whose native error details 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 NativeErrorDetails<
TRequests extends NativeBridgeRequestMap,
TMethod extends keyof TRequests
> =
TRequests[TMethod] extends { errorDetails?: infer TErrorDetails }
? TErrorDetails
: unknown;