Typescript Classes 10 exercises
Problem

Classes in TypeScript

Here we have a class called CanvasNode that currently functions identically to an empty object:


class CanvasNode {}

Inside of a test case, we instantiate the class by calling new CanvasNode().

However, have some errors since we expect it to house two properties, specifically

Loading exercise

Transcript

00:00 In this exercise, we have a class called CanvasNode, which is currently acting like an empty object. We can initiate CanvasNode like this by calling new CanvasNode on it. And currently we're expecting it to have two properties on that class. We're expecting it to have a property of X, which is gonna be zero,

00:18 and a property of Y, which is gonna be zero. And we're also hoping that it's going to be read-only too. So you've got a couple of different jobs here that you should know how to solve vaguely if you understand or remember the object syntax that we saw before. And we're also gonna need to probably add a constructor to CanvasNode, but there's actually a solution

00:38 where you don't add a constructor as well. So your job is to investigate the basic properties of classes based on the TypeScript documentation, which I'll link to below, and try to get this working. Good luck.