From 3428e275e66eda357a1a94b33be1a7c1929a0f2c Mon Sep 17 00:00:00 2001 From: Nathan Shively-Sanders <293473+sandersn@users.noreply.github.com> Date: Fri, 10 Apr 2020 09:06:43 -0700 Subject: [PATCH] Reorder tsconfig and move one more function --- src/services/codefixes/fixAddMissingMember.ts | 13 ------------ .../codefixes/fixPropertyOverrideAccessor.ts | 16 +-------------- src/services/codefixes/generateAccessors.ts | 16 ++++++++++++++- src/services/tsconfig.json | 20 +++++++++---------- 4 files changed, 26 insertions(+), 39 deletions(-) diff --git a/src/services/codefixes/fixAddMissingMember.ts b/src/services/codefixes/fixAddMissingMember.ts index 7a5098d60655a..fbecac8f33afa 100644 --- a/src/services/codefixes/fixAddMissingMember.ts +++ b/src/services/codefixes/fixAddMissingMember.ts @@ -83,19 +83,6 @@ namespace ts.codefix { }, }); - function getAllSupers(decl: ClassOrInterface | undefined, checker: TypeChecker): readonly ClassOrInterface[] { - const res: ClassLikeDeclaration[] = []; - while (decl) { - const superElement = getClassExtendsHeritageElement(decl); - const superSymbol = superElement && checker.getSymbolAtLocation(superElement.expression); - const superDecl = superSymbol && find(superSymbol.declarations, isClassLike); - if (superDecl) { res.push(superDecl); } - decl = superDecl; - } - return res; - } - - type ClassOrInterface = ClassLikeDeclaration | InterfaceDeclaration; const enum InfoKind { Enum, ClassOrInterface } interface EnumInfo { readonly kind: InfoKind.Enum; diff --git a/src/services/codefixes/fixPropertyOverrideAccessor.ts b/src/services/codefixes/fixPropertyOverrideAccessor.ts index 7fdf18f1eec60..ac4b292b5bf4a 100644 --- a/src/services/codefixes/fixPropertyOverrideAccessor.ts +++ b/src/services/codefixes/fixPropertyOverrideAccessor.ts @@ -34,6 +34,7 @@ namespace ts.codefix { endPosition = context.span.start + context.span.length } else if (context.errorCode === Diagnostics._0_is_defined_as_a_property_in_class_1_but_is_overridden_here_in_2_as_an_accessor.code) { + // TODO: A lot of these should be bails instead of asserts const checker = context.program.getTypeChecker() const node = getTokenAtPosition(context.sourceFile, context.span.start).parent; Debug.assert(isAccessor(node), "it wasn't an accessor"); @@ -55,19 +56,4 @@ namespace ts.codefix { const refactorContext = { ...context, file: context.sourceFile, startPosition, endPosition } return getEditsForAction(refactorContext, Diagnostics.Generate_get_and_set_accessors.message); } - - // TODO: Stolen from a different codefix, should dedupe it somewhere. - function getAllSupers(decl: ClassOrInterface | undefined, checker: TypeChecker): readonly ClassOrInterface[] { - const res: ClassLikeDeclaration[] = []; - while (decl) { - const superElement = getClassExtendsHeritageElement(decl); - const superSymbol = superElement && checker.getSymbolAtLocation(superElement.expression); - const superDecl = superSymbol && find(superSymbol.declarations, isClassLike); - if (superDecl) { res.push(superDecl); } - decl = superDecl; - } - return res; - } - - type ClassOrInterface = ClassLikeDeclaration | InterfaceDeclaration; } diff --git a/src/services/codefixes/generateAccessors.ts b/src/services/codefixes/generateAccessors.ts index 5fb2cf0507761..067c47923dbcc 100644 --- a/src/services/codefixes/generateAccessors.ts +++ b/src/services/codefixes/generateAccessors.ts @@ -17,7 +17,7 @@ namespace ts.codefix { } // TODO: Use a general type instead of Refactor* types - // TODO: Rename this to show that it generates accessor + // TODO: Rename this to show that it generates accessors export function getEditsForAction(context: RefactorContext, _actionName: string): RefactorEditInfo | undefined { const { file } = context; @@ -217,4 +217,18 @@ namespace ts.codefix { } }); } + + export function getAllSupers(decl: ClassOrInterface | undefined, checker: TypeChecker): readonly ClassOrInterface[] { + const res: ClassLikeDeclaration[] = []; + while (decl) { + const superElement = getClassExtendsHeritageElement(decl); + const superSymbol = superElement && checker.getSymbolAtLocation(superElement.expression); + const superDecl = superSymbol && find(superSymbol.declarations, isClassLike); + if (superDecl) { res.push(superDecl); } + decl = superDecl; + } + return res; + } + + export type ClassOrInterface = ClassLikeDeclaration | InterfaceDeclaration; } diff --git a/src/services/tsconfig.json b/src/services/tsconfig.json index 9777f53d95136..5aa8d835fb629 100644 --- a/src/services/tsconfig.json +++ b/src/services/tsconfig.json @@ -61,30 +61,30 @@ "codefixes/correctQualifiedNameToIndexedAccessType.ts", "codefixes/convertToTypeOnlyExport.ts", "codefixes/convertToTypeOnlyImport.ts", + "codefixes/fixClassIncorrectlyImplementsInterface.ts", + "codefixes/importFixes.ts", + "codefixes/fixImplicitThis.ts", + "codefixes/fixSpelling.ts", + "codefixes/returnValueCorrect.ts", "codefixes/fixAddMissingMember.ts", "codefixes/fixAddMissingNewOperator.ts", - "codefixes/fixAwaitInSyncFunction.ts", "codefixes/fixCannotFindModule.ts", "codefixes/fixClassDoesntImplementInheritedAbstractMember.ts", - "codefixes/fixClassIncorrectlyImplementsInterface.ts", "codefixes/fixClassSuperMustPrecedeThisAccess.ts", "codefixes/fixConstructorForDerivedNeedSuperCall.ts", "codefixes/fixEnableExperimentalDecorators.ts", "codefixes/fixEnableJsxFlag.ts", + "codefixes/fixModuleAndTargetOptions.ts", "codefixes/fixExtendsInterfaceBecomesImplements.ts", "codefixes/fixForgottenThisPropertyAccess.ts", - "codefixes/fixImplicitThis.ts", "codefixes/fixInvalidJsxCharacters.ts", + "codefixes/fixUnusedIdentifier.ts", + "codefixes/fixUnreachableCode.ts", + "codefixes/fixUnusedLabel.ts", "codefixes/fixJSDocTypes.ts", "codefixes/fixMissingCallParentheses.ts", - "codefixes/fixModuleAndTargetOptions.ts", + "codefixes/fixAwaitInSyncFunction.ts", "codefixes/fixPropertyOverrideAccessor.ts", - "codefixes/fixSpelling.ts", - "codefixes/fixUnreachableCode.ts", - "codefixes/fixUnusedIdentifier.ts", - "codefixes/fixUnusedLabel.ts", - "codefixes/importFixes.ts", - "codefixes/returnValueCorrect.ts", "codefixes/inferFromUsage.ts", "codefixes/disableJsDiagnostics.ts", "codefixes/helpers.ts",