S
S
ScarletFlash2019-01-31 10:23:54
Angular
ScarletFlash, 2019-01-31 10:23:54

How to fix TSlint firing on @Input() with set/get in Angular?

The rule in tslint.json is:


...
"no-unsafe-any": true
...

The component uses two-way binding:

...
@Input() public get value(): string {
return this._value;
}
public set value(newValue: string) {
this._value = newValue;
this.valueChange.emit(this.value);
}
...

Linter throws an error on @Input() . Tell me how to fix it without disabling the rule?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
M
msdosx86, 2019-01-31
@msdosx86

For two-way linking, you need

@Input()
public value: string;

@Output()
public valueChange: EventEmitter<string>;

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question