vue-request icon indicating copy to clipboard operation
vue-request copied to clipboard

[Feature Request] Export return value interfaces like `QueryResult` etc.

Open Tanimodori opened this issue 2 years ago • 1 comments

需求描述 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

Tanimodori avatar Sep 29 '22 02:09 Tanimodori

Will be added in next version

John60676 avatar Sep 29 '22 10:09 John60676