Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

161
Views
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 answers
Answer question

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!