diff --git a/.eslintrc b/.eslintrc index 1d13a64c086..f9f06ea7aa4 100644 --- a/.eslintrc +++ b/.eslintrc @@ -48,7 +48,7 @@ "semi": "off", "@typescript-eslint/semi": "error", "@typescript-eslint/type-annotation-spacing": "error", - "@typescript-eslint/unified-signatures": "off", + "@typescript-eslint/unified-signatures": "error", "microsoft-typescript/object-literal-surrounding-space": "error", "microsoft-typescript/no-type-assertion-whitespace": "error", @@ -129,6 +129,7 @@ "rules": { "@typescript-eslint/interface-name-prefix": "off", "@typescript-eslint/prefer-function-type": "off", + "@typescript-eslint/unified-signatures": "off", "no-var": "off" } diff --git a/src/compiler/core.ts b/src/compiler/core.ts index f1511b79c12..063cfb10144 100644 --- a/src/compiler/core.ts +++ b/src/compiler/core.ts @@ -999,8 +999,8 @@ namespace ts { export function compact(array: (T | undefined | null | false | 0 | "")[]): T[]; export function compact(array: ReadonlyArray): ReadonlyArray; // 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 - export function compact(array: T[]): T[]; // tslint:disable-line unified-signatures - export function compact(array: ReadonlyArray): ReadonlyArray; // tslint:disable-line unified-signatures + export function compact(array: T[]): T[]; + export function compact(array: ReadonlyArray): ReadonlyArray; export function compact(array: T[]): T[] { let result: T[] | undefined; if (array) { diff --git a/src/compiler/factory.ts b/src/compiler/factory.ts index ac276bafd83..845de5941b7 100644 --- a/src/compiler/factory.ts +++ b/src/compiler/factory.ts @@ -65,7 +65,7 @@ namespace ts { // Literals - /* @internal */ export function createLiteral(value: string | StringLiteral | NoSubstitutionTemplateLiteral | NumericLiteral | Identifier, isSingleQuote: boolean): StringLiteral; // tslint:disable-line unified-signatures + /* @internal */ export function createLiteral(value: string | StringLiteral | NoSubstitutionTemplateLiteral | NumericLiteral | Identifier, isSingleQuote: boolean): StringLiteral; /** If a node is passed, creates a string literal whose source text is read from a source node during emit. */ export function createLiteral(value: string | StringLiteral | NoSubstitutionTemplateLiteral | NumericLiteral | Identifier): StringLiteral; export function createLiteral(value: number | PseudoBigInt): NumericLiteral; @@ -125,7 +125,7 @@ namespace ts { export function createIdentifier(text: string): Identifier; /* @internal */ - export function createIdentifier(text: string, typeArguments: ReadonlyArray | undefined): Identifier; // tslint:disable-line unified-signatures + export function createIdentifier(text: string, typeArguments: ReadonlyArray | undefined): Identifier; export function createIdentifier(text: string, typeArguments?: ReadonlyArray): Identifier { const node = createSynthesizedNode(SyntaxKind.Identifier); node.escapedText = escapeLeadingUnderscores(text); @@ -140,7 +140,7 @@ namespace ts { export function updateIdentifier(node: Identifier): Identifier; /* @internal */ - export function updateIdentifier(node: Identifier, typeArguments: NodeArray | undefined): Identifier; // tslint:disable-line unified-signatures + export function updateIdentifier(node: Identifier, typeArguments: NodeArray | undefined): Identifier; export function updateIdentifier(node: Identifier, typeArguments?: NodeArray | undefined): Identifier { return node.typeArguments !== typeArguments ? updateNode(createIdentifier(idText(node), typeArguments), node) @@ -151,7 +151,7 @@ namespace ts { /** Create a unique temporary variable. */ export function createTempVariable(recordTempVariable: ((node: Identifier) => void) | undefined): Identifier; - /* @internal */ export function createTempVariable(recordTempVariable: ((node: Identifier) => void) | undefined, reservedInNestedScopes: boolean): GeneratedIdentifier; // tslint:disable-line unified-signatures + /* @internal */ export function createTempVariable(recordTempVariable: ((node: Identifier) => void) | undefined, reservedInNestedScopes: boolean): GeneratedIdentifier; export function createTempVariable(recordTempVariable: ((node: Identifier) => void) | undefined, reservedInNestedScopes?: boolean): GeneratedIdentifier { const name = createIdentifier("") as GeneratedIdentifier; name.autoGenerateFlags = GeneratedIdentifierFlags.Auto; @@ -204,7 +204,7 @@ namespace ts { /** Create a unique name generated for a node. */ export function getGeneratedNameForNode(node: Node | undefined): Identifier; - /* @internal */ export function getGeneratedNameForNode(node: Node | undefined, flags: GeneratedIdentifierFlags): Identifier; // tslint:disable-line unified-signatures + /* @internal */ export function getGeneratedNameForNode(node: Node | undefined, flags: GeneratedIdentifierFlags): Identifier; export function getGeneratedNameForNode(node: Node | undefined, flags?: GeneratedIdentifierFlags): Identifier { const name = createIdentifier(node && isIdentifier(node) ? idText(node) : ""); name.autoGenerateFlags = GeneratedIdentifierFlags.Node | flags!; diff --git a/src/compiler/moduleNameResolver.ts b/src/compiler/moduleNameResolver.ts index 604b82cce5e..62c416b3804 100644 --- a/src/compiler/moduleNameResolver.ts +++ b/src/compiler/moduleNameResolver.ts @@ -918,7 +918,7 @@ namespace ts { } export function nodeModuleNameResolver(moduleName: string, containingFile: string, compilerOptions: CompilerOptions, host: ModuleResolutionHost, cache?: ModuleResolutionCache, redirectedReference?: ResolvedProjectReference): ResolvedModuleWithFailedLookupLocations; - /* @internal */ export function nodeModuleNameResolver(moduleName: string, containingFile: string, compilerOptions: CompilerOptions, host: ModuleResolutionHost, cache?: ModuleResolutionCache, redirectedReference?: ResolvedProjectReference, lookupConfig?: boolean): ResolvedModuleWithFailedLookupLocations; // tslint:disable-line unified-signatures + /* @internal */ export function nodeModuleNameResolver(moduleName: string, containingFile: string, compilerOptions: CompilerOptions, host: ModuleResolutionHost, cache?: ModuleResolutionCache, redirectedReference?: ResolvedProjectReference, lookupConfig?: boolean): ResolvedModuleWithFailedLookupLocations; export function nodeModuleNameResolver(moduleName: string, containingFile: string, compilerOptions: CompilerOptions, host: ModuleResolutionHost, cache?: ModuleResolutionCache, redirectedReference?: ResolvedProjectReference, lookupConfig?: boolean): ResolvedModuleWithFailedLookupLocations { return nodeModuleNameResolverWorker(moduleName, getDirectoryPath(containingFile), compilerOptions, host, cache, lookupConfig ? tsconfigExtensions : (compilerOptions.resolveJsonModule ? tsPlusJsonExtensions : tsExtensions), redirectedReference); } diff --git a/src/compiler/program.ts b/src/compiler/program.ts index 421f9c03249..faa5a580a97 100644 --- a/src/compiler/program.ts +++ b/src/compiler/program.ts @@ -316,7 +316,6 @@ namespace ts { }; } - // tslint:disable unified-signatures export function getPreEmitDiagnostics(program: Program, sourceFile?: SourceFile, cancellationToken?: CancellationToken): ReadonlyArray; /*@internal*/ export function getPreEmitDiagnostics(program: BuilderProgram, sourceFile?: SourceFile, cancellationToken?: CancellationToken): ReadonlyArray; export function getPreEmitDiagnostics(program: Program | BuilderProgram, sourceFile?: SourceFile, cancellationToken?: CancellationToken): ReadonlyArray { @@ -334,7 +333,6 @@ namespace ts { return sortAndDeduplicateDiagnostics(diagnostics); } - // tslint:enable unified-signatures export interface FormatDiagnosticsHost { getCurrentDirectory(): string; diff --git a/src/compiler/scanner.ts b/src/compiler/scanner.ts index 36ac8adfa90..a0f0f83309c 100644 --- a/src/compiler/scanner.ts +++ b/src/compiler/scanner.ts @@ -340,7 +340,6 @@ namespace ts { export function getPositionOfLineAndCharacter(sourceFile: SourceFileLike, line: number, character: number): number; /* @internal */ - // tslint:disable-next-line:unified-signatures export function getPositionOfLineAndCharacter(sourceFile: SourceFileLike, line: number, character: number, allowEdits?: true): number; export function getPositionOfLineAndCharacter(sourceFile: SourceFileLike, line: number, character: number, allowEdits?: true): number { return sourceFile.getPositionOfLineAndCharacter ? diff --git a/src/compiler/types.ts b/src/compiler/types.ts index 845c63b707b..8b2fea83dcd 100644 --- a/src/compiler/types.ts +++ b/src/compiler/types.ts @@ -3120,13 +3120,13 @@ namespace ts { // TODO: GH#18217 `xToDeclaration` calls are frequently asserted as defined. /** Note that the resulting nodes cannot be checked. */ typeToTypeNode(type: Type, enclosingDeclaration?: Node, flags?: NodeBuilderFlags): TypeNode | undefined; - /* @internal */ typeToTypeNode(type: Type, enclosingDeclaration?: Node, flags?: NodeBuilderFlags, tracker?: SymbolTracker): TypeNode | undefined; // tslint:disable-line unified-signatures + /* @internal */ typeToTypeNode(type: Type, enclosingDeclaration?: Node, flags?: NodeBuilderFlags, tracker?: SymbolTracker): TypeNode | undefined; // eslint-disable-line @typescript-eslint/unified-signatures /** Note that the resulting nodes cannot be checked. */ signatureToSignatureDeclaration(signature: Signature, kind: SyntaxKind, enclosingDeclaration?: Node, flags?: NodeBuilderFlags): SignatureDeclaration & {typeArguments?: NodeArray} | undefined; - /* @internal */ signatureToSignatureDeclaration(signature: Signature, kind: SyntaxKind, enclosingDeclaration?: Node, flags?: NodeBuilderFlags, tracker?: SymbolTracker): SignatureDeclaration & {typeArguments?: NodeArray} | undefined; // tslint:disable-line unified-signatures + /* @internal */ signatureToSignatureDeclaration(signature: Signature, kind: SyntaxKind, enclosingDeclaration?: Node, flags?: NodeBuilderFlags, tracker?: SymbolTracker): SignatureDeclaration & {typeArguments?: NodeArray} | undefined; // eslint-disable-line @typescript-eslint/unified-signatures /** Note that the resulting nodes cannot be checked. */ indexInfoToIndexSignatureDeclaration(indexInfo: IndexInfo, kind: IndexKind, enclosingDeclaration?: Node, flags?: NodeBuilderFlags): IndexSignatureDeclaration | undefined; - /* @internal */ indexInfoToIndexSignatureDeclaration(indexInfo: IndexInfo, kind: IndexKind, enclosingDeclaration?: Node, flags?: NodeBuilderFlags, tracker?: SymbolTracker): IndexSignatureDeclaration | undefined; // tslint:disable-line unified-signatures + /* @internal */ indexInfoToIndexSignatureDeclaration(indexInfo: IndexInfo, kind: IndexKind, enclosingDeclaration?: Node, flags?: NodeBuilderFlags, tracker?: SymbolTracker): IndexSignatureDeclaration | undefined; // eslint-disable-line @typescript-eslint/unified-signatures /** Note that the resulting nodes cannot be checked. */ symbolToEntityName(symbol: Symbol, meaning: SymbolFlags, enclosingDeclaration?: Node, flags?: NodeBuilderFlags): EntityName | undefined; /** Note that the resulting nodes cannot be checked. */ @@ -5867,8 +5867,7 @@ namespace ts { // If fileName is provided, gets all the diagnostics associated with that file name. // Otherwise, returns all the diagnostics (global and file associated) in this collection. - getDiagnostics(fileName: string): DiagnosticWithLocation[]; - getDiagnostics(): Diagnostic[]; + getDiagnostics(fileName?: string): DiagnosticWithLocation[]; reattachFileDiagnostics(newFile: SourceFile): void; } diff --git a/src/compiler/utilities.ts b/src/compiler/utilities.ts index 3d6c889986d..a6e6b7910ce 100644 --- a/src/compiler/utilities.ts +++ b/src/compiler/utilities.ts @@ -7626,7 +7626,6 @@ namespace ts { /** * Gets a relative path that can be used to traverse between `from` and `to`. */ - // tslint:disable-next-line:unified-signatures export function getRelativePathFromDirectory(fromDirectory: string, to: string, getCanonicalFileName: GetCanonicalFileName): string; export function getRelativePathFromDirectory(fromDirectory: string, to: string, getCanonicalFileNameOrIgnoreCase: GetCanonicalFileName | boolean) { Debug.assert((getRootLength(fromDirectory) > 0) === (getRootLength(to) > 0), "Paths must either both be absolute or both be relative"); diff --git a/src/server/editorServices.ts b/src/server/editorServices.ts index 219b9dce885..b773fca8ea8 100644 --- a/src/server/editorServices.ts +++ b/src/server/editorServices.ts @@ -659,7 +659,6 @@ namespace ts.server { updateTypingsForProject(response: SetTypings | InvalidateCachedTypings | PackageInstalledResponse): void; /** @internal */ - // tslint:disable-next-line:unified-signatures updateTypingsForProject(response: SetTypings | InvalidateCachedTypings | PackageInstalledResponse | BeginInstallTypes | EndInstallTypes): void; updateTypingsForProject(response: SetTypings | InvalidateCachedTypings | PackageInstalledResponse | BeginInstallTypes | EndInstallTypes): void { const project = this.findProject(response.projectName); diff --git a/src/server/scriptInfo.ts b/src/server/scriptInfo.ts index 68c448a7e76..d8fb9b5dd5c 100644 --- a/src/server/scriptInfo.ts +++ b/src/server/scriptInfo.ts @@ -595,7 +595,7 @@ namespace ts.server { */ lineOffsetToPosition(line: number, offset: number): number; /*@internal*/ - // tslint:disable-next-line:unified-signatures + // eslint-disable-next-line @typescript-eslint/unified-signatures lineOffsetToPosition(line: number, offset: number, allowEdits?: true): number; lineOffsetToPosition(line: number, offset: number, allowEdits?: true): number { return this.textStorage.lineOffsetToPosition(line, offset, allowEdits); diff --git a/src/services/types.ts b/src/services/types.ts index 1139ccbe6e1..33695244246 100644 --- a/src/services/types.ts +++ b/src/services/types.ts @@ -5,11 +5,9 @@ namespace ts { getChildAt(index: number, sourceFile?: SourceFile): Node; getChildren(sourceFile?: SourceFile): Node[]; /* @internal */ - // tslint:disable-next-line unified-signatures getChildren(sourceFile?: SourceFileLike): Node[]; getStart(sourceFile?: SourceFile, includeJsDocComment?: boolean): number; /* @internal */ - // tslint:disable-next-line unified-signatures getStart(sourceFile?: SourceFileLike, includeJsDocComment?: boolean): number; getFullStart(): number; getEnd(): number; @@ -340,6 +338,8 @@ namespace ts { getCodeFixesAtPosition(fileName: string, start: number, end: number, errorCodes: ReadonlyArray, formatOptions: FormatCodeSettings, preferences: UserPreferences): ReadonlyArray; getCombinedCodeFix(scope: CombinedCodeFixScope, fixId: {}, formatOptions: FormatCodeSettings, preferences: UserPreferences): CombinedCodeActions; + + /* eslint-disable @typescript-eslint/unified-signatures */ applyCodeActionCommand(action: CodeActionCommand, formatSettings?: FormatCodeSettings): Promise; applyCodeActionCommand(action: CodeActionCommand[], formatSettings?: FormatCodeSettings): Promise; applyCodeActionCommand(action: CodeActionCommand | CodeActionCommand[], formatSettings?: FormatCodeSettings): Promise; @@ -349,6 +349,8 @@ namespace ts { applyCodeActionCommand(fileName: string, action: CodeActionCommand[]): Promise; /** @deprecated `fileName` will be ignored */ applyCodeActionCommand(fileName: string, action: CodeActionCommand | CodeActionCommand[]): Promise; + /* eslint-enable @typescript-eslint/unified-signatures */ + getApplicableRefactors(fileName: string, positionOrRange: number | TextRange, preferences: UserPreferences | undefined): ApplicableRefactorInfo[]; getEditsForRefactor(fileName: string, formatOptions: FormatCodeSettings, positionOrRange: number | TextRange, refactorName: string, actionName: string, preferences: UserPreferences | undefined): RefactorEditInfo | undefined; organizeImports(scope: OrganizeImportsScope, formatOptions: FormatCodeSettings, preferences: UserPreferences | undefined): ReadonlyArray;