Skip to content

Unexpected deprecation warning after upgrading to TypeScript v4.2.2 #43053

@Julien-Marcou

Description

@Julien-Marcou

Bug Report

🔎 Search Terms

RxJS Deprecation Warning TSLint ESLint VSCode Signature Doc Tags DocTags

🕗 Version & Regression Information

Since TypeScript v4.2.2, I get deprecation warnings with RxJS, that I was not getting in TypeScript v4.1.5

I first opened an issue on RxJS (here), but it may be a TypeScript issue

💻 Code

import { Observable, Subject } from 'rxjs';

const somethingHappened: Subject<void> = new Subject();
const somethingHappened$: Observable<void> = somethingHappened.asObservable();

// Deprecation warning on the next line
somethingHappened$.subscribe(() => {
  console.log('something happened');
});

somethingHappened.next();

🙁 Actual behavior

When I subscribe to the observable, I get the deprecation warning subscribe is deprecated: Use an observer instead of a complete callback even though I'm not using any complete callback

It occurs with both TSLint v6.1.3 and ESLint v7.21.0 (using eslint-plugin-deprecation v1.2.0)

Here are the signatures for the subscribe method in RxJS v6.6.6 :

subscribe(observer?: PartialObserver<T>): Subscription;
/** @deprecated Use an observer instead of a complete callback */
subscribe(next: null | undefined, error: null | undefined, complete: () => void): Subscription;
/** @deprecated Use an observer instead of an error callback */
subscribe(next: null | undefined, error: (error: any) => void, complete?: () => void): Subscription;
/** @deprecated Use an observer instead of a complete callback */
subscribe(next: (value: T) => void, error: null | undefined, complete: () => void): Subscription;
subscribe(next?: (value: T) => void, error?: (error: any) => void, complete?: () => void): Subscription;

If I understand this correctly, in my case it should be using this signature :

subscribe(next?: (value: T) => void, error?: (error: any) => void, complete?: () => void): Subscription;

Which is not deprecated

🙂 Expected behavior

There should be no deprecation warning

Metadata

Metadata

Assignees

Labels

Fix AvailableA PR has been opened for this issueNeeds InvestigationThis issue needs a team member to investigate its status.

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions