Skip to content

Commit 26fd879

Browse files
committed
Merge branch 'master' into extendsExpressions
2 parents efcccaa + 33b0a56 commit 26fd879

File tree

551 files changed

+1067
-1592
lines changed

Some content is hidden

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

551 files changed

+1067
-1592
lines changed

src/compiler/checker.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3600,7 +3600,7 @@ namespace ts {
36003600
// -> typeParameter and symbol.declaration originate from the same type parameter list
36013601
// -> illegal for all declarations in symbol
36023602
// forEach === exists
3603-
links.isIllegalTypeReferenceInConstraint = forEach(symbol.declarations, d => d.parent == typeParameter.parent);
3603+
links.isIllegalTypeReferenceInConstraint = forEach(symbol.declarations, d => d.parent === typeParameter.parent);
36043604
}
36053605
}
36063606
if (links.isIllegalTypeReferenceInConstraint) {
@@ -8489,7 +8489,7 @@ namespace ts {
84898489
// contextually typed function and arrow expressions in the initial phase.
84908490
function checkExpression(node: Expression | QualifiedName, contextualMapper?: TypeMapper): Type {
84918491
let type: Type;
8492-
if (node.kind == SyntaxKind.QualifiedName) {
8492+
if (node.kind === SyntaxKind.QualifiedName) {
84938493
type = checkQualifiedName(<QualifiedName>node);
84948494
}
84958495
else {
@@ -9925,7 +9925,7 @@ namespace ts {
99259925
function checkForStatement(node: ForStatement) {
99269926
// Grammar checking
99279927
if (!checkGrammarStatementInAmbientContext(node)) {
9928-
if (node.initializer && node.initializer.kind == SyntaxKind.VariableDeclarationList) {
9928+
if (node.initializer && node.initializer.kind === SyntaxKind.VariableDeclarationList) {
99299929
checkGrammarVariableDeclarationList(<VariableDeclarationList>node.initializer);
99309930
}
99319931
}
@@ -11805,7 +11805,7 @@ namespace ts {
1180511805
}
1180611806

1180711807
function isTypeDeclarationName(name: Node): boolean {
11808-
return name.kind == SyntaxKind.Identifier &&
11808+
return name.kind === SyntaxKind.Identifier &&
1180911809
isTypeDeclaration(name.parent) &&
1181011810
(<Declaration>name.parent).name === name;
1181111811
}
@@ -11974,7 +11974,7 @@ namespace ts {
1197411974
// Intentional fall-through
1197511975
case SyntaxKind.NumericLiteral:
1197611976
// index access
11977-
if (node.parent.kind == SyntaxKind.ElementAccessExpression && (<ElementAccessExpression>node.parent).argumentExpression === node) {
11977+
if (node.parent.kind === SyntaxKind.ElementAccessExpression && (<ElementAccessExpression>node.parent).argumentExpression === node) {
1197811978
let objectType = checkExpression((<ElementAccessExpression>node.parent).expression);
1197911979
if (objectType === unknownType) return undefined;
1198011980
let apparentType = getApparentType(objectType);

src/compiler/core.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -572,7 +572,7 @@ namespace ts {
572572
export function getNormalizedPathComponents(path: string, currentDirectory: string) {
573573
path = normalizeSlashes(path);
574574
let rootLength = getRootLength(path);
575-
if (rootLength == 0) {
575+
if (rootLength === 0) {
576576
// If the path is not rooted it is relative to current directory
577577
path = combinePaths(normalizeSlashes(currentDirectory), path);
578578
rootLength = getRootLength(path);

src/compiler/emitter.ts

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,7 @@ namespace ts {
2121
var __extends = (this && this.__extends) || function (d, b) {
2222
for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
2323
function __() { this.constructor = d; }
24-
__.prototype = b.prototype;
25-
d.prototype = new __();
24+
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
2625
};`;
2726

2827
// emit output for the __decorate helper function
@@ -320,7 +319,7 @@ var __param = (this && this.__param) || function (paramIndex, decorator) {
320319

321320
let prevEncodedEmittedColumn = lastEncodedSourceMapSpan.emittedColumn;
322321
// Line/Comma delimiters
323-
if (lastEncodedSourceMapSpan.emittedLine == lastRecordedSourceMapSpan.emittedLine) {
322+
if (lastEncodedSourceMapSpan.emittedLine === lastRecordedSourceMapSpan.emittedLine) {
324323
// Emit comma to separate the entry
325324
if (sourceMapData.sourceMapMappings) {
326325
sourceMapData.sourceMapMappings += ",";
@@ -403,8 +402,8 @@ var __param = (this && this.__param) || function (paramIndex, decorator) {
403402

404403
// If this location wasn't recorded or the location in source is going backwards, record the span
405404
if (!lastRecordedSourceMapSpan ||
406-
lastRecordedSourceMapSpan.emittedLine != emittedLine ||
407-
lastRecordedSourceMapSpan.emittedColumn != emittedColumn ||
405+
lastRecordedSourceMapSpan.emittedLine !== emittedLine ||
406+
lastRecordedSourceMapSpan.emittedColumn !== emittedColumn ||
408407
(lastRecordedSourceMapSpan.sourceIndex === sourceMapSourceIndex &&
409408
(lastRecordedSourceMapSpan.sourceLine > sourceLinePos.line ||
410409
(lastRecordedSourceMapSpan.sourceLine === sourceLinePos.line && lastRecordedSourceMapSpan.sourceColumn > sourceLinePos.character)))) {
@@ -654,7 +653,7 @@ var __param = (this && this.__param) || function (paramIndex, decorator) {
654653
if (nodeIsSynthesized(node)) {
655654
return emitNodeWithoutSourceMap(node);
656655
}
657-
if (node.kind != SyntaxKind.SourceFile) {
656+
if (node.kind !== SyntaxKind.SourceFile) {
658657
recordEmitNodeStartSpan(node);
659658
emitNodeWithoutSourceMap(node);
660659
recordEmitNodeEndSpan(node);
@@ -1962,7 +1961,7 @@ var __param = (this && this.__param) || function (paramIndex, decorator) {
19621961

19631962
// Make sure we consider all nested cast expressions, e.g.:
19641963
// (<any><number><any>-A).x;
1965-
while (operand.kind == SyntaxKind.TypeAssertionExpression) {
1964+
while (operand.kind === SyntaxKind.TypeAssertionExpression) {
19661965
operand = (<TypeAssertion>operand).expression;
19671966
}
19681967

src/compiler/program.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ namespace ts {
144144
let program: Program;
145145
let files: SourceFile[] = [];
146146
let diagnostics = createDiagnosticCollection();
147-
147+
148148
let commonSourceDirectory: string;
149149
let diagnosticsProducingTypeChecker: TypeChecker;
150150
let noDiagnosticsTypeChecker: TypeChecker;
@@ -678,4 +678,4 @@ namespace ts {
678678
}
679679
}
680680
}
681-
}
681+
}

src/compiler/scanner.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -934,7 +934,7 @@ namespace ts {
934934
error(Diagnostics.Unexpected_end_of_text);
935935
isInvalidExtendedEscape = true;
936936
}
937-
else if (text.charCodeAt(pos) == CharacterCodes.closeBrace) {
937+
else if (text.charCodeAt(pos) === CharacterCodes.closeBrace) {
938938
// Only swallow the following character up if it's a '}'.
939939
pos++;
940940
}

src/compiler/utilities.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ namespace ts {
4242
// Pool writers to avoid needing to allocate them for every symbol we write.
4343
let stringWriters: StringSymbolWriter[] = [];
4444
export function getSingleLineStringWriter(): StringSymbolWriter {
45-
if (stringWriters.length == 0) {
45+
if (stringWriters.length === 0) {
4646
let str = "";
4747

4848
let writeText: (text: string) => void = text => str += text;

src/harness/fourslash.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -831,13 +831,15 @@ module FourSlash {
831831
if (expectedText !== undefined) {
832832
assert.notEqual(actualQuickInfoText, expectedText, this.messageAtLastKnownMarker("quick info text"));
833833
}
834+
// TODO: should be '==='?
834835
if (expectedDocumentation != undefined) {
835836
assert.notEqual(actualQuickInfoDocumentation, expectedDocumentation, this.messageAtLastKnownMarker("quick info doc comment"));
836837
}
837838
} else {
838839
if (expectedText !== undefined) {
839840
assert.equal(actualQuickInfoText, expectedText, this.messageAtLastKnownMarker("quick info text"));
840841
}
842+
// TODO: should be '==='?
841843
if (expectedDocumentation != undefined) {
842844
assert.equal(actualQuickInfoDocumentation, expectedDocumentation, assertionMessage("quick info doc"));
843845
}
@@ -1820,7 +1822,7 @@ module FourSlash {
18201822
}
18211823

18221824
private verifyProjectInfo(expected: string[]) {
1823-
if (this.testType == FourSlashTestType.Server) {
1825+
if (this.testType === FourSlashTestType.Server) {
18241826
let actual = (<ts.server.SessionClient>this.languageService).getProjectInfo(
18251827
this.activeFile.fileName,
18261828
/* needFileNameList */ true
@@ -1937,7 +1939,7 @@ module FourSlash {
19371939
}
19381940
}
19391941

1940-
if (expected != actual) {
1942+
if (expected !== actual) {
19411943
this.raiseError('verifyNavigationItemsCount failed - found: ' + actual + ' navigation items, expected: ' + expected + '.');
19421944
}
19431945
}
@@ -1984,7 +1986,7 @@ module FourSlash {
19841986
var items = this.languageService.getNavigationBarItems(this.activeFile.fileName);
19851987
var actual = this.getNavigationBarItemsCount(items);
19861988

1987-
if (expected != actual) {
1989+
if (expected !== actual) {
19881990
this.raiseError('verifyGetScriptLexicalStructureListCount failed - found: ' + actual + ' navigation items, expected: ' + expected + '.');
19891991
}
19901992
}
@@ -2402,6 +2404,7 @@ module FourSlash {
24022404
globalOptions[match[1]] = match[2];
24032405
}
24042406
}
2407+
// TODO: should be '==='?
24052408
} else if (line == '' || lineLength === 0) {
24062409
// Previously blank lines between fourslash content caused it to be considered as 2 files,
24072410
// Remove this behavior since it just causes errors now

src/harness/projectsRunner.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,7 @@ class ProjectRunner extends RunnerBase {
110110
else if (url.indexOf(diskProjectPath) === 0) {
111111
// Replace the disk specific path into the project root path
112112
url = url.substr(diskProjectPath.length);
113+
// TODO: should be '!=='?
113114
if (url.charCodeAt(0) != ts.CharacterCodes.slash) {
114115
url = "/" + url;
115116
}
@@ -240,7 +241,7 @@ class ProjectRunner extends RunnerBase {
240241
if (Harness.Compiler.isJS(fileName)) {
241242
// Make sure if there is URl we have it cleaned up
242243
var indexOfSourceMapUrl = data.lastIndexOf("//# sourceMappingURL=");
243-
if (indexOfSourceMapUrl != -1) {
244+
if (indexOfSourceMapUrl !== -1) {
244245
data = data.substring(0, indexOfSourceMapUrl + 21) + cleanProjectUrl(data.substring(indexOfSourceMapUrl + 21));
245246
}
246247
}

src/harness/sourceMapRecorder.ts

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ module Harness.SourceMapRecoder {
4646
}
4747

4848
function isSourceMappingSegmentEnd() {
49-
if (decodingIndex == sourceMapMappings.length) {
49+
if (decodingIndex === sourceMapMappings.length) {
5050
return true;
5151
}
5252

@@ -95,15 +95,15 @@ module Harness.SourceMapRecoder {
9595
var currentByte = base64FormatDecode();
9696

9797
// If msb is set, we still have more bits to continue
98-
moreDigits = (currentByte & 32) != 0;
98+
moreDigits = (currentByte & 32) !== 0;
9999

100100
// least significant 5 bits are the next msbs in the final value.
101101
value = value | ((currentByte & 31) << shiftCount);
102102
shiftCount += 5;
103103
}
104104

105105
// Least significant bit if 1 represents negative and rest of the msb is actual absolute value
106-
if ((value & 1) == 0) {
106+
if ((value & 1) === 0) {
107107
// + number
108108
value = value >> 1;
109109
}
@@ -182,7 +182,7 @@ module Harness.SourceMapRecoder {
182182
}
183183
}
184184
// Dont support reading mappings that dont have information about original source and its line numbers
185-
if (createErrorIfCondition(!isSourceMappingSegmentEnd(), "Unsupported Error Format: There are more entries after " + (decodeOfEncodedMapping.nameIndex == -1 ? "sourceColumn" : "nameIndex"))) {
185+
if (createErrorIfCondition(!isSourceMappingSegmentEnd(), "Unsupported Error Format: There are more entries after " + (decodeOfEncodedMapping.nameIndex === -1 ? "sourceColumn" : "nameIndex"))) {
186186
return { error: errorDecodeOfEncodedMapping, sourceMapSpan: decodeOfEncodedMapping };
187187
}
188188

@@ -249,7 +249,7 @@ module Harness.SourceMapRecoder {
249249
mapString += " name (" + sourceMapNames[mapEntry.nameIndex] + ")";
250250
}
251251
else {
252-
if (mapEntry.nameIndex != -1 || getAbsentNameIndex) {
252+
if (mapEntry.nameIndex !== -1 || getAbsentNameIndex) {
253253
mapString += " nameIndex (" + mapEntry.nameIndex + ")";
254254
}
255255
}
@@ -262,12 +262,12 @@ module Harness.SourceMapRecoder {
262262
var decodeResult = SourceMapDecoder.decodeNextEncodedSourceMapSpan();
263263
var decodedErrors: string[];
264264
if (decodeResult.error
265-
|| decodeResult.sourceMapSpan.emittedLine != sourceMapSpan.emittedLine
266-
|| decodeResult.sourceMapSpan.emittedColumn != sourceMapSpan.emittedColumn
267-
|| decodeResult.sourceMapSpan.sourceLine != sourceMapSpan.sourceLine
268-
|| decodeResult.sourceMapSpan.sourceColumn != sourceMapSpan.sourceColumn
269-
|| decodeResult.sourceMapSpan.sourceIndex != sourceMapSpan.sourceIndex
270-
|| decodeResult.sourceMapSpan.nameIndex != sourceMapSpan.nameIndex) {
265+
|| decodeResult.sourceMapSpan.emittedLine !== sourceMapSpan.emittedLine
266+
|| decodeResult.sourceMapSpan.emittedColumn !== sourceMapSpan.emittedColumn
267+
|| decodeResult.sourceMapSpan.sourceLine !== sourceMapSpan.sourceLine
268+
|| decodeResult.sourceMapSpan.sourceColumn !== sourceMapSpan.sourceColumn
269+
|| decodeResult.sourceMapSpan.sourceIndex !== sourceMapSpan.sourceIndex
270+
|| decodeResult.sourceMapSpan.nameIndex !== sourceMapSpan.nameIndex) {
271271
if (decodeResult.error) {
272272
decodedErrors = ["!!^^ !!^^ There was decoding error in the sourcemap at this location: " + decodeResult.error];
273273
}
@@ -288,7 +288,7 @@ module Harness.SourceMapRecoder {
288288
}
289289

290290
export function recordNewSourceFileSpan(sourceMapSpan: ts.SourceMapSpan, newSourceFileCode: string) {
291-
assert.isTrue(spansOnSingleLine.length == 0 || spansOnSingleLine[0].sourceMapSpan.emittedLine !== sourceMapSpan.emittedLine, "new file source map span should be on new line. We currently handle only that scenario");
291+
assert.isTrue(spansOnSingleLine.length === 0 || spansOnSingleLine[0].sourceMapSpan.emittedLine !== sourceMapSpan.emittedLine, "new file source map span should be on new line. We currently handle only that scenario");
292292
recordSourceMapSpan(sourceMapSpan);
293293

294294
assert.isTrue(spansOnSingleLine.length === 1);
@@ -395,9 +395,9 @@ module Harness.SourceMapRecoder {
395395

396396
var tsCodeLineMap = ts.computeLineStarts(sourceText);
397397
for (var i = 0; i < tsCodeLineMap.length; i++) {
398-
writeSourceMapIndent(prevEmittedCol, i == 0 ? markerIds[index] : " >");
398+
writeSourceMapIndent(prevEmittedCol, i === 0 ? markerIds[index] : " >");
399399
sourceMapRecoder.Write(getTextOfLine(i, tsCodeLineMap, sourceText));
400-
if (i == tsCodeLineMap.length - 1) {
400+
if (i === tsCodeLineMap.length - 1) {
401401
sourceMapRecoder.WriteLine("");
402402
}
403403
}
@@ -447,7 +447,7 @@ module Harness.SourceMapRecoder {
447447
for (var j = 0; j < sourceMapData.sourceMapDecodedMappings.length; j++) {
448448
var decodedSourceMapping = sourceMapData.sourceMapDecodedMappings[j];
449449
var currentSourceFile = program.getSourceFile(sourceMapData.inputSourceFileNames[decodedSourceMapping.sourceIndex]);
450-
if (currentSourceFile != prevSourceFile) {
450+
if (currentSourceFile !== prevSourceFile) {
451451
SourceMapSpanWriter.recordNewSourceFileSpan(decodedSourceMapping, currentSourceFile.text);
452452
prevSourceFile = currentSourceFile;
453453
}

src/server/client.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -219,7 +219,7 @@ namespace ts.server {
219219

220220
var request = this.processRequest<protocol.CompletionDetailsRequest>(CommandNames.CompletionDetails, args);
221221
var response = this.processResponse<protocol.CompletionDetailsResponse>(request);
222-
Debug.assert(response.body.length == 1, "Unexpected length of completion details response body.");
222+
Debug.assert(response.body.length === 1, "Unexpected length of completion details response body.");
223223
return response.body[0];
224224
}
225225

@@ -429,8 +429,8 @@ namespace ts.server {
429429
if (!this.lastRenameEntry ||
430430
this.lastRenameEntry.fileName !== fileName ||
431431
this.lastRenameEntry.position !== position ||
432-
this.lastRenameEntry.findInStrings != findInStrings ||
433-
this.lastRenameEntry.findInComments != findInComments) {
432+
this.lastRenameEntry.findInStrings !== findInStrings ||
433+
this.lastRenameEntry.findInComments !== findInComments) {
434434
this.getRenameInfo(fileName, position, findInStrings, findInComments);
435435
}
436436

0 commit comments

Comments
 (0)