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