angular-cli icon indicating copy to clipboard operation
angular-cli copied to clipboard

ng build results in error TS2554: Expected 0 arguments, but got 1.

Open AnassL opened this issue 9 years ago • 12 comments

  • [x] bug report

After upgraded to Angular CLI 1.5.0 ng build command resulted in the follwing error: ERROR in app/app-error.handler.ts error TS2554: Expected 0 arguments, but got 1.

Versions.

Angular CLI: 1.5.0 Node: 8.9.0 OS: win32 x64 Angular: 5.0.1 ... animations, common, compiler, compiler-cli, core, forms ... http, language-service, platform-browser ... platform-browser-dynamic, platform-server, router @angular/cdk: 5.0.0-rc0 @angular/cli: 1.5.0 @angular/material: 5.0.0-rc0 @angular-devkit/ build-optimizer: 0.0.33 @angular-devkit/ core: 0.0.20 @angular-devkit/ schematics: 0.0.35 @ngtools/ json-schema: 1.1.0 @ngtools/ webpack: 1.8.0 @schematics/ angular: 0.1.3 typescript: 2.6.1 webpack-hot-middleware: 2.19.1 webpack-merge: 4.1.0 webpack: 3.6.0

When checking the app-error.handler.ts , the line:

import { Injectable, ErrorHandler } from '@angular/core';

has "Injectable" and "Error handler" underlined with the errors:

[ts] Module '"c:/...../node_modules/@angular/core/core"' has no exported member 'Injectable'.

[ts] Module '"c:/...../node_modules/@angular/core/core"' has no exported member 'ErrorHandler'.

Update:

After a machine reboot, the words "Injectable" and "Error handler" were not underlined but this time it was the argument "super(true)" in the constructor below:

    constructor() {
        super(true);
    }:

Here the error is:
constructor ErrorHandler(): ErrorHandler

AnassL avatar Nov 16 '17 15:11 AnassL

This doesn’t appear to be related to the CLI. The constructor being called doesn’t take an argument. Remove the ‘true’ from the super call.

clydin avatar Nov 16 '17 19:11 clydin

Removing the ‘true’ from the super call releases the error, but I wonder why it is supplied originally with 'true' if I have to remove it.

AnassL avatar Nov 16 '17 22:11 AnassL

That file doesn't exist in a newly generated project. The constructor parameter was deprecated in Angular 4 and removed in Angular 5.

clydin avatar Nov 17 '17 00:11 clydin

As @clydin pointed out, the constructor parameter was removed in Angular 5. I'm closing this as solved/answered.

hansl avatar Nov 22 '17 18:11 hansl

Hi , how to solve this problem any body help me. using Angular2 Error TS2554: Expected 3 arguments, but got 0.

DeepzSandra avatar Feb 16 '18 08:02 DeepzSandra

error TS2554: Expected 2 arguments, but got 1.

Here sign(myForm){ if(myForm.valid){ this.af.auth.createUserWithEmailAndPassword({ //here is the problem email:this.email, password:this.password }).then( (success)=> { console.log(success); this.router.navigate(['/login']) }).catch( (err)=> { console.log(err); this.error=err; }) } }

durjoy28 avatar May 09 '18 17:05 durjoy28

@durjoy28 : It so appears that your createUserWithEmailAndPassword function is expecting two parameters whereas you're sending an object, which is 01 parameter. Try sending the email and password as individual parameters, maybe?

thatsuperdev avatar Jun 19 '18 10:06 thatsuperdev

error TS2554: Expected 2 arguments, but got 1.

onFormSubmit(form:NgForm) { this.api.updateBook(this.id, form) .subscribe(res => { let id = res['_id']; this.router.navigate(['/book-details', id]); }, (err) => { console.log(err); } ); }

vishnuBoppani avatar Oct 17 '18 07:10 vishnuBoppani

ERROR in src\app\modules\configuration\external-system\containers\external-system-home.component.ts.ExternalSystemHomeComponent.html(2,33): : Expected 0 arguments, but got 1.

armandohuarcaya avatar Feb 07 '19 15:02 armandohuarcaya

ERROR in src\app\modules\configuration\external-system\containers\external-system-home.component.ts.ExternalSystemHomeComponent.html(2,33): : Expected 0 arguments, but got 1.

When this happened to me, I found that it was a function I was calling from the html with a parameter, but in the ts file no parameters were expected.

Example: HTML FILE <app-filters (OnClear)="this.clearFilter($event)">

TS FILE clearFilter() {....}

You can see that in your project says that is on the line 2, check if is the same error

fflores-origin avatar Feb 26 '19 20:02 fflores-origin

My problem is solved.

On Wed, Feb 27, 2019 at 2:25 AM Francisco Andres Flores Fanelli < [email protected]> wrote:

ERROR in src\app\modules\configuration\external-system\containers\external-system-home.component.ts.ExternalSystemHomeComponent.html(2,33): : Expected 0 arguments, but got 1.

When this happened to me, I found that it was a function I was calling from the html with a parameter, but in the ts file no parameters were expected.

Example: HTML FILE <app-filters (OnClear)="this.clearFilter()">

TS FILE clearFilter() {....}

You can see angular says that is on the line 2

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/angular/angular-cli/issues/8514#issuecomment-467599173, or mute the thread https://github.com/notifications/unsubscribe-auth/ATuxWXMvsudgbWiecn68RCJ4271z154tks5vRZgtgaJpZM4Qgr99 .

durjoy28 avatar Feb 27 '19 19:02 durjoy28

This issue has been automatically locked due to inactivity. Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.