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

164
Visualizações
SyntaxError: Unexpected identifier on class attribut declaration
class ClassData {
  name: string;
  interfaces: string[] = [];
  superclass: string;
  members: any = {};
}

Sorry to ask but I'm stuck: what did I do wrong? I use node v14.17.0

I have this error:

 name: string;
SyntaxError: Unexpected identifier
about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

It looks like you are writing TypeScript here. Node and JavaScript does not have types at all.

take a look at Typescript when you are used to write types.

EDIT: Node.js and JavaScript interpret your example as failure because it does not understand what prop: string means. If you want your IDE to give you some autocomplete and type information you can specify some stuff in a doc comment like so:

class Rectangle {
  /**
   * @param {number} height 
   * @param {number} width 
   */
  constructor(height, width) {
    this.height = height;
    this.width = width;
  }
  area() {
    return this.height * this.width;
  }
};

Works in most IDEs.

about 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
Recomende algumas ofertas para mim
Preciso de ajuda