01 / 05
Write it as you did in JavaScript and you get told off
Bring a class from the JavaScript course straight over into TypeScript and it goes red. All it does inside the constructor is put a value into this.name.
What you get is "Property 'name' does not exist on type 'Person'". To TypeScript a class is also a blueprint for what data it holds, so it will not let something you never declared spring up out of nowhere.
class Person { constructor(name: string) { this.name = name; }}Result
Type error: Property 'name' does not exist on type 'Person'.