currently studying and new to TypeScript.
I am trying to create a class and using a constructor to initiate private variables inside this class, however, I get hit with a [property name] is declared but never used.
export class CloClient extends Client {
private identity: string[];
private commands: { [name: string]: typeof CommandClass };
private behaviors: { [name: string]: typeof Behavior };
constructor(identity: string[], options: ClientOptions) {
super(options);
this.identity = identity;
this.commands = {};
this.behaviors = {};
}
}
Using TypeScript 4.4.3, any suggestions?
That warning will be displayed for all properties which are declared but are never accessed.
Typescript is trying to inform you that in its current state, that property does not need to exist as it is never used during the execution of the script.
Once you access / read from the property than this warning will disappear. i.e some thing like:
if(this.identity){
... other code
}