New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.
Already on GitHub? Sign in to your account
Using React.ComponentProps
on the component created by styled
cause significant delay in compilation
#36391
Comments
I debugged the TypeScript compiler and found the process got stuck at the I think what it's trying to do is to compare Checking the styleFunctionSx.d.ts file, it seems |
Can you check if it is similar when using We should definitely simplify a bit the types for the |
5.11.11: Feel free to try out the sample project I provided above.
What is your plan for the simplification, please? Would it resolve the circular references between |
Not sure at this moment, but my thought was that probably we can limit the recursiveness by supporting nesting up until level 3 for e.g. Would be interesting to see if this will help. |
I've been able to reproduce with the repository you shared. On my M1 Pro, it initially took 79.18s 馃敟 :
Using
Since this issue was originally created, TypeScript released version 5, which is way faster (1.62s) without having to change anything outside of the TypeScript version:
We can also notice the number of symbols, types, and memory used significantly dropping. |
Duplicates
Latest version
Steps to reproduce 馃暪
Link to live example:
A minimum repro can be seen here:
https://github.com/chance-an/styled_repro
Steps:
npm install
npm run build
Despite its simplicity, significant time was taken to compile the project.
If we comment out this line in
index.tsx
And uncomment this line
the build can finish very quickly.
Separately, if we don't use
styled
from@mui/system/styled
but use the one from@emotion/styled
the issue goes away, and the project will be built very quickly as well.Current behavior 馃槸
The project builds very slowly with the introduction of
React.ComponentProps
on the component returned by thestyled
of the@mui/system
package.This is a reduced example from an actual React project. In the full project, using
React.ComponentProps
on the component returned bystyled
will incur a javascript heap out of memory after a significantly prolonged compilation process.For the minimum repro though, I cannot reproduce the
javascript heap out of memory
error, but only the slow compilation.In the meantime, if an IDE like VS Code is being used, the editor also takes a significant amount of time loading intellisense. A "Code Helper" (Used by VS Code) process takes 100% CPU cycles at the same time. So it looks like VS Code's ts compiler is also stressed out.
Expected behavior 馃
Using
styled
from@mui/system/styled
should have a similar compilation performance as the one from@emotion/styled
.Context 馃敠
A developer should be able to use
styled
andReact.ComponentProps
to extract the props of the produced component correctly without slowing down the compilation or crashing the node heap.Your environment 馃寧
npx @mui/envinfo
The text was updated successfully, but these errors were encountered: