Skip to content

Commit 4329b45

Browse files
author
Arthur Ozga
committed
Cleanup
1 parent 7340c4c commit 4329b45

File tree

4 files changed

+12
-9
lines changed

4 files changed

+12
-9
lines changed

src/compiler/visitor.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -326,10 +326,12 @@ namespace ts {
326326

327327
case SyntaxKind.TypeOperator:
328328
return updateTypeOperatorNode(<TypeOperatorNode>node, visitNode((<TypeOperatorNode>node).type, visitor, isTypeNode));
329+
329330
case SyntaxKind.IndexedAccessType:
330331
return updateIndexedAccessTypeNode((<IndexedAccessTypeNode>node),
331332
visitNode((<IndexedAccessTypeNode>node).objectType, visitor, isTypeNode),
332333
visitNode((<IndexedAccessTypeNode>node).indexType, visitor, isTypeNode));
334+
333335
case SyntaxKind.MappedType:
334336
return updateMappedTypeNode((<MappedTypeNode>node),
335337
visitNode((<MappedTypeNode>node).readonlyToken, tokenVisitor, isToken),

src/harness/fourslash.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1676,7 +1676,7 @@ namespace FourSlash {
16761676
// We get back a set of edits, but langSvc.editScript only accepts one at a time. Use this to keep track
16771677
// of the incremental offset from each edit to the next. Assumption is that these edit ranges don't overlap
16781678
let runningOffset = 0;
1679-
edits = ts.stableSort(edits, (a, b) => a.span.start - b.span.start);
1679+
edits = edits.sort((a, b) => a.span.start - b.span.start);
16801680
// Get a snapshot of the content of the file so we can make sure any formatting edits didn't destroy non-whitespace characters
16811681
const oldContent = this.getFileContent(fileName);
16821682

src/services/codefixes/helpers.ts

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ namespace ts.codefix {
1111
}
1212

1313
const changes = changeTracker.getChanges();
14-
if (!(changes && changes.length > 0)) {
14+
if (!some(changes)) {
1515
return changes;
1616
}
1717

@@ -93,7 +93,7 @@ namespace ts.codefix {
9393
// (eg: an abstract method or interface declaration), there is a 1-1
9494
// correspondence of declarations and signatures.
9595
const signatures = checker.getSignaturesOfType(type, SignatureKind.Call);
96-
if (!(signatures && signatures.length > 0)) {
96+
if (!some(signatures)) {
9797
return undefined;
9898
}
9999

@@ -103,7 +103,7 @@ namespace ts.codefix {
103103
return signatureToMethodDeclaration(signature, enclosingDeclaration, createStubbedMethodBody());
104104
}
105105

106-
const signatureDeclarations = [];
106+
const signatureDeclarations: MethodDeclaration[] = [];
107107
for (let i = 0; i < signatures.length; i++) {
108108
const signature = signatures[i];
109109
const methodDeclaration = signatureToMethodDeclaration(signature, enclosingDeclaration);
@@ -132,6 +132,7 @@ namespace ts.codefix {
132132
function signatureToMethodDeclaration(signature: Signature, enclosingDeclaration: Node, body?: Block) {
133133
const signatureDeclaration = <MethodDeclaration>checker.signatureToSignatureDeclaration(signature, SyntaxKind.MethodDeclaration, enclosingDeclaration);
134134
if (signatureDeclaration) {
135+
signatureDeclaration.decorators = undefined;
135136
signatureDeclaration.modifiers = modifiers;
136137
signatureDeclaration.name = name;
137138
signatureDeclaration.questionToken = optional ? createToken(SyntaxKind.QuestionToken) : undefined;
@@ -142,8 +143,6 @@ namespace ts.codefix {
142143
}
143144

144145
function createMethodImplementingSignatures(signatures: Signature[], name: PropertyName, optional: boolean, modifiers: Modifier[] | undefined): MethodDeclaration {
145-
Debug.assert(signatures && signatures.length > 0);
146-
147146
/** This is *a* signature with the maximal number of arguments,
148147
* such that if there is a "maximal" signature without rest arguments,
149148
* this is one of them.
@@ -154,7 +153,9 @@ namespace ts.codefix {
154153
for (let i = 0; i < signatures.length; i++) {
155154
const sig = signatures[i];
156155
minArgumentCount = Math.min(sig.minArgumentCount, minArgumentCount);
157-
someSigHasRestParameter = someSigHasRestParameter || sig.hasRestParameter;
156+
if (sig.hasRestParameter) {
157+
someSigHasRestParameter = true;
158+
}
158159
if (sig.parameters.length >= maxArgsSignature.parameters.length && (!sig.hasRestParameter || maxArgsSignature.hasRestParameter)) {
159160
maxArgsSignature = sig;
160161
}

src/services/textChanges.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -276,7 +276,7 @@ namespace ts.textChanges {
276276
/**
277277
* This function should be used to insert nodes in lists when nodes don't carry separators as the part of the node range,
278278
* i.e. arguments in arguments lists, parameters in parameter lists etc.
279-
* Note that separators are art of the node in statements and class elements.
279+
* Note that separators are part of the node in statements and class elements.
280280
*/
281281
public insertNodeInListAfter(sourceFile: SourceFile, after: Node, newNode: Node) {
282282
const containingList = formatting.SmartIndenter.getContainingList(after, sourceFile);
@@ -484,7 +484,7 @@ namespace ts.textChanges {
484484
private static normalize(changes: Change[]) {
485485
// order changes by start position
486486
const normalized = stableSort(changes, (a, b) => a.range.pos - b.range.pos);
487-
// verify that change intervals to not overlap, except possible at end points.
487+
// verify that change intervals do not overlap, except possibly at end points.
488488
for (let i = 0; i < normalized.length - 2; i++) {
489489
Debug.assert(normalized[i].range.end <= normalized[i + 1].range.pos);
490490
}

0 commit comments

Comments
 (0)