Open sigmaSd opened 2 years ago
I found a simpler pattern in type only while original version is JS only.
type x = {"x":[{"x":[{"x":[{"x":[{"x":[{"x":[{"x":[{"x":[{'x':[{'x':'x'}]},{'x':[{'x':'x'}]},{'x':[{'x':'x'}]},{'x':[{'x':'x'}]},{'x':[{'x':'x'}]},{'x':[{'x':'x'}]},{'x':[{'x':'x'}]},{'x':[{'x':'x'}]},{'x':[{'x':'x'}]},{'x':[{'x':'x'}]},{'x':[{'x':'x'}]},{'x':[{'x':'x'}]},{'x':[{'x':'x'}]},{'x':[{'x':'x'}]}]}]}]}]}]}]}]}]}
Save as typescript file and run fmt, it leads super memory consuming. (maybe at least around 8GB or more somehow) It reaches maximum memory usage in a few seconds.
Using version deno 1.28.1 (release, x86_64-unknown-linux-gnu)
.
Expected form is like following. This can be formatted soon:
type x = {
"x": [
{
"x": [
{
"x": [
{
"x": [
{
"x": [
{
"x": [
{
"x": [
{
"x": [
{ "x": [{ "x": "x" }] },
{ "x": [{ "x": "x" }] },
{ "x": [{ "x": "x" }] },
{ "x": [{ "x": "x" }] },
{ "x": [{ "x": "x" }] },
{ "x": [{ "x": "x" }] },
{ "x": [{ "x": "x" }] },
{ "x": [{ "x": "x" }] },
{ "x": [{ "x": "x" }] },
{ "x": [{ "x": "x" }] },
{ "x": [{ "x": "x" }] },
{ "x": [{ "x": "x" }] },
{ "x": [{ "x": "x" }] },
{ "x": [{ "x": "x" }] },
];
},
];
},
];
},
];
},
];
},
];
},
];
},
];
};
Increasing nest or number of last repeating { "x": [{ "x": "x" }] },
makes it more memory consuming.
deno fmt seems to exhaust memory and not finish when used on certain files
to reproduce: (!careful this crashes my pc)
In contrast using https://esm.sh/js-beautify finish almost immediately