Skip to content

Commit 015c2c1

Browse files
author
Arthur Ozga
committed
Merge branch 'master' into mergedDeclarationClassInterface
2 parents 365ea3d + ca4bf6b commit 015c2c1

22 files changed

+340
-117
lines changed

src/compiler/checker.ts

Lines changed: 76 additions & 73 deletions
Large diffs are not rendered by default.

src/compiler/commandLineParser.ts

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -349,7 +349,7 @@ module ts {
349349

350350
return {
351351
options: getCompilerOptions(),
352-
fileNames: getFiles(),
352+
fileNames: getFileNames(),
353353
errors
354354
};
355355

@@ -395,23 +395,24 @@ module ts {
395395
return options;
396396
}
397397

398-
function getFiles(): string[] {
399-
var files: string[] = [];
398+
function getFileNames(): string[] {
399+
var fileNames: string[] = [];
400400
if (hasProperty(json, "files")) {
401401
if (json["files"] instanceof Array) {
402-
var files = map(<string[]>json["files"], s => combinePaths(basePath, s));
402+
fileNames = map(<string[]>json["files"], s => combinePaths(basePath, s));
403403
}
404404
}
405405
else {
406-
var sysFiles = host.readDirectory(basePath, ".ts");
406+
var exclude = json["exclude"] instanceof Array ? map(<string[]>json["exclude"], normalizeSlashes) : undefined;
407+
var sysFiles = host.readDirectory(basePath, ".ts", exclude);
407408
for (var i = 0; i < sysFiles.length; i++) {
408409
var name = sysFiles[i];
409410
if (!fileExtensionIs(name, ".d.ts") || !contains(sysFiles, name.substr(0, name.length - 5) + ".ts")) {
410-
files.push(name);
411+
fileNames.push(name);
411412
}
412413
}
413414
}
414-
return files;
415+
return fileNames;
415416
}
416417
}
417418
}

src/compiler/diagnosticInformationMap.generated.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -530,7 +530,7 @@ module ts {
530530
Object_literal_s_property_0_implicitly_has_an_1_type: { code: 7018, category: DiagnosticCategory.Error, key: "Object literal's property '{0}' implicitly has an '{1}' type." },
531531
Rest_parameter_0_implicitly_has_an_any_type: { code: 7019, category: DiagnosticCategory.Error, key: "Rest parameter '{0}' implicitly has an 'any[]' type." },
532532
Call_signature_which_lacks_return_type_annotation_implicitly_has_an_any_return_type: { code: 7020, category: DiagnosticCategory.Error, key: "Call signature, which lacks return-type annotation, implicitly has an 'any' return type." },
533-
_0_implicitly_has_type_any_because_it_is_does_not_have_a_type_annotation_and_is_referenced_directly_or_indirectly_in_its_own_initializer: { code: 7022, category: DiagnosticCategory.Error, key: "'{0}' implicitly has type 'any' because it is does not have a type annotation and is referenced directly or indirectly in its own initializer." },
533+
_0_implicitly_has_type_any_because_it_does_not_have_a_type_annotation_and_is_referenced_directly_or_indirectly_in_its_own_initializer: { code: 7022, category: DiagnosticCategory.Error, key: "'{0}' implicitly has type 'any' because it does not have a type annotation and is referenced directly or indirectly in its own initializer." },
534534
_0_implicitly_has_return_type_any_because_it_does_not_have_a_return_type_annotation_and_is_referenced_directly_or_indirectly_in_one_of_its_return_expressions: { code: 7023, category: DiagnosticCategory.Error, key: "'{0}' implicitly has return type 'any' because it does not have a return type annotation and is referenced directly or indirectly in one of its return expressions." },
535535
Function_implicitly_has_return_type_any_because_it_does_not_have_a_return_type_annotation_and_is_referenced_directly_or_indirectly_in_one_of_its_return_expressions: { code: 7024, category: DiagnosticCategory.Error, key: "Function implicitly has return type 'any' because it does not have a return type annotation and is referenced directly or indirectly in one of its return expressions." },
536536
Generator_implicitly_has_type_0_because_it_does_not_yield_any_values_Consider_supplying_a_return_type: { code: 7025, category: DiagnosticCategory.Error, key: "Generator implicitly has type '{0}' because it does not yield any values. Consider supplying a return type." },

src/compiler/diagnosticMessages.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2110,7 +2110,7 @@
21102110
"category": "Error",
21112111
"code": 7020
21122112
},
2113-
"'{0}' implicitly has type 'any' because it is does not have a type annotation and is referenced directly or indirectly in its own initializer.": {
2113+
"'{0}' implicitly has type 'any' because it does not have a type annotation and is referenced directly or indirectly in its own initializer.": {
21142114
"category": "Error",
21152115
"code": 7022
21162116
},

src/compiler/sys.ts

Lines changed: 31 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ module ts {
1515
createDirectory(path: string): void;
1616
getExecutingFilePath(): string;
1717
getCurrentDirectory(): string;
18-
readDirectory(path: string, extension?: string): string[];
18+
readDirectory(path: string, extension?: string, exclude?: string[]): string[];
1919
getMemoryUsage?(): number;
2020
exit(exitCode?: number): void;
2121
}
@@ -109,29 +109,38 @@ module ts {
109109
}
110110
}
111111

112-
function getNames(collection: any): string[] {
112+
function getCanonicalPath(path: string): string {
113+
return path.toLowerCase();
114+
}
115+
116+
function getNames(collection: any): string[]{
113117
var result: string[] = [];
114118
for (var e = new Enumerator(collection); !e.atEnd(); e.moveNext()) {
115119
result.push(e.item().Name);
116120
}
117121
return result.sort();
118122
}
119123

120-
function readDirectory(path: string, extension?: string): string[] {
124+
function readDirectory(path: string, extension?: string, exclude?: string[]): string[] {
121125
var result: string[] = [];
126+
exclude = map(exclude, s => getCanonicalPath(combinePaths(path, s)));
122127
visitDirectory(path);
123128
return result;
124129
function visitDirectory(path: string) {
125130
var folder = fso.GetFolder(path || ".");
126131
var files = getNames(folder.files);
127-
for (let name of files) {
128-
if (!extension || fileExtensionIs(name, extension)) {
129-
result.push(combinePaths(path, name));
132+
for (let current of files) {
133+
let name = combinePaths(path, current);
134+
if ((!extension || fileExtensionIs(name, extension)) && !contains(exclude, getCanonicalPath(name))) {
135+
result.push(name);
130136
}
131137
}
132138
var subfolders = getNames(folder.subfolders);
133139
for (let current of subfolders) {
134-
visitDirectory(combinePaths(path, current));
140+
let name = combinePaths(path, current);
141+
if (!contains(exclude, getCanonicalPath(name))) {
142+
visitDirectory(name);
143+
}
135144
}
136145
}
137146
}
@@ -222,23 +231,30 @@ module ts {
222231
_fs.writeFileSync(fileName, data, "utf8");
223232
}
224233

225-
function readDirectory(path: string, extension?: string): string[] {
234+
function getCanonicalPath(path: string): string {
235+
return useCaseSensitiveFileNames ? path.toLowerCase() : path;
236+
}
237+
238+
function readDirectory(path: string, extension?: string, exclude?: string[]): string[] {
226239
var result: string[] = [];
240+
exclude = map(exclude, s => getCanonicalPath(combinePaths(path, s)));
227241
visitDirectory(path);
228242
return result;
229243
function visitDirectory(path: string) {
230244
var files = _fs.readdirSync(path || ".").sort();
231245
var directories: string[] = [];
232246
for (let current of files) {
233247
var name = combinePaths(path, current);
234-
var stat = _fs.statSync(name);
235-
if (stat.isFile()) {
236-
if (!extension || fileExtensionIs(name, extension)) {
237-
result.push(name);
248+
if (!contains(exclude, getCanonicalPath(name))) {
249+
var stat = _fs.statSync(name);
250+
if (stat.isFile()) {
251+
if (!extension || fileExtensionIs(name, extension)) {
252+
result.push(name);
253+
}
254+
}
255+
else if (stat.isDirectory()) {
256+
directories.push(name);
238257
}
239-
}
240-
else if (stat.isDirectory()) {
241-
directories.push(name);
242258
}
243259
}
244260
for (let current of directories) {

src/compiler/types.ts

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1168,7 +1168,7 @@ module ts {
11681168
}
11691169

11701170
export interface ParseConfigHost {
1171-
readDirectory(rootDir: string, extension: string): string[];
1171+
readDirectory(rootDir: string, extension: string, exclude: string[]): string[];
11721172
}
11731173

11741174
export interface WriteFileCallback {
@@ -1582,14 +1582,15 @@ module ts {
15821582
Tuple = 0x00002000, // Tuple
15831583
Union = 0x00004000, // Union
15841584
Anonymous = 0x00008000, // Anonymous
1585+
Instantiated = 0x00010000, // Instantiated anonymous type
15851586
/* @internal */
1586-
FromSignature = 0x00010000, // Created for signature assignment check
1587-
ObjectLiteral = 0x00020000, // Originates in an object literal
1587+
FromSignature = 0x00020000, // Created for signature assignment check
1588+
ObjectLiteral = 0x00040000, // Originates in an object literal
15881589
/* @internal */
1589-
ContainsUndefinedOrNull = 0x00040000, // Type is or contains Undefined or Null type
1590+
ContainsUndefinedOrNull = 0x00080000, // Type is or contains Undefined or Null type
15901591
/* @internal */
1591-
ContainsObjectLiteral = 0x00080000, // Type is or contains object literal type
1592-
ESSymbol = 0x00100000, // Type of symbol primitive introduced in ES6
1592+
ContainsObjectLiteral = 0x00100000, // Type is or contains object literal type
1593+
ESSymbol = 0x00200000, // Type of symbol primitive introduced in ES6
15931594

15941595
/* @internal */
15951596
Intrinsic = Any | String | Number | Boolean | ESSymbol | Void | Undefined | Null,
@@ -1674,8 +1675,8 @@ module ts {
16741675
properties: Symbol[]; // Properties
16751676
callSignatures: Signature[]; // Call signatures of type
16761677
constructSignatures: Signature[]; // Construct signatures of type
1677-
stringIndexType: Type; // String index type
1678-
numberIndexType: Type; // Numeric index type
1678+
stringIndexType?: Type; // String index type
1679+
numberIndexType?: Type; // Numeric index type
16791680
}
16801681

16811682
// Just a place to cache element types of iterables and iterators
@@ -1731,7 +1732,6 @@ module ts {
17311732
/* @internal */
17321733
export interface TypeMapper {
17331734
(t: TypeParameter): Type;
1734-
mappings?: Map<Type>; // Type mapping cache
17351735
}
17361736

17371737
/* @internal */
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
//// [cyclicGenericTypeInstantiation.ts]
2+
function foo<T>() {
3+
var z = foo<typeof y>();
4+
var y: {
5+
y2: typeof z
6+
};
7+
return y;
8+
}
9+
10+
11+
function bar<T>() {
12+
var z = bar<typeof y>();
13+
var y: {
14+
y2: typeof z;
15+
}
16+
return y;
17+
}
18+
19+
var a = foo<number>();
20+
var b = bar<number>();
21+
a = b;
22+
23+
24+
//// [cyclicGenericTypeInstantiation.js]
25+
function foo() {
26+
var z = foo();
27+
var y;
28+
return y;
29+
}
30+
function bar() {
31+
var z = bar();
32+
var y;
33+
return y;
34+
}
35+
var a = foo();
36+
var b = bar();
37+
a = b;
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
=== tests/cases/compiler/cyclicGenericTypeInstantiation.ts ===
2+
function foo<T>() {
3+
>foo : Symbol(foo, Decl(cyclicGenericTypeInstantiation.ts, 0, 0))
4+
>T : Symbol(T, Decl(cyclicGenericTypeInstantiation.ts, 0, 13))
5+
6+
var z = foo<typeof y>();
7+
>z : Symbol(z, Decl(cyclicGenericTypeInstantiation.ts, 1, 7))
8+
>foo : Symbol(foo, Decl(cyclicGenericTypeInstantiation.ts, 0, 0))
9+
>y : Symbol(y, Decl(cyclicGenericTypeInstantiation.ts, 2, 7))
10+
11+
var y: {
12+
>y : Symbol(y, Decl(cyclicGenericTypeInstantiation.ts, 2, 7))
13+
14+
y2: typeof z
15+
>y2 : Symbol(y2, Decl(cyclicGenericTypeInstantiation.ts, 2, 12))
16+
>z : Symbol(z, Decl(cyclicGenericTypeInstantiation.ts, 1, 7))
17+
18+
};
19+
return y;
20+
>y : Symbol(y, Decl(cyclicGenericTypeInstantiation.ts, 2, 7))
21+
}
22+
23+
24+
function bar<T>() {
25+
>bar : Symbol(bar, Decl(cyclicGenericTypeInstantiation.ts, 6, 1))
26+
>T : Symbol(T, Decl(cyclicGenericTypeInstantiation.ts, 9, 13))
27+
28+
var z = bar<typeof y>();
29+
>z : Symbol(z, Decl(cyclicGenericTypeInstantiation.ts, 10, 7))
30+
>bar : Symbol(bar, Decl(cyclicGenericTypeInstantiation.ts, 6, 1))
31+
>y : Symbol(y, Decl(cyclicGenericTypeInstantiation.ts, 11, 7))
32+
33+
var y: {
34+
>y : Symbol(y, Decl(cyclicGenericTypeInstantiation.ts, 11, 7))
35+
36+
y2: typeof z;
37+
>y2 : Symbol(y2, Decl(cyclicGenericTypeInstantiation.ts, 11, 12))
38+
>z : Symbol(z, Decl(cyclicGenericTypeInstantiation.ts, 10, 7))
39+
}
40+
return y;
41+
>y : Symbol(y, Decl(cyclicGenericTypeInstantiation.ts, 11, 7))
42+
}
43+
44+
var a = foo<number>();
45+
>a : Symbol(a, Decl(cyclicGenericTypeInstantiation.ts, 17, 3))
46+
>foo : Symbol(foo, Decl(cyclicGenericTypeInstantiation.ts, 0, 0))
47+
48+
var b = bar<number>();
49+
>b : Symbol(b, Decl(cyclicGenericTypeInstantiation.ts, 18, 3))
50+
>bar : Symbol(bar, Decl(cyclicGenericTypeInstantiation.ts, 6, 1))
51+
52+
a = b;
53+
>a : Symbol(a, Decl(cyclicGenericTypeInstantiation.ts, 17, 3))
54+
>b : Symbol(b, Decl(cyclicGenericTypeInstantiation.ts, 18, 3))
55+
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
=== tests/cases/compiler/cyclicGenericTypeInstantiation.ts ===
2+
function foo<T>() {
3+
>foo : <T>() => { y2: any; }
4+
>T : T
5+
6+
var z = foo<typeof y>();
7+
>z : { y2: any; }
8+
>foo<typeof y>() : { y2: any; }
9+
>foo : <T>() => { y2: any; }
10+
>y : { y2: any; }
11+
12+
var y: {
13+
>y : { y2: any; }
14+
15+
y2: typeof z
16+
>y2 : { y2: any; }
17+
>z : { y2: any; }
18+
19+
};
20+
return y;
21+
>y : { y2: any; }
22+
}
23+
24+
25+
function bar<T>() {
26+
>bar : <T>() => { y2: any; }
27+
>T : T
28+
29+
var z = bar<typeof y>();
30+
>z : { y2: any; }
31+
>bar<typeof y>() : { y2: any; }
32+
>bar : <T>() => { y2: any; }
33+
>y : { y2: any; }
34+
35+
var y: {
36+
>y : { y2: any; }
37+
38+
y2: typeof z;
39+
>y2 : { y2: any; }
40+
>z : { y2: any; }
41+
}
42+
return y;
43+
>y : { y2: any; }
44+
}
45+
46+
var a = foo<number>();
47+
>a : { y2: any; }
48+
>foo<number>() : { y2: any; }
49+
>foo : <T>() => { y2: any; }
50+
51+
var b = bar<number>();
52+
>b : { y2: any; }
53+
>bar<number>() : { y2: any; }
54+
>bar : <T>() => { y2: any; }
55+
56+
a = b;
57+
>a = b : { y2: any; }
58+
>a : { y2: any; }
59+
>b : { y2: any; }
60+
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
tests/cases/conformance/es6/for-ofStatements/for-of32.ts(1,10): error TS7022: 'v' implicitly has type 'any' because it is does not have a type annotation and is referenced directly or indirectly in its own initializer.
1+
tests/cases/conformance/es6/for-ofStatements/for-of32.ts(1,10): error TS7022: 'v' implicitly has type 'any' because it does not have a type annotation and is referenced directly or indirectly in its own initializer.
22

33

44
==== tests/cases/conformance/es6/for-ofStatements/for-of32.ts (1 errors) ====
55
for (var v of v) { }
66
~
7-
!!! error TS7022: 'v' implicitly has type 'any' because it is does not have a type annotation and is referenced directly or indirectly in its own initializer.
7+
!!! error TS7022: 'v' implicitly has type 'any' because it does not have a type annotation and is referenced directly or indirectly in its own initializer.

0 commit comments

Comments
 (0)