Skip to content

Commit 783b124

Browse files
committed
Added Tests
1 parent d9bb1c1 commit 783b124

5,913 files changed

Lines changed: 162348 additions & 0 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
//@target: ES5, ES2015
2+
interface SymbolConstructor {
3+
foo: string;
4+
}
5+
var Symbol: SymbolConstructor;
6+
7+
var obj = {
8+
[Symbol.foo]: 0
9+
}
10+
11+
obj[Symbol.foo];
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
// @strict: false
2+
//@target: ES5, ES2015
3+
namespace M {
4+
var Symbol: any;
5+
6+
export class C {
7+
[Symbol.iterator]() { }
8+
}
9+
(new C)[Symbol.iterator];
10+
}
11+
12+
(new M.C)[Symbol.iterator];
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
//@target: ES5, ES2015
2+
var Symbol: any;
3+
4+
class C {
5+
[Symbol.iterator]() { }
6+
}
7+
8+
(new C)[Symbol.iterator]
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
//@target: ES5, ES2015
2+
var Symbol: { iterator: string };
3+
4+
class C {
5+
[Symbol.iterator]() { }
6+
}
7+
8+
(new C)[Symbol.iterator]
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
//@target: ES5, ES2015
2+
declare var Symbol: { iterator: symbol };
3+
4+
class C {
5+
[Symbol.iterator]() { }
6+
}
7+
8+
(new C)[Symbol.iterator](0) // Should error
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
//@target: ES5, ES2015
2+
class C {
3+
[Symbol.iterator]() { }
4+
}
5+
6+
(new C)[Symbol.iterator]
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
//@target: ES5, ES2015
2+
var Symbol: { iterator: any };
3+
4+
class C {
5+
[Symbol.iterator]() { }
6+
}
7+
8+
(new C)[Symbol.iterator]
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
//@target: ES5, ES2015
2+
var s: symbol;
3+
s.toString();
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
// @target: es2015
2+
// @noPropertyAccessFromIndexSignature: true
3+
4+
interface A {
5+
foo: string
6+
}
7+
8+
interface B {
9+
[k: string]: string
10+
}
11+
12+
interface C {
13+
foo: string
14+
[k: string]: string
15+
}
16+
17+
declare const a: A;
18+
declare const b: B;
19+
declare const c: C;
20+
declare const d: C | undefined;
21+
22+
// access property
23+
a.foo;
24+
a["foo"]
25+
26+
// access index signature
27+
b.foo;
28+
b["foo"];
29+
30+
// access property
31+
c.foo;
32+
c["foo"]
33+
34+
// access index signature
35+
c.bar;
36+
c["bar"];
37+
38+
// optional access property
39+
d?.foo;
40+
d?.["foo"]
41+
42+
// optional access index signature
43+
d?.bar;
44+
d?.["bar"];
Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
// @target: es2015
2+
// @strict: false
3+
// Ambient variable without type annotation
4+
declare var n;
5+
6+
// Ambient variable with type annotation
7+
declare var m: string;
8+
9+
// Ambient function with no type annotations
10+
declare function fn1();
11+
12+
// Ambient function with type annotations
13+
declare function fn2(n: string): number;
14+
15+
// Ambient function with valid overloads
16+
declare function fn3(n: string): number;
17+
declare function fn4(n: number, y: number): string;
18+
19+
// Ambient function with optional parameters
20+
declare function fn5(x, y?);
21+
declare function fn6(e?);
22+
declare function fn7(x, y?, ...z);
23+
declare function fn8(y?, ...z: number[]);
24+
declare function fn9(...q: {}[]);
25+
declare function fn10<T>(...q: T[]);
26+
27+
// Ambient class
28+
declare class cls {
29+
constructor();
30+
method(): cls;
31+
static static(p): number;
32+
static q;
33+
private fn();
34+
private static fns();
35+
}
36+
37+
// Ambient enum
38+
declare enum E1 {
39+
x,
40+
y,
41+
z
42+
}
43+
44+
// Ambient enum with integer literal initializer
45+
declare enum E2 {
46+
q,
47+
a = 1,
48+
b,
49+
c = 2,
50+
d
51+
}
52+
53+
// Ambient enum members are always exported with or without export keyword
54+
declare enum E3 {
55+
A
56+
}
57+
declare namespace E3 {
58+
var B;
59+
}
60+
var x = E3.B;
61+
62+
// Ambient module
63+
declare namespace M1 {
64+
var x;
65+
function fn(): number;
66+
}
67+
68+
// Ambient module members are always exported with or without export keyword
69+
var p = M1.x;
70+
var q = M1.fn();
71+
72+
// Ambient external module in the global module
73+
// Ambient external module with a string literal name that is a top level external module name
74+
declare module 'external1' {
75+
var q;
76+
}
77+

0 commit comments

Comments
 (0)