Vue seems to intermittently catch sight of the TypeScript getter

Trying to wrap my head around when Vue decides to re-render an element.

Let's explore the grid displayed below:

https://i.sstatic.net/DtSQy.png

In this grid, notice that Steve Rogers' total hours have been updated to 9 hours after inputting data for Saturday. However, the total for Saturday remains at 0 hours.

These values are generated by TypeScript getters:

class ScheduledEmployee {

    Id: number;
    Name: string;

    get TotalHours(): number {
        let total = 0;
        for (let i = 0; i < this.ScheduledDays.length; i++) {
            total = total + this.ScheduledDays[i].TotalHours;
        }
        return total;
    }

    ScheduledDays: ScheduledDay[] = [];
}

and

class ScheduleDate {
    Date: Date;
    Id: number; //id is ticks at midnight
    Day: string;
    ParentSchedulerVM: SchedulerVM;

    ScheduledDays: ScheduledDay[] = [];

    get TotalHours():number {
        let total: number = 0;
        for (let i = 0; i++; i < this.ScheduledDays.length) {
            total += this.ScheduledDays[i].TotalHours;
        }
        return total;
    }
}

It is acknowledged that this might be stretching the limits of Vue's simple data prop. Nevertheless, it would be helpful to understand why one getter is functioning smoothly while the other is not.

Answer №1

Well, it looks like I stumbled upon a minor bug. I accidentally swapped the test with the incrementer in the second for loop. Thankfully, Vue is still functioning properly :P.

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 parameter type ‘DocumentData’ cannot be assigned to type ‘never’ in this argument

I've been struggling to find a solution to my issue: Ts gives me an error: Argument of type 'DocumentData' is not assignable to parameter of type 'never' I attempted the solution I found on this page: Argument of type 'Docume ...

Dealing with CORS Policy Restrictions with jQuery Select2 in Laravel Vue

I encountered an issue while trying to utilize jQuery Select2 in Laravel Vue. When I use my base URL, I receive the following error. However, when I use a different API service such as https://countriesnow.space/api/v0.1/countries/population/cities, data r ...

Instructions on how to dynamically show specific text within a reusable component by utilizing React and JavaScript

My goal is to conditionally display text in a reusable component using React and JavaScript. I have a Bar component that I use in multiple other components. In one particular ParentComponent, the requirement is to show limit/total instead of percentage va ...

Tips on customizing the Nuxt Route Middleware using Typescript

I am working on creating a route middleware in TypeScript that will validate the request.meta.auth field from the request object. I want to ensure this field has autocomplete options of 'user' and 'guest': export default defineNuxtRoute ...

Angular 6: TypeError - The function you are trying to use is not recognized as a valid function, even though it should be

I'm currently facing a puzzling issue where I'm encountering the ERROR TypeError: "_this.device.addKeysToObj is not a function". Despite having implemented the function, I can't figure out why it's not functioning properly or callable. ...

Integrate an additional filter into vue-table-2

Looking for assistance on integrating an external filter into vue-table-2. I've attempted using slots, but haven't had success. <div slot="filter__id"> <input type="input" class="form-control"> </d ...

The Vue component fails to render when embedded within the HTML markup

I am having trouble implementing Vue components in my project. Additionally, I am using Pug (Jade) as a preprocessor. However, when I view the resulting HTML code, I see the raw template without the transformation from Vue component to HTML code. Below ...

Implementing the Same Vue Component with Different Path Names

Is there a more efficient way to have different URLs (Consumer and Seller) for the same SingleProduct component? The initial method works well: const routes = [ { path: "/:name", name: "SingleProductSeller", component: SingleProduct }, { ...

Retain the parameter name when defining a function type mapping

Imagine you need to change the result of a function: (bob: Bob) => R => (bob: Bob) => R2 Is it possible to achieve this without changing the argument name? (e.g bob instead of using a general name like a) ...

React type error: The argument 'profile' cannot be assigned to the parameter of type 'ComponentType<never>'

I've recently started learning TypeScript and I'm struggling with this particular issue. Below is the code I'm working on. import { IProps, IState } from './types'; class Profile extends Component<RouteComponentProps & I ...

Ng2-smart-table: Utilizing Angular 2 for Efficient Data Organization with Identically Named Columns

Here is a snippet of code where I am trying to display columns from a table: products: { title: 'Prodotto', filter: false, class: "colonneTabella", width: "15%", ...

What are the limitations of jest and jsdom in supporting contenteditable features?

I am facing an issue with a particular test case: test('get html element content editable value', () => { // arrange const id = 'foo'; document.body.innerHTML = `<div id='${id}' contenteditable="true">1</div ...

Creating a dynamic visual experience with Angular 2: How to implement multiple font colors

I have a text area which is connected to one string, with the default text color set to white. <textarea style="background-color: black;color:#fff;" [(ngModel)]="outputText"></textarea> The connected string contains multiple variables. retur ...

What is the best way to set up my page to detect the "enter" key input when the form is not created with the <form> tag?

Within the HTML code, data is received and stored in variables within my TypeScript file. At the end of the HTML, there is a button that was created separately from any user input containers. This button triggers a function that processes the information i ...

Avoiding duplication of jquery when using webpack and typescript

I encountered an error message that reads: Uncaught TypeError: $(...).dialog is not a function The issue appears to be arising from importing jquery twice, and I am struggling to find a solution. Additionally, the error references bootstrap in the follo ...

Is there a secure alternative in Typescript for handling null values, such as a "safe operator"?

I'm currently working on implementing a feature in my Angular application where I need to toggle the visibility of a div using ngIf. Below you can find the snippet of HTML code I am using: <div *ngIf="damageReportToPolice()"> </div> Her ...

The Vuex state or getters consistently yield 'undefined'

After creating some modules in Vuex 4, I am faced with an issue where I am unable to retrieve any data from it. It is possible that the data is not being saved or there might be a flaw in my logic. store/mutation-types.js export const SET_LOCALE = &apos ...

What is the reason behind TypeScript's decision not to raise an error in case of a mismatched function argument type?

Here's a simple illustration to showcase my point: type Info = { id: number; } type ImportantInfo = { id: number; value: 5; } type Task = (data: Info) => void; const task: Task = data => null; const data: ImportantInfo = { i ...

Images in the public/image folder cannot be loaded due to a 403 Forbidden error in Laravel, Vue.js,

Although the image in my profile is displayed perfectly, I have encountered an error in the console. When trying to access the image from the public folder, no error occurs. However, if I attempt to access it from the image folder, which is a subfolder, th ...

React typed (script) properties are not validated

Embarking on a brand new app development journey with React, I decided to experiment with TypeScript for the very first time. I have a React component set up like this: import React, { SFC } from 'react'; type Props = { username: string }; ...