ScalablyTyped/Converter

Stack overflow when importing echarts

mlvn23 opened this issue · 2 comments

mlvn23 commented

Hello! Thank you for working on this project. I find it very useful and I've been migrating everything I have.

I've tried to import echarts (v5.4.2), and I'm getting a stack overflow:

[error] PhaseRes.scala:81  StackOverflowError [thread => 1803, project => echarts, ms => 7951, phase => typescript, id => echarts]java.lang.StackOverflowError
[error]         at org.scalablytyped.converter.internal.ts.TsTreeScope$Entry$Idents.equals(TsTreeScope.scala:184)
[error]         at scala.runtime.BoxesRunTime.equals2(BoxesRunTime.java:137)
[error]         at scala.runtime.BoxesRunTime.equals(BoxesRunTime.java:123)
[error]         at scala.collection.LinearSeqOptimized.contains(LinearSeqOptimized.scala:105)
[error]         at scala.collection.LinearSeqOptimized.contains$(LinearSeqOptimized.scala:102)
[error]         at scala.collection.immutable.List.contains(List.scala:91)
[error]         at org.scalablytyped.converter.internal.ts.TsTreeScope$LoopDetector.including(TsTreeScope.scala:169)
[error]         at org.scalablytyped.converter.internal.ts.TsTreeScope.lookupInternal(TsTreeScope.scala:94)
[error]         at org.scalablytyped.converter.internal.ts.TsTreeScope.lookupInternal$(TsTreeScope.scala:89)
[error]         at org.scalablytyped.converter.internal.ts.TsTreeScope$Scoped.lookupInternal(TsTreeScope.scala:277)
[error]         at org.scalablytyped.converter.internal.ts.TsTreeScope$.$anonfun$search$4(TsTreeScope.scala:507)
[error]         at org.scalablytyped.converter.internal.IArray.map(IArray.scala:469)
[error]         at org.scalablytyped.converter.internal.ts.TsTreeScope$.search(TsTreeScope.scala:478)
[error]         at org.scalablytyped.converter.internal.ts.TsTreeScope$Scoped.local$1(TsTreeScope.scala:349)
[error]         at org.scalablytyped.converter.internal.ts.TsTreeScope$Scoped.lookupImpl(TsTreeScope.scala:420)
[error]         at org.scalablytyped.converter.internal.ts.TsTreeScope.lookupInternal(TsTreeScope.scala:110)
[error]         at org.scalablytyped.converter.internal.ts.TsTreeScope.lookupInternal$(TsTreeScope.scala:89)
[error]         at org.scalablytyped.converter.internal.ts.TsTreeScope$Scoped.lookupInternal(TsTreeScope.scala:277)
[error]         at org.scalablytyped.converter.internal.ts.TsTreeScope.lookupBase(TsTreeScope.scala:78)
[error]         at org.scalablytyped.converter.internal.ts.TsTreeScope.lookupBase$(TsTreeScope.scala:70)
[error]         at org.scalablytyped.converter.internal.ts.TsTreeScope$Scoped.lookupBase(TsTreeScope.scala:277)
:

It looks like it's failing because it reused the same name in the final line when it tries to do the exports. Here's a simplified pattern that can reproduce the issue:

declare type SeriesInjectedOption = {
    markArea?: number;
};

interface BoxplotSeriesOption {
    type?: 'boxplot';
}

declare type BoxplotSeriesOption$1 = BoxplotSeriesOption & SeriesInjectedOption;

export {BoxplotSeriesOption$1 as BoxplotSeriesOption};

If I comment the last line, it would work. Same goes for the echarts.d.ts.

Thanks for the analysis and repro! I keep getting surprised at all the... interesting things people do :)

I'll get to this for the next release, sorry I don't have the time right now

xerial commented

I hit the same issue when I tried to test echarts.