When linting the following code:
public doStuf = (): Promise<null> => {
const data = new Stuff(this.value);
if (this.state === 'test') {
data.mail = {
object: label,
files: this.dropppedFiles || []
};
return this.validate = (data) => null;
} else {
return this.validate = (data) => null;
}
}
I'm passing doStuff()
as promise to a child component that's why I need to keep the context with this.validate = (data) => null;
(There's maybe a more elegant way of doing things?)
I get
Shadowed variable: 'data'
I tried unsing let
instead of const
but lint complains again about data is never modified, use const instead
All my tests pass, and the component works as expected. How do I get rid of this error?
EDIT:
What works is
this.validate = (boo = data) => null;
How horrible is that?
EDIT:
I actually want to pass parameters to the validate function and keep the arrow function structure at the same time. Something like:
this.validate(data) = () => null;