Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
Tanimodori opened this issue Sep 29, 2022 · 1 comment
Open
Labels
2.x 2.x ts typescript problem

Comments

@Tanimodori
Copy link

Tanimodori commented Sep 29, 2022

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

@John60676
Copy link
Member

Will be added in next version

@John60676 John60676 added ts typescript problem 2.x 2.x labels Sep 29, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
2.x 2.x ts typescript problem
Projects
None yet
Development

No branches or pull requests

2 participants