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

provide refs is not type safe #8201

Closed
94726 opened this issue Apr 30, 2023 · 0 comments
Closed

provide refs is not type safe #8201

94726 opened this issue Apr 30, 2023 · 0 comments
Labels
🔨 p3-minor-bug Priority 3: this fixes a bug, but is an edge case that only affects very specific usage. scope: types

Comments

@94726
Copy link

94726 commented Apr 30, 2023

Vue version

3.2.47

Link to minimal reproduction

https://stackblitz.com/edit/vitejs-vite-nyan1h?file=src/main.ts

Steps to reproduce

  1. Use InjectionKey with type Ref<someObject>
  2. use InjectionKey to provide a Ref<{}>
  3. No Type Error
import { InjectionKey, provide, ref, Ref } from 'vue';

type Cube = {
  size: number;
};

const injectionKeyRef = Symbol('key') as InjectionKey<Ref<Cube>>;

// no type error
provide(injectionKeyRef, ref({}));

What is expected?

When using provide, I expect a type error when assigning Ref<{}> to Ref<Cube>, the same way that {} isn't assignable to Cube.

What is actually happening?

Ref<{}> is assignable to Ref<Cube> when using provide

System Info

System:
    OS: Linux 5.10 Ubuntu 22.04.2 LTS 22.04.2 LTS (Jammy Jellyfish)
    CPU: (16) x64 AMD Ryzen 7 2700X Eight-Core Processor
    Memory: 3.16 GB / 7.74 GB
    Container: Yes
    Shell: 3.5.1 - /usr/bin/fish
Binaries:
    Node: 16.16.0 - ~/.nvm/versions/node/v16.16.0/bin/node
    npm: 8.11.0 - ~/.nvm/versions/node/v16.16.0/bin/npm

Any additional comments?

No response

@yyx990803 yyx990803 added scope: types 🔨 p3-minor-bug Priority 3: this fixes a bug, but is an edge case that only affects very specific usage. labels May 1, 2023
@github-actions github-actions bot locked and limited conversation to collaborators Sep 11, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
🔨 p3-minor-bug Priority 3: this fixes a bug, but is an edge case that only affects very specific usage. scope: types
Projects
None yet
Development

No branches or pull requests

2 participants