Tslint: Don't trigger deprecation warning if some overload is deprecated

Created on 19 Feb 2019  ยท  10Comments  ยท  Source: palantir/tslint

Bug Report

  • __TSLint version__: 5.12.1
  • __TypeScript version__: 3.2.4
  • __Running TSLint via__: CLI

TypeScript code being linted

window.location.reload(); // no deprecation warning

const reload = window.location.reload; // deprecation warning is triggered
reload();

with tslint.json configuration:

{
  "rules": {
    "deprecation": true
  }
}

Actual behavior

As of typescript 3.2.1, window.location.reload(forcedReload: boolean) is deprecated, while the parameterless version is not. When linting the code, a direct call to reload() is ok. However, just accessing the function (as is, e.g., done in unit tests) triggers the deprecation warning.

Expected behavior

No deprecation warning is triggered in the code above, because no deprecated functionality is used.

Medium Requires Type Checker Bug ๐ŸŒน R.I.P. ๐ŸŒน

Most helpful comment

If it's RxJS usage that is causing the warnings, update to their latest as
they removed their deprecated flag for of:
https://github.com/ReactiveX/rxjs/blob/master/CHANGELOG.md#bug-fixes

On Thu, Jun 6, 2019 at 8:13 AM Benjamin Charity notifications@github.com
wrote:

We got hit with this for every usage of RxJS's of. We're currently
disabling like so:

// tslint:disable-next-line deprecation
of(..)

You could also set that rule to false in your configuration (we just

still wanted to be able to use that rule elsewhere)

BTW there is a PR open for this that apparently needs some adjustments:

4649 https://github.com/palantir/tslint/pull/4649

โ€”
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
https://github.com/palantir/tslint/issues/4522?email_source=notifications&email_token=AAB527RD5EFWDE3Y5BBKY3DPZESTDA5CNFSM4GYJFATKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGODXDFQJY#issuecomment-499537959,
or mute the thread
https://github.com/notifications/unsubscribe-auth/AAB527WK5N6RYDTOITMHNN3PZESTDANCNFSM4GYJFATA
.

All 10 comments

Hi, I'm faced to the same issue on my project when I'm trying to use functions overloads.
If I want to access the function without explicitly calling it, TSLint returns a warning.
The deprecation rule seems to be triggered when at least one overload is tagged as @deprecated.

class Foo {
    /** @deprecated */
    public bar(p1: number): any;
    public bar(p1: string, p2: number): any;
    public bar(...params: any) {
        return params;
    }
}

const myFoo = new Foo();
myFoo.bar(2);             // deprecation warning    => OK
myFoo.bar('2', 2);        // no deprecation warning => OK
const myBar = myFoo.bar;  // deprecation warning    => Unexpected behavior
  • TSLint version: 5.12.1
  • TypeScript version: 3.3.3
  • Running TSLint via: CLI

what is the status here? unfortunately my project is filled with deprecation warnings after the update.
are there any plans of resolving this soon?
would be awesome :)

@pkelleter it's accepting PRs, so as soon as someone has code that can fix the issue, we'd be happy to take it in. You're more than welcome to send that PR if you'd like! ๐Ÿ˜„

In the meantime, you can always disable the rule.

Which rule can i disable, please?
Is there a specific rule for that or do I have to disable tslint deprecations in generel then?
Unfortunately there is no way that I can come up with enough spare time to work myself into this project and fix it on my own :(

To disable it in your configuration: https://palantir.github.io/tslint/usage/configuration/

To disable it with inline comments: https://palantir.github.io/tslint/usage/rule-flags/

We got hit with this for every usage of RxJS's of. We are currently disabling like so:

// tslint:disable-next-line deprecation
of(..)

You could also set that rule to false in your configuration (we just still wanted to be able to use that rule elsewhere)


BTW there is a PR open for this that apparently needs some adjustments: https://github.com/palantir/tslint/pull/4649

If it's RxJS usage that is causing the warnings, update to their latest as
they removed their deprecated flag for of:
https://github.com/ReactiveX/rxjs/blob/master/CHANGELOG.md#bug-fixes

On Thu, Jun 6, 2019 at 8:13 AM Benjamin Charity notifications@github.com
wrote:

We got hit with this for every usage of RxJS's of. We're currently
disabling like so:

// tslint:disable-next-line deprecation
of(..)

You could also set that rule to false in your configuration (we just

still wanted to be able to use that rule elsewhere)

BTW there is a PR open for this that apparently needs some adjustments:

4649 https://github.com/palantir/tslint/pull/4649

โ€”
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
https://github.com/palantir/tslint/issues/4522?email_source=notifications&email_token=AAB527RD5EFWDE3Y5BBKY3DPZESTDA5CNFSM4GYJFATKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGODXDFQJY#issuecomment-499537959,
or mute the thread
https://github.com/notifications/unsubscribe-auth/AAB527WK5N6RYDTOITMHNN3PZESTDANCNFSM4GYJFATA
.

Ahh great find! Thanks!

๐Ÿ’€ _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!

๐Ÿค– 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! ๐Ÿ‘‹

Was this page helpful?
0 / 5 - 0 ratings

Related issues

denkomanceski picture denkomanceski  ยท  3Comments

allbto picture allbto  ยท  3Comments

zewa666 picture zewa666  ยท  3Comments

Ne-Ne picture Ne-Ne  ยท  3Comments

cateyes99 picture cateyes99  ยท  3Comments