Skip to content

Commit e5e7d47

Browse files
committed
merge with origin/master
2 parents 46d28f1 + 8e4541e commit e5e7d47

File tree

158 files changed

+10245
-6327
lines changed

Some content is hidden

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

158 files changed

+10245
-6327
lines changed

Jakefile.js

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -166,19 +166,13 @@ var harnessSources = harnessCoreSources.concat([
166166
}));
167167

168168
var es2015LibrarySources = [
169-
"es2015.array.d.ts",
169+
"es2015.core.d.ts",
170170
"es2015.collection.d.ts",
171-
"es2015.function.d.ts",
172171
"es2015.generator.d.ts",
173172
"es2015.iterable.d.ts",
174-
"es2015.math.d.ts",
175-
"es2015.number.d.ts",
176-
"es2015.object.d.ts",
177173
"es2015.promise.d.ts",
178174
"es2015.proxy.d.ts",
179175
"es2015.reflect.d.ts",
180-
"es2015.regexp.d.ts",
181-
"es2015.string.d.ts",
182176
"es2015.symbol.d.ts",
183177
"es2015.symbol.wellknown.d.ts",
184178
];
@@ -209,7 +203,7 @@ var librarySourceMap = [
209203

210204
// JavaScript + all host library
211205
{ target: "lib.d.ts", sources: ["header.d.ts", "es5.d.ts"].concat(hostsLibrarySources), },
212-
{ target: "lib.full.es2015.d.ts", sources: ["header.d.ts", "es5.d.ts"].concat(es2015LibrarySources, hostsLibrarySources), },
206+
{ target: "lib.es6.d.ts", sources: ["header.d.ts", "es5.d.ts"].concat(es2015LibrarySources, hostsLibrarySources), },
213207
].concat(es2015LibrarySourceMap, es2016LibrarySourceMap);
214208

215209
var libraryTargets = librarySourceMap.map(function (f) {

src/compiler/binder.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,7 @@ namespace ts {
122122
let hasAsyncFunctions: boolean;
123123
let hasDecorators: boolean;
124124
let hasParameterDecorators: boolean;
125+
let hasJsxSpreadAttribute: boolean;
125126

126127
// If this file is an external module, then it is automatically in strict-mode according to
127128
// ES6. If it is not an external module, then we'll determine if it is in strict mode or
@@ -161,6 +162,7 @@ namespace ts {
161162
hasAsyncFunctions = false;
162163
hasDecorators = false;
163164
hasParameterDecorators = false;
165+
hasJsxSpreadAttribute = false;
164166
}
165167

166168
return bindSourceFile;
@@ -498,6 +500,9 @@ namespace ts {
498500
if (hasAsyncFunctions) {
499501
flags |= NodeFlags.HasAsyncFunctions;
500502
}
503+
if (hasJsxSpreadAttribute) {
504+
flags |= NodeFlags.HasJsxSpreadAttribute;
505+
}
501506
}
502507

503508
node.flags = flags;
@@ -1298,6 +1303,10 @@ namespace ts {
12981303
case SyntaxKind.EnumMember:
12991304
return bindPropertyOrMethodOrAccessor(<Declaration>node, SymbolFlags.EnumMember, SymbolFlags.EnumMemberExcludes);
13001305

1306+
case SyntaxKind.JsxSpreadAttribute:
1307+
hasJsxSpreadAttribute = true;
1308+
return;
1309+
13011310
case SyntaxKind.CallSignature:
13021311
case SyntaxKind.ConstructSignature:
13031312
case SyntaxKind.IndexSignature:

src/compiler/checker.ts

Lines changed: 164 additions & 38 deletions
Large diffs are not rendered by default.

src/compiler/commandLineParser.ts

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,11 @@ namespace ts {
122122
type: "boolean",
123123
description: Diagnostics.Raise_error_on_expressions_and_declarations_with_an_implied_any_type,
124124
},
125+
{
126+
name: "noImplicitThis",
127+
type: "boolean",
128+
description: Diagnostics.Raise_error_on_this_expressions_with_an_implied_any_type,
129+
},
125130
{
126131
name: "noLib",
127132
type: "boolean",
@@ -354,6 +359,10 @@ namespace ts {
354359
type: "boolean",
355360
description: Diagnostics.Do_not_emit_use_strict_directives_in_module_output
356361
},
362+
{
363+
name: "listEmittedFiles",
364+
type: "boolean"
365+
},
357366
{
358367
name: "lib",
359368
type: "list",
@@ -371,19 +380,13 @@ namespace ts {
371380
"webworker": "lib.webworker.d.ts",
372381
"scripthost": "lib.scripthost.d.ts",
373382
// ES2015 Or ESNext By-feature options
374-
"es2015.array": "lib.es2015.array.d.ts",
383+
"es2015.core": "lib.es2015.core.d.ts",
375384
"es2015.collection": "lib.es2015.collection.d.ts",
376385
"es2015.generator": "lib.es2015.generator.d.ts",
377-
"es2015.function": "lib.es2015.function.d.ts",
378386
"es2015.iterable": "lib.es2015.iterable.d.ts",
379-
"es2015.math": "lib.es2015.math.d.ts",
380-
"es2015.number": "lib.es2015.number.d.ts",
381-
"es2015.object": "lib.es2015.object.d.ts",
382387
"es2015.promise": "lib.es2015.promise.d.ts",
383388
"es2015.proxy": "lib.es2015.proxy.d.ts",
384389
"es2015.reflect": "lib.es2015.reflect.d.ts",
385-
"es2015.regexp": "lib.es2015.regexp.d.ts",
386-
"es2015.string": "lib.es2015.string.d.ts",
387390
"es2015.symbol": "lib.es2015.symbol.d.ts",
388391
"es2015.symbol.wellknown": "lib.es2015.symbol.wellknown.d.ts",
389392
"es2016.array.include": "lib.es2016.array.include.d.ts"

src/compiler/declarationEmitter.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ namespace ts {
3535
forEachExpectedEmitFile(host, getDeclarationDiagnosticsFromFile, targetSourceFile);
3636
return declarationDiagnostics.getDiagnostics(targetSourceFile ? targetSourceFile.fileName : undefined);
3737

38-
function getDeclarationDiagnosticsFromFile({ declarationFilePath }, sources: SourceFile[], isBundledEmit: boolean) {
38+
function getDeclarationDiagnosticsFromFile({ declarationFilePath }: EmitFileNames, sources: SourceFile[], isBundledEmit: boolean) {
3939
emitDeclarations(host, resolver, declarationDiagnostics, declarationFilePath, sources, isBundledEmit);
4040
}
4141
}
@@ -530,7 +530,10 @@ namespace ts {
530530
else {
531531
// Expression
532532
const tempVarName = getExportDefaultTempVariableName();
533-
write("declare var ");
533+
if (!noDeclare) {
534+
write("declare ");
535+
}
536+
write("var ");
534537
write(tempVarName);
535538
write(": ");
536539
writer.getSymbolAccessibilityDiagnostic = getDefaultExportAccessibilityDiagnostic;

src/compiler/diagnosticMessages.json

Lines changed: 49 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1879,6 +1879,34 @@
18791879
"category": "Error",
18801880
"code": 2678
18811881
},
1882+
"A function that is called with the 'new' keyword cannot have a 'this' type that is 'void'.": {
1883+
"category": "Error",
1884+
"code": 2679
1885+
},
1886+
"A 'this' parameter must be the first parameter.": {
1887+
"category": "Error",
1888+
"code": 2680
1889+
},
1890+
"A constructor cannot have a 'this' parameter.": {
1891+
"category": "Error",
1892+
"code": 2681
1893+
},
1894+
"A setter cannot have a 'this' parameter.": {
1895+
"category": "Error",
1896+
"code": 2682
1897+
},
1898+
"'this' implicitly has type 'any' because it does not have a type annotation.": {
1899+
"category": "Error",
1900+
"code": 2683
1901+
},
1902+
"The 'this' context of type '{0}' is not assignable to method's 'this' of type '{1}'.": {
1903+
"category": "Error",
1904+
"code": 2684
1905+
},
1906+
"The 'this' types of each signature are incompatible.": {
1907+
"category": "Error",
1908+
"code": 2685
1909+
},
18821910
"Import declaration '{0}' is using private name '{1}'.": {
18831911
"category": "Error",
18841912
"code": 4000
@@ -2637,58 +2665,62 @@
26372665
"category": "Error",
26382666
"code": 6114
26392667
},
2640-
"======== Resolving type reference directive '{0}', containing file '{1}', root directory '{2}'. ========": {
2668+
"Raise error on 'this' expressions with an implied 'any' type.": {
26412669
"category": "Message",
26422670
"code": 6115
26432671
},
2644-
"Resolving using primary search paths...": {
2672+
"======== Resolving type reference directive '{0}', containing file '{1}', root directory '{2}'. ========": {
26452673
"category": "Message",
26462674
"code": 6116
26472675
},
2648-
"Resolving from node_modules folder...": {
2676+
"Resolving using primary search paths...": {
26492677
"category": "Message",
26502678
"code": 6117
26512679
},
2652-
"======== Type reference directive '{0}' was successfully resolved to '{1}', primary: {2}. ========": {
2680+
"Resolving from node_modules folder...": {
26532681
"category": "Message",
26542682
"code": 6118
26552683
},
2656-
"======== Type reference directive '{0}' was not resolved. ========": {
2684+
"======== Type reference directive '{0}' was successfully resolved to '{1}', primary: {2}. ========": {
26572685
"category": "Message",
26582686
"code": 6119
26592687
},
2660-
"Resolving with primary search path '{0}'": {
2688+
"======== Type reference directive '{0}' was not resolved. ========": {
26612689
"category": "Message",
26622690
"code": 6120
26632691
},
2664-
"Root directory cannot be determined, skipping primary search paths.": {
2692+
"Resolving with primary search path '{0}'": {
26652693
"category": "Message",
26662694
"code": 6121
26672695
},
2668-
"======== Resolving type reference directive '{0}', containing file '{1}', root directory not set. ========": {
2696+
"Root directory cannot be determined, skipping primary search paths.": {
26692697
"category": "Message",
26702698
"code": 6122
26712699
},
2672-
"Type declaration files to be included in compilation.": {
2700+
"======== Resolving type reference directive '{0}', containing file '{1}', root directory not set. ========": {
26732701
"category": "Message",
26742702
"code": 6123
26752703
},
2676-
"Looking up in 'node_modules' folder, initial location '{0}'": {
2704+
"Type declaration files to be included in compilation.": {
26772705
"category": "Message",
26782706
"code": 6124
26792707
},
2680-
"Containing file is not specified and root directory cannot be determined, skipping lookup in 'node_modules' folder.": {
2708+
"Looking up in 'node_modules' folder, initial location '{0}'": {
26812709
"category": "Message",
26822710
"code": 6125
26832711
},
2684-
"======== Resolving type reference directive '{0}', containing file not set, root directory '{1}'. ========": {
2712+
"Containing file is not specified and root directory cannot be determined, skipping lookup in 'node_modules' folder.": {
26852713
"category": "Message",
26862714
"code": 6126
26872715
},
2688-
"======== Resolving type reference directive '{0}', containing file not set, root directory not set. ========": {
2716+
"======== Resolving type reference directive '{0}', containing file not set, root directory '{1}'. ========": {
26892717
"category": "Message",
26902718
"code": 6127
26912719
},
2720+
"======== Resolving type reference directive '{0}', containing file not set, root directory not set. ========": {
2721+
"category": "Message",
2722+
"code": 6128
2723+
},
26922724
"Variable '{0}' implicitly has an '{1}' type.": {
26932725
"category": "Error",
26942726
"code": 7005
@@ -2777,6 +2809,10 @@
27772809
"category": "Error",
27782810
"code": 7030
27792811
},
2812+
"Binding element '{0}' implicitly has an '{1}' type.": {
2813+
"category": "Error",
2814+
"code": 7031
2815+
},
27802816
"You cannot rename this element.": {
27812817
"category": "Error",
27822818
"code": 8000

src/compiler/emitter.ts

Lines changed: 35 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -345,6 +345,16 @@ var __extends = (this && this.__extends) || function (d, b) {
345345
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
346346
};`;
347347

348+
const assignHelper = `
349+
var __assign = (this && this.__assign) || Object.assign || function(t) {
350+
for (var s, i = 1, n = arguments.length; i < n; i++) {
351+
s = arguments[i];
352+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
353+
t[p] = s[p];
354+
}
355+
return t;
356+
};`;
357+
348358
// emit output for the __decorate helper function
349359
const decorateHelper = `
350360
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
@@ -380,6 +390,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
380390
const languageVersion = getEmitScriptTarget(compilerOptions);
381391
const modulekind = getEmitModuleKind(compilerOptions);
382392
const sourceMapDataList: SourceMapData[] = compilerOptions.sourceMap || compilerOptions.inlineSourceMap ? [] : undefined;
393+
const emittedFilesList: string[] = compilerOptions.listEmittedFiles ? [] : undefined;
383394
const emitterDiagnostics = createDiagnosticCollection();
384395
let emitSkipped = false;
385396
const newLine = host.getNewLine();
@@ -390,6 +401,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
390401
return {
391402
emitSkipped,
392403
diagnostics: emitterDiagnostics.getDiagnostics(),
404+
emittedFiles: emittedFilesList,
393405
sourceMaps: sourceMapDataList
394406
};
395407

@@ -540,6 +552,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
540552
let convertedLoopState: ConvertedLoopState;
541553

542554
let extendsEmitted: boolean;
555+
let assignEmitted: boolean;
543556
let decorateEmitted: boolean;
544557
let paramEmitted: boolean;
545558
let awaiterEmitted: boolean;
@@ -623,6 +636,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
623636
decorateEmitted = false;
624637
paramEmitted = false;
625638
awaiterEmitted = false;
639+
assignEmitted = false;
626640
tempFlags = 0;
627641
tempVariables = undefined;
628642
tempParameters = undefined;
@@ -1259,11 +1273,10 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
12591273
}
12601274
else {
12611275
// Either emit one big object literal (no spread attribs), or
1262-
// a call to React.__spread
1276+
// a call to the __assign helper
12631277
const attrs = openingNode.attributes;
12641278
if (forEach(attrs, attr => attr.kind === SyntaxKind.JsxSpreadAttribute)) {
1265-
emitExpressionIdentifier(syntheticReactRef);
1266-
write(".__spread(");
1279+
write("__assign(");
12671280

12681281
let haveOpenedObjectLiteral = false;
12691282
for (let i = 0; i < attrs.length; i++) {
@@ -4630,8 +4643,9 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
46304643
write("(");
46314644
if (node) {
46324645
const parameters = node.parameters;
4646+
const skipCount = node.parameters.length && (<Identifier>node.parameters[0].name).text === "this" ? 1 : 0;
46334647
const omitCount = languageVersion < ScriptTarget.ES6 && hasRestParameter(node) ? 1 : 0;
4634-
emitList(parameters, 0, parameters.length - omitCount, /*multiLine*/ false, /*trailingComma*/ false);
4648+
emitList(parameters, skipCount, parameters.length - omitCount - skipCount, /*multiLine*/ false, /*trailingComma*/ false);
46354649
}
46364650
write(")");
46374651
decreaseIndent();
@@ -7651,7 +7665,7 @@ const _super = (function (geti, seti) {
76517665
}
76527666

76537667
function isUseStrictPrologue(node: ExpressionStatement): boolean {
7654-
return !!(node.expression as StringLiteral).text.match(/use strict/);
7668+
return (node.expression as StringLiteral).text === "use strict";
76557669
}
76567670

76577671
function ensureUseStrictPrologue(startWithNewLine: boolean, writeUseStrict: boolean) {
@@ -7701,11 +7715,16 @@ const _super = (function (geti, seti) {
77017715
if (!compilerOptions.noEmitHelpers) {
77027716
// Only Emit __extends function when target ES5.
77037717
// For target ES6 and above, we can emit classDeclaration as is.
7704-
if ((languageVersion < ScriptTarget.ES6) && (!extendsEmitted && node.flags & NodeFlags.HasClassExtends)) {
7718+
if (languageVersion < ScriptTarget.ES6 && !extendsEmitted && node.flags & NodeFlags.HasClassExtends) {
77057719
writeLines(extendsHelper);
77067720
extendsEmitted = true;
77077721
}
77087722

7723+
if (compilerOptions.jsx !== JsxEmit.Preserve && !assignEmitted && (node.flags & NodeFlags.HasJsxSpreadAttribute)) {
7724+
writeLines(assignHelper);
7725+
assignEmitted = true;
7726+
}
7727+
77097728
if (!decorateEmitted && node.flags & NodeFlags.HasDecorators) {
77107729
writeLines(decorateHelper);
77117730
if (compilerOptions.emitDecoratorMetadata) {
@@ -8232,6 +8251,16 @@ const _super = (function (geti, seti) {
82328251
if (declarationFilePath) {
82338252
emitSkipped = writeDeclarationFile(declarationFilePath, sourceFiles, isBundledEmit, host, resolver, emitterDiagnostics) || emitSkipped;
82348253
}
8254+
8255+
if (!emitSkipped && emittedFilesList) {
8256+
emittedFilesList.push(jsFilePath);
8257+
if (sourceMapFilePath) {
8258+
emittedFilesList.push(sourceMapFilePath);
8259+
}
8260+
if (declarationFilePath) {
8261+
emittedFilesList.push(declarationFilePath);
8262+
}
8263+
}
82358264
}
82368265
}
82378266
}

0 commit comments

Comments
 (0)