Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions src/compiler/checker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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(<QualifiedName>node);
}
else {
Expand Down Expand Up @@ -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(<VariableDeclarationList>node.initializer);
}
}
Expand Down Expand Up @@ -11751,7 +11751,7 @@ namespace ts {
}

function isTypeDeclarationName(name: Node): boolean {
return name.kind == SyntaxKind.Identifier &&
return name.kind === SyntaxKind.Identifier &&
isTypeDeclaration(name.parent) &&
(<Declaration>name.parent).name === name;
}
Expand Down Expand Up @@ -11920,7 +11920,7 @@ namespace ts {
// Intentional fall-through
case SyntaxKind.NumericLiteral:
// index access
if (node.parent.kind == SyntaxKind.ElementAccessExpression && (<ElementAccessExpression>node.parent).argumentExpression === node) {
if (node.parent.kind === SyntaxKind.ElementAccessExpression && (<ElementAccessExpression>node.parent).argumentExpression === node) {
let objectType = checkExpression((<ElementAccessExpression>node.parent).expression);
if (objectType === unknownType) return undefined;
let apparentType = getApparentType(objectType);
Expand Down
2 changes: 1 addition & 1 deletion src/compiler/core.ts
Original file line number Diff line number Diff line change
Expand Up @@ -572,7 +572,7 @@ namespace ts {
export function getNormalizedPathComponents(path: string, currentDirectory: string) {
path = normalizeSlashes(path);
let rootLength = getRootLength(path);
if (rootLength == 0) {
if (rootLength === 0) {
// If the path is not rooted it is relative to current directory
path = combinePaths(normalizeSlashes(currentDirectory), path);
rootLength = getRootLength(path);
Expand Down
10 changes: 5 additions & 5 deletions src/compiler/emitter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -320,7 +320,7 @@ var __param = (this && this.__param) || function (paramIndex, decorator) {

let prevEncodedEmittedColumn = lastEncodedSourceMapSpan.emittedColumn;
// Line/Comma delimiters
if (lastEncodedSourceMapSpan.emittedLine == lastRecordedSourceMapSpan.emittedLine) {
if (lastEncodedSourceMapSpan.emittedLine === lastRecordedSourceMapSpan.emittedLine) {
// Emit comma to separate the entry
if (sourceMapData.sourceMapMappings) {
sourceMapData.sourceMapMappings += ",";
Expand Down Expand Up @@ -403,8 +403,8 @@ var __param = (this && this.__param) || function (paramIndex, decorator) {

// If this location wasn't recorded or the location in source is going backwards, record the span
if (!lastRecordedSourceMapSpan ||
lastRecordedSourceMapSpan.emittedLine != emittedLine ||
lastRecordedSourceMapSpan.emittedColumn != emittedColumn ||
lastRecordedSourceMapSpan.emittedLine !== emittedLine ||
lastRecordedSourceMapSpan.emittedColumn !== emittedColumn ||
(lastRecordedSourceMapSpan.sourceIndex === sourceMapSourceIndex &&
(lastRecordedSourceMapSpan.sourceLine > sourceLinePos.line ||
(lastRecordedSourceMapSpan.sourceLine === sourceLinePos.line && lastRecordedSourceMapSpan.sourceColumn > sourceLinePos.character)))) {
Expand Down Expand Up @@ -654,7 +654,7 @@ var __param = (this && this.__param) || function (paramIndex, decorator) {
if (nodeIsSynthesized(node)) {
return emitNodeWithoutSourceMap(node);
}
if (node.kind != SyntaxKind.SourceFile) {
if (node.kind !== SyntaxKind.SourceFile) {
recordEmitNodeStartSpan(node);
emitNodeWithoutSourceMap(node);
recordEmitNodeEndSpan(node);
Expand Down Expand Up @@ -1962,7 +1962,7 @@ var __param = (this && this.__param) || function (paramIndex, decorator) {

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

Expand Down
2 changes: 1 addition & 1 deletion src/compiler/scanner.ts
Original file line number Diff line number Diff line change
Expand Up @@ -934,7 +934,7 @@ namespace ts {
error(Diagnostics.Unexpected_end_of_text);
isInvalidExtendedEscape = true;
}
else if (text.charCodeAt(pos) == CharacterCodes.closeBrace) {
else if (text.charCodeAt(pos) === CharacterCodes.closeBrace) {
// Only swallow the following character up if it's a '}'.
pos++;
}
Expand Down
2 changes: 1 addition & 1 deletion src/compiler/utilities.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ namespace ts {
// Pool writers to avoid needing to allocate them for every symbol we write.
let stringWriters: StringSymbolWriter[] = [];
export function getSingleLineStringWriter(): StringSymbolWriter {
if (stringWriters.length == 0) {
if (stringWriters.length === 0) {
let str = "";

let writeText: (text: string) => void = text => str += text;
Expand Down
9 changes: 6 additions & 3 deletions src/harness/fourslash.ts
Original file line number Diff line number Diff line change
Expand Up @@ -831,13 +831,15 @@ module FourSlash {
if (expectedText !== undefined) {
assert.notEqual(actualQuickInfoText, expectedText, this.messageAtLastKnownMarker("quick info text"));
}
// TODO: should be '==='?
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i would switch them to just if( expectedDocumentation) and please remove comments

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 remove these comments. If these were causing issues, discuss in person with someone else on the team.

if (expectedDocumentation != undefined) {
assert.notEqual(actualQuickInfoDocumentation, expectedDocumentation, this.messageAtLastKnownMarker("quick info doc comment"));
}
} else {
if (expectedText !== undefined) {
assert.equal(actualQuickInfoText, expectedText, this.messageAtLastKnownMarker("quick info text"));
}
// TODO: should be '==='?
if (expectedDocumentation != undefined) {
assert.equal(actualQuickInfoDocumentation, expectedDocumentation, assertionMessage("quick info doc"));
}
Expand Down Expand Up @@ -1820,7 +1822,7 @@ module FourSlash {
}

private verifyProjectInfo(expected: string[]) {
if (this.testType == FourSlashTestType.Server) {
if (this.testType === FourSlashTestType.Server) {
let actual = (<ts.server.SessionClient>this.languageService).getProjectInfo(
this.activeFile.fileName,
/* needFileNameList */ true
Expand Down Expand Up @@ -1937,7 +1939,7 @@ module FourSlash {
}
}

if (expected != actual) {
if (expected !== actual) {
this.raiseError('verifyNavigationItemsCount failed - found: ' + actual + ' navigation items, expected: ' + expected + '.');
}
}
Expand Down Expand Up @@ -1984,7 +1986,7 @@ module FourSlash {
var items = this.languageService.getNavigationBarItems(this.activeFile.fileName);
var actual = this.getNavigationBarItemsCount(items);

if (expected != actual) {
if (expected !== actual) {
this.raiseError('verifyGetScriptLexicalStructureListCount failed - found: ' + actual + ' navigation items, expected: ' + expected + '.');
}
}
Expand Down Expand Up @@ -2402,6 +2404,7 @@ module FourSlash {
globalOptions[match[1]] = match[2];
}
}
// TODO: should be '==='?
} else if (line == '' || lineLength === 0) {
// Previously blank lines between fourslash content caused it to be considered as 2 files,
// Remove this behavior since it just causes errors now
Expand Down
3 changes: 2 additions & 1 deletion src/harness/projectsRunner.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 '!=='?
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should be safe to remove it.. i would run the tests as well. and please remove the comment

if (url.charCodeAt(0) != ts.CharacterCodes.slash) {
url = "/" + url;
}
Expand Down Expand Up @@ -240,7 +241,7 @@ class ProjectRunner extends RunnerBase {
if (Harness.Compiler.isJS(fileName)) {
// Make sure if there is URl we have it cleaned up
var indexOfSourceMapUrl = data.lastIndexOf("//# sourceMappingURL=");
if (indexOfSourceMapUrl != -1) {
if (indexOfSourceMapUrl !== -1) {
data = data.substring(0, indexOfSourceMapUrl + 21) + cleanProjectUrl(data.substring(indexOfSourceMapUrl + 21));
}
}
Expand Down
30 changes: 15 additions & 15 deletions src/harness/sourceMapRecorder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ module Harness.SourceMapRecoder {
}

function isSourceMappingSegmentEnd() {
if (decodingIndex == sourceMapMappings.length) {
if (decodingIndex === sourceMapMappings.length) {
return true;
}

Expand Down Expand Up @@ -95,15 +95,15 @@ 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);
shiftCount += 5;
}

// 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;
}
Expand Down Expand Up @@ -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 };
}

Expand Down Expand Up @@ -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 + ")";
}
}
Expand All @@ -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];
}
Expand All @@ -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);
Expand Down Expand Up @@ -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("");
}
}
Expand Down Expand Up @@ -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;
}
Expand Down
6 changes: 3 additions & 3 deletions src/server/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@ namespace ts.server {

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

Expand Down Expand Up @@ -429,8 +429,8 @@ namespace ts.server {
if (!this.lastRenameEntry ||
this.lastRenameEntry.fileName !== fileName ||
this.lastRenameEntry.position !== position ||
this.lastRenameEntry.findInStrings != findInStrings ||
this.lastRenameEntry.findInComments != findInComments) {
this.lastRenameEntry.findInStrings !== findInStrings ||
this.lastRenameEntry.findInComments !== findInComments) {
this.getRenameInfo(fileName, position, findInStrings, findInComments);
}

Expand Down
Loading