I'm having trouble understanding line 18 of the following snippet of a TypeScript tutorial.
1 class Greeter {
2 static standardGreeting = "Hello, there";
3 greeting: string;
4 greet() {
5 if (this.greeting) {
6 return "Hello, " + this.greeting;
7 }
8 else {
9 return Greeter.standardGreeting;
10 }
11 }
12 }
13
14 let greeter1: Greeter;
15 greeter1 = new Greeter();
16 console.log(greeter1.greet());
17
18 let greeterMaker: typeof Greeter = Greeter;
19 greeterMaker.standardGreeting = "Hey there!";
20
21 let greeter2: Greeter = new greeterMaker();
22 console.log(greeter2.greet());
As I understand from the tutorial, the goal of the declaration of greatermaker is getting the Greeter class type into a variable, rather than the instance type.
Firstly, what is the function of the assignment operator = in this line?
Secondly, what do we mean exactly with the distinction between the class type and the instance type? I guess, in the first we are able to manipulate the static member variables as opposed to the second?
Edit.
Why don't we just use let greeterMaker: typeof Greeter, that is without the assignment operator?
let greetmaker: Greeter = Greeter;. Or simply remove the type declaration since the assignment will do that implicitly.let greeterMaker : typeof Greeter;greetermaker = Greeter;`?typeof, given your note that typeof, indeed, only returns a string in this case?