Error encountered in Vue code, lacks default export on Editor Terminal

I'm not experiencing any issues in the browser, I am getting the desired output. However, why does this keep showing up in the editor terminal?

Any assistance would be greatly appreciated.

Error - No Default Export:

The module "/vue3/src/components/TestIcon.vue" does not have a default export.

This is how my component looks:

TestIcon.vue

<template>
  <span v-html="svg" class="icon-wrapper" ref="iconWrapper"></span>
</template>    
<script setup lang="ts">
import type { tycon } from "test-icons";
import { computed, onMounted, ref } from "vue";
import { completeDataSet } from "test-icons";

const props = defineProps<{
  icon: tycon;
  class: string;
  color: string;
  height: string;
  width: string;
}>();
const iconPassed = completeDataSet.find((item) => item.name === props.icon);

const svg = computed(() => iconPassed?.data);

const iconWrapper = ref<HTMLElement | null>(null);

onMounted(() => {
  iconWrapper.value?.lastElementChild?.firstElementChild?.setAttribute(
    "class",
    props.class
  );

  iconWrapper.value?.firstElementChild?.setAttribute(
    "style",
    "width:" + props.width + "px;height:" + props.height + "px;"
  );

  iconWrapper.value?.firstElementChild?.firstElementChild?.setAttribute(
    "fill",
    props.color
  );
});
</script>

App.vue:

<template>
  <main>
    <TestIcon :icon="'icon_test'" :class="'tests'" :height="40" :width="40" />
  </main>
</template>
<script lang="ts">
import TestIcon from "@/components/TestIcon.vue";
export default {
  components: {
    TestIcon,
  }
};
</script>

Answer №1

If you happen to be utilizing vue-cli, make sure to check for the existence of a file named shims-vue.d.ts with the following content:

/* eslint-disable */
declare module '*.vue' {
  import type { DefineComponent } from 'vue'
  const component: DefineComponent<{}, {}, any>
  export default component
}

Alternatively, if you are using vite, review the env.d.ts file which should contain:

/// <reference types="vite/client" />

/* eslint-disable */
declare module '*.vue' {
  import type { DefineComponent } from 'vue'
  const component: DefineComponent<{}, {}, any>
  export default component
}

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

Display and conceal div with Jquery as you scroll to specific points on a mobile device

I'm looking to create a dynamic div that appears and disappears based on the user's scroll position. Here is what I have so far: $(document).scroll(function() { var y = $(this).scrollTop(); if (y > 200) { $('.float-contai ...

Save the value entered into an input field using JavaScript and store it in a PHP variable

For a question, I'm developing a dynamic text field where the answer will be displayed based on the user's selection from the answer field. Once the user submits their answer, the PHP code saves it in a PHP variable named $ans1. However, when the ...

Is it possible to execute custom Javascript code when navigating forwards or backwards on a webpage?

My main goal is to recreate the back button functionality using AJAX without needing to add #uglyhashes to every URL, as many solutions currently do. (Just to clarify, I am completely okay with a solution that doesn't support Internet Explorer at all ...

typescript persist zustand: typing your store

Running a simple store interface CartState { cart: { [id: string]: CartDto }; addItem: ({ id, image, name, price }: Omit<CartDto, "quantity">) => void; removeItem: (id: string) => void; reset: () => void; } export const use ...

The use of Bootstrap carousel indicators effectively controls event propagation

One way to achieve the desired effect is by implementing a solution like the one provided in this example from Bootstrap. When interacting with the indicators quickly, the animations can stack on top of each other, resulting in a strange chain of events. ...

Creating PDF files with Laravel serving as the API and Vue acting as the front-end client

My current setup involves using Laravel as an API and Vue as the client. To generate PDFs, I'm utilizing the barryvdh package which can be found at this link. I've created a page with some static elements for testing purposes. Below is the code s ...

Leveraging Vue.js for dynamic component creation and seamless data passing

Recently, I decided to learn Vue.js and stumbled upon a tutorial at the following link: . The tutorial taught me how to create dynamic components for listing products and switching to an edit view when a product is clicked. In my project, I have a 'li ...

Issue with TypeScript: Error appears when importing express after running "npm i @types/express -D"

Struggling with adding the following line of code in an index.ts file: import express, { Application } from 'express'; Initially encountered an error with "from 'express'", so I ran npm i @types/express -D which fixed that is ...

When pasting Arabic text into an input box, the words in HTML appear to be jumbled and shuffled around

When I replicate this text يف عام and input it into a box, the output is shown as follows عام يف ...

What is the best method for obtaining a modified image (img) source (src) on the server side?

Having some trouble with a concept in ASP.Net that's causing me quite the headache. I am fairly new to ASP.Net and struggling with something that seems much easier in PHP. I created an img element with an empty src attribute : <img runat="server" ...

Getting rid of mysterious Google Analytics script from WordPress

My client has requested that I incorporate Google Analytics into her website. After accessing her Google account, I attempted to paste the tracking code into the appropriate section of the Wordpress plugin. To my surprise, the code did not work as expect ...

A tutorial on creating circular patterns within a pyramid structure using p5.js and matter.js

I've been attempting to create a pyramid shape using multiple circles, similar to this: balls in pyramid shape To achieve this, I've developed a 'Balls' class: class Balls { constructor(x, y, radius, color, ballCount) { this.x = ...

When attempting to trigger a function by clicking a button in Angular 8 using HTTP POST, nothing is happening as

I've been struggling to send a POST request to the server with form data using Observables, promises, and xmlhttprequest in the latest Angular with Ionic. It's driving me crazy because either I call the function right at the start and the POST wo ...

Angular refuses to showcase the object

Currently, I am working on a web application and facing an issue in parsing an object. I attempted to retrieve the IDs of all results but unfortunately, it is returning undefined in my console. Here's what I tried: var app = angular.module("DB", ...

WordPress REST API - Issue with New Category returning undefined, yet still able to be accessed

Currently, I am utilizing the WordPress REST API and have successfully created a new category. However, when making queries to the API, it is returning undefined for that particular category. Upon visiting: /wp-json/wp/v2/categories, category 17 does not ...

The issue of memory leakage in Three.js

I have come across an unusual memory leak in three.js (r73). Here are the steps to reproduce it: 1) Go to the following link using Google Chrome (version 46.0.2490.80 m) 2) Open DevTools -> Profiles -> Take Heap Snapshot. Check out my screenshot be ...

Issues encountered when trying to use the export default syntax in Vue components

Programming Issue I attempted to execute the provided code, but unfortunately, it does not work and no output is visible in the browser. Is there an alternative method for writing code within <scripts setup> </script>? I have understood that f ...

JavaScript Error - Value Not Assigned

I'm having trouble formatting a graph in my code. I keep encountering an undefined error when using console.log to output the data. Here's the snippet of my code: $(document).ready(function () { var graphData = new Array(); $.getJSON("ds ...

Automating the click of JavaScript buttons with Selenium

Test page Experimenting with the above Indeed link to test my selenium automation skills. I am attempting to automate the clicking of the 'apply' button using the Firefox webdriver. My code snippet is as follows: from selenium import webdriver ...

Creating an element in JavaScript with a designated ID is a

I'm working on creating a JavaScript array that holds 3 elements: var employees = [ {"firstName":"John", "lastName":"Doe"}, {"firstName":"Anna", "lastName":"Smith"}, {"firstName":"Peter", "lastName":"Jones"} ] To iter ...