Skip to content

Commit ad9bff8

Browse files
Merge branch 'master' into theyreNotTHATSpecial
2 parents 5e05c75 + b037419 commit ad9bff8

File tree

199 files changed

+2426
-474
lines changed

Some content is hidden

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

199 files changed

+2426
-474
lines changed

AUTHORS.md

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,11 @@ TypeScript is authored by:
22

33
* Adam Freidin
44
* Ahmad Farid
5+
* Akshar Patel
56
* Anders Hejlsberg
67
* Arnav Singh
78
* Arthur Ozga
9+
* Asad Saeeduddin
810
* Basarat Ali Syed
911
* Ben Duffield
1012
* Bill Ticehurst
@@ -15,52 +17,67 @@ TypeScript is authored by:
1517
* Colby Russell
1618
* Colin Snover
1719
* Cyrus Najmabadi
20+
* Dan Corder
1821
* Dan Quirk
1922
* Daniel Rosenwasser
23+
* @dashaus
2024
* David Li
2125
* Denis Nedelyaev
2226
* Dick van den Brink
2327
* Dirk Bäumer
28+
* Dirk Holtwick
2429
* Eyas Sharaiha
30+
* @falsandtru
2531
* Frank Wallis
2632
* Gabriel Isenberg
2733
* Gilad Peleg
2834
* Graeme Wicksted
2935
* Guillaume Salles
36+
* Guy Bedford
3037
* Harald Niesche
38+
* Iain Monro
3139
* Ingvar Stepanyan
3240
* Ivo Gabe de Wolff
3341
* James Whitney
3442
* Jason Freeman
43+
* Jason Killian
3544
* Jason Ramsay
3645
* Jed Mao
46+
* Jeffrey Morlan
3747
* Johannes Rieken
3848
* John Vilk
3949
* Jonathan Bond-Caron
4050
* Jonathan Park
4151
* Jonathan Turner
52+
* Jonathon Smith
4253
* Josh Kalderimis
4354
* Julian Williams
4455
* Kagami Sascha Rosylight
4556
* Keith Mashinter
4657
* Ken Howard
4758
* Kenji Imamula
4859
* Lorant Pinter
60+
* Lucien Greathouse
4961
* Martin Všetička
5062
* Masahiro Wakame
63+
* Mattias Buelens
5164
* Max Deepfield
5265
* Micah Zoltu
5366
* Mohamed Hegazy
5467
* Nathan Shively-Sanders
68+
* Nathan Yee
5569
* Oleg Mihailik
5670
* Oleksandr Chekhovskyi
5771
* Paul van Brenk
72+
* @pcbro
5873
* Pedro Maltez
5974
* Philip Bulley
6075
* piloopin
6176
* @progre
6277
* Punya Biswal
78+
* Richard Sentino
6379
* Ron Buckton
80+
* Rowan Wyborn
6481
* Ryan Cavanaugh
6582
* Ryohei Ikegami
6683
* Sébastien Arod
@@ -71,7 +88,9 @@ TypeScript is authored by:
7188
* Solal Pirelli
7289
* Stan Thomas
7390
* Steve Lucco
91+
* Thomas Loubiou
7492
* Tien Hoanhtien
93+
* Tim Perry
7594
* Tingan Ho
7695
* togru
7796
* Tomas Grubliauskas
@@ -81,5 +100,6 @@ TypeScript is authored by:
81100
* Wesley Wigham
82101
* York Yao
83102
* Yui Tanglertsampan
103+
* Yuichi Nukiyama
84104
* Zev Spitz
85105
* Zhengbo Li

src/compiler/binder.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1462,7 +1462,7 @@ namespace ts {
14621462
function bindCallExpression(node: CallExpression) {
14631463
// We're only inspecting call expressions to detect CommonJS modules, so we can skip
14641464
// this check if we've already seen the module indicator
1465-
if (!file.commonJsModuleIndicator && isRequireCall(node)) {
1465+
if (!file.commonJsModuleIndicator && isRequireCall(node, /*checkArgumentIsStringLiteral*/false)) {
14661466
setCommonJsModuleIndicator(node);
14671467
}
14681468
}

src/compiler/checker.ts

Lines changed: 113 additions & 15 deletions
Large diffs are not rendered by default.

src/compiler/declarationEmitter.ts

Lines changed: 18 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -637,18 +637,21 @@ namespace ts {
637637
}
638638
}
639639

640-
function emitClassMemberDeclarationFlags(node: Declaration) {
641-
if (node.flags & NodeFlags.Private) {
640+
function emitClassMemberDeclarationFlags(flags: NodeFlags) {
641+
if (flags & NodeFlags.Private) {
642642
write("private ");
643643
}
644-
else if (node.flags & NodeFlags.Protected) {
644+
else if (flags & NodeFlags.Protected) {
645645
write("protected ");
646646
}
647647

648-
if (node.flags & NodeFlags.Static) {
648+
if (flags & NodeFlags.Static) {
649649
write("static ");
650650
}
651-
if (node.flags & NodeFlags.Abstract) {
651+
if (flags & NodeFlags.Readonly) {
652+
write("readonly ");
653+
}
654+
if (flags & NodeFlags.Abstract) {
652655
write("abstract ");
653656
}
654657
}
@@ -1074,7 +1077,7 @@ namespace ts {
10741077
}
10751078

10761079
emitJsDocComments(node);
1077-
emitClassMemberDeclarationFlags(node);
1080+
emitClassMemberDeclarationFlags(node.flags);
10781081
emitVariableDeclaration(<VariableDeclaration>node);
10791082
write(";");
10801083
writeLine();
@@ -1227,7 +1230,7 @@ namespace ts {
12271230
if (node === accessors.firstAccessor) {
12281231
emitJsDocComments(accessors.getAccessor);
12291232
emitJsDocComments(accessors.setAccessor);
1230-
emitClassMemberDeclarationFlags(node);
1233+
emitClassMemberDeclarationFlags(node.flags | (accessors.setAccessor ? 0 : NodeFlags.Readonly));
12311234
writeTextOfNode(currentText, node.name);
12321235
if (!(node.flags & NodeFlags.Private)) {
12331236
accessorWithTypeAnnotation = node;
@@ -1314,7 +1317,7 @@ namespace ts {
13141317
emitModuleElementDeclarationFlags(node);
13151318
}
13161319
else if (node.kind === SyntaxKind.MethodDeclaration) {
1317-
emitClassMemberDeclarationFlags(node);
1320+
emitClassMemberDeclarationFlags(node.flags);
13181321
}
13191322
if (node.kind === SyntaxKind.FunctionDeclaration) {
13201323
write("function ");
@@ -1342,15 +1345,17 @@ namespace ts {
13421345
const prevEnclosingDeclaration = enclosingDeclaration;
13431346
enclosingDeclaration = node;
13441347

1345-
// Construct signature or constructor type write new Signature
1346-
if (node.kind === SyntaxKind.ConstructSignature || node.kind === SyntaxKind.ConstructorType) {
1347-
write("new ");
1348-
}
1349-
emitTypeParameters(node.typeParameters);
13501348
if (node.kind === SyntaxKind.IndexSignature) {
1349+
// Index signature can have readonly modifier
1350+
emitClassMemberDeclarationFlags(node.flags);
13511351
write("[");
13521352
}
13531353
else {
1354+
// Construct signature or constructor type write new Signature
1355+
if (node.kind === SyntaxKind.ConstructSignature || node.kind === SyntaxKind.ConstructorType) {
1356+
write("new ");
1357+
}
1358+
emitTypeParameters(node.typeParameters);
13541359
write("(");
13551360
}
13561361

src/compiler/diagnosticMessages.json

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -199,6 +199,10 @@
199199
"category": "Error",
200200
"code": 1063
201201
},
202+
"The return type of an async function or method must be the global Promise<T> type.": {
203+
"category": "Error",
204+
"code": 1064
205+
},
202206
"In ambient enum declarations member initializer must be constant expression.": {
203207
"category": "Error",
204208
"code": 1066
@@ -802,7 +806,7 @@
802806
"A decorator can only decorate a method implementation, not an overload.": {
803807
"category": "Error",
804808
"code": 1249
805-
},
809+
},
806810
"'with' statements are not allowed in an async function block.": {
807811
"category": "Error",
808812
"code": 1300
@@ -1695,6 +1699,10 @@
16951699
"category": "Error",
16961700
"code": 2528
16971701
},
1702+
"Duplicate identifier '{0}'. Compiler reserves name '{1}' in top level scope of a module containing async functions.": {
1703+
"category": "Error",
1704+
"code": 2529
1705+
},
16981706
"JSX element attributes type '{0}' may not be a union type.": {
16991707
"category": "Error",
17001708
"code": 2600
@@ -2763,5 +2771,9 @@
27632771
"JSX element '{0}' has no corresponding closing tag.": {
27642772
"category": "Error",
27652773
"code": 17008
2774+
},
2775+
"'super' must be called before accessing 'this' in the constructor of a derived class.": {
2776+
"category": "Error",
2777+
"code": 17009
27662778
}
27672779
}

src/compiler/emitter.ts

Lines changed: 23 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -320,7 +320,7 @@ var __param = (this && this.__param) || function (paramIndex, decorator) {
320320

321321
const awaiterHelper = `
322322
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
323-
return new P(function (resolve, reject) {
323+
return new (P || (P = Promise))(function (resolve, reject) {
324324
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
325325
function rejected(value) { try { step(generator.throw(value)); } catch (e) { reject(e); } }
326326
function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
@@ -477,6 +477,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
477477
// =>
478478
// var x;... exporter("x", x = 1)
479479
let exportFunctionForFile: string;
480+
let contextObjectForFile: string;
480481

481482
let generatedNameSet: Map<string>;
482483
let nodeToGeneratedName: string[];
@@ -557,6 +558,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
557558
currentText = undefined;
558559
currentLineMap = undefined;
559560
exportFunctionForFile = undefined;
561+
contextObjectForFile = undefined;
560562
generatedNameSet = undefined;
561563
nodeToGeneratedName = undefined;
562564
computedPropertyNamesToGeneratedNames = undefined;
@@ -585,6 +587,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
585587
currentText = sourceFile.text;
586588
currentLineMap = getLineStarts(sourceFile);
587589
exportFunctionForFile = undefined;
590+
contextObjectForFile = undefined;
588591
isEs6Module = sourceFile.symbol && sourceFile.symbol.exports && !!sourceFile.symbol.exports["___esModule"];
589592
renamedDependencies = sourceFile.renamedDependencies;
590593
currentFileIdentifiers = sourceFile.identifiers;
@@ -4561,11 +4564,11 @@ const _super = (function (geti, seti) {
45614564
write(", void 0, ");
45624565
}
45634566

4564-
if (promiseConstructor) {
4565-
emitEntityNameAsExpression(promiseConstructor, /*useFallback*/ false);
4567+
if (languageVersion >= ScriptTarget.ES6 || !promiseConstructor) {
4568+
write("void 0");
45664569
}
45674570
else {
4568-
write("Promise");
4571+
emitEntityNameAsExpression(promiseConstructor, /*useFallback*/ false);
45694572
}
45704573

45714574
// Emit the call to __awaiter.
@@ -7058,6 +7061,7 @@ const _super = (function (geti, seti) {
70587061
Debug.assert(!exportFunctionForFile);
70597062
// make sure that name of 'exports' function does not conflict with existing identifiers
70607063
exportFunctionForFile = makeUniqueName("exports");
7064+
contextObjectForFile = makeUniqueName("context");
70617065
writeLine();
70627066
write("System.register(");
70637067
writeModuleName(node, emitRelativePathAsModuleName);
@@ -7068,14 +7072,22 @@ const _super = (function (geti, seti) {
70687072

70697073
for (let i = 0; i < externalImports.length; i++) {
70707074
const text = getExternalModuleNameText(externalImports[i], emitRelativePathAsModuleName);
7071-
if (hasProperty(groupIndices, text)) {
7075+
if (text === undefined) {
7076+
continue;
7077+
}
7078+
7079+
// text should be quoted string
7080+
// for deduplication purposes in key remove leading and trailing quotes so 'a' and "a" will be considered the same
7081+
const key = text.substr(1, text.length - 2);
7082+
7083+
if (hasProperty(groupIndices, key)) {
70727084
// deduplicate/group entries in dependency list by the dependency name
7073-
const groupIndex = groupIndices[text];
7085+
const groupIndex = groupIndices[key];
70747086
dependencyGroups[groupIndex].push(externalImports[i]);
70757087
continue;
70767088
}
70777089
else {
7078-
groupIndices[text] = dependencyGroups.length;
7090+
groupIndices[key] = dependencyGroups.length;
70797091
dependencyGroups.push([externalImports[i]]);
70807092
}
70817093

@@ -7085,10 +7097,13 @@ const _super = (function (geti, seti) {
70857097

70867098
write(text);
70877099
}
7088-
write(`], function(${exportFunctionForFile}) {`);
7100+
write(`], function(${exportFunctionForFile}, ${contextObjectForFile}) {`);
70897101
writeLine();
70907102
increaseIndent();
70917103
const startIndex = emitDirectivePrologues(node.statements, /*startWithNewLine*/ true, /*ensureUseStrict*/ true);
7104+
writeLine();
7105+
write(`var __moduleName = ${contextObjectForFile} && ${contextObjectForFile}.id;`);
7106+
writeLine();
70927107
emitEmitHelpers(node);
70937108
emitCaptureThisForNodeIfNecessary(node);
70947109
emitSystemModuleBody(node, dependencyGroups, startIndex);

src/compiler/parser.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4017,7 +4017,7 @@ namespace ts {
40174017
setDecoratorContext(/*val*/ true);
40184018
}
40194019

4020-
return finishNode(node);
4020+
return addJSDocComment(finishNode(node));
40214021
}
40224022

40234023
function parseOptionalIdentifier() {
@@ -4301,13 +4301,13 @@ namespace ts {
43014301
const labeledStatement = <LabeledStatement>createNode(SyntaxKind.LabeledStatement, fullStart);
43024302
labeledStatement.label = <Identifier>expression;
43034303
labeledStatement.statement = parseStatement();
4304-
return finishNode(labeledStatement);
4304+
return addJSDocComment(finishNode(labeledStatement));
43054305
}
43064306
else {
43074307
const expressionStatement = <ExpressionStatement>createNode(SyntaxKind.ExpressionStatement, fullStart);
43084308
expressionStatement.expression = expression;
43094309
parseSemicolon();
4310-
return finishNode(expressionStatement);
4310+
return addJSDocComment(finishNode(expressionStatement));
43114311
}
43124312
}
43134313

src/compiler/program.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1328,7 +1328,7 @@ namespace ts {
13281328
}
13291329

13301330
function collectRequireCalls(node: Node): void {
1331-
if (isRequireCall(node)) {
1331+
if (isRequireCall(node, /*checkArgumentIsStringLiteral*/true)) {
13321332
(imports || (imports = [])).push(<StringLiteral>(<CallExpression>node).arguments[0]);
13331333
}
13341334
else {

src/compiler/types.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2070,6 +2070,7 @@ namespace ts {
20702070
LoopWithCapturedBlockScopedBinding = 0x00010000, // Loop that contains block scoped variable captured in closure
20712071
CapturedBlockScopedBinding = 0x00020000, // Block-scoped binding that is captured in some function
20722072
BlockScopedBindingInLoop = 0x00040000, // Block-scoped binding with declaration nested inside iteration statement
2073+
HasSeenSuperCall = 0x00080000, // Set during the binding when encounter 'super'
20732074
}
20742075

20752076
/* @internal */

0 commit comments

Comments
 (0)