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

unified-signatures: rest parameter overloading #2845

Closed
WilcoBakker opened this issue May 30, 2017 · 0 comments
Closed

unified-signatures: rest parameter overloading #2845

WilcoBakker opened this issue May 30, 2017 · 0 comments

Comments

@WilcoBakker
Copy link

Bug Report

  • TSLint version: 5.3.2
  • TypeScript version: 2.3.3
  • Running TSLint via: Atom

TypeScript code being linted

protected oneOf(...accepted: string[]): (arg1: string, arg2: any) => void;
protected oneOf(...accepted: number[]): (arg1: string, arg2: any) => void;

with tslint.json configuration:

{
  "extends": "tslint:recommended",
  "rules": {
    "quotemark": "double",
    "no-console": false,
    "jsdoc-format": false,
    "interface-name": false,
    "object-literal-sort-keys": false,
    "no-bitwise": false
  }
}

Actual behavior

It claims this conflicts with the unified-signatures rule because according to tslint, it can be unified to:

protected oneOf(...accepted: string[] | number[]): (arg1: string, arg2: any) => void;

However this is not supported by TypeScript as TypeScript doesn't support this unification.
It gives an error stating that a rest paramter should be of type Array.

Expected behavior

Tslint knows this is an impossible unification and so does not mark this in conflict with the unified-signatures rule.

Note: TypeScript will most likely never allow this unification as this exact issue (TypeScript part) is marked as By Design a.k.a. this is not possible on purpose. (and with a reason)

Typescript issue: microsoft/TypeScript#5077

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