[code-infra] Convert @mui/private-theming to TypeScript#48565
Conversation
Deploy previewhttps://deploy-preview-48565--material-ui.netlify.app/ Bundle size
Check out the code infra dashboard for more information about this PR. |
Convert the package from hand-written `.js` + `.d.ts` to true TypeScript (single `.ts`/`.tsx` source, declarations emitted by `tsc`), removing the `--skipTsc` build. The exported type surface is unchanged, verified with a bidirectional type-equivalence probe; `unstable_nested` stays a runtime-only export via `@internal` + `stripInternal`.
56299ee to
f305df7
Compare
|
|
||
| if (process.env.NODE_ENV !== 'production') { | ||
| ThemeProvider.propTypes = exactProp(ThemeProvider.propTypes); | ||
| (ThemeProvider as any).propTypes /* remove-proptypes */ = exactProp( |
There was a problem hiding this comment.
| (ThemeProvider as any).propTypes /* remove-proptypes */ = exactProp( | |
| (ThemeProvider as any).propTypes = exactProp( |
nit: is this not needed since there's already a NODE_ENV !== production check?
There was a problem hiding this comment.
👍 Yep, redundant, I'm removing it
The assignment is inside if (NODE_ENV !== 'production') so it's already dead-code-eliminated in production builds; the marker is unnecessary and inconsistent with the mui-material convention.
The reassignment inside if (NODE_ENV !== 'production') is already dead-code-eliminated in production, so the babel forceRemoval marker is redundant — matches mui-material's convention. Lesson from PR mui#48565.
|
Is this part of a larger objective? I'm aware of #15984, but I'm curious about this one; it seems different. When I run we get this list: List57.63% 4417052 JavaScript JavaScript: TypeScript: CSS: HTML: |
The initial objective is to remove the manual authoring of It's explicitly not the immediate goal to convert each and every javascript file to typescript, although moving codemod to esm would be a good candidate when it comes to tackling the next tech debt. (a conversion to typescript would be trivial, it doesn't export any public types) |

Converts
@mui/private-themingfrom hand-written.js+.d.tsto true TypeScript (single.ts/.tsxsource, declarations emitted bytsc), removing the--skipTscbuild — like@mui/utilsand@mui/styled-engine(#48544).The exported type surface is unchanged, verified with a bidirectional type-equivalence probe across the root and every subpath entry (
ThemeProvider,useTheme,defaultTheme). Emitted JS is byte-identical modulo comments; the.d.tsdifferences are limited to type-preserving form changes (import type,export type *,declare function).unstable_nestedstays a runtime-only export, absent from the public types as before, via@internal+stripInternal.@mui/systemgains atsconfig.build.jsonproject reference to the now-true-TS package.Published artifact diff
Diff of the published package before/after this PR:
@mui/private-theming