This repository was archived by the owner on Dec 5, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 13
/
Copy pathtest.ts
181 lines (143 loc) · 2.67 KB
/
test.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
// Copyright 2017 chaishushan{AT}gmail.com. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
const fs = require('fs')
import * as fs2 from 'fs'
import {xxx} from 'fs'
namespace Math {
export function add(x, y) { ... }
}
type Maybe<T> = T | void;
function isDefined<T>(x: Maybe<T>): x is T {
return x !== undefined && x !== null;
}
async function printDelayed(elements: string[]) {
for(const element of elements) {
await delay(200);
console.log(element);
}
}
let symbol = new Symbol();
let map = new Map();
let list: Array<number> = [1, 2, 3];
let a: any = null
let u: undefined = undefined;
function error(message: string): never {
throw new Error(message);
}
function f1() {}
function f2(){}
export function f3() {}
export function f4(x: number) {
if(1 == 2) {
//
}
}
class class1{}
class class2{
name = ''
}
export class class3{
name = ''
}
class class4 {
a = 1
b:number = 2
c? = 3
get d():number{ return 1 }
set d(x: number){}
readonly e = 1
public f = 1
private g = 1
protected h = 1
public readonly i = 1
get(){}
set(){}
@f4
foo() {}
}
export class class5 implements pkg.interfacex {
constructor() {
iffoor()
// bug
foo()
foo22()
// bug
if(1 == 2) {
//
}
for() {}
switch() {}
forfor()
// bug
let x = {
a: 1,
b: 2,
}
//
}
method() {
}
}
export class class6 extends pkg.classx {
constructor() {
//
}
}
export class class7 extends pkg.classx[''] {
constructor() {
//
}
}
function resolveAfter2Seconds(x) {
return new Promise(resolve => {
setTimeout(() => {
resolve(x);
}, 2000);
});
}
async function async_f1() {
var x = await resolveAfter2Seconds(10);
console.log(x); // 10
}
export async function async_f2() {
var x = await resolveAfter2Seconds(10);
console.log(x); // 10
}
// best: use tab as indent
interface StringerTab {
String(): string
}
// WARNNING: indent only support tab/2space/4space
// regexp: ^(\t|[ ]{2,4})
interface Stringer2space {
String(): string
}
interface Stringer3space {
String(): string
}
interface Stringer4space {
String(): string
}
class Stringer2spaceClass {
String(): string {
// WARNNING: also show in funclist!
notMethod()
}
}
// WARNNING: funclist, don't support 1space indent
interface Stringer1 {
String(): string
}
global['aa'] = 'aa'
process.argv
console.log(1)
setTimeout()
clearTimeout()
setInterval()
clearInterval()
module
exports.hello = function(){}
__filename
__dirname
require