diff --git a/src/compiler/visitor.ts b/src/compiler/visitor.ts index c110ea4227..297d2cc0dd 100644 --- a/src/compiler/visitor.ts +++ b/src/compiler/visitor.ts @@ -326,10 +326,12 @@ namespace ts { case SyntaxKind.TypeOperator: return updateTypeOperatorNode(node, visitNode((node).type, visitor, isTypeNode)); + case SyntaxKind.IndexedAccessType: return updateIndexedAccessTypeNode((node), visitNode((node).objectType, visitor, isTypeNode), visitNode((node).indexType, visitor, isTypeNode)); + case SyntaxKind.MappedType: return updateMappedTypeNode((node), visitNode((node).readonlyToken, tokenVisitor, isToken), diff --git a/src/harness/fourslash.ts b/src/harness/fourslash.ts index 4ef6b54e1b..98ebacd49b 100644 --- a/src/harness/fourslash.ts +++ b/src/harness/fourslash.ts @@ -1676,7 +1676,7 @@ namespace FourSlash { // We get back a set of edits, but langSvc.editScript only accepts one at a time. Use this to keep track // of the incremental offset from each edit to the next. Assumption is that these edit ranges don't overlap let runningOffset = 0; - edits = ts.stableSort(edits, (a, b) => a.span.start - b.span.start); + edits = edits.sort((a, b) => a.span.start - b.span.start); // Get a snapshot of the content of the file so we can make sure any formatting edits didn't destroy non-whitespace characters const oldContent = this.getFileContent(fileName); diff --git a/src/services/codefixes/helpers.ts b/src/services/codefixes/helpers.ts index a7809cdd21..b836815fc2 100644 --- a/src/services/codefixes/helpers.ts +++ b/src/services/codefixes/helpers.ts @@ -11,7 +11,7 @@ namespace ts.codefix { } const changes = changeTracker.getChanges(); - if (!(changes && changes.length > 0)) { + if (!some(changes)) { return changes; } @@ -93,7 +93,7 @@ namespace ts.codefix { // (eg: an abstract method or interface declaration), there is a 1-1 // correspondence of declarations and signatures. const signatures = checker.getSignaturesOfType(type, SignatureKind.Call); - if (!(signatures && signatures.length > 0)) { + if (!some(signatures)) { return undefined; } @@ -103,7 +103,7 @@ namespace ts.codefix { return signatureToMethodDeclaration(signature, enclosingDeclaration, createStubbedMethodBody()); } - const signatureDeclarations = []; + const signatureDeclarations: MethodDeclaration[] = []; for (let i = 0; i < signatures.length; i++) { const signature = signatures[i]; const methodDeclaration = signatureToMethodDeclaration(signature, enclosingDeclaration); @@ -132,6 +132,7 @@ namespace ts.codefix { function signatureToMethodDeclaration(signature: Signature, enclosingDeclaration: Node, body?: Block) { const signatureDeclaration = checker.signatureToSignatureDeclaration(signature, SyntaxKind.MethodDeclaration, enclosingDeclaration); if (signatureDeclaration) { + signatureDeclaration.decorators = undefined; signatureDeclaration.modifiers = modifiers; signatureDeclaration.name = name; signatureDeclaration.questionToken = optional ? createToken(SyntaxKind.QuestionToken) : undefined; @@ -142,8 +143,6 @@ namespace ts.codefix { } function createMethodImplementingSignatures(signatures: Signature[], name: PropertyName, optional: boolean, modifiers: Modifier[] | undefined): MethodDeclaration { - Debug.assert(signatures && signatures.length > 0); - /** This is *a* signature with the maximal number of arguments, * such that if there is a "maximal" signature without rest arguments, * this is one of them. @@ -154,7 +153,9 @@ namespace ts.codefix { for (let i = 0; i < signatures.length; i++) { const sig = signatures[i]; minArgumentCount = Math.min(sig.minArgumentCount, minArgumentCount); - someSigHasRestParameter = someSigHasRestParameter || sig.hasRestParameter; + if (sig.hasRestParameter) { + someSigHasRestParameter = true; + } if (sig.parameters.length >= maxArgsSignature.parameters.length && (!sig.hasRestParameter || maxArgsSignature.hasRestParameter)) { maxArgsSignature = sig; } diff --git a/src/services/textChanges.ts b/src/services/textChanges.ts index 73d5fc61bc..afc9892749 100644 --- a/src/services/textChanges.ts +++ b/src/services/textChanges.ts @@ -276,7 +276,7 @@ namespace ts.textChanges { /** * This function should be used to insert nodes in lists when nodes don't carry separators as the part of the node range, * i.e. arguments in arguments lists, parameters in parameter lists etc. - * Note that separators are art of the node in statements and class elements. + * Note that separators are part of the node in statements and class elements. */ public insertNodeInListAfter(sourceFile: SourceFile, after: Node, newNode: Node) { const containingList = formatting.SmartIndenter.getContainingList(after, sourceFile); @@ -484,7 +484,7 @@ namespace ts.textChanges { private static normalize(changes: Change[]) { // order changes by start position const normalized = stableSort(changes, (a, b) => a.range.pos - b.range.pos); - // verify that change intervals to not overlap, except possible at end points. + // verify that change intervals do not overlap, except possibly at end points. for (let i = 0; i < normalized.length - 2; i++) { Debug.assert(normalized[i].range.end <= normalized[i + 1].range.pos); }