Skip to content

error TS2464: A computed property name must be of type 'string', 'number', 'symbol', or 'any' #10803

Answered by hecticme
fbraem asked this question in Help/Questions
Discussion options

You must be logged in to vote

props is pretty much an object, so TypeScript is complaining because you're using a value which can be null as the object property. Changing the falsy value in your ternary operator to an empty string can fix the problem, but I'm not sure if it's ideal.

const to = computed(() => props.route ? 'to' : '');

However, if your intention is to add the attributes only if you have included them in the props. I think you can just specify them normally like this, because if the bound value is null or undefined, then the attribute will be removed from the rendered element. Reference: https://vuejs.org/guide/essentials/template-syntax.html#attribute-bindings.

<script setup lang="ts">
interface Props {

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by fbraem
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
2 participants