Encountering an unknown parse error while working with Typescript, Vue, vue-property-decorator, and VSCode

I am brand new to Typescript and Vue.js, and I haven't been able to find a solution here.

The code below is causing a parsing error: '}' expected

I have double-checked all the bracket pairs and as far as my eye can see, everything looks correct.

Here is the base code. I forked it from a fully functional base example. https://github.com/hanachan1026/vue-firebase-startup-kit

// Hello.vue
<template>
  <section class="section">
    <div class="container">
      <h1 class="title">
        Hello
        {{userName}}
      </h1>
      <p>Firebase rocks!</p>
      <img id="img1" src="" alt="img1" />
    </div>
  </section>
</template>

<script lang="ts">
import { storage } from "../scripts/firebase";
import Vue from "vue";
import { Component } from "vue-property-decorator";

@Component
export default class Home extends Vue {
  created() { 
    const storageRef = storage.ref();

    const imagesRef = storageRef.child('images');

    const fileName = 'IMG_1009.JPG';

    const imgRef = imagesRef.child(fileName);

    imgRef.getDownloadURL().then(function (url) {
      const img: HTMLImageElement = <HTMLImageElement>document.getElementById('img1');

      img.src = url;
    }).catch(function(error) {
      console.log(error); // <= parse error here. why?
    });
  }

  get userName(): string {
    if (this.$store.state.user) {
      return this.$store.state.user.displayName;
    }
    return "";
  }
}
</script>

I understand that this might not be an easy question to answer since there could be numerous reasons. If anyone has had similar experiences, I would appreciate any comments. Thank you.

*add

➤ npm run serve

> <a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="66101303390d0f12265648574856">[email protected]</a> serve /Users/me/show-cam-img-demo
> vue-cli-service serve

 INFO  Starting development server...
Starting type checking service...
Using 1 worker with 2048MB memory limit
98% after emitting CopyPlugin

 ERROR  Failed to compile with 1 errors                                                                                                                                                                                                                           3:34:02 PM

 error  in ./src/views/Hello.vue

Module Error (from ./node_modules/eslint-loader/index.js):

/Users/me/show-cam-img-demo/src/views/Hello.vue
  35:24  error  Parsing error: '}' expected

✖ 1 problem (1 error, 0 warnings)


 @ ./src/router/index.ts 4:0-37 9:13-17
 @ ./src/main.ts
 @ multi (webpack)-dev-server/client?http://192.168.1.37:8080/sockjs-node (webpack)/hot/dev-server.js ./src/main.ts

No type errors found
Version: typescript 3.8.3
Time: 20252ms

Answer №1

There was an issue detected in eslint. The solution involves configuring eslint for TypeScript and Vue, as outlined in this helpful article. Previously, tslint with vue-tslint-loader was used until 2019.

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

Can a Jquery *compiler* be developed?

Upon encountering this informative question, the idea of creating a jQuery compiler crossed my mind. The concept was to design a tool that could translate jQuery code into raw JavaScript code for execution. In my imagination, the process of executing a bl ...

Unlocking secure content with Ajax

Trying to access a webservice or webpage solely through ajax, as it is the only allowed method for some reason. The webservice is secured with corporate SSO. When requesting webpage X for the first time, you are redirected to login page Y, outside of the a ...

Getting the project path in the Sonarqube JavaScript Extension is a straightforward process

I am currently developing a custom rules plugin for the SonarQube Javascript Plugin. I have encountered an issue where I need to disable certain checks in specific directories, such as the bin path. My main question is: how can I obtain the file path rela ...

How does the AngularJS Dependency Injection system determine the names of the arguments it needs to inject?

Here is an example directly from the official website: function PhoneListCtrl ($scope, $http) { $http.get('phones/phones.json').success(function(data) { $scope.phones = data; }); $scope.orderProp = 'age'; } The $s ...

Using JSON data to populate the jQuery UI Datepicker

Is it possible to populate this jQuery UI datepicker calendar with data from a JSON file containing all non-working days for the years 2017 and 2018? P.S. return [!(month == 8 && day == 27), 'highlight', highlight]; - This example demons ...

Failed request using Ajax

I've been trying to call a C# function using ajax, but for some reason it's not working. Here is the ajax call I'm making: $('#button1 button').click(function () { var username = "username_declared"; var firstname = "firs ...

JavaScript format nested data structure

For my latest project, I am working on a blog using Strapi combined with Nuxt. To fetch the categories and articles data for my blog, I send a JSON object from my front-end application using Axios. { "data": [ { "id": 1, ...

Implementing a file download feature in Python when clicking on a hyperlink

I'm attempting to click on the href link below. href="javascript:;" <div class="xlsdownload"> <a id="downloadOCTable" download="data-download.csv" href="javascript:;" onclick=&q ...

Transfer spoken words into a textbox using the keyboard-microphone feature on an iPad or mobile device

When we tap on a textbox on an iPad or mobile device in a web browser, the keyboard pops up on the screen. We have the option to choose the microphone and dictate the text directly into the input box using our voice instead of typing. Since speech convers ...

Verifying if checkboxes are selected in PHP using JavaScript

echo '<div class="col-lg-10 col-lg-offset-1 panel">' . "<table id='data' class='table'> <tr> <th></th> <th>Document No</th> <th>AWB NO</th> ...

Tips for preventing the nesting of promises when managing errors from various APIs

Currently, I am developing an application that requires making requests to two different APIs. The authentication process is handled by Cognito, while a lambda function communicates with a database. However, the issue I am facing does not seem to be specif ...

Guide on storing images in a designated folder using CodeIgniter

My code is located in view/admin_view2.php <?php echo form_open_multipart('home_admin/createBerita'); ?> <div class="form-group" > <label class="control-label">upload foto</label> <inpu ...

Restrict input to only text characters in a textbox using AngularJS

Looking for a way to ensure that users can only input characters into a textbox in my project. Any suggestions on how I can accomplish this? ...

Building a NestJS/Prisma RESTful API to retrieve data from a related field

I am diving into creating my very own Rest API using Nestjs and Prisma for the first time. This project is a basic representation of an inventory management system, keeping things simple with shelves and boxes to store items. The structure in place has tab ...

I would like to know more about the concept of getters and setters and how they can be effectively utilized

I've been struggling to understand the concept of getters and setters. Despite reading articles like JavaScript Getters and Setters and Defining Getters and Setters, I just can't seem to grasp it. Could someone please explain: The purpose of g ...

Creating a mind map: A step-by-step guide

I'm currently developing an algorithm to create a mind map. The key focus is on organizing the nodes intelligently to prevent any overlap and ensure a visually pleasing layout. Take a look at this snapshot (from MindNode) as an example: Any suggestio ...

Is it more efficient to store a UIImage as a String or as a UIImage in a data model in order to minimize storage space?

I am currently faced with a decision regarding the most efficient way to store my UIImages. These images are retrieved from my database and then added to a data model within the application. I'm debating whether it's better to store them as UIIma ...

What is the correct data type for the vuex store that is passed to the vuex plugin when it is being initialized?

Here is how the store initialization process is currently being implemented: /* Logic */ import Vue from 'vue' import Vuex, { StoreOptions } from 'vuex' Vue.use(Vuex) const DataManager = new UserDataManager() type RootStateType = { ...

The second attempt at an AJAX call is unsuccessful

I am currently developing a form that displays database results based on two entries: Automarke (brand) and Modell (model). You can view the entries here. The Modell dropdown dynamically changes based on the selected Automarke. Here is the code snippet I ...

Can the grunt command be executed automatically after saving code in TypeScript?

As a newcomer to FrontEnd and JavaScript coding in TypeScript, I find myself constantly needing to follow these steps after making a code change: save the code -> compile it using Grunt -> reload the webpage. It can be quite time-consuming. Is there ...