Skip to content

Commit

Permalink
Fix recursive call to javaToTypeScript.
Browse files Browse the repository at this point in the history
  • Loading branch information
Oleg Schelykalnov committed Sep 10, 2019
1 parent e539950 commit 46a55f9
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -302,7 +302,7 @@ private <T> TsBeanModel processBean(SymbolTable symbolTable, Model model, Map<Ty
TsBeanCategory.Data,
isClass,
symbolTable.getSymbol(bean.getOrigin()),
getTypeParameters(bean.getOrigin()),
getTypeParameters(symbolTable, bean.getOrigin()),
parentType,
extendsList,
implementsList,
Expand All @@ -319,13 +319,13 @@ private boolean mappedToClass(Class<?> cls) {
return cls != null && !cls.isInterface() && settings.getMapClassesAsClassesFilter().test(cls.getName());
}

private List<TsType.BoundedGenericVariableType> getTypeParameters(Class<?> cls) {
private List<TsType.BoundedGenericVariableType> getTypeParameters(SymbolTable symbolTable, Class<?> cls) {
final List<TsType.BoundedGenericVariableType> typeParameters = new ArrayList<>();
for (TypeVariable<?> typeParameter : cls.getTypeParameters()) {
final List<TsType> bounds = new ArrayList<>();
for (Type bound : typeParameter.getBounds()) {
if (!Object.class.equals(bound)) {
bounds.add(javaToTypeScript(bound));
bounds.add(typeFromJava(symbolTable, bound));
}
}
switch (bounds.size()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,19 @@ public void testGenericBoundsParameter() {
assertEquals(expected, output.trim());
}

@Test
public void testGenericRecirsiveBoundsParameter() {
final Settings settings = TestUtils.settings();
final String output = new TypeScriptGenerator(settings).generateTypeScript(Input.from(H.class));
final String nl = settings.newline;
final String expected =
"interface H<T, S extends H<T, S>> {" + nl +
" x: T;" + nl +
" y: S;" + nl +
"}";
assertEquals(expected, output.trim());
}

class A<U,V> {
public A<String, String> x;
public A<A<String, B>, List<String>> y;
Expand Down Expand Up @@ -186,6 +199,11 @@ class G<T extends F> {
public T x;
}

class H<T, S extends H<T, S>> {
public T x;
public S y;
}

abstract class IA implements IB<String>, Comparable<IA> {
}

Expand Down

0 comments on commit 46a55f9

Please sign in to comment.