Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit fd41521

Browse filesBrowse files
author
Andy
authored
Enable 'callable-types' tslint rule (microsoft#19654)
1 parent 2ea723f commit fd41521
Copy full SHA for fd41521

10 files changed

+33-47Lines changed: 33 additions & 47 deletions

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎src/compiler/resolutionCache.ts‎

Copy file name to clipboardExpand all lines: src/compiler/resolutionCache.ts
+2-3Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -69,9 +69,8 @@ namespace ts {
6969

7070
export const maxNumberOfFilesToIterateForInvalidation = 256;
7171

72-
interface GetResolutionWithResolvedFileName<T extends ResolutionWithFailedLookupLocations = ResolutionWithFailedLookupLocations, R extends ResolutionWithResolvedFileName = ResolutionWithResolvedFileName> {
73-
(resolution: T): R;
74-
}
72+
type GetResolutionWithResolvedFileName<T extends ResolutionWithFailedLookupLocations = ResolutionWithFailedLookupLocations, R extends ResolutionWithResolvedFileName = ResolutionWithResolvedFileName> =
73+
(resolution: T) => R;
7574

7675
export function createResolutionCache(resolutionHost: ResolutionCacheHost, rootDirForResolution: string): ResolutionCache {
7776
let filesWithChangedSetOfUnresolvedImports: Path[] | undefined;
Collapse file

‎src/compiler/scanner.ts‎

Copy file name to clipboardExpand all lines: src/compiler/scanner.ts
+1-3Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,7 @@
22
/// <reference path="diagnosticInformationMap.generated.ts"/>
33

44
namespace ts {
5-
export interface ErrorCallback {
6-
(message: DiagnosticMessage, length: number): void;
7-
}
5+
export type ErrorCallback = (message: DiagnosticMessage, length: number) => void;
86

97
/* @internal */
108
export function tokenIsIdentifierOrKeyword(token: SyntaxKind): boolean {
Collapse file

‎src/compiler/types.ts‎

Copy file name to clipboardExpand all lines: src/compiler/types.ts
+9-9Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2471,9 +2471,13 @@ namespace ts {
24712471
readFile(path: string): string | undefined;
24722472
}
24732473

2474-
export interface WriteFileCallback {
2475-
(fileName: string, data: string, writeByteOrderMark: boolean, onError: ((message: string) => void) | undefined, sourceFiles: ReadonlyArray<SourceFile>): void;
2476-
}
2474+
export type WriteFileCallback = (
2475+
fileName: string,
2476+
data: string,
2477+
writeByteOrderMark: boolean,
2478+
onError: ((message: string) => void) | undefined,
2479+
sourceFiles: ReadonlyArray<SourceFile>,
2480+
) => void;
24772481

24782482
export class OperationCanceledException { }
24792483

@@ -3582,9 +3586,7 @@ namespace ts {
35823586
}
35833587

35843588
/* @internal */
3585-
export interface TypeMapper {
3586-
(t: TypeParameter): Type;
3587-
}
3589+
export type TypeMapper = (t: TypeParameter) => Type;
35883590

35893591
export const enum InferencePriority {
35903592
Contravariant = 1 << 0, // Inference from contravariant position
@@ -4192,9 +4194,7 @@ namespace ts {
41924194
}
41934195

41944196
/* @internal */
4195-
export interface HasInvalidatedResolution {
4196-
(sourceFile: Path): boolean;
4197-
}
4197+
export type HasInvalidatedResolution = (sourceFile: Path) => boolean;
41984198

41994199
export interface CompilerHost extends ModuleResolutionHost {
42004200
getSourceFile(fileName: string, languageVersion: ScriptTarget, onError?: (message: string) => void, shouldCreateNewSourceFile?: boolean): SourceFile | undefined;
Collapse file

‎src/harness/harness.ts‎

Copy file name to clipboardExpand all lines: src/harness/harness.ts
+9-3Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -784,9 +784,15 @@ namespace Harness {
784784
? IO.newLine() + `//# sourceURL=${IO.resolvePath(tcServicesFileName)}`
785785
: "");
786786

787-
export interface SourceMapEmitterCallback {
788-
(emittedFile: string, emittedLine: number, emittedColumn: number, sourceFile: string, sourceLine: number, sourceColumn: number, sourceName: string): void;
789-
}
787+
export type SourceMapEmitterCallback = (
788+
emittedFile: string,
789+
emittedLine: number,
790+
emittedColumn: number,
791+
sourceFile: string,
792+
sourceLine: number,
793+
sourceColumn: number,
794+
sourceName: string,
795+
) => void;
790796

791797
// Settings
792798
export let userSpecifiedRoot = "";
Collapse file

‎src/server/editorServices.ts‎

Copy file name to clipboardExpand all lines: src/server/editorServices.ts
+1-3Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -78,9 +78,7 @@ namespace ts.server {
7878

7979
export type ProjectServiceEvent = ProjectsUpdatedInBackgroundEvent | ConfigFileDiagEvent | ProjectLanguageServiceStateEvent | ProjectInfoTelemetryEvent;
8080

81-
export interface ProjectServiceEventHandler {
82-
(event: ProjectServiceEvent): void;
83-
}
81+
export type ProjectServiceEventHandler = (event: ProjectServiceEvent) => void;
8482

8583
export interface SafeList {
8684
[name: string]: { match: RegExp, exclude?: (string | number)[][], types?: string[] };
Collapse file

‎src/server/project.ts‎

Copy file name to clipboardExpand all lines: src/server/project.ts
+1-3Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -98,9 +98,7 @@ namespace ts.server {
9898
getExternalFiles?(proj: Project): string[];
9999
}
100100

101-
export interface PluginModuleFactory {
102-
(mod: { typescript: typeof ts }): PluginModule;
103-
}
101+
export type PluginModuleFactory = (mod: { typescript: typeof ts }) => PluginModule;
104102

105103
/**
106104
* The project root can be script info - if root is present,
Collapse file

‎src/services/formatting/ruleOperationContext.ts‎

Copy file name to clipboardExpand all lines: src/services/formatting/ruleOperationContext.ts
+2-2Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@
44
namespace ts.formatting {
55

66
export class RuleOperationContext {
7-
private readonly customContextChecks: { (context: FormattingContext): boolean; }[];
7+
private readonly customContextChecks: ((context: FormattingContext) => boolean)[];
88

9-
constructor(...funcs: { (context: FormattingContext): boolean; }[]) {
9+
constructor(...funcs: ((context: FormattingContext) => boolean)[]) {
1010
this.customContextChecks = funcs;
1111
}
1212

Collapse file

‎tests/baselines/reference/api/tsserverlibrary.d.ts‎

Copy file name to clipboardExpand all lines: tests/baselines/reference/api/tsserverlibrary.d.ts
+6-14Lines changed: 6 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1623,9 +1623,7 @@ declare namespace ts {
16231623
fileExists(path: string): boolean;
16241624
readFile(path: string): string | undefined;
16251625
}
1626-
interface WriteFileCallback {
1627-
(fileName: string, data: string, writeByteOrderMark: boolean, onError: ((message: string) => void) | undefined, sourceFiles: ReadonlyArray<SourceFile>): void;
1628-
}
1626+
type WriteFileCallback = (fileName: string, data: string, writeByteOrderMark: boolean, onError: ((message: string) => void) | undefined, sourceFiles: ReadonlyArray<SourceFile>) => void;
16291627
class OperationCanceledException {
16301628
}
16311629
interface CancellationToken {
@@ -3095,9 +3093,7 @@ declare namespace ts {
30953093
function isGetAccessor(node: Node): node is GetAccessorDeclaration;
30963094
}
30973095
declare namespace ts {
3098-
interface ErrorCallback {
3099-
(message: DiagnosticMessage, length: number): void;
3100-
}
3096+
type ErrorCallback = (message: DiagnosticMessage, length: number) => void;
31013097
interface Scanner {
31023098
getStartPos(): number;
31033099
getToken(): SyntaxKind;
@@ -7144,11 +7140,9 @@ declare namespace ts.server {
71447140
create(createInfo: PluginCreateInfo): LanguageService;
71457141
getExternalFiles?(proj: Project): string[];
71467142
}
7147-
interface PluginModuleFactory {
7148-
(mod: {
7149-
typescript: typeof ts;
7150-
}): PluginModule;
7151-
}
7143+
type PluginModuleFactory = (mod: {
7144+
typescript: typeof ts;
7145+
}) => PluginModule;
71527146
/**
71537147
* The project root can be script info - if root is present,
71547148
* or it could be just normalized path if root wasnt present on the host(only for non inferred project)
@@ -7418,9 +7412,7 @@ declare namespace ts.server {
74187412
readonly dts: number;
74197413
}
74207414
type ProjectServiceEvent = ProjectsUpdatedInBackgroundEvent | ConfigFileDiagEvent | ProjectLanguageServiceStateEvent | ProjectInfoTelemetryEvent;
7421-
interface ProjectServiceEventHandler {
7422-
(event: ProjectServiceEvent): void;
7423-
}
7415+
type ProjectServiceEventHandler = (event: ProjectServiceEvent) => void;
74247416
interface SafeList {
74257417
[name: string]: {
74267418
match: RegExp;
Collapse file

‎tests/baselines/reference/api/typescript.d.ts‎

Copy file name to clipboardExpand all lines: tests/baselines/reference/api/typescript.d.ts
+2-6Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1623,9 +1623,7 @@ declare namespace ts {
16231623
fileExists(path: string): boolean;
16241624
readFile(path: string): string | undefined;
16251625
}
1626-
interface WriteFileCallback {
1627-
(fileName: string, data: string, writeByteOrderMark: boolean, onError: ((message: string) => void) | undefined, sourceFiles: ReadonlyArray<SourceFile>): void;
1628-
}
1626+
type WriteFileCallback = (fileName: string, data: string, writeByteOrderMark: boolean, onError: ((message: string) => void) | undefined, sourceFiles: ReadonlyArray<SourceFile>) => void;
16291627
class OperationCanceledException {
16301628
}
16311629
interface CancellationToken {
@@ -2758,9 +2756,7 @@ declare namespace ts {
27582756
let sys: System;
27592757
}
27602758
declare namespace ts {
2761-
interface ErrorCallback {
2762-
(message: DiagnosticMessage, length: number): void;
2763-
}
2759+
type ErrorCallback = (message: DiagnosticMessage, length: number) => void;
27642760
interface Scanner {
27652761
getStartPos(): number;
27662762
getToken(): SyntaxKind;
Collapse file

‎tslint.json‎

Copy file name to clipboardExpand all lines: tslint.json
-1Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,6 @@
7676
"arrow-return-shorthand": false,
7777
"ban-comma-operator": false,
7878
"ban-types": false,
79-
"callable-types": false,
8079
"forin": false,
8180
"member-access": false, // [true, "no-public"]
8281
"no-conditional-assignment": false,

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.