The assignment expression requires the left-hand side to be either a variable or a property that is being accessed

I have been attempting to define a new constant in the following manner, but I encountered an error

export const fakeExpertOperationalEdited: ExpertOperational = {
    comment: 'comment',
    useSlots: true,
    workingDay: new ExpertWorkingDay[] = [
        {
            weekDay: 'MONDAY',
            operationalAM: {
                fixed: false,
                startTime: '11:00',
                endTime: '12:00'
            },
            operationalPM: {
                fixed: false,
                startTime: '11:00',
                endTime: '12:00'
            }
        }

    ],
    workSpeedSurvey: '10'
};

export class ExpertWorkingDay {
  constructor(
    public weekDay: WeekDays,
    public operationalAM: ExpertWorkingHours,
    public operationalPM: ExpertWorkingHours
  ) { }
}

This is the error message I am receiving

The left-hand side of an assignment expression must be a variable or a property access

Does anyone have any insights into where I might be going wrong?

Answer №1

The issue at hand

workingDay: new ExpertWorkingDay[] = [ ... ]

simply attempt

workingDay:  [ ... ]

as creating an array using new is incorrect. New is meant for initializing classes.

Therefore, it should be

 workingDay: [
     new ExportWorkingDay( ... ),
     new ExportWorkingDay( ... )
 ]

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

Variations in key options based on specific situations

Is it possible to make certain keys required in Typescript depending on the circumstances? For instance interface IDog { name: string; weight: number; } class Retriever implements IDog { name = "Dug"; weight = 70; public updateAttribute(props ...

Using Bootstrap 4 with Angular 2: A Beginner's Guide

Currently, I am in the process of developing an Angular 2 application using TypeScript. My goal is to integrate the Bootstrap 4 framework with some custom theming. Is this achievable? I have encountered issues with the "ng2-bootstrap" npm package, as it d ...

Using Typescript to import functions

TLDR - I need help understanding the difference between these imports in ReactJs using Typescript: setState1: (numbers: number[]) => void, setState2: Function Hello everyone, I've encountered some strange behavior when importing functions with Typ ...

React 18 update causes malfunctioning of react-switch-selector component

I'm facing an issue where the component is not rendering. I attempted to start a new project but it still didn't work. Is there a solution to fix this problem or should I just wait for an update from the original repository? Encountered Error: ...

What sets the do/tap operator apart from other observable operators?

Can anyone clarify the distinction in simple terms between the typical observable operators used for observing output and why do/tap appear to serve the same purpose? What is the reason for utilizing do/tap? ...

Incorporate a stylish gradient background into react-chartjs-2

I am currently working on adding a gradient background with some transparency to a radar graph within a react component. So far, I have only found solutions that involve referencing a chartjs canvas in an html file, but none for implementing it directly in ...

Error: The argument 'IParams' is not compatible with the parameter type 'IParams' in Typescript with NextJS14

I encountered an error in my code while using Prisma with Next.js 14 and TypeScript. The issue arises when trying to load product details via product ID. The error is captured in the screenshot below. Failed to compile. ./app/product/[productId]/page.tsx:1 ...

Unable to downgrade Angular CLI to version 8.x.x

I'm facing an issue where I need to revert my Angular CLI from version 9 back to version 8. I've attempted the following steps: npm uninstall -g @angular/cli npm cache verify npm install -g @angular/<a href="/cdn-cgi/l/email-protection" cla ...

The multi-select function is coming back empty

I am currently developing a straightforward form using reactive angular forms with the following elements: an email input, a dropdown selection, a multi-select option, and a text area field. The two-way binding is functioning correctly for all elements e ...

Using sl-vue-tree with vue-cli3.1 on internet explorer 11

Hello, I am a Japanese individual and my proficiency in English is lacking, so please bear with me. Currently, I am using vue-cli3.1 and I am looking to incorporate the sl-vue-tree module into my project for compatibility with ie11. The documentation menti ...

File uploading in Angular combined with a RESTful JAX-RS Java EE web service

Currently, I am working on a project that involves uploading an image to a server. The front end is built using Angular, while the back end utilizes Java EE web service JAX-RS RestEasy. Here is the code snippet for the Angular front end: HTML page: <m ...

Angular onscroll event creating a parallax effect

I attempted to create a parallax effect using Angular and the OnScroll event, however, while scrolling, the text seems to be flickering. Is there a way to make the smooth rendering onscroll? Maybe through CSS alone? Here is the script I used: https://sta ...

arranging data in html table columns using angular 2

I am facing a challenge where I require each column of a table to be sorted in ascending order every time it is clicked. The sorting logic implemented is a standard JavaScript method. While this method works well in most scenarios, it encounters issues whe ...

Extracting information from an Observable in Angular: A comprehensive guide

I am currently working on an Angular application that interacts with a server through RESTful requests, and receives a JSON stream response containing objects of a specific type. The interface for these objects is as follows: export interface Personal { ...

Adjusting the dimensions of the cropper for optimal image cropping

I am currently working on integrating an image cropper component into my project, using the react-cropper package. However, I am facing a challenge in defining a fixed width and height for the cropper box such as "width:200px; height:300px;" impo ...

What determines the narrowing of a type when it is defined as a literal versus when it is returned from a function?

I'm really trying to wrap my head around why type narrowing isn't working in this scenario. Here's an example where name is successfully narrowed down: function getPath(name: string | null): "continue" | "halt" { if (n ...

Creating a table with a horizontal layout using Angular Material's mat-table

I am currently utilizing angular material 8.2.3 for my website. However, I have encountered a seemingly simple issue that has me stuck. I am looking to display a table horizontally instead of vertically. In my table, I only have two columns. Below is the ...

Creating a secure connection on localhost with angular dart webdev: A step-by-step guide

Currently, I am developing a web application using Angular Dart. One issue I encountered is accessing the user's location feature through geolocation, as browsers like Chrome require HTTPS for this functionality. When deploying the web application, th ...

Establishing the types of object properties prior to performing a destructuring assignment

Consider a scenario where a function is utilized to return an object with property types that can be inferred or explicitly provided: const myFn = (arg: number) => { return { a: 1 + arg, b: 'b' + arg, c: (() => { ...

Upgrading from Angular 2 to 4 causes compilation failure in project

Recently, I upgraded my Angular project from version 2 to version 4. The steps I followed for this upgrade are as follows: 1- Deleted the /node_modules/ folder 2- Executed the following command: npm install @angular/common@latest @angular/compiler@lat ...