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

159
Vistas
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 Respuestas
Responde la pregunta

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 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