import-js/eslint-plugin-import

False positive import/no-deprecated for typescript overloads

Offen

#1.532 geöffnet am 02.11.2019

 (13 Kommentare) (18 Reaktionen) (0 zugewiesene Personen)JavaScript (1.549 Forks)batch import
bughelp wantedtypescript

Repository-Metriken

Stars
 (5.940 Sterne)
PR-Merge-Metriken
 (Durchschn. Merge 138T 22h) (3 gemergte PRs in 30 T)

Beschreibung

Consider this external library I'm consuming:

export declare function doSomethingWith(items: string[]): string;

/** @deprecated Pass arguments in a single array instead `doSomethingWith([a, b, c])` */
export declare function doSomethingWith(...items: string[]): string;

The import/no-deprecated rule currently flags even the proper usages:

import { doSomethingWith } from 'external-library'; // flagged

doSomethingWith('a', 'b', 'c'); // flagged, rightly so
doSomethingWith(['a', 'b', 'c']); // flagged, wrongly so

TSLint's deprecation rule gets it right (not bashing ESLint here at all, just pointing to a working implementation).


Additionally, in the following case:

export declare function doSomethingWith(items: string[]): string;

/** @deprecated Pass arguments in a single array instead `doSomethingWith([a, b, c])` */
export declare function doSomethingWith(...items: string[]): string;

/** @deprecated Please don't use this method anymore, it's actually gonna blow everything up */
export declare function doSomethingWith(unused: number, ...items: string): string;

The deprecation warning displayed is that of the last overloaded method (AFAICT), and it may not make sense.

import { doSomethingWith } from 'external-library'; // "Please don't use this method anymore..."

doSomethingWith('a', 'b', 'c'); // "Please don't use this method anymore..."
doSomethingWith(['a', 'b', 'c']); // "Please don't use this method anymore..."

Contributor Guide