An error occurred while defining props due to a parsing issue with the prop type. The unexpected token was encountered. Perhaps you meant to use `{`}` or `}`?

const dataProps = defineProps({
  selectedData: <Record<string, string>>
});

Under the closing bracket, there is a red line indicating:

Error: Unexpected token. Consider using {'}'} or &rbrace; instead?eslint Expression expected.ts(1109)

Is my type definition incorrect? I am unsure of the correct way to do it. I attempted to follow this example provided by vue.js: https://vuejs.org/guide/typescript/composition-api.html#typing-component-props

Answer №1

According to the Vue documentation:

If you're working with TypeScript, it's also possible to define props and emits using type annotations alone.

This means you can simply do:

const properties = defineProps<{
  selectedData: Record<string, string>;
}>();

Answer №2

Utilizing generics for this task

const { data } = defineProps<{ data: <Record<string, string>> }>()

You can find more information in the Vue documentation by scrolling down:

https://i.stack.imgur.com/09xW3.png

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Vue randomly sets the prototype of props in its definition

When the same code with the identical data structure is passed to the prop, it randomly sets the prop as an array or an object. The following is the code fragment: const props = defineProps({ all: { type: Array, default: [], } }) ...

The Vue/Vuetify wrapper component does not automatically pass on the `hide-details` parameter to the input component

I recently crafted a custom wrapper for the v-select input using Vuetify. Along with custom properties, I utilized the v-bind="$props"attribute to inherit all props. Upon testing, I observed that while this method applies to most props, it doesn ...

Oops! There seems to be an issue with locating a differ that supports the object '[object Object]' of type 'object', like an Array

I'm currently encountering an error that reads: (ERROR Error: NG02200: Cannot find a differ supporting object '[object Object]' of type 'object'. NgFor only supports binding to Iterables, such as Arrays. Did you mean to use the key ...

What is the best way to make the font size bigger in the header of my v-data-table component?

How can I change the font size of the <th> element to 20px within a Vuetify table using the v-data-table component? Despite my attempts, the font remains at 12px. The code I tried is as follows: table.v-table thead tr th { font-size: 20px!importa ...

Guide on integrating vue.js into expressjs using pug

Below is the code I have attempted: In my .pug file: extends layout block content h1= title p Welcome to #{title} script(src='/javascripts/custom_vue.js') div(id="app") {{ message }} Here is custom_vue.js: new Vue({ el: &apos ...

Guide on setting up and configuring the seeder in MikroORM

Hey there, I recently tried to execute seeders in MikroORM and encountered a problem. I followed all the steps outlined here: . In the MikroORM route folder (alongside mikro-orm.config.ts), I created a seeders directory. I updated mikro-orm.ts with the fo ...

Packaging Vue with Gradle into Spark for seamless integration

I am integrating a Vue UI with a backend developed in Spark Java. Both components are created independently and successfully integrated using the following structure: project +-- backend | +-- src | | +-- main | | +-- resources ...

Guide to specifying the indexer type of a function argument as T[K] being of type X in order for t[k]=x to be a permissible expression

Currently, I am attempting to create a function that can alter a boolean property within an object based on the provided object and property name. While I have found some helpful information here, the function body is still producing errors. Is there a way ...

Tips for relocating the indicators of a react-material-ui-carousel

I am working with a carousel and dots indicators, but I want to move the indicators from the bottom to the circular position as shown in the image below. I attempted using a negative margin-top, but the indicators ended up being hidden. Is there another ...

Vue Nativescript failing to display an image

Why are my images not showing up? The label is displaying the URL properly but the image is not showing. Why is it not displaying? Do I need to add something? It was working before. When I added a normal image with the source plain text like this, it show ...

Unable to retrieve values using any = {} in TypeScript Angular 8

import { Component, OnInit } from '@angular/core'; import { HttpClient } from '@angular/common/http'; import { enableProdMode } from '@angular/core'; enableProdMode(); @Component({ selector: 'app-home', templat ...

Retrieve the values of private variables within a defined function

While experimenting with typescript, I have encountered an issue that I can't seem to resolve. My project involves using Angular, so I will present my problem within that context. Here is a snippet of my code: class PersonCtrl{ private $scope: I ...

I attempted to use ng add @angular/pwa, but encountered an error code that is baffling to me. Are there any steps I can take to resolve this issue?

npm ERR! ERESOLVE could not resolve npm ERR! npm ERR! While trying to find a solution: [email protected] npm ERR! Found: @angular/[email protected] npm ERR! in node_modules/@angular/common npm ERR! @angular/common@"^14.2.3" ...

Can React.js components and packages be utilized in Vue.js, and vice versa?

Imagine you're working on a cutting-edge Angular project, but you want to incorporate components from your legacy Ember projects. You could easily achieve this by transferring and importing the component files into your new Angular project. I've ...

Ways to enhance focus on childNodes using Javascript

I am currently working on implementing a navigation system using a UL HTML Element. Here's the code I have so far: let htmlUL = <HTMLElement>document.getElementById('autocomplete_ul_' + this.name); if (arg.keyCode == 40) { // down a ...

How can I retrieve the previous value of the selected option in Vue 2.0?

Is it possible to retrieve the previously selected option value (using Vue) when updating a form? This is my current view: <div class="well" id="app"> <div class="form-group"> <label>Room category</label> ...

Implementing TypeScript with react-router-dom v6 and using withRouter for class components

Trying to migrate my TypeScript React app to use react-router-dom version v6, but facing challenges. The official react-router-dom documentation mentions: When upgrading to v5.1, it's advised to replace all instances of withRouter with hooks. Howe ...

Is it possible to use a '.JS' file downloaded through Node Package Manager (npm) directly in a web browser?

Generally, I am looking to utilize a specific library without relying on Node CMD. For instance: I aim to create a TypeScript playground without having to execute 'tsc.cmd' from "npm\node_modules", instead, I want to directly call the tsc c ...

Modifying SASS variable within an Angular 2 TypeScript project

How can I update the Sass color variable based on user input in Angular 2? I came across a helpful resource, but it doesn't include any examples specifically for Angular 2. Any assistance would be greatly appreciated. Thank you! ...

Implementing character limits in VueJS fields

new Vue({ el: '#app', data() { return { terms: false, fullname:'', maxfullname: 10, mobile: '', maxmobile: 10, area: '', maxarea: 12, city: '', ...