on master help sign in
Add basic typescript test file
commiteb3e2dca2479f73d8d9a62070d9c95eb08d6bf6a authorparksb <parkgds@gmail.com> dateSun 4 Oct 2020, 18:04 (6 years ago) parent2d9b936
3 files changed+237
tests/syntax-tests/highlighted/TypeScript/example.ts+110 tests/syntax-tests/source/TypeScript/LICENSE.md+17 tests/syntax-tests/source/TypeScript/example.ts+110
tests/syntax-tests/highlighted/TypeScript/example.tsnew file+110
@@ -0,0 +1,110 @@
1+let letNumber = 10;
2+const constNumber = 20;
3+
4+const bool: boolean = true;
5+const list: number[] = [1, 2, 3];
6+const array: Array<number> = [1, 2, 3];
7+const pair: [string, number] = ['hello', 10];
8+
9+for (let i = 0; i < list.length; i += 1) {
10+ console.log(list[i]);
11+}
12+
13+if (bool) {
14+ console.log('True');
15+} else {
16+ console.log('False');
17+}
18+
19+const str: string = 'Jake';
20+const templateStr: string = `Hello, ${str}!`;
21+
22+// A comment
23+
24+/*
25+ * Multiline comments
26+ * Multiline comments
27+ */
28+
29+interface SquareConfig {
30+ label: string;
31+ color?: string;
32+ width?: number;
33+ [propName: string]: any;
34+}
35+
36+interface SearchFunc {
37+ (source: string, subString: string): boolean;
38+}
39+
40+enum Color {
41+ Red,
42+ Green,
43+}
44+
45+type Easing = "ease-in" | "ease-out" | "ease-in-out";
46+
47+class Greeter {
48+ private readonly greeting: string;
49+
50+ constructor(message: string) {
51+ this.greeting = message;
52+ }
53+
54+ greet() {
55+ return "Hello, " + this.greeting;
56+ }
57+}
58+
59+let greeter = new Greeter("world");
60+
61+class Animal {
62+ move(distanceInMeters: number = 0) {
63+ console.log(`Animal moved ${distanceInMeters}m.`);
64+ }
65+}
66+
67+class Dog extends Animal {
68+ bark() {
69+ console.log("Woof! Woof!");
70+ }
71+}
72+
73+const dog = new Dog();
74+dog.bark();
75+dog.move(10);
76+dog.bark();
77+
78+class Point {
79+ x: number;
80+ y: number;
81+}
82+
83+interface Point3d extends Point {
84+ z: number;
85+}
86+
87+let point3d: Point3d = { x: 1, y: 2, z: 3 };
88+
89+function add(x, y) {
90+ return x + y;
91+}
92+
93+let myAdd = function (x, y) {
94+ return x + y;
95+};
96+
97+(function () {
98+ console.log('IIFE');
99+}());
100+
101+function identity<T>(arg: T): T {
102+ return arg;
103+}
104+
105+let myIdentity: <T>(arg: T) => T = identity;
106+
107+class GenericNumber<T> {
108+ zeroValue: T;
109+ add: (x: T, y: T) => T;
110+}
tests/syntax-tests/source/TypeScript/LICENSE.mdnew file+17
@@ -0,0 +1,17 @@
1+The MIT License (MIT)
2+Copyright (c) Microsoft Corporation
3+
4+Permission is hereby granted, free of charge, to any person obtaining a copy of this software and
5+associated documentation files (the "Software"), to deal in the Software without restriction,
6+including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense,
7+and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so,
8+subject to the following conditions:
9+
10+The above copyright notice and this permission notice shall be included in all copies or substantial
11+portions of the Software.
12+
13+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT
14+NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
15+IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
16+WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
17+SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
tests/syntax-tests/source/TypeScript/example.tsnew file+110
@@ -0,0 +1,110 @@
1+let letNumber = 10;
2+const constNumber = 20;
3+
4+const bool: boolean = true;
5+const list: number[] = [1, 2, 3];
6+const array: Array<number> = [1, 2, 3];
7+const pair: [string, number] = ['hello', 10];
8+
9+for (let i = 0; i < list.length; i += 1) {
10+ console.log(list[i]);
11+}
12+
13+if (bool) {
14+ console.log('True');
15+} else {
16+ console.log('False');
17+}
18+
19+const str: string = 'Jake';
20+const templateStr: string = `Hello, ${str}!`;
21+
22+// A comment
23+
24+/*
25+ * Multiline comments
26+ * Multiline comments
27+ */
28+
29+interface SquareConfig {
30+ label: string;
31+ color?: string;
32+ width?: number;
33+ [propName: string]: any;
34+}
35+
36+interface SearchFunc {
37+ (source: string, subString: string): boolean;
38+}
39+
40+enum Color {
41+ Red,
42+ Green,
43+}
44+
45+type Easing = "ease-in" | "ease-out" | "ease-in-out";
46+
47+class Greeter {
48+ private readonly greeting: string;
49+
50+ constructor(message: string) {
51+ this.greeting = message;
52+ }
53+
54+ greet() {
55+ return "Hello, " + this.greeting;
56+ }
57+}
58+
59+let greeter = new Greeter("world");
60+
61+class Animal {
62+ move(distanceInMeters: number = 0) {
63+ console.log(`Animal moved ${distanceInMeters}m.`);
64+ }
65+}
66+
67+class Dog extends Animal {
68+ bark() {
69+ console.log("Woof! Woof!");
70+ }
71+}
72+
73+const dog = new Dog();
74+dog.bark();
75+dog.move(10);
76+dog.bark();
77+
78+class Point {
79+ x: number;
80+ y: number;
81+}
82+
83+interface Point3d extends Point {
84+ z: number;
85+}
86+
87+let point3d: Point3d = { x: 1, y: 2, z: 3 };
88+
89+function add(x, y) {
90+ return x + y;
91+}
92+
93+let myAdd = function (x, y) {
94+ return x + y;
95+};
96+
97+(function () {
98+ console.log('IIFE');
99+}());
100+
101+function identity<T>(arg: T): T {
102+ return arg;
103+}
104+
105+let myIdentity: <T>(arg: T) => T = identity;
106+
107+class GenericNumber<T> {
108+ zeroValue: T;
109+ add: (x: T, y: T) => T;
110+}