Skip to content

Ref types not unwraped in slotProps destructuring default value #5617

@a161803398

Description

@a161803398

Vue - Official extension or vue-tsc version

3.0.6

VSCode version

1.103.2

Vue version

3.5.18

TypeScript version

5.8.3

System Info

System:
    OS: Linux 6.14 Ubuntu 24.04.3 LTS 24.04.3 LTS (Noble Numbat)
    CPU: (16) x64 Intel(R) Core(TM) i5-14400
    Memory: 10.84 GB / 31.07 GB
    Container: Yes
    Shell: 5.2.21 - /bin/bash
  Binaries:
    Node: 22.14.0 - ~/.nvm/versions/node/v22.14.0/bin/node
    Yarn: 3.8.0 - ~/.nvm/versions/node/v22.14.0/bin/yarn
    npm: 10.9.2 - ~/.nvm/versions/node/v22.14.0/bin/npm
  Browsers:
    Chrome: 139.0.7258.138

package.json dependencies

{
  "dependencies": {
    "vue": "^3.5.18"
  },
  "devDependencies": {
    "@tsconfig/node22": "^22.0.2",
    "@types/node": "^22.16.5",
    "@vitejs/plugin-vue": "^6.0.1",
    "@vue/eslint-config-prettier": "^10.2.0",
    "@vue/eslint-config-typescript": "^14.6.0",
    "@vue/tsconfig": "^0.7.0",
    "eslint": "^9.31.0",
    "eslint-plugin-vue": "~10.3.0",
    "jiti": "^2.4.2",
    "npm-run-all2": "^8.0.4",
    "prettier": "3.6.2",
    "typescript": "~5.8.0",
    "vite": "^7.0.6",
    "vite-plugin-vue-devtools": "^8.0.0",
    "vue-tsc": "^3.0.4"
  }
}

Steps to reproduce

Having this component

Foo.vue

<script lang="ts" setup>
defineProps<{ info: { count?: number } }>()
</script>

<template>
  <div>
    <slot :info="info">
      {{ info.count }}
    </slot>
  </div>
</template>

And this usage

App.vue

<script setup lang="ts">
import Foo from './Foo.vue'
import { ref } from 'vue'

const fallbackCount = ref(42)
const data: { count?: number }[] = [{}, { count: 5 }]
</script>

<template>
  <div v-for="(datum, i) of data" :key="i">
    <Foo v-slot="{ info: { count = fallbackCount * 2 } }" :info="datum"> Count: {{ count }} </Foo>
  </div>
</template>

Type checking reports the following errors.
Image
But fallbackCount type should be number in template.

Could also be reproduced in Vue Playground

Image

What is expected?

fallbackCount type should be number.

Run vue-tsc --build should not report errors.

What is actually happening?

Run vue-tsc --build reports the following errors.
Image

Link to minimal reproduction

No response

Any additional comments?

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    good reproduction ✨This issue provides a good reproduction, we will be able to investigate it first🔩 p2-edge-case

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions