The error code TS2345 indicates that the argument '{ read: typeof ElementRef; }' cannot be assigned to the parameter '{ read?: any; static: boolean; }'

Currently in the process of updating my Angular application from version 7 to version 8. Upon running ng serve, I encounter the following error:

Error TS2739: Type '{}' is missing the following properties from type 'EmployeeModel': statut, hasLaws, disablePlanningManagerOrLeaderOrFixe

303         this.employee = {...this.employee, ...entry[1]};

Within my Typescript file:

getEmployeeDetail() {
    this.setIdSecuriteSocialAndIdBanqueToEmployeeBefore();
    Object.entries(this.infosPersonnellesForm.value).forEach(entry => {
      if (entry[0] === 'coordonnees' || entry[0] === 'divers') {
        this.employee = {...this.employee, ...entry[1]};
      } else {
        this.employee[entry[0]] = entry[1];
      }
    });
    this.setIdSecuriteSocialAndIdBanqueToEmployeeAfter();

  }

Seeking assistance on how to resolve this issue. Any help would be greatly appreciated. Thank you.

Answer №1

It seems like the full code hasn't been provided, but based on the error message, it is recommended to update the @ViewChild declaration as shown below.

Previous Code:

@ViewChild('foo') foo: ElementRef;

Updated Code:

// To access query results in ngOnInit
@ViewChild('foo', {static: true}) foo: ElementRef;

OR

// To access query results in ngAfterViewInit
@ViewChild('foo', {static: false}) foo: ElementRef;

Answer №2

After some troubleshooting, I realized that the variables

status, hasLow, disablePlanningManagerOrLeaderOrFixe
were missing as optional parameters.

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

Firebase deployment encounters an error due to missing dependencies

I've run into an issue while trying to deploy a Firebase function. Despite my attempts to resolve it by deleting `node_modules` and `package-lock.json`, running `npm install`, and using `firebase deploy --only functions` multiple times, the build proc ...

Persistent reappearance of .bin files within node_modules

Each time I execute the command yarn or yarn install, a yarn file mysteriously materializes in the depths of node_modules/.bin. This file seems to belong to an ancient era and requires manual deletion every time. How can I put an end to this recurring is ...

What is the process of declaring a global function in TypeScript?

I am looking to create a universal function that can be accessed globally without needing to import the module each time it is used. The purpose of this function is to serve as an alternative to the safe navigation operator (?) found in C#. I want to avoi ...

No slides will be displayed in Ionic 2 once the workout is completed

Here is the result of the JSONOBJ: In my home.html file, I have ion-card containing a method called navigate(), which is structured as follows: navigate(event, exercise, exercise2, exercise3, exercise4){ this.navCtrl.push(exerciseSlides, { ...

Exploring Computed Properties in Angular Models

We are currently in the process of developing an application that involves the following models: interface IEmployee{ firstName?: string; lastName?: string; } export class Employee implements IEmployee{ public firstName?: string; public l ...

Encounter a Issue Setting up Angular 4 with git Bash

Hey, I was in the midst of installing Angular when suddenly after 11 hours of waiting, my internet slowed down and I received an error message. npm ERR! code ENOTFOUND npm ERR! errno ENOTFOUND npm ERR! network request to https://registry.npmjs.org/resolve ...

Encountering a problem with NPM when trying to install a new NPM

Hey there, I'm currently trying to install an npm module from http://socket.io/. Interestingly, I seem to be encountering the same error every time I attempt to install any NPM Module. C:\wamp\www\nodetutorial>npm install socket.io ...

Tips for Running Angular 2 Webpack Application on AWS EC2 Instance

I am currently running an AngularJs 2 application in development mode using the webpack-development-server My goal is to deploy this on EC2. So far, I have: - set up a new linux instance - installed node.js and npm - cloned my repository from git ...

"TypeScript Static Classes: A Powerful Tool for Struct

In my TypeScript code, there is a static class with an async build method as shown below: export default class DbServiceInit { public static myProperty: string; public static build = async(): Promise<void> => { try { ...

Using Angular with Spring Boot: Angular Service sending Http requests to localhost:4200 instead of the expected localhost:8080

I am currently working on a project that involves Angular and Spring Boot. In this setup, the Angular project has services that make Http requests to the Spring Boot app running on port 8080. However, I have encountered an issue where one of the services i ...

Tips for implementing a decorator in a TypeScript-dependent Node module with Create-React-App

I am working on a project using TypeScript and React, which has a dependency on another local TypeScript based project. Here are the configurations: tsconfig.json of the React project: "compilerOptions": { "target": "esnext& ...

The index declaration file has not been uploaded to NPM

After creating a Typescript package and publishing it on NPM, I encountered an issue with the declaration files not being included in the published version. Despite setting declaration: true in the tsconfig.json, only the JavaScript files were being publis ...

Retrieve all elements within an Angular6 Directive that share the same name as the Directive

I have created a custom Directive called isSelected and applied it to several elements in different components as shown below: <i isSelected class="icon"></i> <i isSelected class="icon"></i> <i isSelected class="icon"></i ...

Creating a conditional property in TypeScript based on an existing type - a comprehensive guide

Imagine if I had the following: type Link = { text: string; link: string; } interface BigLink extends Link { some: number; something: string; else: string; } However, there's a variable that shares all these properties except for the fact ...

Troubleshooting Angular HTTP: Issue with the HTTP request headers not updating

// assigning the httpclient protected _http: HttpClient = inject(HttpClient); // defining the options for the request const httpOptions = { headers: new HttpHeaders({ 'Content-Type': 'application/tcc' }), observe: 'resp ...

Enhanced HTML support for * syntax in IntelliJ Angular 2

It appears that IntelliJ 2017.1 does not fully support the * syntax for HTML files with Angular 2. The autocompletion only suggests the template syntax without the star. https://i.stack.imgur.com/k6SuD.png https://i.stack.imgur.com/QfNPH.png Moreover, w ...

Incorporate the angular-cdk table functionality seamlessly with the sleek design of Bootstrap

Looking to enhance the design of my Angular application by incorporating Bootstrap table styling with the use of Angular CDK table (without Angular Material2). One challenge I've encountered is that while it's possible to add classes to the CDK ...

Is it possible to extract Apollo type guards from a package?

I came across a helpful Apollo type guard that I want to integrate into my app. Here is the code snippet: export function isField(selection) { return selection.kind === 'Field'; } You can find it in node_modules/@apollo/client/utilities/grap ...

Trouble installing NPM packages from Artifactory on Windows 10

Problem Description: I am utilizing Artifactory for my NPM packages. When attempting to install them on "Windows - 7", everything is functioning correctly. However, on "Windows - 10" an error is being displayed and the packages are not installing. Error M ...

How to implement the connect function in an Angular 2 table

Topic: Angular Material 2 implementation of md-table UI using cdk-table Problem: Unable to trigger connect method after a user-initiated HTTP call receives a response Approach: Create a hot observable from a behavior subject in a service. The parent c ...