Skip to content

Commit 39c7e9a

Browse files
committed
@typescript-eslint/unified-signatures
1 parent 5921cd4 commit 39c7e9a

11 files changed

+19
-22
lines changed

.eslintrc

+2-1
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@
4848
"semi": "off",
4949
"@typescript-eslint/semi": "error",
5050
"@typescript-eslint/type-annotation-spacing": "error",
51-
"@typescript-eslint/unified-signatures": "off",
51+
"@typescript-eslint/unified-signatures": "error",
5252

5353
"microsoft-typescript/object-literal-surrounding-space": "error",
5454
"microsoft-typescript/no-type-assertion-whitespace": "error",
@@ -129,6 +129,7 @@
129129
"rules": {
130130
"@typescript-eslint/interface-name-prefix": "off",
131131
"@typescript-eslint/prefer-function-type": "off",
132+
"@typescript-eslint/unified-signatures": "off",
132133

133134
"no-var": "off"
134135
}

src/compiler/core.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -999,8 +999,8 @@ namespace ts {
999999
export function compact<T>(array: (T | undefined | null | false | 0 | "")[]): T[];
10001000
export function compact<T>(array: ReadonlyArray<T | undefined | null | false | 0 | "">): ReadonlyArray<T>;
10011001
// TSLint thinks these can be combined with the above - they cannot; they'd produce higher-priority inferences and prevent the falsey types from being stripped
1002-
export function compact<T>(array: T[]): T[]; // tslint:disable-line unified-signatures
1003-
export function compact<T>(array: ReadonlyArray<T>): ReadonlyArray<T>; // tslint:disable-line unified-signatures
1002+
export function compact<T>(array: T[]): T[];
1003+
export function compact<T>(array: ReadonlyArray<T>): ReadonlyArray<T>;
10041004
export function compact<T>(array: T[]): T[] {
10051005
let result: T[] | undefined;
10061006
if (array) {

src/compiler/factory.ts

+5-5
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ namespace ts {
6565

6666
// Literals
6767

68-
/* @internal */ export function createLiteral(value: string | StringLiteral | NoSubstitutionTemplateLiteral | NumericLiteral | Identifier, isSingleQuote: boolean): StringLiteral; // tslint:disable-line unified-signatures
68+
/* @internal */ export function createLiteral(value: string | StringLiteral | NoSubstitutionTemplateLiteral | NumericLiteral | Identifier, isSingleQuote: boolean): StringLiteral;
6969
/** If a node is passed, creates a string literal whose source text is read from a source node during emit. */
7070
export function createLiteral(value: string | StringLiteral | NoSubstitutionTemplateLiteral | NumericLiteral | Identifier): StringLiteral;
7171
export function createLiteral(value: number | PseudoBigInt): NumericLiteral;
@@ -125,7 +125,7 @@ namespace ts {
125125

126126
export function createIdentifier(text: string): Identifier;
127127
/* @internal */
128-
export function createIdentifier(text: string, typeArguments: ReadonlyArray<TypeNode | TypeParameterDeclaration> | undefined): Identifier; // tslint:disable-line unified-signatures
128+
export function createIdentifier(text: string, typeArguments: ReadonlyArray<TypeNode | TypeParameterDeclaration> | undefined): Identifier;
129129
export function createIdentifier(text: string, typeArguments?: ReadonlyArray<TypeNode | TypeParameterDeclaration>): Identifier {
130130
const node = <Identifier>createSynthesizedNode(SyntaxKind.Identifier);
131131
node.escapedText = escapeLeadingUnderscores(text);
@@ -140,7 +140,7 @@ namespace ts {
140140

141141
export function updateIdentifier(node: Identifier): Identifier;
142142
/* @internal */
143-
export function updateIdentifier(node: Identifier, typeArguments: NodeArray<TypeNode | TypeParameterDeclaration> | undefined): Identifier; // tslint:disable-line unified-signatures
143+
export function updateIdentifier(node: Identifier, typeArguments: NodeArray<TypeNode | TypeParameterDeclaration> | undefined): Identifier;
144144
export function updateIdentifier(node: Identifier, typeArguments?: NodeArray<TypeNode | TypeParameterDeclaration> | undefined): Identifier {
145145
return node.typeArguments !== typeArguments
146146
? updateNode(createIdentifier(idText(node), typeArguments), node)
@@ -151,7 +151,7 @@ namespace ts {
151151

152152
/** Create a unique temporary variable. */
153153
export function createTempVariable(recordTempVariable: ((node: Identifier) => void) | undefined): Identifier;
154-
/* @internal */ export function createTempVariable(recordTempVariable: ((node: Identifier) => void) | undefined, reservedInNestedScopes: boolean): GeneratedIdentifier; // tslint:disable-line unified-signatures
154+
/* @internal */ export function createTempVariable(recordTempVariable: ((node: Identifier) => void) | undefined, reservedInNestedScopes: boolean): GeneratedIdentifier;
155155
export function createTempVariable(recordTempVariable: ((node: Identifier) => void) | undefined, reservedInNestedScopes?: boolean): GeneratedIdentifier {
156156
const name = createIdentifier("") as GeneratedIdentifier;
157157
name.autoGenerateFlags = GeneratedIdentifierFlags.Auto;
@@ -204,7 +204,7 @@ namespace ts {
204204

205205
/** Create a unique name generated for a node. */
206206
export function getGeneratedNameForNode(node: Node | undefined): Identifier;
207-
/* @internal */ export function getGeneratedNameForNode(node: Node | undefined, flags: GeneratedIdentifierFlags): Identifier; // tslint:disable-line unified-signatures
207+
/* @internal */ export function getGeneratedNameForNode(node: Node | undefined, flags: GeneratedIdentifierFlags): Identifier;
208208
export function getGeneratedNameForNode(node: Node | undefined, flags?: GeneratedIdentifierFlags): Identifier {
209209
const name = createIdentifier(node && isIdentifier(node) ? idText(node) : "");
210210
name.autoGenerateFlags = GeneratedIdentifierFlags.Node | flags!;

src/compiler/moduleNameResolver.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -918,7 +918,7 @@ namespace ts {
918918
}
919919

920920
export function nodeModuleNameResolver(moduleName: string, containingFile: string, compilerOptions: CompilerOptions, host: ModuleResolutionHost, cache?: ModuleResolutionCache, redirectedReference?: ResolvedProjectReference): ResolvedModuleWithFailedLookupLocations;
921-
/* @internal */ export function nodeModuleNameResolver(moduleName: string, containingFile: string, compilerOptions: CompilerOptions, host: ModuleResolutionHost, cache?: ModuleResolutionCache, redirectedReference?: ResolvedProjectReference, lookupConfig?: boolean): ResolvedModuleWithFailedLookupLocations; // tslint:disable-line unified-signatures
921+
/* @internal */ export function nodeModuleNameResolver(moduleName: string, containingFile: string, compilerOptions: CompilerOptions, host: ModuleResolutionHost, cache?: ModuleResolutionCache, redirectedReference?: ResolvedProjectReference, lookupConfig?: boolean): ResolvedModuleWithFailedLookupLocations;
922922
export function nodeModuleNameResolver(moduleName: string, containingFile: string, compilerOptions: CompilerOptions, host: ModuleResolutionHost, cache?: ModuleResolutionCache, redirectedReference?: ResolvedProjectReference, lookupConfig?: boolean): ResolvedModuleWithFailedLookupLocations {
923923
return nodeModuleNameResolverWorker(moduleName, getDirectoryPath(containingFile), compilerOptions, host, cache, lookupConfig ? tsconfigExtensions : (compilerOptions.resolveJsonModule ? tsPlusJsonExtensions : tsExtensions), redirectedReference);
924924
}

src/compiler/program.ts

-2
Original file line numberDiff line numberDiff line change
@@ -316,7 +316,6 @@ namespace ts {
316316
};
317317
}
318318

319-
// tslint:disable unified-signatures
320319
export function getPreEmitDiagnostics(program: Program, sourceFile?: SourceFile, cancellationToken?: CancellationToken): ReadonlyArray<Diagnostic>;
321320
/*@internal*/ export function getPreEmitDiagnostics(program: BuilderProgram, sourceFile?: SourceFile, cancellationToken?: CancellationToken): ReadonlyArray<Diagnostic>;
322321
export function getPreEmitDiagnostics(program: Program | BuilderProgram, sourceFile?: SourceFile, cancellationToken?: CancellationToken): ReadonlyArray<Diagnostic> {
@@ -334,7 +333,6 @@ namespace ts {
334333

335334
return sortAndDeduplicateDiagnostics(diagnostics);
336335
}
337-
// tslint:enable unified-signatures
338336

339337
export interface FormatDiagnosticsHost {
340338
getCurrentDirectory(): string;

src/compiler/scanner.ts

-1
Original file line numberDiff line numberDiff line change
@@ -340,7 +340,6 @@ namespace ts {
340340

341341
export function getPositionOfLineAndCharacter(sourceFile: SourceFileLike, line: number, character: number): number;
342342
/* @internal */
343-
// tslint:disable-next-line:unified-signatures
344343
export function getPositionOfLineAndCharacter(sourceFile: SourceFileLike, line: number, character: number, allowEdits?: true): number;
345344
export function getPositionOfLineAndCharacter(sourceFile: SourceFileLike, line: number, character: number, allowEdits?: true): number {
346345
return sourceFile.getPositionOfLineAndCharacter ?

src/compiler/types.ts

+4-5
Original file line numberDiff line numberDiff line change
@@ -3120,13 +3120,13 @@ namespace ts {
31203120
// TODO: GH#18217 `xToDeclaration` calls are frequently asserted as defined.
31213121
/** Note that the resulting nodes cannot be checked. */
31223122
typeToTypeNode(type: Type, enclosingDeclaration?: Node, flags?: NodeBuilderFlags): TypeNode | undefined;
3123-
/* @internal */ typeToTypeNode(type: Type, enclosingDeclaration?: Node, flags?: NodeBuilderFlags, tracker?: SymbolTracker): TypeNode | undefined; // tslint:disable-line unified-signatures
3123+
/* @internal */ typeToTypeNode(type: Type, enclosingDeclaration?: Node, flags?: NodeBuilderFlags, tracker?: SymbolTracker): TypeNode | undefined; // eslint-disable-line @typescript-eslint/unified-signatures
31243124
/** Note that the resulting nodes cannot be checked. */
31253125
signatureToSignatureDeclaration(signature: Signature, kind: SyntaxKind, enclosingDeclaration?: Node, flags?: NodeBuilderFlags): SignatureDeclaration & {typeArguments?: NodeArray<TypeNode>} | undefined;
3126-
/* @internal */ signatureToSignatureDeclaration(signature: Signature, kind: SyntaxKind, enclosingDeclaration?: Node, flags?: NodeBuilderFlags, tracker?: SymbolTracker): SignatureDeclaration & {typeArguments?: NodeArray<TypeNode>} | undefined; // tslint:disable-line unified-signatures
3126+
/* @internal */ signatureToSignatureDeclaration(signature: Signature, kind: SyntaxKind, enclosingDeclaration?: Node, flags?: NodeBuilderFlags, tracker?: SymbolTracker): SignatureDeclaration & {typeArguments?: NodeArray<TypeNode>} | undefined; // eslint-disable-line @typescript-eslint/unified-signatures
31273127
/** Note that the resulting nodes cannot be checked. */
31283128
indexInfoToIndexSignatureDeclaration(indexInfo: IndexInfo, kind: IndexKind, enclosingDeclaration?: Node, flags?: NodeBuilderFlags): IndexSignatureDeclaration | undefined;
3129-
/* @internal */ indexInfoToIndexSignatureDeclaration(indexInfo: IndexInfo, kind: IndexKind, enclosingDeclaration?: Node, flags?: NodeBuilderFlags, tracker?: SymbolTracker): IndexSignatureDeclaration | undefined; // tslint:disable-line unified-signatures
3129+
/* @internal */ indexInfoToIndexSignatureDeclaration(indexInfo: IndexInfo, kind: IndexKind, enclosingDeclaration?: Node, flags?: NodeBuilderFlags, tracker?: SymbolTracker): IndexSignatureDeclaration | undefined; // eslint-disable-line @typescript-eslint/unified-signatures
31303130
/** Note that the resulting nodes cannot be checked. */
31313131
symbolToEntityName(symbol: Symbol, meaning: SymbolFlags, enclosingDeclaration?: Node, flags?: NodeBuilderFlags): EntityName | undefined;
31323132
/** Note that the resulting nodes cannot be checked. */
@@ -5867,8 +5867,7 @@ namespace ts {
58675867

58685868
// If fileName is provided, gets all the diagnostics associated with that file name.
58695869
// Otherwise, returns all the diagnostics (global and file associated) in this collection.
5870-
getDiagnostics(fileName: string): DiagnosticWithLocation[];
5871-
getDiagnostics(): Diagnostic[];
5870+
getDiagnostics(fileName?: string): DiagnosticWithLocation[];
58725871

58735872
reattachFileDiagnostics(newFile: SourceFile): void;
58745873
}

src/compiler/utilities.ts

-1
Original file line numberDiff line numberDiff line change
@@ -7626,7 +7626,6 @@ namespace ts {
76267626
/**
76277627
* Gets a relative path that can be used to traverse between `from` and `to`.
76287628
*/
7629-
// tslint:disable-next-line:unified-signatures
76307629
export function getRelativePathFromDirectory(fromDirectory: string, to: string, getCanonicalFileName: GetCanonicalFileName): string;
76317630
export function getRelativePathFromDirectory(fromDirectory: string, to: string, getCanonicalFileNameOrIgnoreCase: GetCanonicalFileName | boolean) {
76327631
Debug.assert((getRootLength(fromDirectory) > 0) === (getRootLength(to) > 0), "Paths must either both be absolute or both be relative");

src/server/editorServices.ts

-1
Original file line numberDiff line numberDiff line change
@@ -659,7 +659,6 @@ namespace ts.server {
659659

660660
updateTypingsForProject(response: SetTypings | InvalidateCachedTypings | PackageInstalledResponse): void;
661661
/** @internal */
662-
// tslint:disable-next-line:unified-signatures
663662
updateTypingsForProject(response: SetTypings | InvalidateCachedTypings | PackageInstalledResponse | BeginInstallTypes | EndInstallTypes): void;
664663
updateTypingsForProject(response: SetTypings | InvalidateCachedTypings | PackageInstalledResponse | BeginInstallTypes | EndInstallTypes): void {
665664
const project = this.findProject(response.projectName);

src/server/scriptInfo.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -595,7 +595,7 @@ namespace ts.server {
595595
*/
596596
lineOffsetToPosition(line: number, offset: number): number;
597597
/*@internal*/
598-
// tslint:disable-next-line:unified-signatures
598+
// eslint-disable-next-line @typescript-eslint/unified-signatures
599599
lineOffsetToPosition(line: number, offset: number, allowEdits?: true): number;
600600
lineOffsetToPosition(line: number, offset: number, allowEdits?: true): number {
601601
return this.textStorage.lineOffsetToPosition(line, offset, allowEdits);

src/services/types.ts

+4-2
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,9 @@ namespace ts {
55
getChildAt(index: number, sourceFile?: SourceFile): Node;
66
getChildren(sourceFile?: SourceFile): Node[];
77
/* @internal */
8-
// tslint:disable-next-line unified-signatures
98
getChildren(sourceFile?: SourceFileLike): Node[];
109
getStart(sourceFile?: SourceFile, includeJsDocComment?: boolean): number;
1110
/* @internal */
12-
// tslint:disable-next-line unified-signatures
1311
getStart(sourceFile?: SourceFileLike, includeJsDocComment?: boolean): number;
1412
getFullStart(): number;
1513
getEnd(): number;
@@ -340,6 +338,8 @@ namespace ts {
340338

341339
getCodeFixesAtPosition(fileName: string, start: number, end: number, errorCodes: ReadonlyArray<number>, formatOptions: FormatCodeSettings, preferences: UserPreferences): ReadonlyArray<CodeFixAction>;
342340
getCombinedCodeFix(scope: CombinedCodeFixScope, fixId: {}, formatOptions: FormatCodeSettings, preferences: UserPreferences): CombinedCodeActions;
341+
342+
/* eslint-disable @typescript-eslint/unified-signatures */
343343
applyCodeActionCommand(action: CodeActionCommand, formatSettings?: FormatCodeSettings): Promise<ApplyCodeActionCommandResult>;
344344
applyCodeActionCommand(action: CodeActionCommand[], formatSettings?: FormatCodeSettings): Promise<ApplyCodeActionCommandResult[]>;
345345
applyCodeActionCommand(action: CodeActionCommand | CodeActionCommand[], formatSettings?: FormatCodeSettings): Promise<ApplyCodeActionCommandResult | ApplyCodeActionCommandResult[]>;
@@ -349,6 +349,8 @@ namespace ts {
349349
applyCodeActionCommand(fileName: string, action: CodeActionCommand[]): Promise<ApplyCodeActionCommandResult[]>;
350350
/** @deprecated `fileName` will be ignored */
351351
applyCodeActionCommand(fileName: string, action: CodeActionCommand | CodeActionCommand[]): Promise<ApplyCodeActionCommandResult | ApplyCodeActionCommandResult[]>;
352+
/* eslint-enable @typescript-eslint/unified-signatures */
353+
352354
getApplicableRefactors(fileName: string, positionOrRange: number | TextRange, preferences: UserPreferences | undefined): ApplicableRefactorInfo[];
353355
getEditsForRefactor(fileName: string, formatOptions: FormatCodeSettings, positionOrRange: number | TextRange, refactorName: string, actionName: string, preferences: UserPreferences | undefined): RefactorEditInfo | undefined;
354356
organizeImports(scope: OrganizeImportsScope, formatOptions: FormatCodeSettings, preferences: UserPreferences | undefined): ReadonlyArray<FileTextChanges>;

0 commit comments

Comments
 (0)