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

Build error: "name is specified more than once" when using named slots and v-bind if object has a key of name #7572

Closed
vphilot opened this issue Jan 23, 2023 · 5 comments

Comments

@vphilot
Copy link

vphilot commented Jan 23, 2023

Vue version

3.2.45

Link to minimal reproduction

https://stackblitz.com/edit/vitejs-vite-peyj9y?terminal=dev

Steps to reproduce

<script setup lang="ts">
const myObject = {
  name: 'someName',
};
</script>

<template>
  <slot name="action" v-bind="myObject" /> // error: 'name' is specified more than once, so this usage will be overwritten
</template>
  • Open the repro link
  • Run npm run build
  • Verify the error

What is expected?

I would expect Typescript to understand name shouldn't be merged with the object being passed to v-bind.

What is actually happening?

TS fails to undertand the name prop in <slot /> is different from objects being bound to it.
In this example, <slot name="foo" v-bind="{ name: 'bar'}" /> clash and it breaks the build command.

System Info

System:
    OS: macOS 13.1
    CPU: (10) x64 Apple M1 Pro
    Memory: 8.98 MB / 16.00 GB
    Shell: 5.8.1 - /bin/zsh
  Binaries:
    Node: 16.13.0 - ~/.nvm/versions/node/v16.13.0/bin/node
    Yarn: 1.22.19 - ~/Desktop/CL/remx/apps/remx/node_modules/.bin/yarn
    npm: 8.1.0 - ~/.nvm/versions/node/v16.13.0/bin/npm
  Browsers:
    Chrome: 109.0.5414.87
    Safari: 16.2
    Safari Technology Preview: 16.4
  npmPackages:
    vue: ^3.2.45 => 3.2.45 


### Any additional comments?

_No response_
@vphilot vphilot changed the title Build error: "name is specified more than once" when using named slots and v-bind if object has a key of "name" Build error: "name is specified more than once" when using named slots and v-bind if object has a key of name Jan 23, 2023
@LinusBorg
Copy link
Member

LinusBorg commented Jan 23, 2023

This should likely be addressed in the Volar repo, not here.

https://github.com/johnsoncodehk/volar

@vphilot
Copy link
Author

vphilot commented Jan 23, 2023

would you mind clarifying why Volar? is it because of vue-tsc? 🤔

@LinusBorg
Copy link
Member

Because Volar/vue-tsc transforms the template into something TS can understand (a form of TSX). So your issue needs to be fixed in that step. Vue Core does not really have a say here in what TS sees.

@johnsoncodehk
Copy link
Member

Please track vuejs/language-tools#2308.

@vphilot
Copy link
Author

vphilot commented Jan 24, 2023

Thanks y'all for the clarification, much appreciated.

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

No branches or pull requests

3 participants