Describe the bug
- A custom type is created to represent form values
- The type is of a certain structure
- The type is used as a generic in
then typescript compilation will slow down tremendously.
In larger apps with many useForms that take this generic, Node can run out of heap memory even with 8gb of allocated heap. I’ve created a code sandbox, but unfortunately, the issue can not really be observed there since we cannot track typescript compilation time (at least to my knowledge). Therefore, I’ve created a very simple sample project to show the issue.
Steps to reproduce the behavior:
- Download the sample project.
- Run npm/yarn install
- Run npm/yarn start
- Observe the extremely long time it takes for typescript to compute results via react-scripts latest version
Codesandbox link (Required)
might not help but included regardless.
Desktop (please complete the following information):
- OS: Ubuntu 20.04 LTS
I copied over my types exactly. The issue is focused around using an object in a triple nested array. So line 51 in types.ts. If you remove the custom select type here and just use null, then the issue is improved exponentially.