Skip to content

Conversation

@dynst
Copy link

@dynst dynst commented Dec 5, 2025

Description:

As pointed out in #7536, the docs for rxjs 7+ have specifically said this since #5307:

const subject = new Subject(); // Shorthand for Subject<void>

<span class="informal">Before version 7, the default type of Subject values was `any`. `Subject<any>` disables type checking of the emitted values, whereas `Subject<void>` prevents accidental access to the emitted value. If you want the old behavior, then replace `Subject` with `Subject<any>`.</span>

But the <T = void> was removed for unexplained reasons in #5430 even though the docs were never updated.

BREAKING CHANGE:

Code that depends on new Subject() returning Subject<unknown> will break.

Related issue (if exists):

This also had to fix tests missing type parameters from #3449 #5750 #6216 #6478

@dynst dynst force-pushed the void-type branch 2 times, most recently from 88ba216 to bed867e Compare December 5, 2025 19:10
dynst added 3 commits December 5, 2025 19:13
catches more accidentally untyped uses, and allows new Subject()
as a shorthand for a void subject, like the documentation promises.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant