2
votes

Error

ERROR in src/app/custom-filterdt/custom-filterdt.component.ts(11,4): error TS2554: Expected 2 arguments, but got 1.

Typescript code

 import { Component, OnInit, OnDestroy, ViewChild } from '@angular/core';
 import { DataTableDirective } from 'angular-datatables';
  @Component({
    selector: 'app-custom-filterdt',
    templateUrl: './custom-filterdt.component.html',
    styleUrls: ['./custom-filterdt.component.css']
    })

Error in code

import { Component, OnInit, OnDestroy, ViewChild } from '@angular/core';

error message

import Component Module '"../../../node_modules/@angular/core/core"' has no exported member 'Component'.ts(230

ng version

                            Angular CLI: 8.0.3
                            Node: 12.4.0
                            OS: win32 x64
                            Angular: 8.0.1
                            ... animations, cdk, common, compiler, compiler-cli, core, forms
                            ... language-service, material, platform-browser
                            ... platform-browser-dynamic, router, service-worker

                            Package                           Version
                            -----------------------------------------------------------
                            @angular-devkit/architect         0.800.3
                            @angular-devkit/build-angular     0.800.3
                            @angular-devkit/build-optimizer   0.800.3
                            @angular-devkit/build-webpack     0.800.3
                            @angular-devkit/core              8.0.3
                            @angular-devkit/schematics        8.0.3
                            @angular/cli                      8.0.3
                            @angular/http                     7.2.15
                            @angular/pwa                      0.800.3
                            @ngtools/webpack                  8.0.3
                            @schematics/angular               8.0.3
                            @schematics/update                0.800.3 (cli-only)
                            rxjs                              6.5.2
                            typescript                        3.4.5
                            webpack                           4.30.0
  • Any help is most welcome

Above problem Get solved by deleting node module

But after this new error

Expected 2 arguments, but got 1.ts(2554) core.d.ts(8064, 47): An argument for 'opts' was not provided

 viewchild @ViewChild('maincontent') mainContent: any; An argument for 'opts' was not provided.  error TS2554: Expected 2 arguments, but got 1 in v8

Typescript

 export class ViewchildexampleComponent implements OnInit {
 @ViewChild('maincontent') mainContent: any;
1
Try deleting the node_modules and installing them again using npm i.SiddAjmera
thanks sid i will try thisafeef
but new error in viewchild @ViewChild('maincontent') mainContent: any; An argument for 'opts' was not provided.afeef
ViewChild requires a second argument since Angular 8. Try it this way: @ViewChild('maincontent', {static: false}) mainContent: any;SiddAjmera
thanks it solved issueafeef

1 Answers

3
votes

As SiddAjmera suggested deleting node_modules folder and running npm install seems to solve the issue. Solved mine atlist