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

types(reactive): UnwrapNestedRefs is not working #1083

Closed
yangmingshan opened this issue Apr 30, 2020 · 4 comments
Closed

types(reactive): UnwrapNestedRefs is not working #1083

yangmingshan opened this issue Apr 30, 2020 · 4 comments
Labels

Comments

@yangmingshan
Copy link
Contributor

Version

3.0.0-beta.4

Reproduction link

https://codesandbox.io/s/dreamy-chandrasekhar-7pqfh

Steps to reproduce

Check src/index.ts line 5.

What is expected?

Type of a.a is number.

What is actually happening?

Type of a.a is Ref<number>.


See the comments in src/index.ts. It's weird, maybe it's a TS bug.

@pikax
Copy link
Member

pikax commented Apr 30, 2020

I would say this is an intended behaviour, since we are bailing the types Node | Window on https://github.com/vuejs/vue-next/blob/master/packages/reactivity/src/ref.ts#L142

There's the original issue: #951

EDIT: If adding dom is not an option, you can declare Window and Node interfaces example

import { ref, reactive } from "vue";
declare global {
  interface Window {
    // describe this interface with some unique props
    __window: boolean;
  }
  interface Node {
    // describe this interface with some unique props
    __node: boolean;
  }
}

const a = reactive({ a: ref(0) });

a.a++; // works

@yyx990803 yyx990803 added scope: types ✨ feature request New feature or request labels May 1, 2020
@yyx990803
Copy link
Member

I think it's expected behavior to require libs: ['dom'] when using vue since it is expected to work in DOM environments.

What we can improve is that UnwrapRef is declared in @vue/reactivity which should not assume the end environment it's running in. This could cause issues for custom renderers.

@yyx990803
Copy link
Member

see b40fcbc

@yangmingshan
Copy link
Contributor Author

@yyx990803 Thanks, and maybe you will be interested in microsoft/rushstack#1709.

@github-actions github-actions bot locked and limited conversation to collaborators Nov 13, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

3 participants