You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The goal of this is so that something like the below would fail:
// ParentComponent.vue
<template>
<!-- 5 is a number, but "foo" and "bar" are strings 👎 -->
<child-component:prop-one="5":prop-two="() => ["foo", "bar"]"
/>
</template
// ParentComponent.vue
<script setup lang="ts">
const getSomeStrings = () => ["foo", "bar"]
</script>
<template>
<!-- 5 is a number, but "foo" and "bar" are strings 👎 -->
<child-component:prop-one="5":prop-two="getSomeStrings"
/>
<!-- this is fine! 👍 -->
<child-componentprop-one="vite rocks!":prop-two="getSomeStrings"
/>
</template>
Great, all working fine. That is, until I try and access the props in ChildComponent.vue...
As soon as I add const props = to then do some logic with the props, I get an error.
at failureErrorWithLog (/Users/josephmaylor/Desktop/vite-project/node_modules/.pnpm/[email protected]/node_modules/esbuild/lib/main.js:1566:15)
at /Users/josephmaylor/Desktop/vite-project/node_modules/.pnpm/[email protected]/node_modules/esbuild/lib/main.js:805:29
at responseCallbacks. (/Users/josephmaylor/Desktop/vite-project/node_modules/.pnpm/[email protected]/node_modules/esbuild/lib/main.js:671:9)
at handleIncomingPacket (/Users/josephmaylor/Desktop/vite-project/node_modules/.pnpm/[email protected]/node_modules/esbuild/lib/main.js:726:9)
at Socket.readFromStdout (/Users/josephmaylor/Desktop/vite-project/node_modules/.pnpm/[email protected]/node_modules/esbuild/lib/main.js:647:7)
at Socket.emit (node:events:526:28)
at addChunk (node:internal/streams/readable:315:12)
at readableAddChunk (node:internal/streams/readable:289:9)
at Socket.Readable.push (node:internal/streams/readable:228:10)
at Pipe.onStreamRead (node:internal/stream_base_commons:190:23
Vue version
3.2.38
Link to minimal reproduction
sfc playground
Steps to reproduce
I am trying to create a reusable Vue 3 component with generically typed props.
Let's say I want a props interface that looks something like:
The goal of this is so that something like the below would fail:
Using this example, and also running into this issue I came up with the following:
This successfully results in the following:
Great, all working fine. That is, until I try and access the props in ChildComponent.vue...
As soon as I add
const props =
to then do some logic with the props, I get an error.I also created a repo more like my use case here
What is expected?
Have access to the component's props
What is actually happening?
An error is thrown:
System Info
System: OS: macOS 12.6 CPU: (16) x64 Intel(R) Core(TM) i9-9880H CPU @ 2.30GHz Memory: 21.29 MB / 16.00 GB Shell: 5.8.1 - /bin/zsh Binaries: Node: 16.14.2 - /usr/local/bin/node Yarn: 1.22.10 - /usr/local/bin/yarn npm: 8.5.0 - /usr/local/bin/npm Browsers: Chrome: 106.0.5249.91 Firefox: 105.0.1 Safari: 16.0 npmPackages: vue: ^3.2.38 => 3.2.40
Any additional comments?
Original ticket in vite repo
The text was updated successfully, but these errors were encountered: