Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

199
Visualizações
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?

over 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

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
}
over 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Assistente virtual