Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

146
Vistas
TypeScript: Constructor Property is declared but never used

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?

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

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
}
about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda