Skip to content

Commit b038d28

Browse files
authored
Merge pull request #15013 from aozgaa/tripleEquals
enforce triple-equals
2 parents 62f44fb + cbbf6f8 commit b038d28

29 files changed

+52
-55
lines changed

src/compiler/checker.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -349,7 +349,7 @@ namespace ts {
349349
TypeofNEHostObject = 1 << 13, // typeof x !== "xxx"
350350
EQUndefined = 1 << 14, // x === undefined
351351
EQNull = 1 << 15, // x === null
352-
EQUndefinedOrNull = 1 << 16, // x == undefined / x == null
352+
EQUndefinedOrNull = 1 << 16, // x === undefined / x === null
353353
NEUndefined = 1 << 17, // x !== undefined
354354
NENull = 1 << 18, // x !== null
355355
NEUndefinedOrNull = 1 << 19, // x != undefined / x != null
@@ -17616,7 +17616,7 @@ namespace ts {
1761617616
function checkObjectTypeForDuplicateDeclarations(node: TypeLiteralNode | InterfaceDeclaration) {
1761717617
const names = createMap<boolean>();
1761817618
for (const member of node.members) {
17619-
if (member.kind == SyntaxKind.PropertySignature) {
17619+
if (member.kind === SyntaxKind.PropertySignature) {
1762017620
let memberName: string;
1762117621
switch (member.name.kind) {
1762217622
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: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4428,7 +4428,7 @@ namespace ts {
44284428
newEndN = Math.max(newEnd2, newEnd2 + (newEnd1 - oldEnd2));
44294429
}
44304430

4431-
return createTextChangeRange(createTextSpanFromBounds(oldStartN, oldEndN), /*newLength:*/ newEndN - oldStartN);
4431+
return createTextChangeRange(createTextSpanFromBounds(oldStartN, oldEndN), /*newLength*/ newEndN - oldStartN);
44324432
}
44334433

44344434
export function getTypeParameterOwner(d: Declaration): Declaration {
@@ -4604,7 +4604,7 @@ namespace ts {
46044604
*/
46054605
export function getParseTreeNode<T extends Node>(node: Node, nodeTest?: (node: Node) => node is T): T;
46064606
export function getParseTreeNode(node: Node, nodeTest?: (node: Node) => boolean): Node {
4607-
if (node == undefined || isParseTreeNode(node)) {
4607+
if (node === undefined || isParseTreeNode(node)) {
46084608
return node;
46094609
}
46104610

src/harness/fourslash.ts

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

23682368
public verifyImportFixAtPosition(expectedTextArray: string[], errorCode?: number) {
23692369
const ranges = this.getRanges();
2370-
if (ranges.length == 0) {
2370+
if (ranges.length === 0) {
23712371
this.raiseError("At least one range should be specified in the testfile.");
23722372
}
23732373

23742374
const codeFixes = this.getCodeFixActions(this.activeFile.fileName, errorCode);
23752375

2376-
if (!codeFixes || codeFixes.length == 0) {
2376+
if (!codeFixes || codeFixes.length === 0) {
23772377
this.raiseError("No codefixes returned.");
23782378
}
23792379

@@ -2738,7 +2738,7 @@ namespace FourSlash {
27382738
private assertItemInCompletionList(items: ts.CompletionEntry[], name: string, text?: string, documentation?: string, kind?: string, spanIndex?: number) {
27392739
for (const item of items) {
27402740
if (item.name === name) {
2741-
if (documentation != undefined || text !== undefined) {
2741+
if (documentation !== undefined || text !== undefined) {
27422742
const details = this.getCompletionEntryDetails(item.name);
27432743

27442744
if (documentation !== undefined) {
@@ -2989,9 +2989,8 @@ ${code}
29892989
}
29902990
}
29912991
}
2992-
// TODO: should be '==='?
29932992
}
2994-
else if (line == "" || lineLength === 0) {
2993+
else if (line === "" || lineLength === 0) {
29952994
// Previously blank lines between fourslash content caused it to be considered as 2 files,
29962995
// Remove this behavior since it just causes errors now
29972996
}

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 & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -111,8 +111,7 @@ class ProjectRunner extends RunnerBase {
111111
else if (url.indexOf(diskProjectPath) === 0) {
112112
// Replace the disk specific path into the project root path
113113
url = url.substr(diskProjectPath.length);
114-
// TODO: should be '!=='?
115-
if (url.charCodeAt(0) != ts.CharacterCodes.slash) {
114+
if (url.charCodeAt(0) !== ts.CharacterCodes.slash) {
116115
url = "/" + url;
117116
}
118117
}

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
@@ -3228,7 +3228,7 @@ namespace ts.projectSystem {
32283228
checkNumberOfInferredProjects(projectService, 1);
32293229

32303230
const configuredProject = projectService.configuredProjects[0];
3231-
assert.isTrue(configuredProject.getFileNames().length == 0);
3231+
assert.isTrue(configuredProject.getFileNames().length === 0);
32323232

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

0 commit comments

Comments
 (0)