My approach is quite simple: I concatenate multiple strings and format them to make them more readable.
info() {
return "x: " + this.xpos.toString() + "\n" \
+ "y: " + this.ypos.toString() + "\n" \
+ "width: " + this.width.toString() + "\n" \
+ "height: " + this.height.toString() + "\n";
}
I understand that the code itself may not be perfect, but when I compile it using tsc
, I encounter the following error:
cli.ts:32:54 - error TS1127: Invalid character.
This issue arises in all lines where there is a \
for escaping the newline. What should I do in TypeScript to properly escape a newline?