Reputation: 2885
When I execute node server-file.ts, receive then receives
name: string;
^
SyntaxError: Unexpected token :
This is my code
"use strict";
class ChatClient {
name: string;
surname: string;
text_color: string;
constructor(name: string, surname: string, text_color: string) {
this.name = name;
this.surname = surname;
this.text_color = text_color;
}
};
Upvotes: 0
Views: 201
Reputation: 250972
You need to compile first... simplistically you could use:
tsc --module umd server-file.ts
This will generate the server.file.js
file that you can run happily on Node.
You can also simplify your class as per the below (stop manually mapping your constructor parameters).
"use strict";
class ChatClient {
constructor(public name: string, public surname: string, public text_color: string) {
}
};
Upvotes: 2