annotate Deprecated/Resources/CodeGeneration/Graveyard/playground2.ts @ 1412:0cbc85e0c583 legacy-loader-refactoring

dummy
author Benjamin Golinvaux <bgo@osimis.io>
date Mon, 04 May 2020 15:28:30 +0200
parents f6a2d46d2b76
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
490
6470248790db ongoing codegen work
bgo-osimis
parents:
diff changeset
1 class Greeter {
6470248790db ongoing codegen work
bgo-osimis
parents:
diff changeset
2 greeting: string;
6470248790db ongoing codegen work
bgo-osimis
parents:
diff changeset
3 constructor(message: string) {
6470248790db ongoing codegen work
bgo-osimis
parents:
diff changeset
4 this.greeting = message;
6470248790db ongoing codegen work
bgo-osimis
parents:
diff changeset
5 }
6470248790db ongoing codegen work
bgo-osimis
parents:
diff changeset
6 greet() {
6470248790db ongoing codegen work
bgo-osimis
parents:
diff changeset
7 return "Hello, " + this.greeting;
6470248790db ongoing codegen work
bgo-osimis
parents:
diff changeset
8 }
6470248790db ongoing codegen work
bgo-osimis
parents:
diff changeset
9 }
6470248790db ongoing codegen work
bgo-osimis
parents:
diff changeset
10 enum Color {
6470248790db ongoing codegen work
bgo-osimis
parents:
diff changeset
11 Red,
6470248790db ongoing codegen work
bgo-osimis
parents:
diff changeset
12 Green,
6470248790db ongoing codegen work
bgo-osimis
parents:
diff changeset
13 Blue,
6470248790db ongoing codegen work
bgo-osimis
parents:
diff changeset
14 };
6470248790db ongoing codegen work
bgo-osimis
parents:
diff changeset
15
6470248790db ongoing codegen work
bgo-osimis
parents:
diff changeset
16 function ColorToString(value: Color)
6470248790db ongoing codegen work
bgo-osimis
parents:
diff changeset
17 {
6470248790db ongoing codegen work
bgo-osimis
parents:
diff changeset
18 switch (value)
6470248790db ongoing codegen work
bgo-osimis
parents:
diff changeset
19 {
6470248790db ongoing codegen work
bgo-osimis
parents:
diff changeset
20 case Color.Red:
6470248790db ongoing codegen work
bgo-osimis
parents:
diff changeset
21 return "Red";
6470248790db ongoing codegen work
bgo-osimis
parents:
diff changeset
22 case Color.Green:
6470248790db ongoing codegen work
bgo-osimis
parents:
diff changeset
23 return "Green";
6470248790db ongoing codegen work
bgo-osimis
parents:
diff changeset
24 case Color.Blue:
6470248790db ongoing codegen work
bgo-osimis
parents:
diff changeset
25 return "Blue";
6470248790db ongoing codegen work
bgo-osimis
parents:
diff changeset
26 default:
6470248790db ongoing codegen work
bgo-osimis
parents:
diff changeset
27 throw new Error(`Unrecognized Color value(${value})`);
6470248790db ongoing codegen work
bgo-osimis
parents:
diff changeset
28 }
6470248790db ongoing codegen work
bgo-osimis
parents:
diff changeset
29 }
6470248790db ongoing codegen work
bgo-osimis
parents:
diff changeset
30
6470248790db ongoing codegen work
bgo-osimis
parents:
diff changeset
31 let color: Color = Color.Red;
6470248790db ongoing codegen work
bgo-osimis
parents:
diff changeset
32
6470248790db ongoing codegen work
bgo-osimis
parents:
diff changeset
33 document.body.textContent = "<p>---------------------</p>"
6470248790db ongoing codegen work
bgo-osimis
parents:
diff changeset
34 document.body.textContent += "<p>********************************</p>"
6470248790db ongoing codegen work
bgo-osimis
parents:
diff changeset
35
6470248790db ongoing codegen work
bgo-osimis
parents:
diff changeset
36 class TestMessage {
6470248790db ongoing codegen work
bgo-osimis
parents:
diff changeset
37 s1: string;
6470248790db ongoing codegen work
bgo-osimis
parents:
diff changeset
38 s2: Array<string>;
6470248790db ongoing codegen work
bgo-osimis
parents:
diff changeset
39 s3: Array<Array<string>>;
6470248790db ongoing codegen work
bgo-osimis
parents:
diff changeset
40 s4: Map<string, number>;
6470248790db ongoing codegen work
bgo-osimis
parents:
diff changeset
41 s5: Map<number, Array<string>>;
6470248790db ongoing codegen work
bgo-osimis
parents:
diff changeset
42 s6: Color;
6470248790db ongoing codegen work
bgo-osimis
parents:
diff changeset
43 s7: boolean;
6470248790db ongoing codegen work
bgo-osimis
parents:
diff changeset
44 }
6470248790db ongoing codegen work
bgo-osimis
parents:
diff changeset
45
6470248790db ongoing codegen work
bgo-osimis
parents:
diff changeset
46 let tm = new TestMessage();
6470248790db ongoing codegen work
bgo-osimis
parents:
diff changeset
47 tm.s2 = new Array<string>()
6470248790db ongoing codegen work
bgo-osimis
parents:
diff changeset
48 tm.s2.push("toto");
6470248790db ongoing codegen work
bgo-osimis
parents:
diff changeset
49 tm.s2.push("toto2");
6470248790db ongoing codegen work
bgo-osimis
parents:
diff changeset
50 tm.s2.push("toto3");
6470248790db ongoing codegen work
bgo-osimis
parents:
diff changeset
51 tm.s4 = new Map<string, number>();
6470248790db ongoing codegen work
bgo-osimis
parents:
diff changeset
52 tm.s4["toto"] = 42;
6470248790db ongoing codegen work
bgo-osimis
parents:
diff changeset
53 tm.s4["toto"] = 1999;
6470248790db ongoing codegen work
bgo-osimis
parents:
diff changeset
54 tm.s4["tatata"] = 1999;
6470248790db ongoing codegen work
bgo-osimis
parents:
diff changeset
55 tm.s6 = Color.Red;
6470248790db ongoing codegen work
bgo-osimis
parents:
diff changeset
56 tm.s7 = true
6470248790db ongoing codegen work
bgo-osimis
parents:
diff changeset
57
6470248790db ongoing codegen work
bgo-osimis
parents:
diff changeset
58 let txt = JSON.stringify(tm)
6470248790db ongoing codegen work
bgo-osimis
parents:
diff changeset
59 let txtElem = document.createElement('textarea');
6470248790db ongoing codegen work
bgo-osimis
parents:
diff changeset
60 txtElem.value = txt;
6470248790db ongoing codegen work
bgo-osimis
parents:
diff changeset
61
6470248790db ongoing codegen work
bgo-osimis
parents:
diff changeset
62 document.body.appendChild(txtElem);
6470248790db ongoing codegen work
bgo-osimis
parents:
diff changeset
63
6470248790db ongoing codegen work
bgo-osimis
parents:
diff changeset
64 let greeter = new Greeter("world");
6470248790db ongoing codegen work
bgo-osimis
parents:
diff changeset
65
6470248790db ongoing codegen work
bgo-osimis
parents:
diff changeset
66 let button = document.createElement('button');
6470248790db ongoing codegen work
bgo-osimis
parents:
diff changeset
67 button.textContent = "Say Hello";
6470248790db ongoing codegen work
bgo-osimis
parents:
diff changeset
68 button.onclick = function() {
6470248790db ongoing codegen work
bgo-osimis
parents:
diff changeset
69 alert(greeter.greet());
6470248790db ongoing codegen work
bgo-osimis
parents:
diff changeset
70 }
6470248790db ongoing codegen work
bgo-osimis
parents:
diff changeset
71
6470248790db ongoing codegen work
bgo-osimis
parents:
diff changeset
72 document.body.appendChild(button);