Skip to content

Commit a026c05

Browse files
committed
Update LKG
1 parent ee0c0f6 commit a026c05

File tree

2 files changed

+133
-253
lines changed

2 files changed

+133
-253
lines changed

bin/tsc.js

Lines changed: 68 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -2207,10 +2207,6 @@ var ts;
22072207
return pathLen > extLen && path.substr(pathLen - extLen, extLen) === extension;
22082208
}
22092209
ts.fileExtensionIs = fileExtensionIs;
2210-
function getCanonicalFileName(fileName) {
2211-
return sys.useCaseSensitiveFileNames ? fileName : fileName.toLowerCase();
2212-
}
2213-
ts.getCanonicalFileName = getCanonicalFileName;
22142210
function Symbol(flags, name) {
22152211
this.flags = flags;
22162212
this.name = name;
@@ -2591,6 +2587,7 @@ var ts;
25912587
}
25922588
}
25932589
ts.getJsDocComments = getJsDocComments;
2590+
ts.fullTripleSlashReferencePathRegEx = /^(\/\/\/\s*<reference\s+path\s*=\s*)('|")(.+?)\2.*?\/>/;
25942591
function forEachChild(node, cbNode, cbNodes) {
25952592
function child(node) {
25962593
if (node)
@@ -5252,8 +5249,7 @@ var ts;
52525249
file.hasNoDefaultLib = true;
52535250
}
52545251
else {
5255-
var fullReferenceRegEx = /^(\/\/\/\s*<reference\s+path\s*=\s*)('|")(.+?)\2.*?\/>/;
5256-
var matchResult = fullReferenceRegEx.exec(comment);
5252+
var matchResult = ts.fullTripleSlashReferencePathRegEx.exec(comment);
52575253
if (!matchResult) {
52585254
var start = range.pos;
52595255
var length = range.end - start;
@@ -6025,7 +6021,7 @@ var ts;
60256021
}
60266022
}
60276023
else {
6028-
writer.writeLiteral(sys.newLine);
6024+
writer.writeLiteral(newLine);
60296025
}
60306026
}
60316027
function calculateIndent(pos, end) {
@@ -6059,6 +6055,8 @@ var ts;
60596055
var detachedCommentsInfo;
60606056
var emitDetachedComments = compilerOptions.removeComments ? function (node) {
60616057
} : emitDetachedCommentsAtPosition;
6058+
var emitPinnedOrTripleSlashComments = compilerOptions.removeComments ? function (node) {
6059+
} : emitPinnedOrTripleSlashCommentsOfNode;
60626060
var writeComment = writeCommentRange;
60636061
var emit = emitNode;
60646062
var emitStart = function (node) {
@@ -6854,8 +6852,9 @@ var ts;
68546852
emitTrailingComments(node);
68556853
}
68566854
function emitFunctionDeclaration(node) {
6857-
if (!node.body)
6858-
return;
6855+
if (!node.body) {
6856+
return emitPinnedOrTripleSlashComments(node);
6857+
}
68596858
if (node.kind !== 116 /* Method */) {
68606859
emitLeadingComments(node);
68616860
}
@@ -7014,8 +7013,9 @@ var ts;
70147013
function emitMemberFunctions(node) {
70157014
ts.forEach(node.members, function (member) {
70167015
if (member.kind === 116 /* Method */) {
7017-
if (!member.body)
7018-
return;
7016+
if (!member.body) {
7017+
return emitPinnedOrTripleSlashComments(member);
7018+
}
70197019
writeLine();
70207020
emitLeadingComments(member);
70217021
emitStart(member);
@@ -7136,6 +7136,11 @@ var ts;
71367136
}
71377137
emitTrailingComments(node);
71387138
function emitConstructorOfClass() {
7139+
ts.forEach(node.members, function (member) {
7140+
if (member.kind === 117 /* Constructor */ && !member.body) {
7141+
emitPinnedOrTripleSlashComments(member);
7142+
}
7143+
});
71397144
var ctor = getFirstConstructorWithBody(node);
71407145
if (ctor) {
71417146
emitLeadingComments(ctor);
@@ -7191,6 +7196,9 @@ var ts;
71917196
}
71927197
}
71937198
}
7199+
function emitInterfaceDeclaration(node) {
7200+
emitPinnedOrTripleSlashComments(node);
7201+
}
71947202
function emitEnumDeclaration(node) {
71957203
emitLeadingComments(node);
71967204
if (!(node.flags & 1 /* Export */)) {
@@ -7263,8 +7271,9 @@ var ts;
72637271
}
72647272
}
72657273
function emitModuleDeclaration(node) {
7266-
if (!ts.isInstantiated(node))
7267-
return;
7274+
if (!ts.isInstantiated(node)) {
7275+
return emitPinnedOrTripleSlashComments(node);
7276+
}
72687277
emitLeadingComments(node);
72697278
if (!(node.flags & 1 /* Export */)) {
72707279
emitStart(node);
@@ -7477,8 +7486,12 @@ var ts;
74777486
}
74787487
}
74797488
function emitNode(node) {
7480-
if (!node || node.flags & 2 /* Ambient */)
7489+
if (!node) {
74817490
return;
7491+
}
7492+
if (node.flags & 2 /* Ambient */) {
7493+
return emitPinnedOrTripleSlashComments(node);
7494+
}
74827495
switch (node.kind) {
74837496
case 55 /* Identifier */:
74847497
return emitIdentifier(node);
@@ -7582,6 +7595,8 @@ var ts;
75827595
return emitVariableDeclaration(node);
75837596
case 169 /* ClassDeclaration */:
75847597
return emitClassDeclaration(node);
7598+
case 170 /* InterfaceDeclaration */:
7599+
return emitInterfaceDeclaration(node);
75857600
case 171 /* EnumDeclaration */:
75867601
return emitEnumDeclaration(node);
75877602
case 172 /* ModuleDeclaration */:
@@ -7605,7 +7620,7 @@ var ts;
76057620
}
76067621
return leadingComments;
76077622
}
7608-
function emitLeadingDeclarationComments(node) {
7623+
function getLeadingCommentsToEmit(node) {
76097624
if (node.parent.kind === 177 /* SourceFile */ || node.pos !== node.parent.pos) {
76107625
var leadingComments;
76117626
if (hasDetachedComments(node.pos)) {
@@ -7614,10 +7629,14 @@ var ts;
76147629
else {
76157630
leadingComments = ts.getLeadingCommentsOfNode(node, currentSourceFile);
76167631
}
7617-
emitNewLineBeforeLeadingComments(node, leadingComments, writer);
7618-
emitComments(leadingComments, true, writer, writeComment);
7632+
return leadingComments;
76197633
}
76207634
}
7635+
function emitLeadingDeclarationComments(node) {
7636+
var leadingComments = getLeadingCommentsToEmit(node);
7637+
emitNewLineBeforeLeadingComments(node, leadingComments, writer);
7638+
emitComments(leadingComments, true, writer, writeComment);
7639+
}
76217640
function emitTrailingDeclarationComments(node) {
76227641
if (node.parent.kind === 177 /* SourceFile */ || node.end !== node.parent.end) {
76237642
var trailingComments = ts.getTrailingComments(currentSourceFile.text, node.end);
@@ -7651,7 +7670,7 @@ var ts;
76517670
detachedComments.push(comment);
76527671
lastComment = comment;
76537672
});
7654-
if (detachedComments && detachedComments.length) {
7673+
if (detachedComments.length) {
76557674
var lastCommentLine = getLineOfLocalPosition(detachedComments[detachedComments.length - 1].end);
76567675
var astLine = getLineOfLocalPosition(ts.skipTrivia(currentSourceFile.text, node.pos));
76577676
if (astLine >= lastCommentLine + 2) {
@@ -7668,6 +7687,19 @@ var ts;
76687687
}
76697688
}
76707689
}
7690+
function emitPinnedOrTripleSlashCommentsOfNode(node) {
7691+
var pinnedComments = ts.filter(getLeadingCommentsToEmit(node), isPinnedOrTripleSlashComment);
7692+
function isPinnedOrTripleSlashComment(comment) {
7693+
if (currentSourceFile.text.charCodeAt(comment.pos + 1) === 42 /* asterisk */) {
7694+
return currentSourceFile.text.charCodeAt(comment.pos + 2) === 33 /* exclamation */;
7695+
}
7696+
else if (currentSourceFile.text.charCodeAt(comment.pos + 1) === 47 /* slash */ && comment.pos + 2 < comment.end && currentSourceFile.text.charCodeAt(comment.pos + 2) === 47 /* slash */ && currentSourceFile.text.substring(comment.pos, comment.end).match(ts.fullTripleSlashReferencePathRegEx)) {
7697+
return true;
7698+
}
7699+
}
7700+
emitNewLineBeforeLeadingComments(node, pinnedComments, writer);
7701+
emitComments(pinnedComments, true, writer, writeComment);
7702+
}
76717703
if (compilerOptions.sourceMap) {
76727704
initializeEmitterWithSourceMaps();
76737705
}
@@ -9102,7 +9134,7 @@ var ts;
91029134
}
91039135
return symbol.name;
91049136
}
9105-
if (enclosingDeclaration && !(symbol.flags & ts.SymbolFlags.PropertyOrAccessor & ts.SymbolFlags.Signature & 4096 /* Constructor */ & 2048 /* Method */ & 262144 /* TypeParameter */)) {
9137+
if (enclosingDeclaration && !(symbol.flags & (ts.SymbolFlags.PropertyOrAccessor | ts.SymbolFlags.Signature | 4096 /* Constructor */ | 2048 /* Method */ | 262144 /* TypeParameter */))) {
91069138
var symbolName;
91079139
while (symbol) {
91089140
var isFirstName = !symbolName;
@@ -10257,13 +10289,12 @@ var ts;
1025710289
return emptyObjectType;
1025810290
}
1025910291
var type = getDeclaredTypeOfSymbol(symbol);
10260-
var name = symbol.name;
1026110292
if (!(type.flags & ts.TypeFlags.ObjectType)) {
10262-
error(getTypeDeclaration(symbol), ts.Diagnostics.Global_type_0_must_be_a_class_or_interface_type, name);
10293+
error(getTypeDeclaration(symbol), ts.Diagnostics.Global_type_0_must_be_a_class_or_interface_type, symbol.name);
1026310294
return emptyObjectType;
1026410295
}
1026510296
if ((type.typeParameters ? type.typeParameters.length : 0) !== arity) {
10266-
error(getTypeDeclaration(symbol), ts.Diagnostics.Global_type_0_must_have_1_type_parameter_s, name, arity);
10297+
error(getTypeDeclaration(symbol), ts.Diagnostics.Global_type_0_must_have_1_type_parameter_s, symbol.name, arity);
1026710298
return emptyObjectType;
1026810299
}
1026910300
return type;
@@ -11395,7 +11426,8 @@ var ts;
1139511426
}
1139611427
return false;
1139711428
}
11398-
function checkSuperExpression(node, isCallExpression) {
11429+
function checkSuperExpression(node) {
11430+
var isCallExpression = node.parent.kind === 132 /* CallExpression */ && node.parent.func === node;
1139911431
var enclosingClass = getAncestor(node, 169 /* ClassDeclaration */);
1140011432
var baseClass;
1140111433
if (enclosingClass && enclosingClass.baseType) {
@@ -11897,7 +11929,7 @@ var ts;
1189711929
}
1189811930
function resolveCallExpression(node) {
1189911931
if (node.func.kind === 81 /* SuperKeyword */) {
11900-
var superType = checkSuperExpression(node.func, true);
11932+
var superType = checkSuperExpression(node.func);
1190111933
if (superType !== unknownType) {
1190211934
return resolveCall(node, getSignaturesOfType(superType, 1 /* Construct */));
1190311935
}
@@ -12370,7 +12402,7 @@ var ts;
1237012402
case 83 /* ThisKeyword */:
1237112403
return checkThisExpression(node);
1237212404
case 81 /* SuperKeyword */:
12373-
return checkSuperExpression(node, false);
12405+
return checkSuperExpression(node);
1237412406
case 79 /* NullKeyword */:
1237512407
return nullType;
1237612408
case 85 /* TrueKeyword */:
@@ -13811,6 +13843,7 @@ var ts;
1381113843
case 114 /* Parameter */:
1381213844
case 115 /* Property */:
1381313845
case 176 /* EnumMember */:
13846+
case 129 /* PropertyAssignment */:
1381413847
return parent.initializer === node;
1381513848
case 146 /* ExpressionStatement */:
1381613849
case 147 /* IfStatement */:
@@ -13913,6 +13946,9 @@ var ts;
1391313946
if (entityName.parent.kind === 175 /* ExportAssignment */) {
1391413947
return resolveEntityName(entityName.parent.parent, entityName, ts.SymbolFlags.Value | ts.SymbolFlags.Type | ts.SymbolFlags.Namespace | 4194304 /* Import */);
1391513948
}
13949+
if (isInRightSideOfImportOrExportAssignment(entityName)) {
13950+
return getSymbolOfPartOfRightHandSideOfImport(entityName);
13951+
}
1391613952
if (isRightSideOfQualifiedNameOrPropertyAccess(entityName)) {
1391713953
entityName = entityName.parent;
1391813954
}
@@ -14001,8 +14037,7 @@ var ts;
1400114037
return getTypeOfSymbol(symbol);
1400214038
}
1400314039
if (isInRightSideOfImportOrExportAssignment(node)) {
14004-
var symbol;
14005-
symbol = node.parent.kind === 175 /* ExportAssignment */ ? getSymbolInfo(node) : getSymbolOfPartOfRightHandSideOfImport(node);
14040+
var symbol = getSymbolInfo(node);
1400614041
var declaredType = getDeclaredTypeOfSymbol(symbol);
1400714042
return declaredType !== unknownType ? declaredType : getTypeOfSymbol(symbol);
1400814043
}
@@ -14138,7 +14173,8 @@ var ts;
1413814173
function isImplementationOfOverload(node) {
1413914174
if (node.body) {
1414014175
var symbol = getSymbolOfNode(node);
14141-
return getSignaturesOfSymbol(symbol).length > 1;
14176+
var signaturesOfSymbol = getSignaturesOfSymbol(symbol);
14177+
return signaturesOfSymbol.length > 1 || (signaturesOfSymbol.length === 1 && signaturesOfSymbol[0].declaration !== node);
1414214178
}
1414314179
return false;
1414414180
}
@@ -14528,6 +14564,9 @@ var ts;
1452814564
function createCompilerHost(options) {
1452914565
var currentDirectory;
1453014566
var existingDirectories = {};
14567+
function getCanonicalFileName(fileName) {
14568+
return sys.useCaseSensitiveFileNames ? fileName : fileName.toLowerCase();
14569+
}
1453114570
function getSourceFile(filename, languageVersion, onError) {
1453214571
try {
1453314572
var text = sys.readFile(filename, options.charset);
@@ -14573,7 +14612,7 @@ var ts;
1457314612
writeFile: writeFile,
1457414613
getCurrentDirectory: function () { return currentDirectory || (currentDirectory = sys.getCurrentDirectory()); },
1457514614
useCaseSensitiveFileNames: function () { return sys.useCaseSensitiveFileNames; },
14576-
getCanonicalFileName: ts.getCanonicalFileName,
14615+
getCanonicalFileName: getCanonicalFileName,
1457714616
getNewLine: function () { return sys.newLine; }
1457814617
};
1457914618
}

0 commit comments

Comments
 (0)