eslint-plugin-deprecation
eslint-plugin-deprecation copied to clipboard
False Positive error when extending a deprecated method
In the following scenario, when calling method()
on an instance of the New
class, the plugin should not report an error, but it does:
class Old {
/** @deprecated */
method(): void {
}
}
class New extends Old {
method(): void {
}
}
new Old().method(); // should throw an error -> everything fine
new New().method(); // should not throw an error -> still throws an error
I'm facing a similar issue where a function has multiple signatures, one of which is deprecated and even if I use the new calling convention I get a warning.
// From "fast-check" package
/**
* @deprecated
*/
declare function lorem(maxWordsCount: number, sentencesMode: boolean): Arbitrary<string>;
declare function lorem(constraints: LoremConstraints): Arbitrary<string>;
import * as fc from "fast-check"
fc.lorem({ maxCount: 5 }) // <- warning issued here.
@wereHamster I cannot reproduce this. For me, everything works fine:
/**
* @deprecated
*/
declare function lorem(maxWordsCount: number, sentencesMode: boolean): string;
declare function lorem(constraints: { maxCount: number }): string;
lorem({ maxCount: 5 }); // -> no warning
lorem(5, false); // -> warning
Are you sure the lint error is reported by this package? I ran into a very similar issue using eslint-plugin-import
https://github.com/import-js/eslint-plugin-import/issues/1532, which made me switch to this package.
Both vscode and eslint cli report the warning:
I'm using the latest eslint and related packages (@typescript-eslint/* etc).
We just released an updated with latest deps in v1.3.1 maybe you can try it out and see if this is still an issue?
@Delagen unfortunately this is still an issue with the latest version.
@json-derulo tried to fix this in https://github.com/Delagen/eslint-plugin-deprecation/pull/1, but I reverted it by his opinion about false positives https://github.com/Delagen/eslint-plugin-deprecation/pull/1#issuecomment-989909128. May be someone try to fix this? PR are welcome
Yes I tried to fix it, but it turned out to be way more complex than expected. I did not succeed to fix this.
What I observed is that the unit tests don't cover every case. I've updated them while trying to fix the issue, opened #42 to add them.
I've been able to narrow down the issue. With TypeScript 4.1 it works, since TypeScript 4.2 the described case is broken. Maybe due to their new feature abstract
Construct Signatures. But had no luck so far finding out what needs to be changed in this repo.
Any updates on this? Facing same exact issue.
Angular 12 "@typescript-eslint/eslint-plugin": "^5.12.0", "eslint": "^7.32.0", "eslint-plugin-deprecation": "^1.3.2", "typescript": "^4.3.5",