Developing a Meteor application with the powerful combination of Vue.js and Typescript

I'm struggling to implement Typescript in a Meteor project with Vue.

Here are the commands I used to create a project from scratch:

Commands

meteor create --vue gift-list-app
meteor add typescript
meteor npm install --save-dev @types/meteor
meteor add nathantreid:vue-typescript-babel
meteor npm install --save-dev @babel/plugin-transform-typescript

After creating the project, I moved on to editing Hello.vue and specified the language in the <script> tag as shown below.

<template>
  <div>
    <button @click="increment">Click Me</button>
    <p>You've pressed the button {{counter}} times.</p>
  </div>
</template>

<script lang="ts">
export default {
  data() {
    return {
      counter: 0,
    }
  },
  methods: {
    increment() {
      this.counter += 1
    }
  },
}
</script>

<style scoped>
  p {
    font-family: serif;
  }
</style>

Error Encountered

[Error Message Here]

What is the correct method for setting up a Meteor/Vue project with Typescript?

Update:

Despite adding the necessary libraries mentioned earlier, issues persist when using the @Component tag as illustrated in several tutorials. I also added the vue-property-decorator library.

Updated Code:

[Updated Code Here]

Error Details:

[Error Messages Here]

Is it possible to use these component formats with Typescript in Vue? Any guidance would be appreciated.

Answer №1

Appreciate the thorough instructions and commands provided.

I encountered a similar issue, but resolved it by cloning nathantreid:vue-typescript into the packages directory and then restarting the application. This successfully installed the necessary packages and allowed the application to function without any issues!

    "devDependencies": {
    "@babel/plugin-transform-typescript": "^7.12.1",
    "@types/meteor": "^1.4.67",
    "@babel/core": "^7.4.4",
    "@babel/plugin-syntax-decorators": "^7.2.0",
    "@babel/plugin-syntax-jsx": "^7.2.0",
    "@babel/preset-typescript": "^7.3.3",
    "@babel/plugin-syntax-dynamic-import": "^7.2.0"
  }

I suggest trying to install these dev dependencies initially, and if that doesn't work, consider cloning the package like I did. Best of luck!

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

The object labeled as "EventEmitter" does not support the method "storeBuffer"

Sorry for the inconvenience and formatting issues. You can find the package on GitHub here: https://github.com/CollectionFS I am currently working on implementing the "Store a File From the Server" example. In my file lib/collections.js, I have the follo ...

Setting up the initial 3 parameters in a v-for loop

What is the best way to begin a v-for loop? For instance, we have an array named "array" with the following values: array = [dog, cat, e, f, g]; I am interested in using a v-for loop that will start looping through and only consider the first 3 values. ...

Leveraging jQuery for handling button functionality and making asynchronous requests

I am relatively new to working with jQuery, and while there are plenty of resources available on how to bind buttons, I find that my current setup is a bit more complex than what's typically covered. My situation involves: -Using Django to populate ...

Static parameter in Vue router

In my Vue Router, I need to pass specific information through the URL. For example: http://localhost/center/SHOPID/products http://localhost/center/SHOPID/categories http://localhost/center/SHOPID/... The SHOPID value will remain constant throughout th ...

Generic TypeScript any object that is plain

update I have included my current code to better illustrate the problem: https://gist.github.com/LukasBombach/7bf255392074509147a250b448388518 Using TypeScript, I aim to define a generic that represents any plain object data structure class MyClass<T ...

Tips for saving a variable in Angular that is being received through a subscription as JSON:

Below is an example of the json I have: [{"id":"1","date":"2020-02-21","status":"present","studentid":"1"},{"id":"2","date":"2020-02-24","status":"present","studentid":"1"}] I am struggling to store the date in a variable using Angular when it is being s ...

Issue in Jasmine test: 'Spy should have been invoked'

I've encountered an issue while writing a Jasmine test case for the following Angular function. The test case failed with the message "Expected spy [object Object] to have been called". $scope.displayTagModelPopup = function() { var dial ...

Create a web application in NodeJS that mimics browser functionality by running JavaScript code from an HTML page

I'm a beginner in NodeJS and I am working on developing a web service that can send a response with the output of a JavaScript script from an HTML page sourced online. For instance: Imagine my webpage contains a JavaScript snippet that outputs "hell ...

There is nothing like Python Bottle when it comes to parsing JSON data from

In my React code, I have the following: const payload = { x : x, y : y } fetch("http://localhost:8080/update_game", { method: "POST", body: JSON.stringify(payload)}) And in Python, I have this implementation: @post(&ap ...

Create a const assertion to combine all keys from an object into a union type

I am working with an object similar to this (demo link): const locations = { city: {name: 'New York'}, country: {name: 'United States'}, continent: {name: 'North America'} } as const My goal is to create a union t ...

Changing the color of an Angular <div> element with scripting

I am currently working on an Angular 6 project and I need to change the colors of a div tag from a script after a click function. However, I also need to change it back to transparent. When I click on the "Inheritance" option, the background color of the ...

Unable to generate a new file via POST request in mongoose and express

Can someone please review my Node.js code? I am trying to save contact page data in Mongoose Compass. The code runs without any errors, but it's not saving the data. <form action="/" class="contact_form grid" method="POST& ...

Is there a method to incorporate the ".then callback" into useEffect?

Is there a way to utilize the ".then callback" to log the word "frog"? I am interested in viewing my token within the async-storage. Once I have obtained my token, I need to append it to the header of a fetch call. Does anyone know how to accomplish this? ...

Is it possible to determine the location of the "phantom image" while moving an object?

Is there a method to retrieve the location of the ghost image when an element is dragged? This is how the scenario is set up: <div id="test" v-on:dragstart="dragStart" v-on:drag="dragging" draggable="true" v-on:drop="drop" v-on:dragover="allowDrop"> ...

How can I submit multiple dropdown menus when they are changed?

I recently added Four dropdown menus on my index.php page. <select name="filter_month" class="filters"> <option>Select a Month</option> <option value="1">January</option> <option value="2">February</optio ...

Verifying the presence of an image via its URL may not be functional across all browsers

Hey folks, I'm working on a project that involves displaying an image along with other fields in a loop where the image source changes with each iteration. I also need to check if the image exists and set a default source if it doesn't. The code ...

Utilizing ngFor to iterate over items within an Observable array serving as unique identifiers

Just starting out with Angular and I'm really impressed with its power so far. I'm using the angularfire2 library to fetch two separate lists from firebase (*.ts): this.list1= this.db.list("list1").valueChanges(); this.list2= this.db.list("list2 ...

Progression from Angular2-rc1 to Angular2-rc2 encounters TypeScript error: anticipating ',' (TS1005)

Encountering an issue with upgrading Angular2 from RC1 to RC2, following exception is being thrown: https://i.sstatic.net/bB6di.png Here's my main.ts file, I haven't made any changes to it during the upgrade process. Line 13 is where the bootstr ...

Setting default values in select options in Vue3

Is there a way to set a default value for this template? I want the default value to be 'Please Select...', which is the first option in the list. <template #dropDownSelection="{ props }"> <td colspan="1"> ...

Ways to retrieve targeted keyframes using JavaScript

Trying to access a scoped "keyframes" named move-left in JavaScript. How can I do this while keeping it scoped? Note that vue-loader will add a random hash to move-left, such as move-left-xxxxxxxxx. <template> <div :style="{animation: animati ...