@@ -2207,10 +2207,6 @@ var ts;
2207
2207
return pathLen > extLen && path.substr(pathLen - extLen, extLen) === extension;
2208
2208
}
2209
2209
ts.fileExtensionIs = fileExtensionIs;
2210
- function getCanonicalFileName(fileName) {
2211
- return sys.useCaseSensitiveFileNames ? fileName : fileName.toLowerCase();
2212
- }
2213
- ts.getCanonicalFileName = getCanonicalFileName;
2214
2210
function Symbol(flags, name) {
2215
2211
this.flags = flags;
2216
2212
this.name = name;
@@ -2591,6 +2587,7 @@ var ts;
2591
2587
}
2592
2588
}
2593
2589
ts.getJsDocComments = getJsDocComments;
2590
+ ts.fullTripleSlashReferencePathRegEx = /^(\/\/\/\s*<reference\s+path\s*=\s*)('|")(.+?)\2.*?\/>/;
2594
2591
function forEachChild(node, cbNode, cbNodes) {
2595
2592
function child(node) {
2596
2593
if (node)
@@ -5252,8 +5249,7 @@ var ts;
5252
5249
file.hasNoDefaultLib = true;
5253
5250
}
5254
5251
else {
5255
- var fullReferenceRegEx = /^(\/\/\/\s*<reference\s+path\s*=\s*)('|")(.+?)\2.*?\/>/;
5256
- var matchResult = fullReferenceRegEx.exec(comment);
5252
+ var matchResult = ts.fullTripleSlashReferencePathRegEx.exec(comment);
5257
5253
if (!matchResult) {
5258
5254
var start = range.pos;
5259
5255
var length = range.end - start;
@@ -6025,7 +6021,7 @@ var ts;
6025
6021
}
6026
6022
}
6027
6023
else {
6028
- writer.writeLiteral(sys. newLine);
6024
+ writer.writeLiteral(newLine);
6029
6025
}
6030
6026
}
6031
6027
function calculateIndent(pos, end) {
@@ -6059,6 +6055,8 @@ var ts;
6059
6055
var detachedCommentsInfo;
6060
6056
var emitDetachedComments = compilerOptions.removeComments ? function (node) {
6061
6057
} : emitDetachedCommentsAtPosition;
6058
+ var emitPinnedOrTripleSlashComments = compilerOptions.removeComments ? function (node) {
6059
+ } : emitPinnedOrTripleSlashCommentsOfNode;
6062
6060
var writeComment = writeCommentRange;
6063
6061
var emit = emitNode;
6064
6062
var emitStart = function (node) {
@@ -6854,8 +6852,9 @@ var ts;
6854
6852
emitTrailingComments(node);
6855
6853
}
6856
6854
function emitFunctionDeclaration(node) {
6857
- if (!node.body)
6858
- return;
6855
+ if (!node.body) {
6856
+ return emitPinnedOrTripleSlashComments(node);
6857
+ }
6859
6858
if (node.kind !== 116 /* Method */) {
6860
6859
emitLeadingComments(node);
6861
6860
}
@@ -7014,8 +7013,9 @@ var ts;
7014
7013
function emitMemberFunctions(node) {
7015
7014
ts.forEach(node.members, function (member) {
7016
7015
if (member.kind === 116 /* Method */) {
7017
- if (!member.body)
7018
- return;
7016
+ if (!member.body) {
7017
+ return emitPinnedOrTripleSlashComments(member);
7018
+ }
7019
7019
writeLine();
7020
7020
emitLeadingComments(member);
7021
7021
emitStart(member);
@@ -7136,6 +7136,11 @@ var ts;
7136
7136
}
7137
7137
emitTrailingComments(node);
7138
7138
function emitConstructorOfClass() {
7139
+ ts.forEach(node.members, function (member) {
7140
+ if (member.kind === 117 /* Constructor */ && !member.body) {
7141
+ emitPinnedOrTripleSlashComments(member);
7142
+ }
7143
+ });
7139
7144
var ctor = getFirstConstructorWithBody(node);
7140
7145
if (ctor) {
7141
7146
emitLeadingComments(ctor);
@@ -7191,6 +7196,9 @@ var ts;
7191
7196
}
7192
7197
}
7193
7198
}
7199
+ function emitInterfaceDeclaration(node) {
7200
+ emitPinnedOrTripleSlashComments(node);
7201
+ }
7194
7202
function emitEnumDeclaration(node) {
7195
7203
emitLeadingComments(node);
7196
7204
if (!(node.flags & 1 /* Export */)) {
@@ -7263,8 +7271,9 @@ var ts;
7263
7271
}
7264
7272
}
7265
7273
function emitModuleDeclaration(node) {
7266
- if (!ts.isInstantiated(node))
7267
- return;
7274
+ if (!ts.isInstantiated(node)) {
7275
+ return emitPinnedOrTripleSlashComments(node);
7276
+ }
7268
7277
emitLeadingComments(node);
7269
7278
if (!(node.flags & 1 /* Export */)) {
7270
7279
emitStart(node);
@@ -7477,8 +7486,12 @@ var ts;
7477
7486
}
7478
7487
}
7479
7488
function emitNode(node) {
7480
- if (!node || node.flags & 2 /* Ambient */)
7489
+ if (!node) {
7481
7490
return;
7491
+ }
7492
+ if (node.flags & 2 /* Ambient */) {
7493
+ return emitPinnedOrTripleSlashComments(node);
7494
+ }
7482
7495
switch (node.kind) {
7483
7496
case 55 /* Identifier */:
7484
7497
return emitIdentifier(node);
@@ -7582,6 +7595,8 @@ var ts;
7582
7595
return emitVariableDeclaration(node);
7583
7596
case 169 /* ClassDeclaration */:
7584
7597
return emitClassDeclaration(node);
7598
+ case 170 /* InterfaceDeclaration */:
7599
+ return emitInterfaceDeclaration(node);
7585
7600
case 171 /* EnumDeclaration */:
7586
7601
return emitEnumDeclaration(node);
7587
7602
case 172 /* ModuleDeclaration */:
@@ -7605,7 +7620,7 @@ var ts;
7605
7620
}
7606
7621
return leadingComments;
7607
7622
}
7608
- function emitLeadingDeclarationComments (node) {
7623
+ function getLeadingCommentsToEmit (node) {
7609
7624
if (node.parent.kind === 177 /* SourceFile */ || node.pos !== node.parent.pos) {
7610
7625
var leadingComments;
7611
7626
if (hasDetachedComments(node.pos)) {
@@ -7614,10 +7629,14 @@ var ts;
7614
7629
else {
7615
7630
leadingComments = ts.getLeadingCommentsOfNode(node, currentSourceFile);
7616
7631
}
7617
- emitNewLineBeforeLeadingComments(node, leadingComments, writer);
7618
- emitComments(leadingComments, true, writer, writeComment);
7632
+ return leadingComments;
7619
7633
}
7620
7634
}
7635
+ function emitLeadingDeclarationComments(node) {
7636
+ var leadingComments = getLeadingCommentsToEmit(node);
7637
+ emitNewLineBeforeLeadingComments(node, leadingComments, writer);
7638
+ emitComments(leadingComments, true, writer, writeComment);
7639
+ }
7621
7640
function emitTrailingDeclarationComments(node) {
7622
7641
if (node.parent.kind === 177 /* SourceFile */ || node.end !== node.parent.end) {
7623
7642
var trailingComments = ts.getTrailingComments(currentSourceFile.text, node.end);
@@ -7651,7 +7670,7 @@ var ts;
7651
7670
detachedComments.push(comment);
7652
7671
lastComment = comment;
7653
7672
});
7654
- if (detachedComments && detachedComments .length) {
7673
+ if (detachedComments.length) {
7655
7674
var lastCommentLine = getLineOfLocalPosition(detachedComments[detachedComments.length - 1].end);
7656
7675
var astLine = getLineOfLocalPosition(ts.skipTrivia(currentSourceFile.text, node.pos));
7657
7676
if (astLine >= lastCommentLine + 2) {
@@ -7668,6 +7687,19 @@ var ts;
7668
7687
}
7669
7688
}
7670
7689
}
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
+ }
7671
7703
if (compilerOptions.sourceMap) {
7672
7704
initializeEmitterWithSourceMaps();
7673
7705
}
@@ -9102,7 +9134,7 @@ var ts;
9102
9134
}
9103
9135
return symbol.name;
9104
9136
}
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 */) )) {
9106
9138
var symbolName;
9107
9139
while (symbol) {
9108
9140
var isFirstName = !symbolName;
@@ -10257,13 +10289,12 @@ var ts;
10257
10289
return emptyObjectType;
10258
10290
}
10259
10291
var type = getDeclaredTypeOfSymbol(symbol);
10260
- var name = symbol.name;
10261
10292
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);
10263
10294
return emptyObjectType;
10264
10295
}
10265
10296
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);
10267
10298
return emptyObjectType;
10268
10299
}
10269
10300
return type;
@@ -11395,7 +11426,8 @@ var ts;
11395
11426
}
11396
11427
return false;
11397
11428
}
11398
- function checkSuperExpression(node, isCallExpression) {
11429
+ function checkSuperExpression(node) {
11430
+ var isCallExpression = node.parent.kind === 132 /* CallExpression */ && node.parent.func === node;
11399
11431
var enclosingClass = getAncestor(node, 169 /* ClassDeclaration */);
11400
11432
var baseClass;
11401
11433
if (enclosingClass && enclosingClass.baseType) {
@@ -11897,7 +11929,7 @@ var ts;
11897
11929
}
11898
11930
function resolveCallExpression(node) {
11899
11931
if (node.func.kind === 81 /* SuperKeyword */) {
11900
- var superType = checkSuperExpression(node.func, true );
11932
+ var superType = checkSuperExpression(node.func);
11901
11933
if (superType !== unknownType) {
11902
11934
return resolveCall(node, getSignaturesOfType(superType, 1 /* Construct */));
11903
11935
}
@@ -12370,7 +12402,7 @@ var ts;
12370
12402
case 83 /* ThisKeyword */:
12371
12403
return checkThisExpression(node);
12372
12404
case 81 /* SuperKeyword */:
12373
- return checkSuperExpression(node, false );
12405
+ return checkSuperExpression(node);
12374
12406
case 79 /* NullKeyword */:
12375
12407
return nullType;
12376
12408
case 85 /* TrueKeyword */:
@@ -13811,6 +13843,7 @@ var ts;
13811
13843
case 114 /* Parameter */:
13812
13844
case 115 /* Property */:
13813
13845
case 176 /* EnumMember */:
13846
+ case 129 /* PropertyAssignment */:
13814
13847
return parent.initializer === node;
13815
13848
case 146 /* ExpressionStatement */:
13816
13849
case 147 /* IfStatement */:
@@ -13913,6 +13946,9 @@ var ts;
13913
13946
if (entityName.parent.kind === 175 /* ExportAssignment */) {
13914
13947
return resolveEntityName(entityName.parent.parent, entityName, ts.SymbolFlags.Value | ts.SymbolFlags.Type | ts.SymbolFlags.Namespace | 4194304 /* Import */);
13915
13948
}
13949
+ if (isInRightSideOfImportOrExportAssignment(entityName)) {
13950
+ return getSymbolOfPartOfRightHandSideOfImport(entityName);
13951
+ }
13916
13952
if (isRightSideOfQualifiedNameOrPropertyAccess(entityName)) {
13917
13953
entityName = entityName.parent;
13918
13954
}
@@ -14001,8 +14037,7 @@ var ts;
14001
14037
return getTypeOfSymbol(symbol);
14002
14038
}
14003
14039
if (isInRightSideOfImportOrExportAssignment(node)) {
14004
- var symbol;
14005
- symbol = node.parent.kind === 175 /* ExportAssignment */ ? getSymbolInfo(node) : getSymbolOfPartOfRightHandSideOfImport(node);
14040
+ var symbol = getSymbolInfo(node);
14006
14041
var declaredType = getDeclaredTypeOfSymbol(symbol);
14007
14042
return declaredType !== unknownType ? declaredType : getTypeOfSymbol(symbol);
14008
14043
}
@@ -14138,7 +14173,8 @@ var ts;
14138
14173
function isImplementationOfOverload(node) {
14139
14174
if (node.body) {
14140
14175
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);
14142
14178
}
14143
14179
return false;
14144
14180
}
@@ -14528,6 +14564,9 @@ var ts;
14528
14564
function createCompilerHost(options) {
14529
14565
var currentDirectory;
14530
14566
var existingDirectories = {};
14567
+ function getCanonicalFileName(fileName) {
14568
+ return sys.useCaseSensitiveFileNames ? fileName : fileName.toLowerCase();
14569
+ }
14531
14570
function getSourceFile(filename, languageVersion, onError) {
14532
14571
try {
14533
14572
var text = sys.readFile(filename, options.charset);
@@ -14573,7 +14612,7 @@ var ts;
14573
14612
writeFile: writeFile,
14574
14613
getCurrentDirectory: function () { return currentDirectory || (currentDirectory = sys.getCurrentDirectory()); },
14575
14614
useCaseSensitiveFileNames: function () { return sys.useCaseSensitiveFileNames; },
14576
- getCanonicalFileName: ts. getCanonicalFileName,
14615
+ getCanonicalFileName: getCanonicalFileName,
14577
14616
getNewLine: function () { return sys.newLine; }
14578
14617
};
14579
14618
}
0 commit comments