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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Typing the return of toRefs #315

Closed
absolutejam opened this issue Apr 23, 2020 · 3 comments
Closed

Typing the return of toRefs #315

absolutejam opened this issue Apr 23, 2020 · 3 comments
Labels
enhancement New feature or request has PR misalignment Misalign with the latest RFC

Comments

@absolutejam
Copy link

Howdy,

First of all, I just want to say how much I enjoy using Vue and the new composition api is amazing. Great job 馃憤

I'm using Typescript in my project and I've generally been using pretty basic interfaces and inference where possible, but I hit a problem yesterday wherein the return type of toRefs() wasn't valid.

I spent quite a while poking around in the composition-api source, inspecting type definitions, and eventually I realised that I could create the following type which will wrap an existing type/interface's properties in Ref.

type Refs<T> = {
  [P in keyof T]: Ref<T[P]>;
};

But I couldn't see something available/documented to provide this. Is this something that should be part of the library or would people be expected to provide something themselves?

Regards,
James.

@LinusBorg
Copy link
Member

LinusBorg commented Apr 24, 2020

I hit a problem yesterday wherein the return type of toRefs() wasn't valid.

Sounds like a bug. Can you provide a small reproduction please?

@LinusBorg LinusBorg added the needs reproduction We need a runnable reproduction from the OP label Apr 24, 2020
@pikax
Copy link
Member

pikax commented Apr 24, 2020

Created a pull on vue-next vuejs/core#1037

I can add that to the PR #311 馃憤

@LinusBorg
Copy link
Member

Awesome, do that after the vue-next PR is accepted, just to be sure that we stay in sync.

Thanks!

pikax added a commit to pikax/vue-function-api that referenced this issue Apr 24, 2020
@LinusBorg LinusBorg added enhancement New feature or request and removed needs reproduction We need a runnable reproduction from the OP labels Apr 27, 2020
@antfu antfu added has PR misalignment Misalign with the latest RFC labels May 31, 2020
@antfu antfu closed this as completed in 7701ff8 Jun 2, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request has PR misalignment Misalign with the latest RFC
Projects
None yet
Development

No branches or pull requests

4 participants