Skip to content

Commit 7e03429

Browse files
committed
enforce triple-equals
1 parent 9bfba73 commit 7e03429

29 files changed

+51
-50
lines changed

src/compiler/checker.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -338,7 +338,7 @@ namespace ts {
338338
TypeofNEHostObject = 1 << 13, // typeof x !== "xxx"
339339
EQUndefined = 1 << 14, // x === undefined
340340
EQNull = 1 << 15, // x === null
341-
EQUndefinedOrNull = 1 << 16, // x == undefined / x == null
341+
EQUndefinedOrNull = 1 << 16, // x === undefined / x === null
342342
NEUndefined = 1 << 17, // x !== undefined
343343
NENull = 1 << 18, // x !== null
344344
NEUndefinedOrNull = 1 << 19, // x != undefined / x != null
@@ -17506,7 +17506,7 @@ namespace ts {
1750617506
function checkObjectTypeForDuplicateDeclarations(node: TypeLiteralNode | InterfaceDeclaration) {
1750717507
const names = createMap<boolean>();
1750817508
for (const member of node.members) {
17509-
if (member.kind == SyntaxKind.PropertySignature) {
17509+
if (member.kind === SyntaxKind.PropertySignature) {
1751017510
let memberName: string;
1751117511
switch (member.name.kind) {
1751217512
case SyntaxKind.StringLiteral:

src/compiler/moduleNameResolver.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -378,7 +378,7 @@ namespace ts {
378378
directoryPathMap.set(parent, result);
379379
current = parent;
380380

381-
if (current == commonPrefix) {
381+
if (current === commonPrefix) {
382382
break;
383383
}
384384
}

src/compiler/program.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -557,7 +557,7 @@ namespace ts {
557557
// combine results of resolutions and predicted results
558558
let j = 0;
559559
for (let i = 0; i < result.length; i++) {
560-
if (result[i] == predictedToResolveToAmbientModuleMarker) {
560+
if (result[i] === predictedToResolveToAmbientModuleMarker) {
561561
result[i] = undefined;
562562
}
563563
else {
@@ -1364,7 +1364,7 @@ namespace ts {
13641364

13651365
// If the file was previously found via a node_modules search, but is now being processed as a root file,
13661366
// then everything it sucks in may also be marked incorrectly, and needs to be checked again.
1367-
if (file && sourceFilesFoundSearchingNodeModules.get(file.path) && currentNodeModulesDepth == 0) {
1367+
if (file && sourceFilesFoundSearchingNodeModules.get(file.path) && currentNodeModulesDepth === 0) {
13681368
sourceFilesFoundSearchingNodeModules.set(file.path, false);
13691369
if (!options.noResolve) {
13701370
processReferencedFiles(file, isDefaultLib);

src/compiler/tsc.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ namespace ts {
3030
}
3131

3232
function reportEmittedFiles(files: string[]): void {
33-
if (!files || files.length == 0) {
33+
if (!files || files.length === 0) {
3434
return;
3535
}
3636

@@ -282,7 +282,7 @@ namespace ts {
282282
// When the configFileName is just "tsconfig.json", the watched directory should be
283283
// the current directory; if there is a given "project" parameter, then the configFileName
284284
// is an absolute file name.
285-
directory == "" ? "." : directory,
285+
directory === "" ? "." : directory,
286286
watchedDirectoryChanged, /*recursive*/ true);
287287
}
288288
}
@@ -334,7 +334,7 @@ namespace ts {
334334
// When the configFileName is just "tsconfig.json", the watched directory should be
335335
// the current directory; if there is a given "project" parameter, then the configFileName
336336
// is an absolute file name.
337-
directory == "" ? "." : directory,
337+
directory === "" ? "." : directory,
338338
watchedDirectoryChanged, /*recursive*/ true);
339339
};
340340
}

src/compiler/utilities.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4658,7 +4658,7 @@ namespace ts {
46584658
*/
46594659
export function getParseTreeNode<T extends Node>(node: Node, nodeTest?: (node: Node) => node is T): T;
46604660
export function getParseTreeNode(node: Node, nodeTest?: (node: Node) => boolean): Node {
4661-
if (node == undefined || isParseTreeNode(node)) {
4661+
if (node === undefined || isParseTreeNode(node)) {
46624662
return node;
46634663
}
46644664

src/harness/fourslash.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2275,13 +2275,13 @@ namespace FourSlash {
22752275

22762276
public verifyImportFixAtPosition(expectedTextArray: string[], errorCode?: number) {
22772277
const ranges = this.getRanges();
2278-
if (ranges.length == 0) {
2278+
if (ranges.length === 0) {
22792279
this.raiseError("At least one range should be specified in the testfile.");
22802280
}
22812281

22822282
const codeFixes = this.getCodeFixActions(this.activeFile.fileName, errorCode);
22832283

2284-
if (!codeFixes || codeFixes.length == 0) {
2284+
if (!codeFixes || codeFixes.length === 0) {
22852285
this.raiseError("No codefixes returned.");
22862286
}
22872287

@@ -2646,7 +2646,7 @@ namespace FourSlash {
26462646
private assertItemInCompletionList(items: ts.CompletionEntry[], name: string, text?: string, documentation?: string, kind?: string, spanIndex?: number) {
26472647
for (const item of items) {
26482648
if (item.name === name) {
2649-
if (documentation != undefined || text !== undefined) {
2649+
if (documentation !== undefined || text !== undefined) {
26502650
const details = this.getCompletionEntryDetails(item.name);
26512651

26522652
if (documentation !== undefined) {
@@ -2899,7 +2899,7 @@ ${code}
28992899
}
29002900
// TODO: should be '==='?
29012901
}
2902-
else if (line == "" || lineLength === 0) {
2902+
else if (line === "" || lineLength === 0) {
29032903
// Previously blank lines between fourslash content caused it to be considered as 2 files,
29042904
// Remove this behavior since it just causes errors now
29052905
}

src/harness/harness.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1933,7 +1933,7 @@ namespace Harness {
19331933
}
19341934

19351935
const parentDirectory = IO.directoryName(dirName);
1936-
if (parentDirectory != "") {
1936+
if (parentDirectory !== "") {
19371937
createDirectoryStructure(parentDirectory);
19381938
}
19391939
IO.createDirectory(dirName);

src/harness/projectsRunner.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ class ProjectRunner extends RunnerBase {
112112
// Replace the disk specific path into the project root path
113113
url = url.substr(diskProjectPath.length);
114114
// TODO: should be '!=='?
115-
if (url.charCodeAt(0) != ts.CharacterCodes.slash) {
115+
if (url.charCodeAt(0) !== ts.CharacterCodes.slash) {
116116
url = "/" + url;
117117
}
118118
}

src/harness/sourceMapRecorder.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -50,11 +50,11 @@ namespace Harness.SourceMapRecorder {
5050
return true;
5151
}
5252

53-
if (sourceMapMappings.charAt(decodingIndex) == ",") {
53+
if (sourceMapMappings.charAt(decodingIndex) === ",") {
5454
return true;
5555
}
5656

57-
if (sourceMapMappings.charAt(decodingIndex) == ";") {
57+
if (sourceMapMappings.charAt(decodingIndex) === ";") {
5858
return true;
5959
}
6060

@@ -117,15 +117,15 @@ namespace Harness.SourceMapRecorder {
117117
}
118118

119119
while (decodingIndex < sourceMapMappings.length) {
120-
if (sourceMapMappings.charAt(decodingIndex) == ";") {
120+
if (sourceMapMappings.charAt(decodingIndex) === ";") {
121121
// New line
122122
decodeOfEncodedMapping.emittedLine++;
123123
decodeOfEncodedMapping.emittedColumn = 1;
124124
decodingIndex++;
125125
continue;
126126
}
127127

128-
if (sourceMapMappings.charAt(decodingIndex) == ",") {
128+
if (sourceMapMappings.charAt(decodingIndex) === ",") {
129129
// Next entry is on same line - no action needed
130130
decodingIndex++;
131131
continue;

src/harness/unittests/tsserverProjectSystem.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3144,7 +3144,7 @@ namespace ts.projectSystem {
31443144
checkNumberOfInferredProjects(projectService, 1);
31453145

31463146
const configuredProject = projectService.configuredProjects[0];
3147-
assert.isTrue(configuredProject.getFileNames().length == 0);
3147+
assert.isTrue(configuredProject.getFileNames().length === 0);
31483148

31493149
const inferredProject = projectService.inferredProjects[0];
31503150
assert.isTrue(inferredProject.containsFile(<server.NormalizedPath>file1.path));

0 commit comments

Comments
 (0)