[internals] Make disposable types self-contained without esnext.disposable lib#23164
Merged
Merged
Conversation
Deploy previewhttps://deploy-preview-23164--material-ui-x.netlify.app/Bundle size
Check out the code infra dashboard for more information about this PR. |
JCQuintas
commented
Jul 17, 2026
| : (Symbol.for('Symbol.dispose') as typeof Symbol.dispose); | ||
| export const disposeSymbol: unique symbol = ( | ||
| typeof Symbol.dispose === 'symbol' ? Symbol.dispose : Symbol.for('Symbol.dispose') | ||
| ) as never; |
Member
Author
There was a problem hiding this comment.
as never here needed so we can export this as unique symbol.
Technically we could downgrade it to symbol only, but then the [disposeSymbol](): void; below wouldn't be picked up, since ts seems to cleanup symbol keys.
JCQuintas
marked this pull request as ready for review
July 20, 2026 12:04
romgrk
approved these changes
Jul 21, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes #23141
The type declarations shipped by
@mui/x-internals/disposablereferencedtypeof Symbol.dispose,typeof Symbol.asyncDispose, andtypeof globalThis.DisposableStack/AsyncDisposableStack. These types only exist whenesnext.disposableis part of the consumer's TypeScriptlib, so any project type-checking withskipLibCheck: falseand alibwithoutesnext.disposablefailed with TS2550/TS7017 in@mui/x-internalsand TS2304 in@mui/x-tree-view.This PR makes the emitted declarations self-contained:
disposeSymbol/asyncDisposeSymbolare now typed asunique symbolinstead oftypeof Symbol.dispose/typeof Symbol.asyncDispose, so they still work as computed member keys (class Foo { [disposeSymbol]() {} }).Disposable,AsyncDisposable,DisposableStack,AsyncDisposableStack(and their constructor interfaces) are declared locally in the module, mirroring theesnext.disposablelib shapes. TheDisposableStackconst and interface merge, so dependent packages' declaration emit resolves the instance type through@mui/x-internals/disposablerather than the global name.Runtime behavior is unchanged: the same native-first resolution with the minimal fallback stacks.
Verified against the issue's setup (built packages,
"lib": ["es2022", "dom"],skipLibCheck: false): previously 5 errors, now clean. Also clean when the consumer does includeesnext.disposable.