From 193f4be355168145ede3a8186b9b7ff13339c3ca Mon Sep 17 00:00:00 2001 From: Andy Date: Thu, 7 Sep 2017 09:14:59 -0700 Subject: [PATCH] Enable interface-over-type-literal lint rule (#17733) --- src/compiler/checker.ts | 2 +- src/harness/unittests/convertTypeAcquisitionFromJson.ts | 2 +- src/server/protocol.ts | 8 ++++---- src/server/typingsInstaller/typingsInstaller.ts | 4 ++-- src/services/navigateTo.ts | 8 +++++++- src/services/types.ts | 9 ++++----- tslint.json | 1 + 7 files changed, 20 insertions(+), 14 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 1c8bc7846d0..b7f0894d284 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -21516,7 +21516,7 @@ namespace ts { return true; } - type InheritanceInfoMap = { prop: Symbol; containingType: Type }; + interface InheritanceInfoMap { prop: Symbol; containingType: Type; } const seen = createUnderscoreEscapedMap(); forEach(resolveDeclaredMembers(type).declaredProperties, p => { seen.set(p.escapedName, { prop: p, containingType: type }); }); let ok = true; diff --git a/src/harness/unittests/convertTypeAcquisitionFromJson.ts b/src/harness/unittests/convertTypeAcquisitionFromJson.ts index aae4ee38382..67646de3680 100644 --- a/src/harness/unittests/convertTypeAcquisitionFromJson.ts +++ b/src/harness/unittests/convertTypeAcquisitionFromJson.ts @@ -2,7 +2,7 @@ /// namespace ts { - type ExpectedResult = { typeAcquisition: TypeAcquisition, errors: Diagnostic[] }; + interface ExpectedResult { typeAcquisition: TypeAcquisition; errors: Diagnostic[]; } describe("convertTypeAcquisitionFromJson", () => { function assertTypeAcquisition(json: any, configFileName: string, expectedResult: ExpectedResult) { assertTypeAcquisitionWithJson(json, configFileName, expectedResult); diff --git a/src/server/protocol.ts b/src/server/protocol.ts index 37bf79837c9..3fdbd8fd7f7 100644 --- a/src/server/protocol.ts +++ b/src/server/protocol.ts @@ -466,7 +466,7 @@ namespace ts.server.protocol { * Represents a single refactoring action - for example, the "Extract Method..." refactor might * offer several actions, each corresponding to a surround class or closure to extract into. */ - export type RefactorActionInfo = { + export interface RefactorActionInfo { /** * The programmatic name of the refactoring action */ @@ -478,7 +478,7 @@ namespace ts.server.protocol { * so this description should make sense by itself if the parent is inlineable=true */ description: string; - }; + } export interface GetEditsForRefactorRequest extends Request { command: CommandTypes.GetEditsForRefactor; @@ -501,7 +501,7 @@ namespace ts.server.protocol { body?: RefactorEditInfo; } - export type RefactorEditInfo = { + export interface RefactorEditInfo { edits: FileCodeEdits[]; /** @@ -510,7 +510,7 @@ namespace ts.server.protocol { */ renameLocation?: Location; renameFilename?: string; - }; + } /** * Request for the available codefixes at a specific position. diff --git a/src/server/typingsInstaller/typingsInstaller.ts b/src/server/typingsInstaller/typingsInstaller.ts index c6423bc3c7b..3eae0755747 100644 --- a/src/server/typingsInstaller/typingsInstaller.ts +++ b/src/server/typingsInstaller/typingsInstaller.ts @@ -73,12 +73,12 @@ namespace ts.server.typingsInstaller { } export type RequestCompletedAction = (success: boolean) => void; - type PendingRequest = { + interface PendingRequest { requestId: number; args: string[]; cwd: string; onRequestCompleted: RequestCompletedAction; - }; + } export abstract class TypingsInstaller { private readonly packageNameToTypingLocation: Map = createMap(); diff --git a/src/services/navigateTo.ts b/src/services/navigateTo.ts index 6d84769082d..ec7b011456f 100644 --- a/src/services/navigateTo.ts +++ b/src/services/navigateTo.ts @@ -1,6 +1,12 @@ /* @internal */ namespace ts.NavigateTo { - type RawNavigateToItem = { name: string; fileName: string; matchKind: PatternMatchKind; isCaseSensitive: boolean; declaration: Declaration }; + interface RawNavigateToItem { + name: string; + fileName: string; + matchKind: PatternMatchKind; + isCaseSensitive: boolean; + declaration: Declaration; + } export function getNavigateToItems(sourceFiles: ReadonlyArray, checker: TypeChecker, cancellationToken: CancellationToken, searchValue: string, maxResultCount: number, excludeDtsFiles: boolean): NavigateToItem[] { const patternMatcher = createPatternMatcher(searchValue); diff --git a/src/services/types.ts b/src/services/types.ts index 609eaf11de5..8a23bfec1c5 100644 --- a/src/services/types.ts +++ b/src/services/types.ts @@ -394,7 +394,7 @@ namespace ts { * Represents a single refactoring action - for example, the "Extract Method..." refactor might * offer several actions, each corresponding to a surround class or closure to extract into. */ - export type RefactorActionInfo = { + export interface RefactorActionInfo { /** * The programmatic name of the refactoring action */ @@ -406,18 +406,17 @@ namespace ts { * so this description should make sense by itself if the parent is inlineable=true */ description: string; - }; + } /** * A set of edits to make in response to a refactor action, plus an optional * location where renaming should be invoked from */ - export type RefactorEditInfo = { + export interface RefactorEditInfo { edits: FileTextChanges[]; renameFilename?: string; renameLocation?: number; - }; - + } export interface TextInsertion { newText: string; diff --git a/tslint.json b/tslint.json index de60ad7683a..30e71eb5e0d 100644 --- a/tslint.json +++ b/tslint.json @@ -11,6 +11,7 @@ "indent": [true, "spaces" ], + "interface-over-type-literal": true, "jsdoc-format": true, "linebreak-style": [true, "CRLF"], "next-line": [true,