Skip to content

Commit 193f4be

Browse files
author
Andy
authored
Enable interface-over-type-literal lint rule (#17733)
1 parent be06338 commit 193f4be

File tree

7 files changed

+20
-14
lines changed

7 files changed

+20
-14
lines changed

src/compiler/checker.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21516,7 +21516,7 @@ namespace ts {
2151621516
return true;
2151721517
}
2151821518

21519-
type InheritanceInfoMap = { prop: Symbol; containingType: Type };
21519+
interface InheritanceInfoMap { prop: Symbol; containingType: Type; }
2152021520
const seen = createUnderscoreEscapedMap<InheritanceInfoMap>();
2152121521
forEach(resolveDeclaredMembers(type).declaredProperties, p => { seen.set(p.escapedName, { prop: p, containingType: type }); });
2152221522
let ok = true;

src/harness/unittests/convertTypeAcquisitionFromJson.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
/// <reference path="..\..\compiler\commandLineParser.ts" />
33

44
namespace ts {
5-
type ExpectedResult = { typeAcquisition: TypeAcquisition, errors: Diagnostic[] };
5+
interface ExpectedResult { typeAcquisition: TypeAcquisition; errors: Diagnostic[]; }
66
describe("convertTypeAcquisitionFromJson", () => {
77
function assertTypeAcquisition(json: any, configFileName: string, expectedResult: ExpectedResult) {
88
assertTypeAcquisitionWithJson(json, configFileName, expectedResult);

src/server/protocol.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -466,7 +466,7 @@ namespace ts.server.protocol {
466466
* Represents a single refactoring action - for example, the "Extract Method..." refactor might
467467
* offer several actions, each corresponding to a surround class or closure to extract into.
468468
*/
469-
export type RefactorActionInfo = {
469+
export interface RefactorActionInfo {
470470
/**
471471
* The programmatic name of the refactoring action
472472
*/
@@ -478,7 +478,7 @@ namespace ts.server.protocol {
478478
* so this description should make sense by itself if the parent is inlineable=true
479479
*/
480480
description: string;
481-
};
481+
}
482482

483483
export interface GetEditsForRefactorRequest extends Request {
484484
command: CommandTypes.GetEditsForRefactor;
@@ -501,7 +501,7 @@ namespace ts.server.protocol {
501501
body?: RefactorEditInfo;
502502
}
503503

504-
export type RefactorEditInfo = {
504+
export interface RefactorEditInfo {
505505
edits: FileCodeEdits[];
506506

507507
/**
@@ -510,7 +510,7 @@ namespace ts.server.protocol {
510510
*/
511511
renameLocation?: Location;
512512
renameFilename?: string;
513-
};
513+
}
514514

515515
/**
516516
* Request for the available codefixes at a specific position.

src/server/typingsInstaller/typingsInstaller.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,12 +73,12 @@ namespace ts.server.typingsInstaller {
7373
}
7474

7575
export type RequestCompletedAction = (success: boolean) => void;
76-
type PendingRequest = {
76+
interface PendingRequest {
7777
requestId: number;
7878
args: string[];
7979
cwd: string;
8080
onRequestCompleted: RequestCompletedAction;
81-
};
81+
}
8282

8383
export abstract class TypingsInstaller {
8484
private readonly packageNameToTypingLocation: Map<string> = createMap<string>();

src/services/navigateTo.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,12 @@
11
/* @internal */
22
namespace ts.NavigateTo {
3-
type RawNavigateToItem = { name: string; fileName: string; matchKind: PatternMatchKind; isCaseSensitive: boolean; declaration: Declaration };
3+
interface RawNavigateToItem {
4+
name: string;
5+
fileName: string;
6+
matchKind: PatternMatchKind;
7+
isCaseSensitive: boolean;
8+
declaration: Declaration;
9+
}
410

511
export function getNavigateToItems(sourceFiles: ReadonlyArray<SourceFile>, checker: TypeChecker, cancellationToken: CancellationToken, searchValue: string, maxResultCount: number, excludeDtsFiles: boolean): NavigateToItem[] {
612
const patternMatcher = createPatternMatcher(searchValue);

src/services/types.ts

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -394,7 +394,7 @@ namespace ts {
394394
* Represents a single refactoring action - for example, the "Extract Method..." refactor might
395395
* offer several actions, each corresponding to a surround class or closure to extract into.
396396
*/
397-
export type RefactorActionInfo = {
397+
export interface RefactorActionInfo {
398398
/**
399399
* The programmatic name of the refactoring action
400400
*/
@@ -406,18 +406,17 @@ namespace ts {
406406
* so this description should make sense by itself if the parent is inlineable=true
407407
*/
408408
description: string;
409-
};
409+
}
410410

411411
/**
412412
* A set of edits to make in response to a refactor action, plus an optional
413413
* location where renaming should be invoked from
414414
*/
415-
export type RefactorEditInfo = {
415+
export interface RefactorEditInfo {
416416
edits: FileTextChanges[];
417417
renameFilename?: string;
418418
renameLocation?: number;
419-
};
420-
419+
}
421420

422421
export interface TextInsertion {
423422
newText: string;

tslint.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
"indent": [true,
1212
"spaces"
1313
],
14+
"interface-over-type-literal": true,
1415
"jsdoc-format": true,
1516
"linebreak-style": [true, "CRLF"],
1617
"next-line": [true,

0 commit comments

Comments
 (0)