Issue
So I've recently switched from tslint to eslint and have activated a lot of rules for my typescript to be more solid.
I however haven't found how to prevent typo's of my class variables in a function. Take this example:
Class input has a variable Seal. I have a getter & setter like this:
public get Seal(): string {
return this._Seal;
}
public set Seal(value: string) {
if (typeof(value) === 'string'){
this._Seak = value.toLowerCase();
} else { this._Seak = null; }
}
As you can see, there is a typo in the setter function which is not flagged by the compiler nor eslint. The app runs and it's much later I find out that Seal is not getting the assigned value. What option do I need to use (compiler option or eslint) to flag this?
I tried the "no-use-before-define" rule, but that didn't work.
Solution
It seems that my issue was caused by a previous setting either in tslint
or compiler options that caused a new class variable to be created instead of flagging the typo in the Seal Setter.
I realized I had a variable (which I did not create) added to my class that made every typo valid
[key:any]: string
Once I removed this line, the typo was flagged again and Seal was suggested as corrective action. Problem solved.
Answered By - Sven Thielen
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.