diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index e27e69bb993..20d8f84e584 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -3523,7 +3523,7 @@ namespace ts { // -> typeParameter and symbol.declaration originate from the same type parameter list // -> illegal for all declarations in symbol // forEach === exists - links.isIllegalTypeReferenceInConstraint = forEach(symbol.declarations, d => d.parent == typeParameter.parent); + links.isIllegalTypeReferenceInConstraint = forEach(symbol.declarations, d => d.parent === typeParameter.parent); } } if (links.isIllegalTypeReferenceInConstraint) { @@ -8432,7 +8432,7 @@ namespace ts { // contextually typed function and arrow expressions in the initial phase. function checkExpression(node: Expression | QualifiedName, contextualMapper?: TypeMapper): Type { let type: Type; - if (node.kind == SyntaxKind.QualifiedName) { + if (node.kind === SyntaxKind.QualifiedName) { type = checkQualifiedName(node); } else { @@ -9871,7 +9871,7 @@ namespace ts { function checkForStatement(node: ForStatement) { // Grammar checking if (!checkGrammarStatementInAmbientContext(node)) { - if (node.initializer && node.initializer.kind == SyntaxKind.VariableDeclarationList) { + if (node.initializer && node.initializer.kind === SyntaxKind.VariableDeclarationList) { checkGrammarVariableDeclarationList(node.initializer); } } @@ -11751,7 +11751,7 @@ namespace ts { } function isTypeDeclarationName(name: Node): boolean { - return name.kind == SyntaxKind.Identifier && + return name.kind === SyntaxKind.Identifier && isTypeDeclaration(name.parent) && (name.parent).name === name; } diff --git a/src/harness/projectsRunner.ts b/src/harness/projectsRunner.ts index 324524272e0..dd5474364d7 100644 --- a/src/harness/projectsRunner.ts +++ b/src/harness/projectsRunner.ts @@ -110,6 +110,7 @@ class ProjectRunner extends RunnerBase { else if (url.indexOf(diskProjectPath) === 0) { // Replace the disk specific path into the project root path url = url.substr(diskProjectPath.length); + // TODO: should be '!=='? if (url.charCodeAt(0) != ts.CharacterCodes.slash) { url = "/" + url; } diff --git a/src/harness/sourceMapRecorder.ts b/src/harness/sourceMapRecorder.ts index 528e6ddd52b..ed079774d94 100644 --- a/src/harness/sourceMapRecorder.ts +++ b/src/harness/sourceMapRecorder.ts @@ -46,7 +46,7 @@ module Harness.SourceMapRecoder { } function isSourceMappingSegmentEnd() { - if (decodingIndex == sourceMapMappings.length) { + if (decodingIndex === sourceMapMappings.length) { return true; } @@ -95,7 +95,7 @@ module Harness.SourceMapRecoder { var currentByte = base64FormatDecode(); // If msb is set, we still have more bits to continue - moreDigits = (currentByte & 32) != 0; + moreDigits = (currentByte & 32) !== 0; // least significant 5 bits are the next msbs in the final value. value = value | ((currentByte & 31) << shiftCount); @@ -103,7 +103,7 @@ module Harness.SourceMapRecoder { } // Least significant bit if 1 represents negative and rest of the msb is actual absolute value - if ((value & 1) == 0) { + if ((value & 1) === 0) { // + number value = value >> 1; } @@ -182,7 +182,7 @@ module Harness.SourceMapRecoder { } } // Dont support reading mappings that dont have information about original source and its line numbers - if (createErrorIfCondition(!isSourceMappingSegmentEnd(), "Unsupported Error Format: There are more entries after " + (decodeOfEncodedMapping.nameIndex == -1 ? "sourceColumn" : "nameIndex"))) { + if (createErrorIfCondition(!isSourceMappingSegmentEnd(), "Unsupported Error Format: There are more entries after " + (decodeOfEncodedMapping.nameIndex === -1 ? "sourceColumn" : "nameIndex"))) { return { error: errorDecodeOfEncodedMapping, sourceMapSpan: decodeOfEncodedMapping }; } @@ -249,7 +249,7 @@ module Harness.SourceMapRecoder { mapString += " name (" + sourceMapNames[mapEntry.nameIndex] + ")"; } else { - if (mapEntry.nameIndex != -1 || getAbsentNameIndex) { + if (mapEntry.nameIndex !== -1 || getAbsentNameIndex) { mapString += " nameIndex (" + mapEntry.nameIndex + ")"; } } @@ -262,12 +262,12 @@ module Harness.SourceMapRecoder { var decodeResult = SourceMapDecoder.decodeNextEncodedSourceMapSpan(); var decodedErrors: string[]; if (decodeResult.error - || decodeResult.sourceMapSpan.emittedLine != sourceMapSpan.emittedLine - || decodeResult.sourceMapSpan.emittedColumn != sourceMapSpan.emittedColumn - || decodeResult.sourceMapSpan.sourceLine != sourceMapSpan.sourceLine - || decodeResult.sourceMapSpan.sourceColumn != sourceMapSpan.sourceColumn - || decodeResult.sourceMapSpan.sourceIndex != sourceMapSpan.sourceIndex - || decodeResult.sourceMapSpan.nameIndex != sourceMapSpan.nameIndex) { + || decodeResult.sourceMapSpan.emittedLine !== sourceMapSpan.emittedLine + || decodeResult.sourceMapSpan.emittedColumn !== sourceMapSpan.emittedColumn + || decodeResult.sourceMapSpan.sourceLine !== sourceMapSpan.sourceLine + || decodeResult.sourceMapSpan.sourceColumn !== sourceMapSpan.sourceColumn + || decodeResult.sourceMapSpan.sourceIndex !== sourceMapSpan.sourceIndex + || decodeResult.sourceMapSpan.nameIndex !== sourceMapSpan.nameIndex) { if (decodeResult.error) { decodedErrors = ["!!^^ !!^^ There was decoding error in the sourcemap at this location: " + decodeResult.error]; } @@ -288,7 +288,7 @@ module Harness.SourceMapRecoder { } export function recordNewSourceFileSpan(sourceMapSpan: ts.SourceMapSpan, newSourceFileCode: string) { - 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"); + 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"); recordSourceMapSpan(sourceMapSpan); assert.isTrue(spansOnSingleLine.length === 1); @@ -395,9 +395,9 @@ module Harness.SourceMapRecoder { var tsCodeLineMap = ts.computeLineStarts(sourceText); for (var i = 0; i < tsCodeLineMap.length; i++) { - writeSourceMapIndent(prevEmittedCol, i == 0 ? markerIds[index] : " >"); + writeSourceMapIndent(prevEmittedCol, i === 0 ? markerIds[index] : " >"); sourceMapRecoder.Write(getTextOfLine(i, tsCodeLineMap, sourceText)); - if (i == tsCodeLineMap.length - 1) { + if (i === tsCodeLineMap.length - 1) { sourceMapRecoder.WriteLine(""); } } @@ -447,7 +447,7 @@ module Harness.SourceMapRecoder { for (var j = 0; j < sourceMapData.sourceMapDecodedMappings.length; j++) { var decodedSourceMapping = sourceMapData.sourceMapDecodedMappings[j]; var currentSourceFile = program.getSourceFile(sourceMapData.inputSourceFileNames[decodedSourceMapping.sourceIndex]); - if (currentSourceFile != prevSourceFile) { + if (currentSourceFile !== prevSourceFile) { SourceMapSpanWriter.recordNewSourceFileSpan(decodedSourceMapping, currentSourceFile.text); prevSourceFile = currentSourceFile; } diff --git a/src/services/formatting/rulesMap.ts b/src/services/formatting/rulesMap.ts index 4f231bd842e..bffbb75c02e 100644 --- a/src/services/formatting/rulesMap.ts +++ b/src/services/formatting/rulesMap.ts @@ -41,15 +41,15 @@ namespace ts.formatting { } private FillRule(rule: Rule, rulesBucketConstructionStateList: RulesBucketConstructionState[]): void { - let specificRule = rule.Descriptor.LeftTokenRange != Shared.TokenRange.Any && - rule.Descriptor.RightTokenRange != Shared.TokenRange.Any; + let specificRule = rule.Descriptor.LeftTokenRange !== Shared.TokenRange.Any && + rule.Descriptor.RightTokenRange !== Shared.TokenRange.Any; rule.Descriptor.LeftTokenRange.GetTokens().forEach((left) => { rule.Descriptor.RightTokenRange.GetTokens().forEach((right) => { let rulesBucketIndex = this.GetRuleBucketIndex(left, right); let rulesBucket = this.map[rulesBucketIndex]; - if (rulesBucket == undefined) { + if (rulesBucket === undefined) { rulesBucket = this.map[rulesBucketIndex] = new RulesBucket(); } @@ -124,7 +124,7 @@ namespace ts.formatting { public IncreaseInsertionIndex(maskPosition: RulesPosition): void { let value = (this.rulesInsertionIndexBitmap >> maskPosition) & Mask; value++; - Debug.assert((value & Mask) == value, "Adding more rules into the sub-bucket than allowed. Maximum allowed is 32 rules."); + Debug.assert((value & Mask) === value, "Adding more rules into the sub-bucket than allowed. Maximum allowed is 32 rules."); let temp = this.rulesInsertionIndexBitmap & ~(Mask << maskPosition); temp |= value << maskPosition; @@ -147,7 +147,7 @@ namespace ts.formatting { public AddRule(rule: Rule, specificTokens: boolean, constructionState: RulesBucketConstructionState[], rulesBucketIndex: number): void { let position: RulesPosition; - if (rule.Operation.Action == RuleAction.Ignore) { + if (rule.Operation.Action === RuleAction.Ignore) { position = specificTokens ? RulesPosition.IgnoreRulesSpecific : RulesPosition.IgnoreRulesAny; diff --git a/src/services/formatting/rulesProvider.ts b/src/services/formatting/rulesProvider.ts index bd8f4fc3a5e..5317e9e50fe 100644 --- a/src/services/formatting/rulesProvider.ts +++ b/src/services/formatting/rulesProvider.ts @@ -25,6 +25,7 @@ namespace ts.formatting { } public ensureUpToDate(options: ts.FormatCodeOptions) { + // TODO: should this be '==='? if (this.options == null || !ts.compareDataObjects(this.options, options)) { let activeRules = this.createActiveRules(options); let rulesMap = RulesMap.create(activeRules); diff --git a/src/services/formatting/tokenRange.ts b/src/services/formatting/tokenRange.ts index 27a43280f2c..3391365f328 100644 --- a/src/services/formatting/tokenRange.ts +++ b/src/services/formatting/tokenRange.ts @@ -54,7 +54,7 @@ namespace ts.formatting { } public Contains(tokenValue: SyntaxKind): boolean { - return tokenValue == this.token; + return tokenValue === this.token; } } diff --git a/src/services/patternMatcher.ts b/src/services/patternMatcher.ts index d56c7fac975..ea433867c46 100644 --- a/src/services/patternMatcher.ts +++ b/src/services/patternMatcher.ts @@ -686,7 +686,7 @@ namespace ts { if (charIsPunctuation(identifier.charCodeAt(i - 1)) || charIsPunctuation(identifier.charCodeAt(i)) || - lastIsDigit != currentIsDigit || + lastIsDigit !== currentIsDigit || hasTransitionFromLowerToUpper || hasTransitionFromUpperToLower) { @@ -757,7 +757,7 @@ namespace ts { // 3) HTMLDocument -> HTML, Document // // etc. - if (index != wordStart && + if (index !== wordStart && index + 1 < identifier.length) { let currentIsUpper = isUpperCaseLetter(identifier.charCodeAt(index)); let nextIsLower = isLowerCaseLetter(identifier.charCodeAt(index + 1)); diff --git a/src/services/services.ts b/src/services/services.ts index 3939e62cfd2..d0ea89c7a16 100644 --- a/src/services/services.ts +++ b/src/services/services.ts @@ -6043,7 +6043,8 @@ namespace ts { */ function hasValueSideModule(symbol: Symbol): boolean { return forEach(symbol.declarations, declaration => { - return declaration.kind === SyntaxKind.ModuleDeclaration && getModuleInstanceState(declaration) == ModuleInstanceState.Instantiated; + return declaration.kind === SyntaxKind.ModuleDeclaration && + getModuleInstanceState(declaration) === ModuleInstanceState.Instantiated; }); } } diff --git a/src/services/shims.ts b/src/services/shims.ts index 9a586a1ec12..2e8b3eb774d 100644 --- a/src/services/shims.ts +++ b/src/services/shims.ts @@ -234,6 +234,7 @@ namespace ts { public getChangeRange(oldSnapshot: IScriptSnapshot): TextChangeRange { var oldSnapshotShim = oldSnapshot; var encoded = this.scriptSnapshotShim.getChangeRange(oldSnapshotShim.scriptSnapshotShim); + // TODO: should this be '==='? if (encoded == null) { return null; } @@ -283,6 +284,7 @@ namespace ts { public getCompilationSettings(): CompilerOptions { var settingsJson = this.shimHost.getCompilationSettings(); + // TODO: should this be '==='? if (settingsJson == null || settingsJson == "") { throw Error("LanguageServiceShimHostAdapter.getCompilationSettings: empty compilationSettings"); return null;