Skip to content
This repository has been archived by the owner on Mar 25, 2021. It is now read-only.

completed-docs should not require documentation on the implementation of function overloads #4573

Closed
UselessPickles opened this issue Mar 11, 2019 · 4 comments

Comments

@UselessPickles
Copy link
Contributor

UselessPickles commented Mar 11, 2019

Bug Report

  • TSLint version: 5.13.1
  • TypeScript version: 3.3.3333
  • Running TSLint via: CLI

TypeScript code being linted

/**
 * Documentation    
 * @param x - A parameter
 * @returns A value
 */
export function foo(x: number): number;
/**
 * Documentation
 * @param x - A parameter
 * @returns A value
 */
export function foo(x: string): string;
export function foo(x: number | string): number | string {
    return x;
}

with tslint.json configuration (excerpt of relevant rule config):

{
    "rules": {
        "completed-docs": [
            true, {
                "functions": {
                    "locations": ["all"]
                }
            }
        ]
    }
}

Actual behavior

completed-docs fails on the signature of the implementation of overloaded function foo.

Screen Shot 2019-03-11 at 3 41 26 PM

Expected behavior

When a function is overloaded, the signature of the implementation is not a callable signature. It's simply a common signature compatible with all overload signatures so that a single implementation can be written that works with all overload signatures. It is not very useful/necessary to have documentation on the overload implementation, because all usages of the function in code will resolve to one of the overload signatures, and IDEs will present the documentation of the appropriately matched overload signature (and/or will allow the user to toggle between all overload signatures and their documentation). The signature of the implementation itself is never useful to present to the user, because it is not callable.

When a function has multiple signatures (is overloaded), the signature of the implementation itself should not require documentation.

Somewhat related to #4416, yet still probably independent of it.

@JoshuaKGoldberg
Copy link
Contributor

Agreed. I think once #4563 goes in, TSLint should consider these to be overloads under the same option.

@UselessPickles
Copy link
Contributor Author

Note that this would similarly be applicable to methods of classes with overload signatures.

@JoshuaKGoldberg
Copy link
Contributor

💀 It's time! 💀

TSLint is deprecated and no longer accepting pull requests other than security fixes. See #4534. ☠️
We recommend you instead use typescript-eslint to lint your TypeScript code with ESLint. ✅

👋 It was a pleasure open sourcing with you!

@JoshuaKGoldberg
Copy link
Contributor

🤖 Beep boop! 👉 TSLint is deprecated 👈 (#4534) and you should switch to typescript-eslint! 🤖

🔒 This issue is being locked to prevent further unnecessary discussions. Thank you! 👋

@palantir palantir locked and limited conversation to collaborators Mar 20, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants