vue-request
vue-request copied to clipboard
[Feature Request] Export return value interfaces like `QueryResult` etc.
需求描述 Feature Description
Please export the return value interfaces like QueryResult
etc.
Say we want to wrap useRequest
like:
function useMyRequest<R, P extends unknown[]>(result: QueryResult<R, P>) {
const foo = computed(() => doSomething(result.data));
return {foo, ...result};
}
But currently QueryResult
is not exported. We need to either refer it as
export type QueryResult<R, P extends unknown[]> = ReturnType<typeof useRequest<R, P>>
where the typeof useRequest<R, P>
part requires instantiation expressions in TS 4.7. Or manually copy-paste fields like as data
, loading
, etc. in a new interface and use it as params type of useMyRequest
建议的解决方案 Proposed Solution
export those interfaces for the sake of DRY.
其他信息 Other information
Will be added in next version