简体   繁体   中英

Assigning an Alias to @Output() and @Input() show TSLint Error

I'm trying to assign an alias to @Output but there are TSLint error,

export class CockpitComponent implements OnInit {
  @Output('bpCreated') blueprintCreated = new EventEmitter<{ serverName: string, serverContent: string }>();
  @Output('srvCreated') serverCreated = new EventEmitter<{ serverName: string, serverContent: string }>();

TSLint: In the class "CockpitComponent", the directive output property "serverCreated" should not be renamed.Please, consider the following use "@Output() serverCreated = new EventEmitter();" (no-output-rename)

so when should Assign an Alias to @Output() and @Input() in Angular?

Tslint 错误片段

This is tsLint error, and it's clear says you should not rename it so

either

@Output() blueprintCreated ...

or

@Output() bpCreated ...

or if you insist to have it add this comment on top of each lines and it will ignore it

// tslint:disable-next-line:no-output-rename
@Output('bpCreated') blueprintCreated

you can enable the tslint from Webstorm Preferences (and Suppress error for current line)

I did this in my code:

// tslint:disable-next-line:no-output-native
@Output() close = new EventEmitter();

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM