Skip to content

Commit 7f6faaa

Browse files
committed
Merge branch 'master' into fix11295
2 parents 40e99e7 + 63160de commit 7f6faaa

File tree

254 files changed

+10845
-726
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

254 files changed

+10845
-726
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ tests/cases/**/*.js.map
4141
scripts/debug.bat
4242
scripts/run.bat
4343
scripts/word2md.js
44+
scripts/buildProtocol.js
4445
scripts/ior.js
4546
scripts/buildProtocol.js
4647
scripts/*.js.map

Jakefile.js

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -70,13 +70,14 @@ var compilerSources = [
7070
"visitor.ts",
7171
"transformers/destructuring.ts",
7272
"transformers/ts.ts",
73-
"transformers/module/es6.ts",
73+
"transformers/module/es2015.ts",
7474
"transformers/module/system.ts",
7575
"transformers/module/module.ts",
7676
"transformers/jsx.ts",
77-
"transformers/es7.ts",
77+
"transformers/es2017.ts",
78+
"transformers/es2016.ts",
79+
"transformers/es2015.ts",
7880
"transformers/generators.ts",
79-
"transformers/es6.ts",
8081
"transformer.ts",
8182
"sourcemap.ts",
8283
"comments.ts",
@@ -104,13 +105,14 @@ var servicesSources = [
104105
"visitor.ts",
105106
"transformers/destructuring.ts",
106107
"transformers/ts.ts",
107-
"transformers/module/es6.ts",
108+
"transformers/module/es2015.ts",
108109
"transformers/module/system.ts",
109110
"transformers/module/module.ts",
110111
"transformers/jsx.ts",
111-
"transformers/es7.ts",
112+
"transformers/es2017.ts",
113+
"transformers/es2016.ts",
114+
"transformers/es2015.ts",
112115
"transformers/generators.ts",
113-
"transformers/es6.ts",
114116
"transformer.ts",
115117
"sourcemap.ts",
116118
"comments.ts",

scripts/buildProtocol.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,14 @@ class DeclarationsWalker {
4242
return;
4343
}
4444
// splice declaration in final d.ts file
45-
const text = decl.getFullText();
45+
let text = decl.getFullText();
46+
if (decl.kind === ts.SyntaxKind.EnumDeclaration && !(decl.flags & ts.NodeFlags.Const)) {
47+
// patch enum declaration to make them constan
48+
const declStart = decl.getStart() - decl.getFullStart();
49+
const prefix = text.substring(0, declStart);
50+
const suffix = text.substring(declStart + "enum".length, decl.getEnd() - decl.getFullStart());
51+
text = prefix + "const enum" + suffix;
52+
}
4653
this.text += `${text}\n`;
4754

4855
// recursively pull all dependencies into result dts file

src/compiler/binder.ts

Lines changed: 80 additions & 35 deletions
Large diffs are not rendered by default.

src/compiler/binder.ts.orig

Lines changed: 3181 additions & 0 deletions
Large diffs are not rendered by default.

src/compiler/checker.ts

Lines changed: 253 additions & 79 deletions
Large diffs are not rendered by default.

src/compiler/commandLineParser.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ namespace ts {
101101
"amd": ModuleKind.AMD,
102102
"system": ModuleKind.System,
103103
"umd": ModuleKind.UMD,
104-
"es6": ModuleKind.ES6,
104+
"es6": ModuleKind.ES2015,
105105
"es2015": ModuleKind.ES2015,
106106
}),
107107
description: Diagnostics.Specify_module_code_generation_Colon_commonjs_amd_system_umd_or_es2015,
@@ -261,8 +261,10 @@ namespace ts {
261261
type: createMap({
262262
"es3": ScriptTarget.ES3,
263263
"es5": ScriptTarget.ES5,
264-
"es6": ScriptTarget.ES6,
264+
"es6": ScriptTarget.ES2015,
265265
"es2015": ScriptTarget.ES2015,
266+
"es2016": ScriptTarget.ES2016,
267+
"es2017": ScriptTarget.ES2017,
266268
}),
267269
description: Diagnostics.Specify_ECMAScript_target_version_Colon_ES3_default_ES5_or_ES2015,
268270
paramType: Diagnostics.VERSION,

src/compiler/core.ts

Lines changed: 35 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -268,13 +268,33 @@ namespace ts {
268268
if (array) {
269269
result = [];
270270
for (let i = 0; i < array.length; i++) {
271-
const v = array[i];
272-
result.push(f(v, i));
271+
result.push(f(array[i], i));
273272
}
274273
}
275274
return result;
276275
}
277276

277+
// Maps from T to T and avoids allocation if all elements map to themselves
278+
export function sameMap<T>(array: T[], f: (x: T, i: number) => T): T[] {
279+
let result: T[];
280+
if (array) {
281+
for (let i = 0; i < array.length; i++) {
282+
if (result) {
283+
result.push(f(array[i], i));
284+
}
285+
else {
286+
const item = array[i];
287+
const mapped = f(item, i);
288+
if (item !== mapped) {
289+
result = array.slice(0, i);
290+
result.push(mapped);
291+
}
292+
}
293+
}
294+
}
295+
return result || array;
296+
}
297+
278298
/**
279299
* Flattens an array containing a mix of array or non-array elements.
280300
*
@@ -402,6 +422,17 @@ namespace ts {
402422
return result;
403423
}
404424

425+
export function some<T>(array: T[], predicate?: (value: T) => boolean): boolean {
426+
if (array) {
427+
for (const v of array) {
428+
if (!predicate || predicate(v)) {
429+
return true;
430+
}
431+
}
432+
}
433+
return false;
434+
}
435+
405436
export function concatenate<T>(array1: T[], array2: T[]): T[] {
406437
if (!array2 || !array2.length) return array1;
407438
if (!array1 || !array1.length) return array2;
@@ -1181,7 +1212,7 @@ namespace ts {
11811212

11821213
/**
11831214
* Returns the path except for its basename. Eg:
1184-
*
1215+
*
11851216
* /path/to/file.ext -> /path/to
11861217
*/
11871218
export function getDirectoryPath(path: Path): Path;
@@ -1207,7 +1238,7 @@ namespace ts {
12071238
export function getEmitModuleKind(compilerOptions: CompilerOptions) {
12081239
return typeof compilerOptions.module === "number" ?
12091240
compilerOptions.module :
1210-
getEmitScriptTarget(compilerOptions) === ScriptTarget.ES6 ? ModuleKind.ES6 : ModuleKind.CommonJS;
1241+
getEmitScriptTarget(compilerOptions) >= ScriptTarget.ES2015 ? ModuleKind.ES2015 : ModuleKind.CommonJS;
12111242
}
12121243

12131244
/* @internal */

src/compiler/diagnosticMessages.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2961,7 +2961,7 @@
29612961
"category": "Error",
29622962
"code": 7033
29632963
},
2964-
"Variable '{0}' implicitly has type 'any' in some locations where its type cannot be determined.": {
2964+
"Variable '{0}' implicitly has type '{1}' in some locations where its type cannot be determined.": {
29652965
"category": "Error",
29662966
"code": 7034
29672967
},

src/compiler/emitter.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2182,7 +2182,7 @@ const _super = (function (geti, seti) {
21822182

21832183
// Only Emit __extends function when target ES5.
21842184
// For target ES6 and above, we can emit classDeclaration as is.
2185-
if ((languageVersion < ScriptTarget.ES6) && (!extendsEmitted && node.flags & NodeFlags.HasClassExtends)) {
2185+
if ((languageVersion < ScriptTarget.ES2015) && (!extendsEmitted && node.flags & NodeFlags.HasClassExtends)) {
21862186
writeLines(extendsHelper);
21872187
extendsEmitted = true;
21882188
helpersEmitted = true;
@@ -2209,9 +2209,12 @@ const _super = (function (geti, seti) {
22092209
helpersEmitted = true;
22102210
}
22112211

2212-
if (!awaiterEmitted && node.flags & NodeFlags.HasAsyncFunctions) {
2212+
// Only emit __awaiter function when target ES5/ES6.
2213+
// Only emit __generator function when target ES5.
2214+
// For target ES2017 and above, we can emit async/await as is.
2215+
if ((languageVersion < ScriptTarget.ES2017) && (!awaiterEmitted && node.flags & NodeFlags.HasAsyncFunctions)) {
22132216
writeLines(awaiterHelper);
2214-
if (languageVersion < ScriptTarget.ES6) {
2217+
if (languageVersion < ScriptTarget.ES2015) {
22152218
writeLines(generatorHelper);
22162219
}
22172220

0 commit comments

Comments
 (0)