Skip to content

Commit 01e1b14

Browse files
committed
Merge pull request #3644 from Microsoft/refactoring
Change var -> let and use destructuring
2 parents d695afa + c3af662 commit 01e1b14

File tree

1 file changed

+23
-23
lines changed

1 file changed

+23
-23
lines changed

src/services/services.ts

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1797,7 +1797,7 @@ namespace ts {
17971797
let outputText: string;
17981798

17991799
// Create a compilerHost object to allow the compiler to read and write files
1800-
var compilerHost: CompilerHost = {
1800+
let compilerHost: CompilerHost = {
18011801
getSourceFile: (fileName, target) => fileName === inputFileName ? sourceFile : undefined,
18021802
writeFile: (name, text, writeByteOrderMark) => {
18031803
Debug.assert(outputText === undefined, "Unexpected multiple outputs for the file: " + name);
@@ -1810,7 +1810,7 @@ namespace ts {
18101810
getNewLine: () => newLine
18111811
};
18121812

1813-
var program = createProgram([inputFileName], options, compilerHost);
1813+
let program = createProgram([inputFileName], options, compilerHost);
18141814

18151815
addRange(/*to*/ diagnostics, /*from*/ program.getSyntacticDiagnostics(sourceFile));
18161816
addRange(/*to*/ diagnostics, /*from*/ program.getOptionsDiagnostics());
@@ -3084,7 +3084,7 @@ namespace ts {
30843084
* accurately aggregate locals from the closest containing scope.
30853085
*/
30863086
function getScopeNode(initialToken: Node, position: number, sourceFile: SourceFile) {
3087-
var scope = initialToken;
3087+
let scope = initialToken;
30883088
while (scope && !positionBelongsToNode(scope, position, sourceFile)) {
30893089
scope = scope.parent;
30903090
}
@@ -3485,10 +3485,10 @@ namespace ts {
34853485

34863486
function getCompletionEntriesFromSymbols(symbols: Symbol[]): CompletionEntry[] {
34873487
let start = new Date().getTime();
3488-
var entries: CompletionEntry[] = [];
3488+
let entries: CompletionEntry[] = [];
34893489

34903490
if (symbols) {
3491-
var nameToSymbol: Map<Symbol> = {};
3491+
let nameToSymbol: Map<Symbol> = {};
34923492
for (let symbol of symbols) {
34933493
let entry = createCompletionEntry(symbol, location);
34943494
if (entry) {
@@ -3522,13 +3522,13 @@ namespace ts {
35223522
let symbol = forEach(symbols, s => getCompletionEntryDisplayNameForSymbol(s, target, /*performCharacterChecks:*/ false) === entryName ? s : undefined);
35233523

35243524
if (symbol) {
3525-
let displayPartsDocumentationsAndSymbolKind = getSymbolDisplayPartsDocumentationAndSymbolKind(symbol, getValidSourceFile(fileName), location, location, SemanticMeaning.All);
3525+
let { displayParts, documentation, symbolKind } = getSymbolDisplayPartsDocumentationAndSymbolKind(symbol, getValidSourceFile(fileName), location, location, SemanticMeaning.All);
35263526
return {
35273527
name: entryName,
3528-
kind: displayPartsDocumentationsAndSymbolKind.symbolKind,
35293528
kindModifiers: getSymbolModifiers(symbol),
3530-
displayParts: displayPartsDocumentationsAndSymbolKind.displayParts,
3531-
documentation: displayPartsDocumentationsAndSymbolKind.documentation
3529+
kind: symbolKind,
3530+
displayParts,
3531+
documentation
35323532
};
35333533
}
35343534
}
@@ -4203,7 +4203,7 @@ namespace ts {
42034203
}
42044204

42054205
if (type.flags & TypeFlags.Union) {
4206-
var result: DefinitionInfo[] = [];
4206+
let result: DefinitionInfo[] = [];
42074207
forEach((<UnionType>type).types, t => {
42084208
if (t.symbol) {
42094209
addRange(/*to*/ result, /*from*/ getDefinitionFromSymbol(t.symbol, node));
@@ -4303,7 +4303,7 @@ namespace ts {
43034303
function getSyntacticDocumentHighlights(node: Node): DocumentHighlights[] {
43044304
let fileName = sourceFile.fileName;
43054305

4306-
var highlightSpans = getHighlightSpans(node);
4306+
let highlightSpans = getHighlightSpans(node);
43074307
if (!highlightSpans || highlightSpans.length === 0) {
43084308
return undefined;
43094309
}
@@ -4881,17 +4881,17 @@ namespace ts {
48814881
}
48824882

48834883
function findRenameLocations(fileName: string, position: number, findInStrings: boolean, findInComments: boolean): RenameLocation[] {
4884-
var referencedSymbols = findReferencedSymbols(fileName, position, findInStrings, findInComments);
4884+
let referencedSymbols = findReferencedSymbols(fileName, position, findInStrings, findInComments);
48854885
return convertReferences(referencedSymbols);
48864886
}
48874887

48884888
function getReferencesAtPosition(fileName: string, position: number): ReferenceEntry[] {
4889-
var referencedSymbols = findReferencedSymbols(fileName, position, /*findInStrings:*/ false, /*findInComments:*/ false);
4889+
let referencedSymbols = findReferencedSymbols(fileName, position, /*findInStrings:*/ false, /*findInComments:*/ false);
48904890
return convertReferences(referencedSymbols);
48914891
}
48924892

48934893
function findReferences(fileName: string, position: number): ReferencedSymbol[]{
4894-
var referencedSymbols = findReferencedSymbols(fileName, position, /*findInStrings:*/ false, /*findInComments:*/ false);
4894+
let referencedSymbols = findReferencedSymbols(fileName, position, /*findInStrings:*/ false, /*findInComments:*/ false);
48954895

48964896
// Only include referenced symbols that have a valid definition.
48974897
return filter(referencedSymbols, rs => !!rs.definition);
@@ -5190,7 +5190,7 @@ namespace ts {
51905190
}
51915191
});
51925192

5193-
var definition: DefinitionInfo = {
5193+
let definition: DefinitionInfo = {
51945194
containerKind: "",
51955195
containerName: "",
51965196
fileName: targetLabel.getSourceFile().fileName,
@@ -5286,10 +5286,10 @@ namespace ts {
52865286
if (referenceSymbol) {
52875287
let referenceSymbolDeclaration = referenceSymbol.valueDeclaration;
52885288
let shorthandValueSymbol = typeChecker.getShorthandAssignmentValueSymbol(referenceSymbolDeclaration);
5289-
var relatedSymbol = getRelatedSymbol(searchSymbols, referenceSymbol, referenceLocation);
5289+
let relatedSymbol = getRelatedSymbol(searchSymbols, referenceSymbol, referenceLocation);
52905290

52915291
if (relatedSymbol) {
5292-
var referencedSymbol = getReferencedSymbol(relatedSymbol);
5292+
let referencedSymbol = getReferencedSymbol(relatedSymbol);
52935293
referencedSymbol.references.push(getReferenceEntryFromNode(referenceLocation));
52945294
}
52955295
/* Because in short-hand property assignment, an identifier which stored as name of the short-hand property assignment
@@ -5299,7 +5299,7 @@ namespace ts {
52995299
* position of property accessing, the referenceEntry of such position will be handled in the first case.
53005300
*/
53015301
else if (!(referenceSymbol.flags & SymbolFlags.Transient) && searchSymbols.indexOf(shorthandValueSymbol) >= 0) {
5302-
var referencedSymbol = getReferencedSymbol(shorthandValueSymbol);
5302+
let referencedSymbol = getReferencedSymbol(shorthandValueSymbol);
53035303
referencedSymbol.references.push(getReferenceEntryFromNode(referenceSymbolDeclaration.name));
53045304
}
53055305
}
@@ -5309,8 +5309,8 @@ namespace ts {
53095309
return;
53105310

53115311
function getReferencedSymbol(symbol: Symbol): ReferencedSymbol {
5312-
var symbolId = getSymbolId(symbol);
5313-
var index = symbolToIndex[symbolId];
5312+
let symbolId = getSymbolId(symbol);
5313+
let index = symbolToIndex[symbolId];
53145314
if (index === undefined) {
53155315
index = result.length;
53165316
symbolToIndex[symbolId] = index;
@@ -5397,7 +5397,7 @@ namespace ts {
53975397
}
53985398
});
53995399

5400-
var definition = getDefinition(searchSpaceNode.symbol);
5400+
let definition = getDefinition(searchSpaceNode.symbol);
54015401
return [{ definition, references }];
54025402
}
54035403

@@ -5592,7 +5592,7 @@ namespace ts {
55925592
// If the reference symbol is an alias, check if what it is aliasing is one of the search
55935593
// symbols.
55945594
if (isImportOrExportSpecifierImportSymbol(referenceSymbol)) {
5595-
var aliasedSymbol = typeChecker.getAliasedSymbol(referenceSymbol);
5595+
let aliasedSymbol = typeChecker.getAliasedSymbol(referenceSymbol);
55965596
if (searchSymbols.indexOf(aliasedSymbol) >= 0) {
55975597
return aliasedSymbol;
55985598
}
@@ -6908,7 +6908,7 @@ namespace ts {
69086908
}
69096909

69106910
function convertClassifications(classifications: Classifications, text: string): ClassificationResult {
6911-
var entries: ClassificationInfo[] = [];
6911+
let entries: ClassificationInfo[] = [];
69126912
let dense = classifications.spans;
69136913
let lastEnd = 0;
69146914

0 commit comments

Comments
 (0)