我得到了一个类型错误,"预期为0个类型参数,但得到了1",尽管我遵循了本教程的一个T.

我已指明:

  newUserInfoComplete:boolean = false

然而,我在这一行的<boolean>上得到了上面指定的错误:

  @Output() newUserInfoCompleteEvent = new EventEmitter <boolean> ();

此外,如果我简单地省略<boolean>,我会得到以下错误:

Argument of type 'boolean' is not assignable to parameter of type 'string'.

还有这个.NewUserInfoComplete在下面加了下划线:

this.newUserInfoCompleteEvent.emit(this.newUserInfoComplete);

以下是我的组件:

import { Component, OnInit, Output } from '@angular/core';
import { slideToRight } from '../../../../router.animations';
import { Router, ActivatedRoute, UrlSegment } from '@angular/router';
import { EventEmitter } from 'protractor';

@Component({
  selector: 'app-new-user-input',
  templateUrl: './new-user-input.component.html',
  styleUrls: ['./new-user-input.component.css'],
  animations: [slideToRight()]
})
export class NewUserInputComponent implements OnInit {

  newUserInfoComplete:boolean = false

  @Output() newUserInfoCompleteEvent = new EventEmitter <boolean> ();

  constructor(private router: Router, r: ActivatedRoute) {
    r.url.subscribe((s: UrlSegment[]) => {
      console.log("url", s); //https://vsavkin.com/angular-router-understanding-router-state-7b5b95a12eab
    });
  }

  ngOnInit() {
  }



  sendNewUserInfoComplete(){
    this.newUserInfoCompleteEvent.emit(this.newUserInfoComplete);
  }


  displaySibling() {
    console.log(this.router);
    this.router.navigate(['../', { outlets: { newuserorginfo: ['newuserorginfo'] } }])
  }

  closeBlade() {
    this.router.navigate([{ outlets: { newuserinput: null } }]);
  }

}

推荐答案

try 从Angular导入EventEmitter,而不是从protractor导入:

import { Component, OnInit, Output, EventEmitter } from '@angular/core';

Typescript相关问答推荐

使用前的组件渲染状态更新

为什么typescript不能推断类的方法返回类型为泛型''

typescribe警告,explate—deps,useEffect依赖项列表

如何通过TypeScript中的工厂函数将区分的联合映射到具体的类型(如类)?

在MessageStore对象中实现条件类型时出现TypeScrip错误

通过字符串索引访问对象';S的值时出现文字脚本错误

带下拉菜单的Angular 响应式选项卡

错误TS2403:后续变量声明必须具有相同的类型.变量';CRYPTO';的类型必须是';CRYPATO';,但这里的类型是';CRYPATO';

在HighChats列时间序列图中,十字准线未按预期工作

如何创建一家Reduxstore ?

如何在Angular 服务中制作同步方法?

是否可以通过映射类型将函数参数约束为预定义类型?

声明遵循映射类型的接口

创建一个函数,该函数返回一个行为方式与传入函数相同的函数

为什么TypeScrip假定{...省略类型,缺少类型,...选取类型,添加&>}为省略类型,缺少类型?

如何使函数参数数组不相交?

如何键入';v型';

为什么 TypeScript 类型条件会影响其分支的结果?

React-Router V6 中的递归好友路由

基于泛型类型的条件类型,具有条目属性判断